Skip to content

Commit 44eb9ac

Browse files
authored
fix: extend whitespace detection in generic-api-key (#343)
<!-- Thanks for contributing to 2ms by offering a pull request. --> **Proposed Changes** <!-- Increasing whitespace limit to better address secrets spread in newlines with increased identation --> **Checklist** - [x] I covered my changes with tests. - [ ] I Updated the documentation that is affected by my changes: - [ ] Change in the CLI arguments - [ ] Change in the configuration file I submit this contribution under the Apache-2.0 license.
1 parent b1ebc31 commit 44eb9ac

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

engine/engine_test.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,11 @@ func TestSecrets(t *testing.T) {
184184
Name: "Generic Api Key",
185185
ShouldFind: false,
186186
},
187+
{
188+
Content: "SecretKey: \n\t\t\t 'NzFEUDg0Y0Jtc25sbko4VU96Q3VxM184bGkxV2xEb0twajY3ZFVybEtrcj0=',",
189+
Name: "Generic Api Key",
190+
ShouldFind: true,
191+
},
187192
}
188193

189194
detector, err := initEngine(&EngineConfig{

engine/rules/utils.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ const (
2424
// boundaries for the secret
2525
// \x60 = `
2626
secretPrefixUnique = `\b(`
27-
secretPrefix = `[\x60'"\s=]{0,5}(` //nolint:gosec // This is a regex pattern
27+
secretPrefix = `[\x60'"\s=]{0,20}(` //nolint:gosec // This is a regex pattern
2828
secretSuffix = `)(?:[\x60'"\s;]|\\[nr]|$)` //nolint:gosec // This is a regex pattern
2929
secretSuffixIncludingXml = `)(?:['|\"|\n|\r|\s|\x60|;]|\\n|\\r|$|\s{0,10}<\/string>)` //nolint:gosec // This is a regex pattern
3030
)

0 commit comments

Comments
 (0)