Skip to content

Commit

Permalink
fix: Fix secrets output not containing file/lines (#2467)
Browse files Browse the repository at this point in the history
  • Loading branch information
liamg authored Jul 8, 2022
1 parent a70fd75 commit 7699153
Show file tree
Hide file tree
Showing 2 changed files with 81 additions and 3 deletions.
82 changes: 80 additions & 2 deletions integration/testdata/secrets.json.golden
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,51 @@
"Title": "AWS Access Key ID",
"StartLine": 3,
"EndLine": 3,
"Match": "export AWS_ACCESS_KEY_ID=********************"
"Match": "export AWS_ACCESS_KEY_ID=********************",
"Code" : {
"Lines": [
{
"Number": 1,
"Content": "#!/bin/sh",
"IsCause": false,
"Annotation": "",
"Truncated": false,
"Highlighted": "#!/bin/sh",
"FirstCause": false,
"LastCause": false
},
{
"Number": 2,
"Content": "",
"IsCause": false,
"Annotation": "",
"Truncated": false,
"Highlighted": "",
"FirstCause": false,
"LastCause": false
},
{
"Number": 3,
"Content": "export AWS_ACCESS_KEY_ID=********************",
"IsCause": true,
"Annotation": "",
"Truncated": false,
"Highlighted": "export AWS_ACCESS_KEY_ID=********************",
"FirstCause": true,
"LastCause": true
},
{
"Number": 4,
"Content": "",
"IsCause": false,
"Annotation": "",
"Truncated": false,
"Highlighted": "",
"FirstCause": false,
"LastCause": false
}
]
}
},
{
"RuleID": "mysecret",
Expand All @@ -35,7 +79,41 @@
"Title": "My Secret",
"StartLine": 7,
"EndLine": 7,
"Match": "echo ********"
"Match": "echo ********",
"Code" : {
"Lines": [
{
"Number": 5,
"Content": "export GITHUB_PAT=ghp_0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ",
"IsCause": false,
"Annotation": "",
"Truncated": false,
"Highlighted": "export GITHUB_PAT=ghp_0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ",
"FirstCause": false,
"LastCause": false
},
{
"Number": 6,
"Content": "",
"IsCause": false,
"Annotation": "",
"Truncated": false,
"Highlighted": "",
"FirstCause": false,
"LastCause": false
},
{
"Number": 7,
"Content": "echo ********",
"IsCause": true,
"Annotation": "",
"Truncated": false,
"Highlighted": "echo ********",
"FirstCause": true,
"LastCause": true
}
]
}
}
]
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/fanal/types/secret.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@ type SecretFinding struct {
Title string
StartLine int
EndLine int
Code Code `json:"-"`
Code Code
Match string
}

0 comments on commit 7699153

Please sign in to comment.