Skip to content

Commit 1ae5e3a

Browse files
fix: incorrect column indexes for some results (#301)
<!-- Thanks for contributing to 2ms by offering a pull request. --> Closes # **Proposed Changes** <!-- Please describe the big picture of your changes here. If it fixes a bug or resolves a feature request, be sure to link to that issue. --> **Checklist** - [ ] 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 0d781d5 commit 1ae5e3a

File tree

11 files changed

+223
-109
lines changed

11 files changed

+223
-109
lines changed

.2ms.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,3 +111,19 @@ ignore-result:
111111
- 754506f714ffc10628e6fe6dd05affa486d78234 # value used for testing
112112
- eebd28cd68ee73b9a1f68b85453575498c12c5b8 # value used for testing
113113
- 14f5cf9d2716f2cec7daf95ab86e1a4feaf7ba41 # value used for testing
114+
- 9d94eb297ac8cb2613d3091e1ee4d085bc3ce218 # value used for testing
115+
- 2d06c941743a66ec44d96c5db4b3b1e6e07a1eee # value used for testing
116+
- 9343373de08c9a35cb8f2d7695b02b5141de29d8 # value used for testing
117+
- 071b6cb8c1affc7e1c49137ead1b875cc5d08876 # value used for testing
118+
- f0dbf084d67ad8d1a132b1b77f3186df939ccb6f # value used for testing
119+
- 36421c2650a6f6ed3ed52ac013c8e73fc47a95da # value used for testing
120+
- e7feb20ae9d14a4cdfce9d4a5451313ffc92253b # value used for testing
121+
- 7c0c039771d4cc8eb455d3bbdccf8131fdd6e45e # value used for testing
122+
- 9a8177d80f9aa9a32759ba7710725b8a1fd3343a # value used for testing
123+
- 82ff8052d87e4cedb3dee7db569fcb181e6caf88 # value used for testing
124+
- 44eca14299c23849c83a7a84fdaa35b8a6a0de34 # value used for testing
125+
- 374eb22f69352d768e8096f9d55299c4dfd8888c # value used for testing
126+
- bd69025b337716ee008f80192523d3cb1c11ed09 # value used for testing
127+
128+
129+

engine/engine.go

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -318,20 +318,33 @@ func buildSecret(ctx context.Context, item plugins.ISourceItem, value report.Fin
318318
}
319319

320320
value.Line = strings.TrimSuffix(value.Line, CxFileEndMarker)
321+
hasNewline := strings.HasPrefix(value.Line, "\n")
322+
323+
if hasNewline {
324+
value.Line = strings.TrimPrefix(value.Line, "\n")
325+
}
326+
value.Line = strings.ReplaceAll(value.Line, "\r", "")
321327

322328
lineContent, err := linecontent.GetLineContent(value.Line, value.Secret)
323329
if err != nil {
324330
return nil, fmt.Errorf("failed to get line content for source %s: %w", item.GetSource(), err)
325331
}
326332

333+
adjustedStartColumn := value.StartColumn
334+
adjustedEndColumn := value.EndColumn
335+
if hasNewline {
336+
adjustedStartColumn--
337+
adjustedEndColumn--
338+
}
339+
327340
secret := &secrets.Secret{
328341
ID: itemId,
329342
Source: item.GetSource(),
330343
RuleID: value.RuleID,
331344
StartLine: startLine,
332-
StartColumn: value.StartColumn,
345+
StartColumn: adjustedStartColumn,
333346
EndLine: endLine,
334-
EndColumn: value.EndColumn,
347+
EndColumn: adjustedEndColumn,
335348
Value: value.Secret,
336349
LineContent: lineContent,
337350
RuleDescription: value.Description,

engine/engine_test.go

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import (
77
"io"
88
"os"
99
"path/filepath"
10+
"strings"
1011
"testing"
1112

1213
"go.uber.org/mock/gomock"
@@ -22,6 +23,7 @@ import (
2223
"github.com/stretchr/testify/require"
2324
"github.com/zricethezav/gitleaks/v8/config"
2425
"github.com/zricethezav/gitleaks/v8/detect"
26+
"github.com/zricethezav/gitleaks/v8/report"
2527
)
2628

2729
var fsPlugin = &plugins.FileSystemPlugin{}
@@ -437,6 +439,89 @@ func TestDetectChunks(t *testing.T) {
437439
}
438440
}
439441

442+
func TestSecretsColumnIndex(t *testing.T) {
443+
444+
tests := []struct {
445+
name string
446+
lineContent string
447+
startColumn int
448+
endColumn int
449+
expectedLineContent string
450+
expectedStartColumn int
451+
expectedEndColumn int
452+
}{
453+
{
454+
name: "secret on first line without newline",
455+
lineContent: `let apikey = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9"`,
456+
startColumn: 14,
457+
endColumn: 50,
458+
expectedLineContent: `let apikey = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9"`,
459+
expectedStartColumn: 14,
460+
expectedEndColumn: 50,
461+
},
462+
{
463+
name: "secret with leading newline",
464+
lineContent: "\nlet apikey = \"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9\"",
465+
startColumn: 15,
466+
endColumn: 51,
467+
expectedLineContent: `let apikey = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9"`,
468+
expectedStartColumn: 14,
469+
expectedEndColumn: 50,
470+
},
471+
{
472+
name: "leading newline followed by tab indentation",
473+
lineContent: "\n let apikey = \"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9\"",
474+
startColumn: 2,
475+
endColumn: 7,
476+
expectedLineContent: " let apikey = \"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9\"",
477+
expectedStartColumn: 1,
478+
expectedEndColumn: 6,
479+
},
480+
{
481+
name: "leading newline followed by tab indentation with special character",
482+
lineContent: "\n\tlet apikey€ = \"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9\"",
483+
startColumn: 2,
484+
endColumn: 7,
485+
expectedLineContent: " let apikey€ = \"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9\"",
486+
expectedStartColumn: 1,
487+
expectedEndColumn: 6,
488+
},
489+
{
490+
name: "newline with content larger than context limit",
491+
lineContent: "\n" + strings.Repeat("A", 500) + "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9" + strings.Repeat("B", 500),
492+
startColumn: 501,
493+
endColumn: 536,
494+
expectedLineContent: strings.Repeat("A", 250) + "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9" + strings.Repeat("B", 250),
495+
expectedStartColumn: 500,
496+
expectedEndColumn: 535,
497+
},
498+
}
499+
for _, tt := range tests {
500+
t.Run(tt.name, func(t *testing.T) {
501+
502+
mockItem := &item{content: &tt.lineContent, source: "test.txt"}
503+
504+
finding := report.Finding{
505+
StartColumn: tt.startColumn,
506+
EndColumn: tt.endColumn,
507+
Secret: "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9",
508+
RuleID: "test-rule",
509+
Description: "Test Description",
510+
Line: tt.lineContent,
511+
StartLine: 1,
512+
EndLine: 1,
513+
}
514+
515+
secret, err := buildSecret(context.Background(), mockItem, finding, fsPlugin.GetName())
516+
517+
require.NoError(t, err)
518+
assert.Equal(t, tt.expectedLineContent, secret.LineContent)
519+
assert.Equal(t, tt.expectedStartColumn, secret.StartColumn)
520+
assert.Equal(t, tt.expectedEndColumn, secret.EndColumn)
521+
})
522+
}
523+
}
524+
440525
type item struct {
441526
content *string
442527
id string

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ require (
2929
github.com/fatih/semgroup v1.2.0 // indirect
3030
github.com/fsnotify/fsnotify v1.8.0 // indirect
3131
github.com/go-ole/go-ole v1.2.6 // indirect
32-
github.com/go-viper/mapstructure/v2 v2.2.1 // indirect
32+
github.com/go-viper/mapstructure/v2 v2.3.0 // indirect
3333
github.com/gorilla/websocket v1.5.0 // indirect
3434
github.com/inconshreveable/mousetrap v1.1.0 // indirect
3535
github.com/lucasb-eyer/go-colorful v1.2.0 // indirect

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ github.com/go-ole/go-ole v1.2.6 h1:/Fpf6oFPoeFik9ty7siob0G6Ke8QvQEuVcuChpwXzpY=
2323
github.com/go-ole/go-ole v1.2.6/go.mod h1:pprOEPIfldk/42T2oK7lQ4v4JSDwmV0As9GaiUsvbm0=
2424
github.com/go-test/deep v1.0.4 h1:u2CU3YKy9I2pmu9pX0eq50wCgjfGIt539SqR7FbHiho=
2525
github.com/go-test/deep v1.0.4/go.mod h1:wGDj63lr65AM2AQyKZd/NYHGb0R+1RLqB8NKt3aSFNA=
26-
github.com/go-viper/mapstructure/v2 v2.2.1 h1:ZAaOCxANMuZx5RCeg0mBdEZk7DZasvvZIxtHqx8aGss=
27-
github.com/go-viper/mapstructure/v2 v2.2.1/go.mod h1:oJDH3BJKyqBA2TXFhDsKDGDTlndYOZ6rGS0BRZIxGhM=
26+
github.com/go-viper/mapstructure/v2 v2.3.0 h1:27XbWsHIqhbdR5TIC911OfYvgSaW93HM+dX7970Q7jk=
27+
github.com/go-viper/mapstructure/v2 v2.3.0/go.mod h1:oJDH3BJKyqBA2TXFhDsKDGDTlndYOZ6rGS0BRZIxGhM=
2828
github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA=
2929
github.com/google/go-cmp v0.5.7/go.mod h1:n+brtR0CgQNWTVd5ZUFpTBC8YFBDLK/h/bpaJ8/DtOE=
3030
github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=

pkg/testData/expectedReport.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@
88
"ruleId" : "github-pat",
99
"startLine" : 1,
1010
"endLine" : 1,
11-
"lineContent" : "\n Text_Example = ghp_CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC\r",
12-
"startColumn" : 64,
13-
"endColumn" : 103,
11+
"lineContent" : " Text_Example = ghp_CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC\r",
12+
"startColumn" : 63,
13+
"endColumn" : 102,
1414
"value" : "ghp_CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC",
1515
"ruleDescription" : "Uncovered a GitHub Personal Access Token, potentially leading to unauthorized repository access and sensitive content exposure.",
1616
"cvssScore" : 8.2
@@ -39,9 +39,9 @@
3939
"ruleId" : "jwt",
4040
"startLine" : 1,
4141
"endLine" : 1,
42-
"lineContent": "\n Text_Example = eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiJtb2NrU3ViMiIsIm5hbWUiOiJtb2NrTmFtZTIifQ.dummysignature2",
43-
"startColumn" : 64,
44-
"endColumn" : 167,
42+
"lineContent": " Text_Example = eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiJtb2NrU3ViMiIsIm5hbWUiOiJtb2NrTmFtZTIifQ.dummysignature2",
43+
"startColumn" : 63,
44+
"endColumn" : 166,
4545
"value" : "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiJtb2NrU3ViMiIsIm5hbWUiOiJtb2NrTmFtZTIifQ.dummysignature2",
4646
"ruleDescription" : "Uncovered a JSON Web Token, which may lead to unauthorized access to web applications and sensitive user data.",
4747
"extraDetails" : {

pkg/testData/expectedReportWithIgnoredRule.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,9 @@
2626
"ruleId" : "jwt",
2727
"startLine" : 1,
2828
"endLine" : 1,
29-
"lineContent": "\n Text_Example = eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiJtb2NrU3ViMiIsIm5hbWUiOiJtb2NrTmFtZTIifQ.dummysignature2",
30-
"startColumn" : 64,
31-
"endColumn" : 167,
29+
"lineContent": " Text_Example = eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiJtb2NrU3ViMiIsIm5hbWUiOiJtb2NrTmFtZTIifQ.dummysignature2",
30+
"startColumn" : 63,
31+
"endColumn" : 166,
3232
"value" : "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiJtb2NrU3ViMiIsIm5hbWUiOiJtb2NrTmFtZTIifQ.dummysignature2",
3333
"ruleDescription" : "Uncovered a JSON Web Token, which may lead to unauthorized access to web applications and sensitive user data.",
3434
"extraDetails" : {

pkg/testData/expectedReportWithValidation.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@
33
"40483a2b07fa3beaf234d1a0b5d0931d7b7ae9f7": [
44
{
55
"cvssScore": 5.2,
6-
"endColumn": 103,
6+
"endColumn": 102,
77
"endLine": 1,
88
"id": "40483a2b07fa3beaf234d1a0b5d0931d7b7ae9f7",
9-
"lineContent": "\n Text_Example = ghp_CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC",
9+
"lineContent": " Text_Example = ghp_CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC",
1010
"ruleDescription": "Uncovered a GitHub Personal Access Token, potentially leading to unauthorized repository access and sensitive content exposure.",
1111
"ruleId": "github-pat",
1212
"source": "testData/secrets/github-pat.txt",
13-
"startColumn": 64,
13+
"startColumn": 63,
1414
"startLine": 1,
1515
"validationStatus": "Invalid",
1616
"value": "ghp_CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC"
@@ -55,7 +55,7 @@
5555
},
5656
{
5757
"cvssScore": 8.2,
58-
"endColumn": 167,
58+
"endColumn": 166,
5959
"endLine": 1,
6060
"extraDetails": {
6161
"secretDetails": {
@@ -64,11 +64,11 @@
6464
}
6565
},
6666
"id": "a0cd293e6e122a1c7384d5a56781e39ba350c54b",
67-
"lineContent": "\n Text_Example = eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiJtb2NrU3ViMiIsIm5hbWUiOiJtb2NrTmFtZTIifQ.dummysignature2",
67+
"lineContent": " Text_Example = eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiJtb2NrU3ViMiIsIm5hbWUiOiJtb2NrTmFtZTIifQ.dummysignature2",
6868
"ruleDescription": "Uncovered a JSON Web Token, which may lead to unauthorized access to web applications and sensitive user data.",
6969
"ruleId": "jwt",
7070
"source": "testData/secrets/jwt.txt",
71-
"startColumn": 64,
71+
"startColumn": 63,
7272
"startLine": 1,
7373
"validationStatus": "Unknown",
7474
"value": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiJtb2NrU3ViMiIsIm5hbWUiOiJtb2NrTmFtZTIifQ.dummysignature2"
Lines changed: 50 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -1,51 +1,51 @@
11
{
2-
"totalItemsScanned": 1,
3-
"totalSecretsFound": 3,
4-
"results": {
5-
"047d26912b890e89c7f01b7ec9e926390224e4f0": [
6-
{
7-
"id": "047d26912b890e89c7f01b7ec9e926390224e4f0",
8-
"source": "testData/input/multi_line_secret.txt",
9-
"ruleId": "private-key",
10-
"startLine": 3,
11-
"endLine": 4,
12-
"lineContent": "\n -----BEGIN RSA PRIVATE KEY----- MIIBOgIBAAJBAKj34GkxFhD90vcNLYLInFEX6Ppy1tPf9Cnzj4p4WGeKLs1Pt8Qu KUpRKfFLfRYC9AIKjbJTWit+Cq\r\n vjWYzvQwECAwEAAQJAIJLixBy2qpFoS4DSmoEm o3qGy0t6z09AIJtH+5OeRV1be+N4cDYJKffGzDa88vQENZiRm0GRq6a+HPGQMd2k TQIhAKMSvzIBnni7ot/OSie2TmJLY4SwTQAevXysE2RbFDYdAiEBCUEaRQnMnbp79mxDXDf6AU0cN/RPBjb9qSHDcWZHGzUCIG2Es59z8ugGrDY+pxLQnwfotadxd+Uy v/Ow5T0q5gIJAiEAyS4RaI9YG8EWx/2w0T67ZUVAw8eOMB6BIUg0Xcu+3okCIBOs /5OiPgoTdSy7bcF9IGpSE8ZgGKzgYQVZeN97YE00 -----END RSA PRIVATE KEY-----\r",
13-
"startColumn": 10,
14-
"endColumn": 377,
15-
"value": "-----BEGIN RSA PRIVATE KEY----- MIIBOgIBAAJBAKj34GkxFhD90vcNLYLInFEX6Ppy1tPf9Cnzj4p4WGeKLs1Pt8Qu KUpRKfFLfRYC9AIKjbJTWit+Cq\r\n vjWYzvQwECAwEAAQJAIJLixBy2qpFoS4DSmoEm o3qGy0t6z09AIJtH+5OeRV1be+N4cDYJKffGzDa88vQENZiRm0GRq6a+HPGQMd2k TQIhAKMSvzIBnni7ot/OSie2TmJLY4SwTQAevXysE2RbFDYdAiEBCUEaRQnMnbp79mxDXDf6AU0cN/RPBjb9qSHDcWZHGzUCIG2Es59z8ugGrDY+pxLQnwfotadxd+Uy v/Ow5T0q5gIJAiEAyS4RaI9YG8EWx/2w0T67ZUVAw8eOMB6BIUg0Xcu+3okCIBOs /5OiPgoTdSy7bcF9IGpSE8ZgGKzgYQVZeN97YE00 -----END RSA PRIVATE KEY-----",
16-
"ruleDescription": "Identified a Private Key, which may compromise cryptographic security and sensitive data encryption.",
17-
"cvssScore": 8.2
18-
}
19-
],
20-
"58e5a02e5571db6dc1f9c0fdba8d86e254225bf1": [
21-
{
22-
"id": "58e5a02e5571db6dc1f9c0fdba8d86e254225bf1",
23-
"source": "testData/input/multi_line_secret.txt",
24-
"ruleId": "generic-api-key",
25-
"startLine": 1,
26-
"endLine": 1,
27-
"lineContent": "`\"client_id\" : \"0afae57f3ccfd9d7f5767067bc48b30f719e271ba470488056e37ab35d4b6506\"`,\r",
28-
"startColumn": 3,
29-
"endColumn": 81,
30-
"value": "0afae57f3ccfd9d7f5767067bc48b30f719e271ba470488056e37ab35d4b6506",
31-
"ruleDescription": "Detected a Generic API Key, potentially exposing access to various services and sensitive operations.",
32-
"cvssScore": 8.2
33-
}
34-
],
35-
"ed47a9a9052d119d91763ce84d689370fdbccf1f": [
36-
{
37-
"id": "ed47a9a9052d119d91763ce84d689370fdbccf1f",
38-
"source": "testData/input/multi_line_secret.txt",
39-
"ruleId": "generic-api-key",
40-
"startLine": 2,
41-
"endLine": 2,
42-
"lineContent": "\n\t\t`\"client_secret\" : \"6da89121079f83b2eb6acccf8219ea982c3d79bccc3e9c6a85856480661f8fde\",`\r",
43-
"startColumn": 6,
44-
"endColumn": 88,
45-
"value": "6da89121079f83b2eb6acccf8219ea982c3d79bccc3e9c6a85856480661f8fde",
46-
"ruleDescription": "Detected a Generic API Key, potentially exposing access to various services and sensitive operations.",
47-
"cvssScore": 8.2
48-
}
49-
]
50-
}
51-
}
2+
"totalItemsScanned": 1,
3+
"totalSecretsFound": 3,
4+
"results": {
5+
"047d26912b890e89c7f01b7ec9e926390224e4f0": [
6+
{
7+
"id": "047d26912b890e89c7f01b7ec9e926390224e4f0",
8+
"source": "testData/input/multi_line_secret.txt",
9+
"ruleId": "private-key",
10+
"startLine": 3,
11+
"endLine": 4,
12+
"lineContent": " -----BEGIN RSA PRIVATE KEY----- MIIBOgIBAAJBAKj34GkxFhD90vcNLYLInFEX6Ppy1tPf9Cnzj4p4WGeKLs1Pt8Qu KUpRKfFLfRYC9AIKjbJTWit+Cq\n vjWYzvQwECAwEAAQJAIJLixBy2qpFoS4DSmoEm o3qGy0t6z09AIJtH+5OeRV1be+N4cDYJKffGzDa88vQENZiRm0GRq6a+HPGQMd2k TQIhAKMSvzIBnni7ot/OSie2TmJLY4SwTQAevXysE2RbFDYdAiEBCUEaRQnMnbp79mxDXDf6AU0cN/RPBjb9qSHDcWZHGzUCIG2Es59z8ugGrDY+pxLQnwfotadxd+Uy v/Ow5T0q5gIJAiEAyS4RaI9YG8EWx/2w0T67ZUVAw8eOMB6BIUg0Xcu+3okCIBOs /5OiPgoTdSy7bcF9IGpSE8ZgGKzgYQVZeN97YE00 -----END RSA PRIVATE KEY-----",
13+
"startColumn": 9,
14+
"endColumn": 376,
15+
"value": "-----BEGIN RSA PRIVATE KEY----- MIIBOgIBAAJBAKj34GkxFhD90vcNLYLInFEX6Ppy1tPf9Cnzj4p4WGeKLs1Pt8Qu KUpRKfFLfRYC9AIKjbJTWit+Cq\r\n vjWYzvQwECAwEAAQJAIJLixBy2qpFoS4DSmoEm o3qGy0t6z09AIJtH+5OeRV1be+N4cDYJKffGzDa88vQENZiRm0GRq6a+HPGQMd2k TQIhAKMSvzIBnni7ot/OSie2TmJLY4SwTQAevXysE2RbFDYdAiEBCUEaRQnMnbp79mxDXDf6AU0cN/RPBjb9qSHDcWZHGzUCIG2Es59z8ugGrDY+pxLQnwfotadxd+Uy v/Ow5T0q5gIJAiEAyS4RaI9YG8EWx/2w0T67ZUVAw8eOMB6BIUg0Xcu+3okCIBOs /5OiPgoTdSy7bcF9IGpSE8ZgGKzgYQVZeN97YE00 -----END RSA PRIVATE KEY-----",
16+
"ruleDescription": "Identified a Private Key, which may compromise cryptographic security and sensitive data encryption.",
17+
"cvssScore": 8.2
18+
}
19+
],
20+
"58e5a02e5571db6dc1f9c0fdba8d86e254225bf1": [
21+
{
22+
"id": "58e5a02e5571db6dc1f9c0fdba8d86e254225bf1",
23+
"source": "testData/input/multi_line_secret.txt",
24+
"ruleId": "generic-api-key",
25+
"startLine": 1,
26+
"endLine": 1,
27+
"lineContent": "`\"client_id\" : \"0afae57f3ccfd9d7f5767067bc48b30f719e271ba470488056e37ab35d4b6506\"`,",
28+
"startColumn": 3,
29+
"endColumn": 81,
30+
"value": "0afae57f3ccfd9d7f5767067bc48b30f719e271ba470488056e37ab35d4b6506",
31+
"ruleDescription": "Detected a Generic API Key, potentially exposing access to various services and sensitive operations.",
32+
"cvssScore": 8.2
33+
}
34+
],
35+
"ed47a9a9052d119d91763ce84d689370fdbccf1f": [
36+
{
37+
"id": "ed47a9a9052d119d91763ce84d689370fdbccf1f",
38+
"source": "testData/input/multi_line_secret.txt",
39+
"ruleId": "generic-api-key",
40+
"startLine": 2,
41+
"endLine": 2,
42+
"lineContent": "\t\t`\"client_secret\" : \"6da89121079f83b2eb6acccf8219ea982c3d79bccc3e9c6a85856480661f8fde\",`",
43+
"startColumn": 5,
44+
"endColumn": 87,
45+
"value": "6da89121079f83b2eb6acccf8219ea982c3d79bccc3e9c6a85856480661f8fde",
46+
"ruleDescription": "Detected a Generic API Key, potentially exposing access to various services and sensitive operations.",
47+
"cvssScore": 8.2
48+
}
49+
]
50+
}
51+
}

tests/testData/expectedReport/secret_at_end_report.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@
99
"ruleId": "generic-api-key",
1010
"startLine": 2,
1111
"endLine": 2,
12-
"lineContent": "\n\t\t`\"client_secret\" : \"6da89121079f83b2eb6acccf8219ea982c3d79bccc3e9c6a85856480661f8fde\",`",
13-
"startColumn": 6,
14-
"endColumn": 88,
12+
"lineContent": "\t\t`\"client_secret\" : \"6da89121079f83b2eb6acccf8219ea982c3d79bccc3e9c6a85856480661f8fde\",`",
13+
"startColumn": 5,
14+
"endColumn": 87,
1515
"value": "6da89121079f83b2eb6acccf8219ea982c3d79bccc3e9c6a85856480661f8fde",
1616
"ruleDescription": "Detected a Generic API Key, potentially exposing access to various services and sensitive operations.",
1717
"cvssScore": 8.2
@@ -24,7 +24,7 @@
2424
"ruleId": "generic-api-key",
2525
"startLine": 1,
2626
"endLine": 1,
27-
"lineContent": "`\"client_id\" : \"0afae57f3ccfd9d7f5767067bc48b30f719e271ba470488056e37ab35d4b6506\"`,\r",
27+
"lineContent": "`\"client_id\" : \"0afae57f3ccfd9d7f5767067bc48b30f719e271ba470488056e37ab35d4b6506\"`,",
2828
"startColumn": 3,
2929
"endColumn": 81,
3030
"value": "0afae57f3ccfd9d7f5767067bc48b30f719e271ba470488056e37ab35d4b6506",

0 commit comments

Comments
 (0)