-
Notifications
You must be signed in to change notification settings - Fork 249
Whitelist lines ending in # nosec #121
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 7 commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
4cd3ea5
nosec_lines for #108's issue
omergunal ae9e8e9
nosec_lines
omergunal 1735db7
added nosec_lines parameter
omergunal fb88051
Update vulnerabilities.py
omergunal d0e8ef0
Code edited
omergunal 8569aa4
unnecessary codes deleted
omergunal e8cddd0
passed nosec_lines on analyse_repo
omergunal 3d5867b
Added nosec_lines
omergunal 1502ee7
added empty nosec lines for tests
omergunal bed2f77
added nosec_lines
omergunal 69d0193
added empty nosec_lines for tests
omergunal 3cb5186
Added ignore-nosec argument
omergunal ec6d23a
Update vulnerabilities_test.py
omergunal 6f09912
unnecessary codes removed
omergunal 9c4dea6
added default nosec_lines
omergunal f4ebbff
Update vulnerabilities.py
omergunal 7c872a0
Update vulnerabilities.py
omergunal b943310
removed spaces
omergunal 175c235
new line between imports and codes
omergunal c79161c
Update __main__.py
omergunal ed13514
new line between imports and codes
omergunal 0928700
removed set() from nosec_lines
omergunal 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -142,6 +142,9 @@ def parse_args(args): | |
| '(only JSON-formatted files are accepted)', | ||
| type=str, | ||
| default=False) | ||
| parser.add_argument('--ignore-nosec', dest='ignore_nosec', action='store_true', | ||
| help='do not skip lines with # nosec comments' | ||
| ) | ||
|
|
||
| save_parser = subparsers.add_parser('save', help='Save menu.') | ||
| save_parser.set_defaults(which='save') | ||
|
|
@@ -192,7 +195,7 @@ def parse_args(args): | |
| return parser.parse_args(args) | ||
|
|
||
|
|
||
| def analyse_repo(args, github_repo, analysis_type, ui_mode): | ||
| def analyse_repo(args, github_repo, analysis_type, ui_mode, nosec_lines): | ||
| cfg_list = list() | ||
| directory = os.path.dirname(github_repo.path) | ||
| project_modules = get_modules(directory) | ||
|
|
@@ -215,7 +218,8 @@ def analyse_repo(args, github_repo, analysis_type, ui_mode): | |
| VulnerabilityFiles( | ||
| args.blackbox_mapping_file, | ||
| args.trigger_word_file | ||
| ) | ||
| ), | ||
| nosec_lines | ||
| ) | ||
| return vulnerabilities | ||
|
|
||
|
|
@@ -235,12 +239,23 @@ def main(command_line_args=sys.argv[1:]): | |
| elif args.trim_reassigned_in: | ||
| ui_mode = UImode.TRIM | ||
|
|
||
| path = os.path.normpath(args.filepath) | ||
| cfg_list = list() | ||
| if args.ignore_nosec: | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. i moved the code this place and deleted |
||
| nosec_lines = set() | ||
| else: | ||
| file = open(path, "r") | ||
| lines = file.readlines() | ||
| nosec_lines = set( | ||
| lineno for | ||
| (lineno, line) in enumerate(lines, start=1) | ||
| if '#nosec' in line or '# nosec' in line) | ||
|
|
||
| if args.git_repos: | ||
| repos = get_repos(args.git_repos) | ||
| for repo in repos: | ||
| repo.clone() | ||
| vulnerabilities = analyse_repo(args, repo, analysis, ui_mode) | ||
| vulnerabilities = analyse_repo(args, repo, analysis, ui_mode, nosec_lines) | ||
| if args.json: | ||
| json.report(vulnerabilities, sys.stdout) | ||
| else: | ||
|
|
@@ -263,8 +278,6 @@ def main(command_line_args=sys.argv[1:]): | |
| ) | ||
| exit() | ||
|
|
||
| path = os.path.normpath(args.filepath) | ||
|
|
||
| directory = None | ||
| if args.project_root: | ||
| directory = os.path.normpath(args.project_root) | ||
|
|
@@ -305,8 +318,10 @@ def main(command_line_args=sys.argv[1:]): | |
| VulnerabilityFiles( | ||
| args.blackbox_mapping_file, | ||
| args.trigger_word_file | ||
| ) | ||
| ), | ||
| nosec_lines | ||
| ) | ||
|
|
||
| if args.baseline: | ||
| vulnerabilities = get_vulnerabilities_not_in_baseline(vulnerabilities, args.baseline) | ||
|
|
||
|
|
||
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.
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.
Its necessary for learning filename. i moved to above the ignore_nosec argument