コード例 #1
0
 def test_load_ocfile(self):
     "Test loading of an OpenControl component YAML file"
     ocfileurl = "https://raw.githubusercontent.com/opencontrol/freedonia-compliance/master/AU_policy/component.yaml"
     ocf = OpenControlFiles()
     # test empty oc
     self.assertTrue(len(ocf.ocfiles) == 0)
     # load an OpenControl file
     ocf.load_ocfile_from_url(ocfileurl)
     print(len(ocf.ocfiles))
     print(list(ocf.ocfiles.keys()))
     #  test length of ocfiles
     self.assertTrue(len(ocf.ocfiles) == 1)
     # self.assertTrue(ocf.list_files() == "https://github.com/pburkholder/freedonia-compliance/blob/master/AU_policy/component.yaml")
     # test not loading same file twice
     ocf.load_ocfile_from_url(ocfileurl)
     self.assertTrue(len(ocf.ocfiles) == 1)
     # load second file
     ocfileurl2 = 'https://raw.githubusercontent.com/opencontrol/cf-compliance/master/UAA/component.yaml'
     ocf.load_ocfile_from_url(ocfileurl2)
     self.assertTrue(len(ocf.ocfiles) == 2)
     print(ocf.ocfiles.keys())
     self.assertTrue('https://raw.githubusercontent.com/opencontrol/cf-compliance/master/UAA/component.yaml' in ocf.ocfiles.keys())
     self.assertTrue('https://raw.githubusercontent.com/opencontrol/freedonia-compliance/master/AU_policy/component.yaml' in ocf.ocfiles.keys())
     # test loading if opencontrol file already in ocfiles object
     print(ocf.load_ocfile_from_url(ocfileurl))
     print(ocf.ocfiles.keys())
     print("ALERT: If this test fails, first check if ocfileurl content has changed!")
     self.assertTrue(ocf.load_ocfile_from_url(ocfileurl)=={'documentation_complete': False, 'references': [{'path': 'https://github.com/opencontrol/freedonia-policies/wiki/Audit-Policy', 'name': 'AU Policy'}], 'satisfies': [{'control_key': 'AU-1', 'standard_key': 'FRIST-800-53', 'covered_by': [], 'implementation_status': 'implemented', 'narrative': [{'text': 'This text describes how our organization is meeting the requirements for the\nAudit policy, and also references a more complete description at ./AU_policy/README.md\n\nSince the AU-1 `control` is to document and disseminate a policy on Audit and Accountability, then\nthis narrative suffices to provide that control. A verification step could be something\nthat checks that the referenced policy is no more than 365 days old.\n'}]}, {'control_key': 'AU-2', 'standard_key': 'FRIST-800-53', 'covered_by': [], 'implementation_status': 'none', 'narrative': [{'text': "Application and Server logs are sent to PaperTrail to provide audit\nreduction and report generation capabilites for Freedonia Devops and end users\nof the Freedonia hello_world system.\n\nPaperTrail is a SaaS for aggregation of audit log data across multiple systems and tiers\n\nWith the PaperTrail capability the organizations's operations and development teams\ncan structure and customize audit logs queries to specific app instances, API\ncalls, system metrics, user access, system components, network traffic flow and\nother criteria.\n"}]}], 'schema_version': '3.0.0', 'name': 'Audit Policy'})
コード例 #2
0
 def test_parse_opencontrolfile(self):
     "Test retrieve and parsing of an opencontrol.yaml file"
     ocf = OpenControlFiles()
     repo_ref = 'https://github.com/18F/cg-compliance'
     ocf = OpenControlFiles()
     repo_ref = 'https://github.com/18F/cg-compliance'
     revision = 'master'
     component_path = ''
     ocfileurl = ocf.resolve_ocfile_url(repo_ref, revision)
     my_dict = ocf.load_ocfile_from_url(ocfileurl)
     print(my_dict.keys())
     print("------")
     print(my_dict['components'])
     self.assertTrue(len(list(my_dict)) == 5)
     self.assertTrue('metadata' in list(my_dict))
     self.assertTrue('dependencies' in list(my_dict))
     self.assertTrue('components' in list(my_dict))
     self.assertTrue('name' in list(my_dict))
     self.assertTrue('schema_version' in list(my_dict))
