Skip to content

Commit d049595

Browse files
committed
progress
1 parent 0309625 commit d049595

File tree

6 files changed

+211
-54
lines changed

6 files changed

+211
-54
lines changed

components/filters/severity/go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ module github.com/smithy-security/smithy/components/filters/severity
22

33
go 1.23.7
44

5-
require github.com/smithy-security/smithy/sdk v0.0.7-alpha.0.20250407140010-7c059b0c7b96
5+
require github.com/smithy-security/smithy/sdk v0.0.11-alpha
66

77
require (
88
ariga.io/atlas v0.29.0 // indirect

components/filters/severity/go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,8 +132,8 @@ github.com/sirupsen/logrus v1.9.3 h1:dueUQJ1C2q9oE3F7wvmSGAaVtTmUizReu6fjN8uqzbQ
132132
github.com/sirupsen/logrus v1.9.3/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ=
133133
github.com/smithy-security/pkg/env v0.0.1 h1:uwLTMLdNN/dv3x4zat75JahEBQDpdBeldjEE8El4OiM=
134134
github.com/smithy-security/pkg/env v0.0.1/go.mod h1:VIJfDqeAbQQcmohaXcZI6grjeJC9Y8CmqR4ITpdngZE=
135-
github.com/smithy-security/smithy/sdk v0.0.7-alpha.0.20250407140010-7c059b0c7b96 h1:kkJvlXKGsp1S/5k4KyqWzEefmuUYYtD0e8Hs5YH8fVM=
136-
github.com/smithy-security/smithy/sdk v0.0.7-alpha.0.20250407140010-7c059b0c7b96/go.mod h1:76LY9UVqLYfc7+a1++rOHkCvvMXAU4zfWw5/TtHbeOI=
135+
github.com/smithy-security/smithy/sdk v0.0.11-alpha h1:ukPP/nBAbLlvJ0KFA7i4/9+lXV2Lwl6W5sFaEX8LwxU=
136+
github.com/smithy-security/smithy/sdk v0.0.11-alpha/go.mod h1:76LY9UVqLYfc7+a1++rOHkCvvMXAU4zfWw5/TtHbeOI=
137137
github.com/spf13/cast v1.3.1 h1:nFm6S0SMdyzrzcmThSipiEubIDy8WEXKNZ0UOgiRpng=
138138
github.com/spf13/cast v1.3.1/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE=
139139
github.com/sqlc-dev/sqlc v1.27.0 h1:wWc+401GLh0whLa30WmDkkl11lMBZuqvDvgu5OsaDiQ=

components/filters/severity/main.go

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,13 @@ import (
1111

1212
"github.com/smithy-security/smithy/sdk/component"
1313
vf "github.com/smithy-security/smithy/sdk/component/vulnerability-finding"
14+
ocsffindinginfo "github.com/smithy-security/smithy/sdk/gen/ocsf_ext/finding_info/v1"
1415
v1 "github.com/smithy-security/smithy/sdk/gen/ocsf_schema/v1"
16+
"google.golang.org/protobuf/encoding/protojson"
1517
)
1618

19+
const providerName = "severity-filter"
20+
1721
type SeverityFilter struct {
1822
minimumSeverity v1.VulnerabilityFinding_SeverityId
1923
}
@@ -39,7 +43,19 @@ func (s SeverityFilter) Filter(ctx context.Context, findings []*vf.Vulnerability
3943
findings_filtered := 0
4044
for _, f := range findings {
4145
if f.Finding.SeverityId >= s.minimumSeverity {
42-
f.Finding.Enrichments = append(f.Finding.Enrichments, &v1.Enrichment{})
46+
enrichment := ocsffindinginfo.Enrichment{
47+
EnrichmentType: ocsffindinginfo.Enrichment_ENRICHMENT_TYPE_FILTER,
48+
Enrichment: &ocsffindinginfo.Enrichment_Filter{},
49+
}
50+
toBytes, err := protojson.Marshal(&enrichment)
51+
if err != nil {
52+
return nil, false, fmt.Errorf("failed to marshal enrichment %v err: %w", enrichment, err)
53+
}
54+
f.Finding.Enrichments = append(f.Finding.Enrichments, &v1.Enrichment{
55+
Name: "Severity Filter",
56+
Provider: &providerName,
57+
Value: string(toBytes),
58+
})
4359
findings_filtered++
4460
}
4561
}

components/filters/severity/vendor/github.com/smithy-security/smithy/sdk/component/scanner.go

Lines changed: 62 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

components/filters/severity/vendor/modules.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ github.com/shopspring/decimal
123123
# github.com/smithy-security/pkg/env v0.0.1
124124
## explicit; go 1.23.2
125125
github.com/smithy-security/pkg/env
126-
# github.com/smithy-security/smithy/sdk v0.0.7-alpha.0.20250407140010-7c059b0c7b96
126+
# github.com/smithy-security/smithy/sdk v0.0.11-alpha
127127
## explicit; go 1.23.2
128128
github.com/smithy-security/smithy/sdk
129129
github.com/smithy-security/smithy/sdk/component
@@ -139,6 +139,7 @@ github.com/smithy-security/smithy/sdk/component/store/remote/postgresql/sqlc/mig
139139
github.com/smithy-security/smithy/sdk/component/uuid
140140
github.com/smithy-security/smithy/sdk/component/vulnerability-finding
141141
github.com/smithy-security/smithy/sdk/gen/findings_service/v1
142+
github.com/smithy-security/smithy/sdk/gen/ocsf_ext/finding_info/v1
142143
github.com/smithy-security/smithy/sdk/gen/ocsf_schema/v1
143144
# github.com/spf13/cast v1.3.1
144145
## explicit

0 commit comments

Comments
 (0)