Skip to content
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

Traceback when analysing Bash remediation of rsyslog_files_permissions #20

Open
ggbecker opened this issue Oct 18, 2021 · 0 comments
Open

Comments

@ggbecker
Copy link
Member

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant