Skip to content

Commit

Permalink
Rename option
Browse files Browse the repository at this point in the history
Rename automatus.py option `--remove-machine-only` to
`--make-applicable-in-containers`. The new name better expresses the
actual purpose of this option. Renaming it also removes the confusion
about the "machine" platform.  Consequently, rename this option also in
the wrapper script test_rule_in_container.sh.
  • Loading branch information
jan-cerny committed Oct 8, 2024
1 parent 018a15b commit 0f8cd57
Show file tree
Hide file tree
Showing 14 changed files with 43 additions and 39 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/automatus-cs9.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ jobs:
name: ${{ env.DATASTREAM }}
- name: Run tests in a container - Bash
if: ${{steps.bash.outputs.prop == 'True' && steps.ctf.outputs.CTF_OUTPUT_SIZE != '0' }}
run: tests/test_rule_in_container.sh --no-remove-machine-only --dontclean --logdir logs_bash --remediate-using bash --name ssg_test_suite --datastream $DATASTREAM ${{join(fromJSON(steps.rules.outputs.prop))}}
run: tests/test_rule_in_container.sh --no-make-applicable-in-containers --dontclean --logdir logs_bash --remediate-using bash --name ssg_test_suite --datastream $DATASTREAM ${{join(fromJSON(steps.rules.outputs.prop))}}
env:
ADDITIONAL_TEST_OPTIONS: "--duplicate-templates --remove-fips-certified --product rhel9"
- name: Check for ERROR in logs
Expand All @@ -157,7 +157,7 @@ jobs:
path: logs_bash/
- name: Run tests in a container - Ansible
if: ${{ steps.ansible.outputs.prop == 'True' && steps.ctf.outputs.CTF_OUTPUT_SIZE != '0' }}
run: tests/test_rule_in_container.sh --no-remove-machine-only --dontclean --logdir logs_ansible --remediate-using ansible --name ssg_test_suite --datastream $DATASTREAM ${{join(fromJSON(steps.rules.outputs.prop))}}
run: tests/test_rule_in_container.sh --no-make-applicable-in-containers --dontclean --logdir logs_ansible --remediate-using ansible --name ssg_test_suite --datastream $DATASTREAM ${{join(fromJSON(steps.rules.outputs.prop))}}
env:
ADDITIONAL_TEST_OPTIONS: "--duplicate-templates --remove-fips-certified --product rhel9"
- name: Check for ERROR in logs
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/automatus-debian12.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ jobs:
name: ${{ env.DATASTREAM }}
- name: Run tests in a container - Bash
if: ${{steps.bash.outputs.prop == 'True' && steps.ctf.outputs.CTF_OUTPUT_SIZE != '0' }}
run: tests/test_rule_in_container.sh --no-remove-machine-only --dontclean --logdir logs_bash --remediate-using bash --name ssg_test_suite --datastream $DATASTREAM ${{join(fromJSON(steps.rules.outputs.prop))}}
run: tests/test_rule_in_container.sh --no-make-applicable-in-containers --dontclean --logdir logs_bash --remediate-using bash --name ssg_test_suite --datastream $DATASTREAM ${{join(fromJSON(steps.rules.outputs.prop))}}
env:
ADDITIONAL_TEST_OPTIONS: "--duplicate-templates --remove-fips-certified"
- name: Check for ERROR in logs
Expand All @@ -173,7 +173,7 @@ jobs:
path: logs_bash/
- name: Run tests in a container - Ansible
if: ${{ steps.ansible.outputs.prop == 'True' && steps.ctf.outputs.CTF_OUTPUT_SIZE != '0' }}
run: tests/test_rule_in_container.sh --no-remove-machine-only --dontclean --logdir logs_ansible --remediate-using ansible --name ssg_test_suite --datastream $DATASTREAM ${{join(fromJSON(steps.rules.outputs.prop))}}
run: tests/test_rule_in_container.sh --no-make-applicable-in-containers --dontclean --logdir logs_ansible --remediate-using ansible --name ssg_test_suite --datastream $DATASTREAM ${{join(fromJSON(steps.rules.outputs.prop))}}
env:
ADDITIONAL_TEST_OPTIONS: "--duplicate-templates --remove-fips-certified --product debian12"
- name: Check for ERROR in logs
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/automatus-sanity.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,13 @@ jobs:
with:
name: ${{ env.DATASTREAM }}
- name: Check One Rule
run: ./tests/automatus.py rule --remove-platforms --remove-machine-only --logdir log_rule --datastream ssg-fedora-ds.xml --container ssg_test_suite package_sudo_installed
run: ./tests/automatus.py rule --remove-platforms --make-applicable-in-containers --logdir log_rule --datastream ssg-fedora-ds.xml --container ssg_test_suite package_sudo_installed
- name: Check One Rule - Ansible
run: ./tests/automatus.py rule --remove-platforms --remove-machine-only --logdir log_rule_ansible --remediate-using ansible --datastream ssg-fedora-ds.xml --container ssg_test_suite package_sudo_installed
run: ./tests/automatus.py rule --remove-platforms --make-applicable-in-containers --logdir log_rule_ansible --remediate-using ansible --datastream ssg-fedora-ds.xml --container ssg_test_suite package_sudo_installed
- name: Check Profile Mode
run: ./tests/automatus.py profile --remove-platforms --remove-machine-only --logdir log_profile --datastream ssg-fedora-ds.xml --container ssg_test_suite test
run: ./tests/automatus.py profile --remove-platforms --make-applicable-in-containers --logdir log_profile --datastream ssg-fedora-ds.xml --container ssg_test_suite test
- name: Check Combined Mode
run: ./tests/automatus.py combined --remove-platforms --remove-machine-only --logdir log_combined --datastream ssg-fedora-ds.xml --container ssg_test_suite test
run: ./tests/automatus.py combined --remove-platforms --make-applicable-in-containers --logdir log_combined --datastream ssg-fedora-ds.xml --container ssg_test_suite test
- name: Check Template Mode
run: ./tests/automatus.py template --logdir log_template --datastream ssg-fedora-ds.xml --container ssg_test_suite --slice 1 15 file_owner
- name: Check for ERROR in logs
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/automatus-sle15.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ jobs:
name: ${{ env.DATASTREAM }}
- name: Run tests in a container - Bash
if: ${{steps.bash.outputs.prop == 'True' && steps.ctf.outputs.CTF_OUTPUT_SIZE != '0' }}
run: tests/test_rule_in_container.sh --no-remove-machine-only --dontclean --logdir logs_bash --remediate-using bash --name ssg_test_suite --datastream $DATASTREAM ${{join(fromJSON(steps.rules.outputs.prop))}}
run: tests/test_rule_in_container.sh --no-make-applicable-in-containers --dontclean --logdir logs_bash --remediate-using bash --name ssg_test_suite --datastream $DATASTREAM ${{join(fromJSON(steps.rules.outputs.prop))}}
env:
ADDITIONAL_TEST_OPTIONS: "--duplicate-templates --remove-fips-certified --product sle15"
- name: Check for ERROR in logs
Expand All @@ -165,7 +165,7 @@ jobs:
path: logs_bash/
- name: Run tests in a container - Ansible
if: ${{ steps.ansible.outputs.prop == 'True' && steps.ctf.outputs.CTF_OUTPUT_SIZE != '0' }}
run: tests/test_rule_in_container.sh --no-remove-machine-only --dontclean --logdir logs_ansible --remediate-using ansible --name ssg_test_suite --datastream $DATASTREAM ${{join(fromJSON(steps.rules.outputs.prop))}}
run: tests/test_rule_in_container.sh --no-make-applicable-in-containers --dontclean --logdir logs_ansible --remediate-using ansible --name ssg_test_suite --datastream $DATASTREAM ${{join(fromJSON(steps.rules.outputs.prop))}}
env:
ADDITIONAL_TEST_OPTIONS: "--duplicate-templates --remove-fips-certified --product sle15"
- name: Check for ERROR in logs
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/automatus-ubi8.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ jobs:
name: ${{ env.DATASTREAM }}
- name: Run tests in a container - Bash
if: ${{steps.bash.outputs.prop == 'True' && steps.ctf.outputs.CTF_OUTPUT_SIZE != '0' }}
run: tests/test_rule_in_container.sh --no-remove-machine-only --dontclean --logdir logs_bash --remediate-using bash --name ssg_test_suite --datastream $DATASTREAM ${{join(fromJSON(steps.rules.outputs.prop))}}
run: tests/test_rule_in_container.sh --no-make-applicable-in-containers --dontclean --logdir logs_bash --remediate-using bash --name ssg_test_suite --datastream $DATASTREAM ${{join(fromJSON(steps.rules.outputs.prop))}}
env:
ADDITIONAL_TEST_OPTIONS: "--duplicate-templates --remove-fips-certified --product rhel8"
- name: Check for ERROR in logs
Expand All @@ -157,7 +157,7 @@ jobs:
path: logs_bash/
- name: Run tests in a container - Ansible
if: ${{ steps.ansible.outputs.prop == 'True' && steps.ctf.outputs.CTF_OUTPUT_SIZE != '0' }}
run: tests/test_rule_in_container.sh --no-remove-machine-only --dontclean --logdir logs_ansible --remediate-using ansible --name ssg_test_suite --datastream $DATASTREAM ${{join(fromJSON(steps.rules.outputs.prop))}}
run: tests/test_rule_in_container.sh --no-make-applicable-in-containers --dontclean --logdir logs_ansible --remediate-using ansible --name ssg_test_suite --datastream $DATASTREAM ${{join(fromJSON(steps.rules.outputs.prop))}}
env:
ADDITIONAL_TEST_OPTIONS: "--duplicate-templates --remove-fips-certified --product rhel8"
- name: Check for ERROR in logs
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/automatus-ubuntu2204.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ jobs:
name: ${{ env.DATASTREAM }}
- name: Run tests in a container - Bash
if: ${{steps.bash.outputs.prop == 'True' && steps.ctf.outputs.CTF_OUTPUT_SIZE != '0' }}
run: tests/test_rule_in_container.sh --no-remove-machine-only --dontclean --logdir logs_bash --remediate-using bash --name ssg_test_suite --datastream $DATASTREAM ${{join(fromJSON(steps.rules.outputs.prop))}}
run: tests/test_rule_in_container.sh --no-make-applicable-in-containers --dontclean --logdir logs_bash --remediate-using bash --name ssg_test_suite --datastream $DATASTREAM ${{join(fromJSON(steps.rules.outputs.prop))}}
env:
ADDITIONAL_TEST_OPTIONS: "--duplicate-templates --remove-fips-certified"
- name: Check for ERROR in logs
Expand All @@ -173,7 +173,7 @@ jobs:
path: logs_bash/
- name: Run tests in a container - Ansible
if: ${{ steps.ansible.outputs.prop == 'True' && steps.ctf.outputs.CTF_OUTPUT_SIZE != '0' }}
run: tests/test_rule_in_container.sh --no-remove-machine-only --dontclean --logdir logs_ansible --remediate-using ansible --name ssg_test_suite --datastream $DATASTREAM ${{join(fromJSON(steps.rules.outputs.prop))}}
run: tests/test_rule_in_container.sh --no-make-applicable-in-containers --dontclean --logdir logs_ansible --remediate-using ansible --name ssg_test_suite --datastream $DATASTREAM ${{join(fromJSON(steps.rules.outputs.prop))}}
env:
ADDITIONAL_TEST_OPTIONS: "--duplicate-templates --remove-fips-certified --product ubuntu2204"
- name: Check for ERROR in logs
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/automatus.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ jobs:
name: ssg-${{steps.product.outputs.prop}}-ds.xml
- name: Run tests in a container - Bash
if: ${{steps.bash.outputs.prop == 'True' && steps.ctf.outputs.CTF_OUTPUT_SIZE != '0' }}
run: tests/test_rule_in_container.sh --no-remove-machine-only --dontclean --logdir logs_bash --remediate-using bash --name ssg_test_suite --datastream ssg-${{steps.product.outputs.prop}}-ds.xml ${{join(fromJSON(steps.rules.outputs.prop))}}
run: tests/test_rule_in_container.sh --no-make-applicable-in-containers --dontclean --logdir logs_bash --remediate-using bash --name ssg_test_suite --datastream ssg-${{steps.product.outputs.prop}}-ds.xml ${{join(fromJSON(steps.rules.outputs.prop))}}
env:
ADDITIONAL_TEST_OPTIONS: "--duplicate-templates --remove-fips-certified"
- name: Check for ERROR in logs
Expand All @@ -155,7 +155,7 @@ jobs:
path: logs_bash/
- name: Run tests in a container - Ansible
if: ${{ steps.ansible.outputs.prop == 'True' && steps.ctf.outputs.CTF_OUTPUT_SIZE != '0' }}
run: tests/test_rule_in_container.sh --no-remove-machine-only --dontclean --logdir logs_ansible --remediate-using ansible --name ssg_test_suite --datastream ssg-${{steps.product.outputs.prop}}-ds.xml ${{join(fromJSON(steps.rules.outputs.prop))}}
run: tests/test_rule_in_container.sh --no-make-applicable-in-containers --dontclean --logdir logs_ansible --remediate-using ansible --name ssg_test_suite --datastream ssg-${{steps.product.outputs.prop}}-ds.xml ${{join(fromJSON(steps.rules.outputs.prop))}}
env:
ADDITIONAL_TEST_OPTIONS: "--duplicate-templates --remove-fips-certified"
- name: Check for ERROR in logs
Expand Down
2 changes: 1 addition & 1 deletion .gitpod.launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
"${workspaceFolder}/build/ssg-${input:pickProductName}-ds.xml",
"--remediate-using",
"${input:pickRemediationType}",
"--remove-machine-only",
"--make-applicable-in-containers",
"--remove-ocp4-only",
"--remove-fips-certified",
"--remove-platforms",
Expand Down
2 changes: 1 addition & 1 deletion docs/workshop/lab3_profiles.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -645,7 +645,7 @@ You also add arguments to turn on full reporting, which generates XML and HTML r
--docker {container_name} \
--datastream build/ssg-rhel8-ds.xml \
--remediate-using bash \
--remove-machine-only \
--make-applicable-in-containers \
--remove-platforms \
--logdir profile-log \
travel
Expand Down
14 changes: 7 additions & 7 deletions docs/workshop/lab5_oval.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ With that in mind, execute the test suite:
--docker {container_name} \
--datastream build/ssg-rhel8-ds.xml \
--remediate-using bash \
--remove-machine-only \
--make-applicable-in-containers \
--remove-platforms \
accounts_tmout
----
Expand Down Expand Up @@ -431,7 +431,7 @@ TIP: You can use the `Up` arrow key to browse the command history so you do not
--docker {container_name} \
--datastream build/ssg-rhel8-ds.xml \
--remediate-using bash \
--remove-machine-only \
--make-applicable-in-containers \
--remove-platforms \
accounts_tmout
----
Expand Down Expand Up @@ -571,7 +571,7 @@ This way, you do not have to worry about possibly introducing those link:https:/
[... ]$ SSH_ADDITIONAL_OPTIONS="-o IdentityFile=/workspace/content/.ssh/id_rsa" tests/automatus.py rule \
--docker {container_name} \
--remediate-using bash \
--remove-machine-only \
--make-applicable-in-containers \
--remove-platforms \
accounts_tmout
----
Expand Down Expand Up @@ -654,7 +654,7 @@ fi
[... ]$ SSH_ADDITIONAL_OPTIONS="-o IdentityFile=/workspace/content/.ssh/id_rsa" tests/automatus.py rule \
--docker {container_name} \
--remediate-using bash \
--remove-machine-only \
--make-applicable-in-containers \
--remove-platforms \
accounts_tmout
----
Expand Down Expand Up @@ -703,7 +703,7 @@ This time, when rebuilt and executed again, the tests pass:
[... ]$ SSH_ADDITIONAL_OPTIONS="-o IdentityFile=/workspace/content/.ssh/id_rsa" tests/automatus.py rule \
--docker {container_name} \
--remediate-using bash \
--remove-machine-only \
--make-applicable-in-containers \
--remove-platforms \
accounts_tmout
----
Expand Down Expand Up @@ -755,7 +755,7 @@ Execute the test suite again and expect the `ERROR - Script correct_value.pass.s
[... ]$ SSH_ADDITIONAL_OPTIONS="-o IdentityFile=/workspace/content/.ssh/id_rsa" tests/automatus.py rule \
--docker {container_name} \
--remediate-using bash \
--remove-machine-only \
--make-applicable-in-containers \
--remove-platforms \
accounts_tmout
----
Expand Down Expand Up @@ -802,7 +802,7 @@ The non-capturing group that consists of `export` followed by at least one white
[... ]$ SSH_ADDITIONAL_OPTIONS="-o IdentityFile=/workspace/content/.ssh/id_rsa" tests/automatus.py rule \
--docker {container_name} \
--remediate-using bash \
--remove-machine-only \
--make-applicable-in-containers \
--remove-platforms \
accounts_tmout
----
Expand Down
2 changes: 1 addition & 1 deletion tests/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -406,7 +406,7 @@ Using Podman:
```