コード例 #3
0
 def test_parse_opencontrolfile(self):
     "Test retrieve and parsing of an opencontrol.yaml file"
     ocf = OpenControlFiles()
     repo_ref = 'https://github.com/18F/cg-compliance'
     ocf = OpenControlFiles()
     repo_ref = 'https://github.com/18F/cg-compliance'
     revision = 'master'
     component_path = ''
     ocfileurl = ocf.resolve_ocfile_url(repo_ref, revision)
     my_dict = ocf.load_ocfile_from_url(ocfileurl)
     print(my_dict.keys())
     print("------")
     print(my_dict['components'])
     self.assertTrue(len(list(my_dict)) == 5)
     self.assertTrue('metadata' in list(my_dict))
     self.assertTrue('dependencies' in list(my_dict))
     self.assertTrue('components' in list(my_dict))
     self.assertTrue('name' in list(my_dict))
     self.assertTrue('schema_version' in list(my_dict))
コード例 #4
0
 def test_load_ocfile(self):
     "Test loading of an OpenControl component YAML file"
     ocfileurl = "https://raw.githubusercontent.com/opencontrol/freedonia-compliance/master/AU_policy/component.yaml"
     ocf = OpenControlFiles()
     # test empty oc
     self.assertTrue(len(ocf.ocfiles) == 0)
     # load an OpenControl file
     ocf.load_ocfile_from_url(ocfileurl)
     print(len(ocf.ocfiles))
     print(list(ocf.ocfiles.keys()))
     #  test length of ocfiles
     self.assertTrue(len(ocf.ocfiles) == 1)
     # self.assertTrue(ocf.list_files() == "https://github.com/pburkholder/freedonia-compliance/blob/master/AU_policy/component.yaml")
     # test not loading same file twice
     ocf.load_ocfile_from_url(ocfileurl)
     self.assertTrue(len(ocf.ocfiles) == 1)
     # load second file
     ocfileurl2 = 'https://raw.githubusercontent.com/opencontrol/cf-compliance/master/UAA/component.yaml'
     ocf.load_ocfile_from_url(ocfileurl2)
     self.assertTrue(len(ocf.ocfiles) == 2)
     print(ocf.ocfiles.keys())
     self.assertTrue(
         'https://raw.githubusercontent.com/opencontrol/cf-compliance/master/UAA/component.yaml'
         in ocf.ocfiles.keys())
     self.assertTrue(
         'https://raw.githubusercontent.com/opencontrol/freedonia-compliance/master/AU_policy/component.yaml'
         in ocf.ocfiles.keys())
     # test loading if opencontrol file already in ocfiles object
     print(ocf.load_ocfile_from_url(ocfileurl))
     print(ocf.ocfiles.keys())
     print(
         "ALERT: If this test fails, first check if ocfileurl content has changed!"
     )
     self.assertTrue(
         ocf.load_ocfile_from_url(ocfileurl) == {
             'documentation_complete':
             False,
             'references': [{
                 'path':
                 'https://github.com/opencontrol/freedonia-policies/wiki/Audit-Policy',
                 'name': 'AU Policy'
             }],
             'satisfies': [{
                 'control_key':
                 'AU-1',
                 'standard_key':
                 'FRIST-800-53',
                 'covered_by': [],
                 'implementation_status':
                 'implemented',
                 'narrative': [{
                     'text':
                     'This text describes how our organization is meeting the requirements for the\nAudit policy, and also references a more complete description at ./AU_policy/README.md\n\nSince the AU-1 `control` is to document and disseminate a policy on Audit and Accountability, then\nthis narrative suffices to provide that control. A verification step could be something\nthat checks that the referenced policy is no more than 365 days old.\n'
                 }]
             }, {
                 'control_key':
                 'AU-2',
                 'standard_key':
                 'FRIST-800-53',
                 'covered_by': [],
                 'implementation_status':
                 'none',
                 'narrative': [{
                     'text':
                     "Application and Server logs are sent to PaperTrail to provide audit\nreduction and report generation capabilites for Freedonia Devops and end users\nof the Freedonia hello_world system.\n\nPaperTrail is a SaaS for aggregation of audit log data across multiple systems and tiers\n\nWith the PaperTrail capability the organizations's operations and development teams\ncan structure and customize audit logs queries to specific app instances, API\ncalls, system metrics, user access, system components, network traffic flow and\nother criteria.\n"
                 }]
             }],
             'schema_version':
             '3.0.0',
             'name':
             'Audit Policy'
         })