-
Notifications
You must be signed in to change notification settings - Fork 244
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
Whitelist lines ending in # nosec #121
Merged
Merged
Changes from 20 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 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 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 |
---|---|---|
|
@@ -73,7 +73,8 @@ def identify_triggers( | |
cfg, | ||
sources, | ||
sinks, | ||
lattice | ||
lattice, | ||
nosec_lines=set() | ||
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. So |
||
): | ||
"""Identify sources, sinks and sanitisers in a CFG. | ||
|
||
|
@@ -89,12 +90,12 @@ def identify_triggers( | |
tainted_nodes = filter_cfg_nodes(cfg, TaintedNode) | ||
tainted_trigger_nodes = [TriggerNode('Framework function URL parameter', None, | ||
node) for node in tainted_nodes] | ||
sources_in_file = find_triggers(assignment_nodes, sources) | ||
sources_in_file = find_triggers(assignment_nodes, sources, nosec_lines) | ||
sources_in_file.extend(tainted_trigger_nodes) | ||
|
||
find_secondary_sources(assignment_nodes, sources_in_file, lattice) | ||
|
||
sinks_in_file = find_triggers(cfg.nodes, sinks) | ||
sinks_in_file = find_triggers(cfg.nodes, sinks, nosec_lines) | ||
|
||
sanitiser_node_dict = build_sanitiser_node_dict(cfg, sinks_in_file) | ||
|
||
|
@@ -170,7 +171,8 @@ def append_node_if_reassigned( | |
|
||
def find_triggers( | ||
nodes, | ||
trigger_words | ||
trigger_words, | ||
nosec_lines=set() | ||
): | ||
"""Find triggers from the trigger_word_list in the nodes. | ||
|
||
|
@@ -183,7 +185,8 @@ def find_triggers( | |
""" | ||
trigger_nodes = list() | ||
for node in nodes: | ||
trigger_nodes.extend(iter(label_contains(node, trigger_words))) | ||
if node.line_number not in nosec_lines: | ||
trigger_nodes.extend(iter(label_contains(node, trigger_words))) | ||
return trigger_nodes | ||
|
||
|
||
|
@@ -466,7 +469,8 @@ def find_vulnerabilities_in_cfg( | |
lattice, | ||
ui_mode, | ||
blackbox_mapping, | ||
vulnerabilities_list | ||
vulnerabilities_list, | ||
nosec_lines | ||
): | ||
"""Find vulnerabilities in a cfg. | ||
|
||
|
@@ -482,7 +486,8 @@ def find_vulnerabilities_in_cfg( | |
cfg, | ||
definitions.sources, | ||
definitions.sinks, | ||
lattice | ||
lattice, | ||
nosec_lines | ||
) | ||
for sink in triggers.sinks: | ||
for source in triggers.sources: | ||
|
@@ -503,7 +508,8 @@ def find_vulnerabilities( | |
cfg_list, | ||
analysis_type, | ||
ui_mode, | ||
vulnerability_files | ||
vulnerability_files, | ||
nosec_lines=set() | ||
): | ||
"""Find vulnerabilities in a list of CFGs from a trigger_word_file. | ||
|
||
|
@@ -518,7 +524,6 @@ def find_vulnerabilities( | |
""" | ||
vulnerabilities = list() | ||
definitions = parse(vulnerability_files.triggers) | ||
|
||
with open(vulnerability_files.blackbox_mapping) as infile: | ||
blackbox_mapping = json.load(infile) | ||
for cfg in cfg_list: | ||
|
@@ -528,9 +533,9 @@ def find_vulnerabilities( | |
Lattice(cfg.nodes, analysis_type), | ||
ui_mode, | ||
blackbox_mapping, | ||
vulnerabilities | ||
vulnerabilities, | ||
nosec_lines | ||
) | ||
with open(vulnerability_files.blackbox_mapping, 'w') as outfile: | ||
json.dump(blackbox_mapping, outfile, indent=4) | ||
|
||
return vulnerabilities |
This file contains 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 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 |
---|---|---|
|
@@ -23,7 +23,6 @@ | |
from pyt.node_types import Node | ||
from pyt.reaching_definitions_taint import ReachingDefinitionsTaintAnalysis | ||
|
||
|
||
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. Same here, sorry. |
||
class EngineTest(BaseTestCase): | ||
def run_empty(self): | ||
return | ||
|
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.
i moved the code this place and deleted
nosec_lines = set()
.Because its already created in if-else statement.