-
Notifications
You must be signed in to change notification settings - Fork 249
-r Recursive option #129
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
-r Recursive option #129
Changes from all commits
2ebe595
ef3a21d
38be6e2
759f632
ed38dbb
fcf4638
3ac883c
e246104
2cbac72
7875c82
ca0b2d7
d9db9dd
c35ae81
9c54d8c
40c0f8f
42759f0
5931faf
5546c3d
8d1d805
35b8001
2e4d07a
0c6b082
ae84a44
1944b4a
ba3d438
6a25e25
f42d283
c7b2f73
2afc177
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -30,7 +30,25 @@ | |
| ) | ||
|
|
||
|
|
||
| def main(command_line_args=sys.argv[1:]): # noqa: C901 | ||
| def discover_files(targets, excluded_files, recursive=False): | ||
| included_files = list() | ||
| excluded_list = excluded_files.split(",") | ||
| for target in targets: | ||
| if os.path.isdir(target): | ||
| for root, dirs, files in os.walk(target): | ||
| for f in files: | ||
| fullpath = os.path.join(root, f) | ||
| if os.path.splitext(fullpath)[1] == '.py' and fullpath.split("/")[-1] not in excluded_list: | ||
| included_files.append(fullpath) | ||
| if not recursive: | ||
| break | ||
| else: | ||
| if target not in excluded_list: | ||
| included_files.append(target) | ||
| return included_files | ||
|
|
||
|
|
||
| def main(command_line_args=sys.argv[1:]): | ||
| args = parse_args(command_line_args) | ||
|
|
||
| ui_mode = UImode.NORMAL | ||
|
|
@@ -39,60 +57,67 @@ def main(command_line_args=sys.argv[1:]): # noqa: C901 | |
| elif args.trim_reassigned_in: | ||
| ui_mode = UImode.TRIM | ||
|
|
||
| path = os.path.normpath(args.filepath) | ||
| files = discover_files( | ||
| args.targets, | ||
| args.excluded_paths, | ||
| args.recursive | ||
| ) | ||
|
|
||
| for path in files: | ||
| vulnerabilities = list() | ||
| if args.ignore_nosec: | ||
| 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.ignore_nosec: | ||
| 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.project_root: | ||
| directory = os.path.normpath(args.project_root) | ||
| else: | ||
| directory = os.path.dirname(path) | ||
| project_modules = get_modules(directory) | ||
| local_modules = get_directory_modules(directory) | ||
| tree = generate_ast(path) | ||
|
|
||
| if args.project_root: | ||
| directory = os.path.normpath(args.project_root) | ||
| else: | ||
| directory = os.path.dirname(path) | ||
| project_modules = get_modules(directory) | ||
| local_modules = get_directory_modules(directory) | ||
| cfg = make_cfg( | ||
| tree, | ||
| project_modules, | ||
| local_modules, | ||
| path | ||
| ) | ||
| cfg_list = [cfg] | ||
|
|
||
| tree = generate_ast(path) | ||
|
|
||
| cfg = make_cfg( | ||
| tree, | ||
| project_modules, | ||
| local_modules, | ||
| path | ||
| ) | ||
| cfg_list = [cfg] | ||
| framework_route_criteria = is_flask_route_function | ||
| if args.adaptor: | ||
| if args.adaptor.lower().startswith('e'): | ||
| framework_route_criteria = is_function | ||
| elif args.adaptor.lower().startswith('p'): | ||
| framework_route_criteria = is_function_without_leading_ | ||
| elif args.adaptor.lower().startswith('d'): | ||
| framework_route_criteria = is_django_view_function | ||
| # Add all the route functions to the cfg_list | ||
| FrameworkAdaptor( | ||
| cfg_list, | ||
| project_modules, | ||
| local_modules, | ||
| framework_route_criteria | ||
| ) | ||
| framework_route_criteria = is_flask_route_function | ||
| if args.adaptor: | ||
| if args.adaptor.lower().startswith('e'): | ||
| framework_route_criteria = is_function | ||
| elif args.adaptor.lower().startswith('p'): | ||
| framework_route_criteria = is_function_without_leading_ | ||
| elif args.adaptor.lower().startswith('d'): | ||
| framework_route_criteria = is_django_view_function | ||
| # Add all the route functions to the cfg_list | ||
| FrameworkAdaptor( | ||
| cfg_list, | ||
| project_modules, | ||
| local_modules, | ||
| framework_route_criteria | ||
| ) | ||
|
|
||
| initialize_constraint_table(cfg_list) | ||
| analyse(cfg_list) | ||
| vulnerabilities = find_vulnerabilities( | ||
| cfg_list, | ||
| ui_mode, | ||
| args.blackbox_mapping_file, | ||
| args.trigger_word_file, | ||
| nosec_lines | ||
| ) | ||
| initialize_constraint_table(cfg_list) | ||
| analyse(cfg_list) | ||
| vulnerabilities.extend(find_vulnerabilities( | ||
|
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. 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. Look good to you? 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. No, there are no vulnerability in a.py b.py and c.py but it printing from xss.py 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 didn't figure out the bug yet, gonna look more tomorrow 😁 This is harder than expected to track down 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. ok, i fixed it. its about |
||
| cfg_list, | ||
| ui_mode, | ||
| args.blackbox_mapping_file, | ||
| args.trigger_word_file, | ||
| nosec_lines | ||
| )) | ||
|
|
||
| if args.baseline: | ||
| vulnerabilities = get_vulnerabilities_not_in_baseline( | ||
|
|
||