From fe058b0457745b7a364b4546aeaacfe6e3a65b70 Mon Sep 17 00:00:00 2001 From: bcaller Date: 2018年8月13日 17:26:44 +0100 Subject: [PATCH 1/2] Deterministic file loading and vulnerability order os.walk is not deterministic (though often on the same computer it will walk in the same order). This means that the vulnerabilities appear in different orders on different machines, making it hard to compare output. Process files in alphabetical order. --- pyt/__main__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyt/__main__.py b/pyt/__main__.py index 192eaf99..b11e995b 100644 --- a/pyt/__main__.py +++ b/pyt/__main__.py @@ -79,7 +79,7 @@ def main(command_line_args=sys.argv[1:]): # noqa: C901 nosec_lines = defaultdict(set) - for path in files: + for path in sorted(files): if not args.ignore_nosec: nosec_lines[path] = retrieve_nosec_lines(path) From d6ad59fedd6c6f8ef7fc343384a7490efa688a1d Mon Sep 17 00:00:00 2001 From: bcaller Date: 2018年8月13日 17:29:43 +0100 Subject: [PATCH 2/2] Don't repeat get_modules call if we use a project root The project_modules only need loading once if -pr is set, not once for every file. --- pyt/__main__.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/pyt/__main__.py b/pyt/__main__.py index b11e995b..d578d4bc 100644 --- a/pyt/__main__.py +++ b/pyt/__main__.py @@ -79,15 +79,18 @@ def main(command_line_args=sys.argv[1:]): # noqa: C901 nosec_lines = defaultdict(set) + if args.project_root: + directory = os.path.normpath(args.project_root) + project_modules = get_modules(directory, prepend_module_root=args.prepend_module_root) + for path in sorted(files): if not args.ignore_nosec: nosec_lines[path] = retrieve_nosec_lines(path) - if args.project_root: - directory = os.path.normpath(args.project_root) - else: + if not args.project_root: directory = os.path.dirname(path) - project_modules = get_modules(directory, prepend_module_root=args.prepend_module_root) + project_modules = get_modules(directory, prepend_module_root=args.prepend_module_root) + local_modules = get_directory_modules(directory) tree = generate_ast(path)

AltStyle によって変換されたページ (->オリジナル) /