or just call the `test_rule_in_container.sh` script that passes the backend options for you
in addition to `--remove-machine-only` and `--remove-platforms`
in addition to `--make-applicable-in-containers` and `--remove-platforms`
that remove some testing limitations of the container backend.

Using Docker:
Expand Down
9 changes: 4 additions & 5 deletions tests/automatus.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,10 +92,10 @@ def parse_args():
"Although more low level platforms such as packages or container/machine "
"CPE are still applicable.")
common_parser.add_argument(
"--remove-machine-only",
"--make-applicable-in-containers",
default=False,
action="store_true",
help="Removes machine-only platform constraint from rules "
help="Removes platform constraints from rules "
"to enable testing these rules on container backends.")
common_parser.add_argument(
"--remove-ocp4-only",
Expand Down Expand Up @@ -501,9 +501,8 @@ def main():
with xml_operations.datastream_root(stashed_datastream, stashed_datastream) as root:
if options.remove_platforms:
xml_operations.remove_platforms(root)
if options.remove_machine_only:
xml_operations.remove_machine_platform(root)
xml_operations.remove_machine_remediation_condition(root)
if options.make_applicable_in_containers:
xml_operations.make_applicable_in_containers(root)
if options.remove_ocp4_only:
xml_operations.remove_ocp4_platforms(root)
if options.add_platform:
Expand Down
5 changes: 5 additions & 0 deletions tests/ssg_test_suite/xml_operations.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,11 @@ def instance_in_platforms(inst, platforms):
(hasattr(platforms, "__iter__") and inst.get("idref") in platforms)


def make_applicable_in_containers(root):
remove_machine_platform(root)
remove_machine_remediation_condition(root)


def remove_machine_platform(root):
remove_platforms_from_element(root, "xccdf-1.2:Rule", "cpe:/a:machine")
remove_platforms_from_element(root, "xccdf-1.2:Group", "cpe:/a:machine")
Expand Down
Loading

0 comments on commit 0f8cd57

Please sign in to comment.