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

Bash remediation of mount_option template incorrectly handles commented lines #10526

Closed
vojtapolasek opened this issue May 4, 2023 · 4 comments · Fixed by #11009
Closed

Bash remediation of mount_option template incorrectly handles commented lines #10526

vojtapolasek opened this issue May 4, 2023 · 4 comments · Fixed by #11009
Assignees
Labels
Bash Bash remediation update.
Milestone

Comments

@vojtapolasek
Copy link
Collaborator

Description of problem:

Recently merged PR introduces a change to OVAL which can correctly process also commented lines in /etc/fstab. The PR is #10518
Unfortunately, the Bash remediation does not work (produces error) in case the /etc/fstab contains a commented line which is correct, and this line is followed by an uncommented incorrect line.

SCAP Security Guide Version:

master as of cad3f18

Operating System Version:

RHEL 8

Steps to Reproduce:

  1. create this test scenario in shared/templates/mount_option/tests:
#!/bin/bash

# platform = multi_platform_all
. $SHARED/partition.sh

clean_up_partition {{{ MOUNTPOINT }}}

create_partition
make_fstab_given_partition_line {{{ MOUNTPOINT }}} ext2 {{{ MOUNTOPTION }}}

# comment last line added above to be ignored
sed -Ei '${s/^/#/}' /etc/fstab

make_fstab_given_partition_line {{{ MOUNTPOINT }}} ext2 defaults

mount_partition {{{ MOUNTPOINT }}} || true
  1. ./build_product rhel8
  2. ce tests
  3. python automatus.py template --libvirt qemu:///system rhel8 mount_option

Actual Results:

The created test scenario makes the scan finish with an error.

Expected Results:

The scenario should be passing.

Additional Information/Debugging Steps:

Ansible remediation works correctly.

@vojtapolasek vojtapolasek added the Bash Bash remediation update. label May 4, 2023
@vojtapolasek vojtapolasek added this to the 0.1.68 milestone May 4, 2023
@jan-cerny jan-cerny modified the milestones: 0.1.68, 0.1.69 May 29, 2023
@vojtapolasek vojtapolasek modified the milestones: 0.1.69, 0.1.70 Jul 18, 2023
@dodys
Copy link
Contributor

dodys commented Jul 31, 2023

I think that this PR might have fixed this issue:
#10754

@jan-cerny
Copy link
Collaborator

Unfortunately, the bug is still reproducible using the scenario above.

@dodys
Copy link
Contributor

dodys commented Aug 22, 2023

Unfortunately, the bug is still reproducible using the scenario above.

this test already exists in shared/templates/mount_option/tests/fstab_comment.pass.sh and it is passing for me. I wonder if there's anything else that we are missing here.

@vojtapolasek
Copy link
Collaborator Author

@dodys the test scenario you mention tests something else. The test scenario in the PR dewscription puts there a correct line and comments it out, then it adds wrong line. The test scenario you mention adds correct line, comments it out, then it adds correct line again.

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

Successfully merging a pull request may close this issue.

3 participants