Skip to content

Commit 1dc22ec

Browse files
Merge pull request #1286 from Checkmarx/other/remove-filepath-from-secrets-ignore
Remove file path from secrets ignore flow (AST-00000)
2 parents ede1a26 + ae1697b commit 1dc22ec

File tree

5 files changed

+6
-7
lines changed

5 files changed

+6
-7
lines changed

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ require (
139139
github.com/go-openapi/jsonreference v0.21.0 // indirect
140140
github.com/go-openapi/swag v0.23.1 // indirect
141141
github.com/go-restruct/restruct v1.2.0-alpha // indirect
142-
github.com/go-viper/mapstructure/v2 v2.3.0 // indirect
142+
github.com/go-viper/mapstructure/v2 v2.4.0 // indirect
143143
github.com/gobwas/glob v0.2.3 // indirect
144144
github.com/gogo/protobuf v1.3.2 // indirect
145145
github.com/golang/groupcache v0.0.0-20241129210726-2c02b8208cf8 // indirect

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -421,8 +421,8 @@ github.com/go-task/slim-sprig/v3 v3.0.0/go.mod h1:W848ghGpv3Qj3dhTPRyJypKRiqCdHZ
421421
github.com/go-test/deep v1.0.4/go.mod h1:wGDj63lr65AM2AQyKZd/NYHGb0R+1RLqB8NKt3aSFNA=
422422
github.com/go-test/deep v1.1.1 h1:0r/53hagsehfO4bzD2Pgr/+RgHqhmf+k1Bpse2cTu1U=
423423
github.com/go-test/deep v1.1.1/go.mod h1:5C2ZWiW0ErCdrYzpqxLbTX7MG14M9iiw8DgHncVwcsE=
424-
github.com/go-viper/mapstructure/v2 v2.3.0 h1:27XbWsHIqhbdR5TIC911OfYvgSaW93HM+dX7970Q7jk=
425-
github.com/go-viper/mapstructure/v2 v2.3.0/go.mod h1:oJDH3BJKyqBA2TXFhDsKDGDTlndYOZ6rGS0BRZIxGhM=
424+
github.com/go-viper/mapstructure/v2 v2.4.0 h1:EBsztssimR/CONLSZZ04E8qAkxNYq4Qp9LvH92wZUgs=
425+
github.com/go-viper/mapstructure/v2 v2.4.0/go.mod h1:oJDH3BJKyqBA2TXFhDsKDGDTlndYOZ6rGS0BRZIxGhM=
426426
github.com/gobwas/glob v0.2.3 h1:A4xDbljILXROh+kObIiy5kIaPYD8e96x1tgBhUI5J+Y=
427427
github.com/gobwas/glob v0.2.3/go.mod h1:d3Ez4x06l9bZtSvzIay5+Yzi0fmZzPgnTbPcKjJAkT8=
428428
github.com/gobwas/httphead v0.1.0/go.mod h1:O/RXo79gxV8G+RqlR/otEwx4Q36zl9rqC5u12GKvMCM=

internal/services/realtimeengine/secretsrealtime/config.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,5 @@ type SecretsRealtimeResult struct {
1313

1414
type IgnoredSecret struct {
1515
Title string `json:"Title"`
16-
FilePath string `json:"FilePath"`
1716
SecretValue string `json:"SecretValue"`
1817
}

internal/services/realtimeengine/secretsrealtime/secrets-realtime.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ func NewSecretsRealtimeService(
4545
func filterIgnoredSecrets(results []SecretsRealtimeResult, ignoreMap map[string]bool) []SecretsRealtimeResult {
4646
filtered := make([]SecretsRealtimeResult, 0, len(results))
4747
for _, r := range results {
48-
key := fmt.Sprintf("%s_%s_%s", r.Title, r.FilePath, r.SecretValue)
48+
key := fmt.Sprintf("%s_%s", r.Title, r.SecretValue)
4949
if !ignoreMap[key] {
5050
filtered = append(filtered, r)
5151
}
@@ -56,7 +56,7 @@ func filterIgnoredSecrets(results []SecretsRealtimeResult, ignoreMap map[string]
5656
func buildIgnoreMap(ignored []IgnoredSecret) map[string]bool {
5757
m := make(map[string]bool)
5858
for _, s := range ignored {
59-
key := fmt.Sprintf("%s_%s_%s", s.Title, s.FilePath, s.SecretValue)
59+
key := fmt.Sprintf("%s_%s", s.Title, s.SecretValue)
6060
m[key] = true
6161
}
6262
return m

internal/services/realtimeengine/secretsrealtime/secrets-realtime_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ func TestRunSecretsRealtimeScan_WithIgnoreFile_FiltersResult(t *testing.T) {
7878

7979
ignoreFile := filepath.Join(tempDir, "ignored.json")
8080
ignored := []IgnoredSecret{
81-
{Title: "github-pat", FilePath: testFile, SecretValue: "ghp_1234567890abcdef123"},
81+
{Title: "github-pat", SecretValue: "ghp_1234567890abcdef123"},
8282
}
8383
data, _ := json.Marshal(ignored)
8484
assert.NoError(t, os.WriteFile(ignoreFile, data, 0644))

0 commit comments

Comments
 (0)