Skip to content

Commit

Permalink
Handle no control_enhancement case
Browse files Browse the repository at this point in the history
  • Loading branch information
terwilligergreen committed Oct 26, 2015
1 parent cfe51e0 commit b19b18d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
9 changes: 6 additions & 3 deletions compliancelib/seccontrol.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,12 @@ def _load_control_from_xml(self):
self.description = ''.join(sc.find('{http://scap.nist.gov/schema/sp800-53/2.0}statement').itertext())
self.description = re.sub(r'[ ]{2,}','',re.sub(r'^[ ]', '',re.sub(r'\n','',re.sub(r'[ ]{2,}',' ',self.description))))
self.description = self.description.replace(self.id, '\n').strip()
self.control_enhancements = ''.join(sc.find('{http://scap.nist.gov/schema/sp800-53/2.0}control-enhancements').itertext())
self.control_enhancements = re.sub(r'[ ]{2,}','',re.sub(r'^[ ]', '',re.sub(r'[\n ]{2,}','\n',re.sub(r'[ ]{2,}',' ',self.control_enhancements))))
# self.control_enhancements = self.control_enhancements.replace(self.id, '\n')
if (sc.find('{http://scap.nist.gov/schema/sp800-53/2.0}control-enhancements')) is not None:
self.control_enhancements = ''.join(sc.find('{http://scap.nist.gov/schema/sp800-53/2.0}control-enhancements').itertext())
self.control_enhancements = re.sub(r'[ ]{2,}','',re.sub(r'^[ ]', '',re.sub(r'[\n ]{2,}','\n',re.sub(r'[ ]{2,}',' ',self.control_enhancements))))
# self.control_enhancements = self.control_enhancements.replace(self.id, '\n')
else:
self.control_enhancements = None
self.sg = sc.find('{http://scap.nist.gov/schema/sp800-53/2.0}supplemental-guidance')
self.supplemental_guidance = self.sg.find('{http://scap.nist.gov/schema/sp800-53/2.0}description').text.strip()
related_controls = []
Expand Down
5 changes: 5 additions & 0 deletions compliancelib/tests/test_seccontrol.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,11 @@ def test_details_nonexistent_control(self):
c = SecControl(id)
self.assertTrue(c.title == None)

def test_nonexistent_control_enhancements(self):
id = "AC-1"
c = SecControl(id)
self.assertTrue(c.control_enhancements == None)

def test_supplemental_guidance(self):
id = "AC-16"
c = SecControl(id)
Expand Down

0 comments on commit b19b18d

Please sign in to comment.