ComplianceAsCode / content-test-filtering

System for Automatic Filtering of Tests for ComplianceAsCode project
8 stars 6 forks source link

Change rule prodtype search and make tests more content change proof #49

Closed mildas closed 9 months ago

mildas commented 9 months ago

Previously, CTF was taking products only from prodtype. That was wrong as it ignored implicit "all products".

Now, with https://github.com/ComplianceAsCode/content/pull/11378 prodtype removal, all rules must be part of some profile (at least the default.profile) to get to benchmark. And to get to profile, they might get there via controls (that was ignored as well by CTF).

This PR adds support for searching rules in control files (works with control_dirs as well) and changes the prodtype search to new approach - products are determined based on used profiles.

Test changes come from https://github.com/ComplianceAsCode/content-test-filtering/pull/47

For testing, you can for example try:

$ python3 content_test_filtering.py pr --verbose --repository /home/mlysonek/SCAP/content 11501

to check that ocp4 product is selected (the rule introduced in this PR is only in controls file). (related to https://github.com/ComplianceAsCode/content/pull/11501#issuecomment-1916764237)

ggbecker commented 9 months ago

PR looks good to me. That's a great improvement.