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

Don't scan after a failed Ansible remediation #290

Merged
merged 1 commit into from
Nov 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions hardening/ansible/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,8 @@
*skip_tags_arg,
playbook,
]
proc, lines = util.subprocess_stream(ansible_cmd)
failed = ansible.report_from_output(lines)
if proc.returncode not in [0,2] or proc.returncode == 2 and not failed:
raise RuntimeError(f"ansible-playbook failed with {proc.returncode}")
_, lines = util.subprocess_stream(ansible_cmd, check=True)
ansible.report_from_output(lines)
g.soft_reboot()

# scan the remediated system
Expand Down
6 changes: 2 additions & 4 deletions hardening/host-os/ansible/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,8 @@
*skip_tags_arg,
playbook,
]
proc, lines = util.subprocess_stream(cmd)
failed = ansible.report_from_output(lines)
if proc.returncode not in [0,2] or proc.returncode == 2 and not failed:
raise RuntimeError(f"ansible-playbook failed with {proc.returncode}")
_, lines = util.subprocess_stream(cmd, check=True)
ansible.report_from_output(lines)

# restore basic login functionality
with open('/etc/sysconfig/sshd', 'a') as f:
Expand Down
6 changes: 2 additions & 4 deletions scanning/disa-alignment/ansible.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,8 @@
*skip_tags_arg,
playbook,
]
proc, lines = util.subprocess_stream(ansible_cmd)
failed = ansible.report_from_output(lines)
if proc.returncode not in [0,2] or proc.returncode == 2 and not failed:
raise RuntimeError(f"ansible-playbook failed with {proc.returncode}")
_, lines = util.subprocess_stream(ansible_cmd, check=True)
ansible.report_from_output(lines)
g.soft_reboot()

with util.get_content(build=False) as content_dir:
Expand Down