-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(trufflehog): report the correct line numbers (#531)
Trufflehog can report wildly incorrect line numbers for secrets, and even report multiple incorrect issues for a given secret. This PR changes our trufflehog parser to scan the file for the secret and report the correct line number. As the trufflehog can report duplicates, we only output a lint issue once for a given secret. This is tested with `wrong_line_number.in.ts`, which trufflehog reports 4 issues on incorrect lines for 2 identical secrets. The parser finds these two secrets on their separate lines. This only fixes the issue for trufflehog filesystem - I'm not sure if this an issue in trufflehog git, and the files may be changed/deleted since the past.
- Loading branch information
Showing
13 changed files
with
681 additions
and
14 deletions.
There are no files selected for viewing
1 change: 0 additions & 1 deletion
1
linters/actionlint/test_data/actionlint_v1.6.26_CUSTOM.check.shot
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
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
1 change: 0 additions & 1 deletion
1
linters/codespell/test_data/codespell_v2.2.6_dictionary.check.shot
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
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
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
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
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
1 change: 0 additions & 1 deletion
1
linters/remark-lint/test_data/remark_lint_v12.0.0_basic.check.shot
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
1 change: 0 additions & 1 deletion
1
linters/remark-lint/test_data/remark_lint_v12.0.0_basic.fmt.shot
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
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
41 changes: 41 additions & 0 deletions
41
linters/trufflehog/test_data/trufflehog_v3.59.0_wrong_line_number.check.shot
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 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`Testing linter trufflehog test wrong_line_number 1`] = ` | ||
{ | ||
"issues": [ | ||
{ | ||
"code": "URI", | ||
"file": "test_data/wrong_line_number.in.ts", | ||
"isSecurity": true, | ||
"level": "LEVEL_HIGH", | ||
"line": "587", | ||
"linter": "trufflehog", | ||
"message": "Secret detected: https://admin:********@the-internet.herokuapp.com", | ||
"targetType": "ALL", | ||
}, | ||
{ | ||
"code": "URI", | ||
"file": "test_data/wrong_line_number.in.ts", | ||
"isSecurity": true, | ||
"level": "LEVEL_HIGH", | ||
"line": "592", | ||
"linter": "trufflehog", | ||
"message": "Secret detected: https://admin:********@the-internet.herokuapp.com", | ||
"targetType": "ALL", | ||
}, | ||
], | ||
"lintActions": [ | ||
{ | ||
"command": "lint", | ||
"fileGroupName": "ALL", | ||
"linter": "trufflehog", | ||
"paths": [ | ||
"test_data/wrong_line_number.in.ts", | ||
], | ||
"verb": "TRUNK_VERB_CHECK", | ||
}, | ||
], | ||
"taskFailures": [], | ||
"unformattedFiles": [], | ||
} | ||
`; |
Oops, something went wrong.