-
Notifications
You must be signed in to change notification settings - Fork 28
fix: add newline in fragment #288
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
34 commits
Select commit
Hold shift + click to select a range
2cdf668
Add e2e tests
cx-miguel-neiva 767651a
ignore testing secrets
cx-miguel-neiva 09d967e
ignore testing secrets
cx-miguel-neiva 46721c8
Change cmp to assert
cx-miguel-neiva 8bb1e97
Add normalized Reports
cx-miguel-neiva 20b63f5
Change test to run in Linux
cx-miguel-neiva 00425bd
ignore results
cx-miguel-neiva f30fc3e
change source
cx-miguel-neiva 2afbcda
ignore results
cx-miguel-neiva 61288cb
ignore secrets for test
cx-miguel-neiva f13df83
Normalize reports
cx-miguel-neiva 835d8cf
Merge branch 'master' into AST-82760-add-newline-in-fragment
cx-miguel-neiva 64daf9b
change id
cx-miguel-neiva 3b69759
Merge branch 'AST-82760-add-newline-in-fragment' of https://github.co…
cx-miguel-neiva 4e43579
try
cx-miguel-neiva 9586dfb
verify
cx-miguel-neiva 4e8c96a
change some inconsistencies
cx-miguel-neiva e393df2
remove 2m.json
cx-miguel-neiva 104a9dc
ignore id
cx-miguel-neiva ee41c96
Updated NromalizeReport funtion
cx-miguel-neiva 1038cbc
NormalizeReportData
cx-miguel-neiva 2f9a28b
Fix errors
cx-miguel-neiva b0c40dc
Fix inconsistency
cx-miguel-neiva 0e5f7b1
ignore secrets
cx-miguel-neiva deac280
ignore Results
cx-miguel-neiva 7dd9ed9
Fix EqualValus
cx-miguel-neiva 3c5a460
ignore 2ms Results
cx-miguel-neiva 252846a
Change e2e test Name
cx-miguel-neiva 549fb58
Remove 2ms Report
cx-miguel-neiva c39c3e2
ignore id
cx-miguel-neiva 437d729
ignroe results
cx-miguel-neiva cab6fdd
Change log errors funtions
cx-miguel-neiva d4630df
Assert changes
cx-miguel-neiva 95baa34
Merge branch 'master' into AST-82760-add-newline-in-fragment
cx-miguel-neiva File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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,27 @@ | ||
| package utils | ||
|
|
||
| import ( | ||
| "encoding/json" | ||
| "fmt" | ||
| "strings" | ||
| ) | ||
|
|
||
| // normalizeReportData recursively traverses the report data and removes any carriage return characters. | ||
| func NormalizeReportData(data interface{}) (interface{}, error) { | ||
| bytes, err := json.Marshal(data) | ||
| if err != nil { | ||
| return nil, fmt.Errorf("failed to marshal data: %w", err) | ||
| } | ||
|
|
||
| jsonStr := string(bytes) | ||
| jsonStr = strings.ReplaceAll(jsonStr, "\\r", "") | ||
|
|
||
| // Unmarshal back to a Go data structure | ||
| var result interface{} | ||
| err = json.Unmarshal([]byte(jsonStr), &result) | ||
| if err != nil { | ||
| return nil, fmt.Errorf("failed to unmarshal data: %w", err) | ||
| } | ||
|
|
||
| return result, nil | ||
| } |
This file contains hidden or 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 hidden or 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 hidden or 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
51 changes: 51 additions & 0 deletions
51
tests/testData/expectedReport/multi_line_secret_report.json
This file contains hidden or 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,51 @@ | ||
| { | ||
| "totalItemsScanned": 1, | ||
| "totalSecretsFound": 3, | ||
| "results": { | ||
| "047d26912b890e89c7f01b7ec9e926390224e4f0": [ | ||
| { | ||
| "id": "047d26912b890e89c7f01b7ec9e926390224e4f0", | ||
| "source": "testData/input/multi_line_secret.txt", | ||
| "ruleId": "private-key", | ||
| "startLine": 3, | ||
| "endLine": 4, | ||
| "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", | ||
| "startColumn": 10, | ||
| "endColumn": 377, | ||
| "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-----", | ||
| "ruleDescription": "Identified a Private Key, which may compromise cryptographic security and sensitive data encryption.", | ||
| "cvssScore": 8.2 | ||
| } | ||
| ], | ||
| "58e5a02e5571db6dc1f9c0fdba8d86e254225bf1": [ | ||
| { | ||
| "id": "58e5a02e5571db6dc1f9c0fdba8d86e254225bf1", | ||
| "source": "testData/input/multi_line_secret.txt", | ||
| "ruleId": "generic-api-key", | ||
| "startLine": 1, | ||
| "endLine": 1, | ||
| "lineContent": "`\"client_id\" : \"0afae57f3ccfd9d7f5767067bc48b30f719e271ba470488056e37ab35d4b6506\"`,\r", | ||
| "startColumn": 3, | ||
| "endColumn": 81, | ||
| "value": "0afae57f3ccfd9d7f5767067bc48b30f719e271ba470488056e37ab35d4b6506", | ||
| "ruleDescription": "Detected a Generic API Key, potentially exposing access to various services and sensitive operations.", | ||
| "cvssScore": 8.2 | ||
| } | ||
| ], | ||
| "ed47a9a9052d119d91763ce84d689370fdbccf1f": [ | ||
| { | ||
| "id": "ed47a9a9052d119d91763ce84d689370fdbccf1f", | ||
| "source": "testData/input/multi_line_secret.txt", | ||
| "ruleId": "generic-api-key", | ||
| "startLine": 2, | ||
| "endLine": 2, | ||
| "lineContent": "\n\t\t`\"client_secret\" : \"6da89121079f83b2eb6acccf8219ea982c3d79bccc3e9c6a85856480661f8fde\",`\r", | ||
| "startColumn": 6, | ||
| "endColumn": 88, | ||
| "value": "6da89121079f83b2eb6acccf8219ea982c3d79bccc3e9c6a85856480661f8fde", | ||
| "ruleDescription": "Detected a Generic API Key, potentially exposing access to various services and sensitive operations.", | ||
| "cvssScore": 8.2 | ||
| } | ||
| ] | ||
| } | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.