Misc fixes - building in plan, PyYAML, datastream XML parsing #260
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
(These were originally part of a new
audit-sample-rules
test, #259, but I decided to split them off for easier discussion tracking.)Going by commits, from oldest:
add
util/backup.py
for backup+restore of filesystem pathsThis was for an earlier version of the test, which actually remediated the audit rules into
/etc/audit
- I first had a VM-using test, but realized we need to run it multi-arch, so I rewrote it without VMs, hence the backup/restore.The current version of the test doesn't use this, but I think it would still be good to have it, rather than throw the code away. The early versions of Contest also had it: https://github.com/RHSecurityCompliance/contest/blob/bb2778816c463f9148395c8e566c7724ce60b28e/lib/backup.sh 😄
start using PyYAML instead of hacking YAML syntax
From the commit message body:
I specifically needed it in the audit test to parse ansible remediations and get
.rules
filepath / contents without having to sed/grep bash code.build
CONTEST_CONTENT
in a TMT plan prepare stepPer the commit:
split off xml-parsing code from
class Datastream
I originally wanted to redesign the whole XML parsing in
class Datastream
to have a more modular "what you want" data retrieval:However, mid-way through implementing it, I realized that when parsing out remediation code, we probably don't want to extract all 10s of MBs of code, just a few select rules.
So I went with what's in the commit - splitting off the batched XML parser, allowing the audit test to parse the DS XML on its own, extracting remediation code only for rules in the
policy_rules
Group.I'm not against revisiting the
class Datastream
code in the future, but (depite the big+++
and---
), nothing has really changed inside, aside from one minor bug fix (elem.get
toelements[-1].get
).