From 9befcc342fdf58f28accadd9fd5a7526059a423f Mon Sep 17 00:00:00 2001 From: Stefan Cornelius Date: Fri, 26 Jan 2024 12:37:19 +0100 Subject: [PATCH] results: skip comments in exclude-paths.txt This allows comments in the path exlusion regex file. Instead of adding each line as a filtering rule, it skips empty lines and lines starting with a # symbol. Fixes: https://issues.redhat.com/browse/OSH-508 Closes: https://github.com/csutils/csmock/pull/150 --- py/common/results.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/py/common/results.py b/py/common/results.py index 5c4ab57..58897dd 100644 --- a/py/common/results.py +++ b/py/common/results.py @@ -404,5 +404,8 @@ def handle_known_fp_list(props, results): lines = file_handle.readlines() for line in lines: path_re = line.strip() + if len(path_re) == 0 or path_re.startswith("#"): + # skip comments and empty lines + continue filter_cmd = f'csgrep --mode=json --invert-match --path="{shell_quote(path_re)}"' props.result_filters += [filter_cmd]