-
Notifications
You must be signed in to change notification settings - Fork 9
Description
token_before: "s/[\"
token_after: "s/[\"
Traceback (most recent call last):
File "/home/ggasparb/workspace/github/content-test-filtering/content_test_filtering.py", line 45, in <module>
diff_structure = diff_analysis.analyse_file(file_record)
File "/home/ggasparb/workspace/github/content-test-filtering/ctf/diff_analysis.py", line 54, in analyse_file
return file_analyzer.process_analysis()
File "/home/ggasparb/workspace/github/content-test-filtering/ctf/analysis/BashAnalysis.py", line 123, in process_analysis
self.analyse_bash()
File "/home/ggasparb/workspace/github/content-test-filtering/ctf/analysis/BashAnalysis.py", line 91, in analyse_bash
token_before = tokens_before.get_token()
File "/usr/lib64/python3.9/shlex.py", line 109, in get_token
raw = self.read_token()
File "/usr/lib64/python3.9/shlex.py", line 191, in read_token
raise ValueError("No closing quotation")
ValueError: No closing quotation
The problem is the backslash that escapes the double quotes. The bash content that is being parsed is this one:
https://github.com/ComplianceAsCode/content/blob/fc6bdac51301debae58900bac597183cd7039620/linux_os/guide/system/logging/ensure_rsyslog_log_file_configuration/rsyslog_files_permissions/bash/shared.sh#L39
CLEANED_PATHS=$(sed -e "s/[\"')]//g; /\\/etc.*\.conf/d; /\\/dev\\//d" <<< "${FILTERED_PATHS}")
CTF identifies partially the token probably because this crazy sed command construction.
Reproducer: python3 content_test_filtering.py pr --rule --output json 7715
I don't know if we can circumvent this here or if this is a legitimate problem with the content. Either way we could catch the ValueError exception so the it doesn't crash.