-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
201 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package main | ||
|
||
import ( | ||
"context" | ||
"log" | ||
"time" | ||
|
||
"github.com/smithy-security/smithy/sdk/component" | ||
ocsf "github.com/smithy-security/smithy/sdk/gen/com/github/ocsf/ocsf_schema/v1" | ||
) | ||
|
||
type sampleEnricher struct{} | ||
|
||
func (s sampleEnricher) Close(ctx context.Context) error { | ||
component.FromContext(ctx).Info("Closing enricher.") | ||
return nil | ||
} | ||
|
||
func (s sampleEnricher) Read(ctx context.Context) ([]*ocsf.VulnerabilityFinding, error) { | ||
component.FromContext(ctx).Info("Read.") | ||
return make([]*ocsf.VulnerabilityFinding, 0, 10), nil | ||
} | ||
|
||
func (s sampleEnricher) Update(ctx context.Context, findings []*ocsf.VulnerabilityFinding) error { | ||
component.FromContext(ctx).Info("Update.") | ||
return nil | ||
} | ||
|
||
func (s sampleEnricher) Annotate(ctx context.Context, findings []*ocsf.VulnerabilityFinding) ([]*ocsf.VulnerabilityFinding, error) { | ||
component.FromContext(ctx).Info("Annotate.") | ||
return make([]*ocsf.VulnerabilityFinding, 0, 10), nil | ||
} | ||
|
||
func main() { | ||
ctx, cancel := context.WithTimeout(context.Background(), time.Second*10) | ||
defer cancel() | ||
|
||
if err := component.RunEnricher(ctx, sampleEnricher{}, component.RunnerWithComponentName("sample-enricher")); err != nil { | ||
log.Fatalf("unexpected run error: %v", err) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package main | ||
|
||
import ( | ||
"context" | ||
"log" | ||
"time" | ||
|
||
"github.com/smithy-security/smithy/sdk/component" | ||
ocsf "github.com/smithy-security/smithy/sdk/gen/com/github/ocsf/ocsf_schema/v1" | ||
) | ||
|
||
type sampleFilter struct{} | ||
|
||
func (s sampleFilter) Close(ctx context.Context) error { | ||
component.FromContext(ctx).Info("Closing filter.") | ||
return nil | ||
} | ||
|
||
func (s sampleFilter) Read(ctx context.Context) ([]*ocsf.VulnerabilityFinding, error) { | ||
component.FromContext(ctx).Info("Read.") | ||
return make([]*ocsf.VulnerabilityFinding, 0, 100), nil | ||
} | ||
|
||
func (s sampleFilter) Update(ctx context.Context, findings []*ocsf.VulnerabilityFinding) error { | ||
component.FromContext(ctx).Info("Update.") | ||
return nil | ||
} | ||
|
||
func (s sampleFilter) Filter(ctx context.Context, findings []*ocsf.VulnerabilityFinding) ([]*ocsf.VulnerabilityFinding, bool, error) { | ||
component.FromContext(ctx).Info("Filter.") | ||
return make([]*ocsf.VulnerabilityFinding, 0, 80), true, nil | ||
} | ||
|
||
func main() { | ||
ctx, cancel := context.WithTimeout(context.Background(), time.Second*10) | ||
defer cancel() | ||
|
||
if err := component.RunFilter(ctx, sampleFilter{}, component.RunnerWithComponentName("sample-filter")); err != nil { | ||
log.Fatalf("unexpected run error: %v", err) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package main | ||
|
||
import ( | ||
"context" | ||
"log" | ||
"time" | ||
|
||
"github.com/smithy-security/smithy/sdk/component" | ||
ocsf "github.com/smithy-security/smithy/sdk/gen/com/github/ocsf/ocsf_schema/v1" | ||
) | ||
|
||
type sampleReporter struct{} | ||
|
||
func (s sampleReporter) Close(ctx context.Context) error { | ||
component.FromContext(ctx).Info("Closing reporter.") | ||
return nil | ||
} | ||
|
||
func (s sampleReporter) Read(ctx context.Context) ([]*ocsf.VulnerabilityFinding, error) { | ||
component.FromContext(ctx).Info("Read.") | ||
return make([]*ocsf.VulnerabilityFinding, 0, 100), nil | ||
} | ||
|
||
func (s sampleReporter) Report(ctx context.Context, findings []*ocsf.VulnerabilityFinding) error { | ||
component.FromContext(ctx).Info("Report.") | ||
return nil | ||
} | ||
|
||
func main() { | ||
ctx, cancel := context.WithTimeout(context.Background(), time.Second*10) | ||
defer cancel() | ||
|
||
if err := component.RunReporter(ctx, sampleReporter{}, component.RunnerWithComponentName("sample-reporter")); err != nil { | ||
log.Fatalf("unexpected run error: %v", err) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
package main | ||
|
||
import ( | ||
"context" | ||
"log" | ||
"time" | ||
|
||
"github.com/smithy-security/smithy/sdk/component" | ||
ocsf "github.com/smithy-security/smithy/sdk/gen/com/github/ocsf/ocsf_schema/v1" | ||
) | ||
|
||
type ( | ||
sampleScanner struct{} | ||
|
||
sampleRawVuln struct{} | ||
) | ||
|
||
func (s sampleRawVuln) Unmarshal() (*ocsf.VulnerabilityFinding, error) { | ||
return &ocsf.VulnerabilityFinding{}, nil | ||
} | ||
|
||
func (s sampleScanner) Close(ctx context.Context) error { | ||
component.FromContext(ctx).Info("Closing scanner.") | ||
return nil | ||
} | ||
|
||
func (s sampleScanner) Store(ctx context.Context, findings []*ocsf.VulnerabilityFinding) error { | ||
component.FromContext(ctx).Info("Storing.") | ||
return nil | ||
} | ||
|
||
func (s sampleScanner) Scan(ctx context.Context) ([]component.Unmarshaler, error) { | ||
component.FromContext(ctx).Info("Scanning.") | ||
var rawVulns = make([]component.Unmarshaler, 0, 10) | ||
for i := 0; i < 10; i++ { | ||
rawVulns = append(rawVulns, sampleRawVuln{}) | ||
} | ||
return rawVulns, nil | ||
} | ||
|
||
func (s sampleScanner) Transform(ctx context.Context, payload component.Unmarshaler) (*ocsf.VulnerabilityFinding, error) { | ||
component.FromContext(ctx).Info("Transforming.") | ||
return &ocsf.VulnerabilityFinding{}, nil | ||
} | ||
|
||
func main() { | ||
ctx, cancel := context.WithTimeout(context.Background(), time.Second*10) | ||
defer cancel() | ||
|
||
if err := component.RunScanner(ctx, sampleScanner{}, component.RunnerWithComponentName("sample-scanner")); err != nil { | ||
log.Fatalf("unexpected run error: %v", err) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package main | ||
|
||
import ( | ||
"context" | ||
"log" | ||
"time" | ||
|
||
"github.com/smithy-security/smithy/sdk/component" | ||
) | ||
|
||
type sampleTarget struct{} | ||
|
||
func (s sampleTarget) Close(ctx context.Context) error { | ||
component.FromContext(ctx).Info("Closing target.") | ||
return nil | ||
} | ||
|
||
func (s sampleTarget) Prepare(ctx context.Context) error { | ||
component.FromContext(ctx).Info("Preparing.") | ||
return nil | ||
} | ||
|
||
func main() { | ||
ctx, cancel := context.WithTimeout(context.Background(), time.Second*10) | ||
defer cancel() | ||
|
||
if err := component.RunTarget(ctx, sampleTarget{}, component.RunnerWithComponentName("sample-target")); err != nil { | ||
log.Fatalf("unexpected run error: %v", err) | ||
} | ||
} |