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

Bugged script for CCE-82024-1 #6898

Closed
BloodBlight opened this issue Apr 26, 2021 · 3 comments · Fixed by #7086
Closed

Bugged script for CCE-82024-1 #6898

BloodBlight opened this issue Apr 26, 2021 · 3 comments · Fixed by #7086

Comments

@BloodBlight
Copy link

Description of problem:

When running the remediation script for CCE-82024-1, it results in the following error:
sed: -e expression #1, char 33: unknown option to `s'

SCAP Security Guide Version:

Not sure

Operating System Version:

RHEL 7

Steps to Reproduce:

Create a script for CCE-82024-1 and run it. Code:

# Remediation is applicable only in certain platforms
if [ ! -f /.dockerenv ] && [ ! -f /run/.containerenv ]; then

if LC_ALL=C grep -q -m 1 "^install dccp" /etc/modprobe.d/dccp.conf ; then
	sed -i 's/^install dccp.*/install dccp /bin/true/g' /etc/modprobe.d/dccp.conf
else
	echo -e "\n# Disable per security requirements" >> /etc/modprobe.d/dccp.conf
	echo "install dccp /bin/true" >> /etc/modprobe.d/dccp.conf
fi

else
    >&2 echo 'Remediation is not applicable, nothing was done'
fi

Actual Results:

ERROR: sed: -e expression #1, char 33: unknown option to `s'

Expected Results:

File should be altered.

Additional Information/Debugging Steps:

Ran 's/^install dccp.*/install dccp /bin/true/g' trough https://sed.js.org/ and got the same error. Something is bugged on that line. I'm not very good with sed, so I'm not sure what it should look like.

@BloodBlight
Copy link
Author

Recommended fix from one of my co-workers:

sed -i 's#^install dccp.*#install dccp /bin/true#g' /etc/modprobe.d/dccp.conf

Seems to have worked after testing.

@BloodBlight
Copy link
Author

Looks like CCE-27277-3 has this issue as well. Maybe someone using an odd version of sed when making/testing these?

@cipherboy
Copy link
Contributor

@BloodBlight Good find! I think this is caused by the template. It'd be a very easy fix if you want to open a PR for it :-)

cipherboy added a commit to cipherboy/scap-security-guide that referenced this issue Jun 4, 2021
As reported in ComplianceAsCode#6898 by @BloodBlight, the sed invocation will fail to
evaluate due to use of `/` as the separator and as a path component in
the install <module> invocation.

Switch to `#` as the separator to avoid confusion with path components.

Resolves: ComplianceAsCode#6898

Signed-off-by: Alexander Scheel <alex.scheel@canonical.com>
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

Successfully merging a pull request may close this issue.

2 participants