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

Automated Reference Assignment: Allow Skippping of Controls #11630

Closed
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
1 change: 1 addition & 0 deletions controls/stig_rhel9.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ controls:
- id: needed_rules
levels:
- medium
skip_reference: true
rules:
- enable_authselect
- var_authselect_profile=sssd
Expand Down
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
Loading