Skip to content

Commit

Permalink
Allow controls to skip being auto referenced
Browse files Browse the repository at this point in the history
Add a new key to tag controls that should not be added as a reference
during build.
  • Loading branch information
yuumasato committed Feb 27, 2024
1 parent c0135ba commit 3c3f68e
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
16 changes: 16 additions & 0 deletions docs/manual/developer/03_creating_content.md
Original file line number Diff line number Diff line change
Expand Up @@ -1097,6 +1097,22 @@ product: rhel9
reference_type: cis
```

#### Skipping automated reference assignment on individual Controls

Sometimes we don't want a specific control to be added as a reference to the rules it is selecting.
For example, the RHEL9 STIG selects rules that are not directly related to a STIG ID, but still are necessary for the correct evaluation of the Profile.

To skip a control from assigning references to its rules, add the `skip_reference: true` to it:
```
- id: needed_rules
levels:
- medium
skip_reference: true
rules:
- enable_authselect
- var_authselect_profile=sssd
```

### Using controls in profiles

Later, we can use the policy requirements in profile YAML. Let's say that we
Expand Down
5 changes: 5 additions & 0 deletions ssg/controls.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ class Control(ssg.entities.common.SelectionHandler, ssg.entities.common.XCCDFEnt
related_rules=list,
rules=list,
controls=list,
skip_reference=bool,
)

MANDATORY_KEYS = {
Expand Down Expand Up @@ -148,6 +149,7 @@ def from_control_dict(cls, control_dict, env_yaml=None, default_level=["default"
control.original_title = control_dict.get('original_title')
control.related_rules = control_dict.get('related_rules')
control.rules = control_dict.get('rules')
control.skip_reference = control_dict.get('skip_reference', False)

if control.status == "automated":
control.automated = "yes"
Expand Down Expand Up @@ -177,6 +179,9 @@ def represent_as_dict(self):
return data

def add_references(self, reference_type, rules):
if self.skip_reference:
return

for selection in self.rules:
if "=" in selection:
continue
Expand Down

0 comments on commit 3c3f68e

Please sign in to comment.