-
-
Notifications
You must be signed in to change notification settings - Fork 655
Fix false positives for SQL string concatenation with constants from another file #247
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
ccojocar
merged 8 commits into
securego:master
from
wongherlung:sql-string-concatenation
Sep 28, 2018
Merged
Changes from 5 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
35bbb97
Allow for SQL concatenation of nodes that resolve to literals
wongherlung 74bad7b
Fix typo in comment.
wongherlung 3cd750d
Go through all files in package to resolve that identifier
wongherlung 8dc54e5
Refactor code and added comments.
wongherlung 13e2cbf
Changed checking to not var or func.
wongherlung 04e1c2a
Allow for supporting code for test cases.
wongherlung 6970dac
Merge branch 'master' into sql-string-concatenation
wongherlung bd870b9
Resolve merge conflict changes.
wongherlung 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
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be nice to have a test for this use case.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 I was thinking so too. But this test case spans across two files and I'm not sure how to do it. Let me try to figure it out.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you can extend the
sample.Code
to support multiple files. The test package is built here:gosec/rules/rules_test.go
Line 35 in 5f98926
In this file are the code samples defined:
https://github.com/securego/gosec/blob/master/testutils/source.go
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added a new value to the
CodeSample
struct.Snippets that have it set to
true
will not be processed against the rules, but added to the samepkg
as the other snippets to be processed together.Not sure if this is this most elegant way to allow for testing with multiple files. Feedback will be welcomed!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks fine. You could have also use a
Code []string
. To keep multiple files. I will refactoring afterwards.Thanks for providing the tests.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ahh yes. It's much better to use
Code []string
. If you are okay, can I help with the refactoring? for https://hacktoberfest.digitalocean.com/ 😂There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I refactored it in the PR #248