Skip to content

Commit ca7da82

Browse files
cx-itay-pazItay Pazcx-ben-alvo
authored
fix token (#1248)
Co-authored-by: Itay Paz <[email protected]> Co-authored-by: Ben Alvo <[email protected]>
1 parent c07be5a commit ca7da82

File tree

3 files changed

+7
-12
lines changed

3 files changed

+7
-12
lines changed

internal/services/realtimeengine/secretsrealtime/config.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ type SecretsRealtimeResult struct {
1212
}
1313

1414
type IgnoredSecret struct {
15-
Title string `json:"Title"`
16-
FilePath string `json:"FilePath"`
17-
Line int `json:"Line"`
15+
Title string `json:"Title"`
16+
FilePath string `json:"FilePath"`
17+
SecretValue string `json:"SecretValue"`
1818
}

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

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -45,11 +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-
if len(r.Locations) == 0 {
49-
filtered = append(filtered, r)
50-
continue
51-
}
52-
key := fmt.Sprintf("%s_%s_%d", r.Title, r.FilePath, r.Locations[0].Line)
48+
key := fmt.Sprintf("%s_%s_%s", r.Title, r.FilePath, r.SecretValue)
5349
if !ignoreMap[key] {
5450
filtered = append(filtered, r)
5551
}
@@ -60,7 +56,7 @@ func filterIgnoredSecrets(results []SecretsRealtimeResult, ignoreMap map[string]
6056
func buildIgnoreMap(ignored []IgnoredSecret) map[string]bool {
6157
m := make(map[string]bool)
6258
for _, s := range ignored {
63-
key := fmt.Sprintf("%s_%s_%d", s.Title, s.FilePath, s.Line)
59+
key := fmt.Sprintf("%s_%s_%s", s.Title, s.FilePath, s.SecretValue)
6460
m[key] = true
6561
}
6662
return m
@@ -131,7 +127,6 @@ func readFile(filePath string) (string, error) {
131127
}
132128

133129
func runScan(source, content string) (*reporting.Report, error) {
134-
135130
item := scanner.ScanItem{
136131
Content: &content,
137132
Source: source,

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,12 +73,12 @@ func TestRunSecretsRealtimeScan_WithIgnoreFile_FiltersResult(t *testing.T) {
7373
tempDir := t.TempDir()
7474

7575
testFile := filepath.Join(tempDir, "test.txt")
76-
testContent := "pat = \"ghp_1234567890abcdef1234567890abcdef12345678\""
76+
testContent := "pat = \"ghp_1234567890abcdef123\""
7777
assert.NoError(t, os.WriteFile(testFile, []byte(testContent), 0644))
7878

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

0 commit comments

Comments
 (0)