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

Add tickets key to control validation #10872

Merged
merged 1 commit into from
Jul 25, 2023
Merged
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
17 changes: 14 additions & 3 deletions ssg/controls.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,10 @@ class Control(ssg.entities.common.SelectionHandler, ssg.entities.common.XCCDFEnt
status_justification=str,
fixtext=str,
check=str,
tickets=list,
original_title=str,
related_rules=list,
controls=list,
)

MANDATORY_KEYS = {
Expand All @@ -108,6 +112,9 @@ def __init__(self):
self.fixtext = ""
self.check = ""
self.controls = []
self.tickets = []
self.original_title = ""
self.related_rules = []

def __hash__(self):
""" Controls are meant to be unique, so using the
Expand All @@ -117,9 +124,9 @@ def __hash__(self):
@classmethod
def _check_keys(cls, control_dict):
for key in control_dict.keys():
if key not in cls.KEYS.keys() and key not in [
'controls', 'original_title', 'related_rules', 'rules']:
raise ValueError("Key %s is not a valid for a control." % key)
# Rules shouldn't be in KEYS that data is in selections
if key not in cls.KEYS.keys() and key not in ['rules', ]:
raise ValueError("Key %s is not allowed in a control file." % key)

@classmethod
def from_control_dict(cls, control_dict, env_yaml=None, default_level=["default"]):
Expand All @@ -136,6 +143,10 @@ def from_control_dict(cls, control_dict, env_yaml=None, default_level=["default"
control.mitigation = control_dict.get('mitigation')
control.fixtext = control_dict.get('fixtext')
control.check = control_dict.get('check')
control.tickets = control_dict.get('tickets')
control.original_title = control_dict.get('original_title')
control.related_rules = control_dict.get('related_rules')

if control.status == "automated":
control.automated = "yes"
if control.automated not in ["yes", "no", "partially"]:
Expand Down