{"action":"created","comment":{"url":"https://api.github.com/repos/OpenSCAP/scap-security-guide/pulls/comments/179789632","pull_request_review_id":110102572,"id":179789632,"diff_hunk":"@@ -137,60 +137,60 @@ def _get_checkid_string(self):\n     def link(self):\n         self.tree = parse_xml_file(self.fname)\n         try:\n-            self._get_linked_oval_tree()\n+            self._link_oval_tree()\n+\n+            # Verify if CCE identifiers present in the XCCDF follow the required form\n+            # (either CCE-XXXX-X, or CCE-XXXXX-X). Drop from XCCDF those who don't follow it\n+            verify_correct_form_of_referenced_cce_identifiers(self.xccdftree)\n         except Exception as exc:\n             raise RuntimeError(\n                 \"Error processing {0}: {1}\"\n                 .format(self.fname, str(exc)))\n         self.tree = self.translator.translate(self.tree, store_defname=True)\n \n-    def _get_linked_oval_tree(self):\n+    def _link_oval_tree(self):\n         xccdf_to_cce_id_mapping = create_xccdf_id_to_cce_id_mapping(self.xccdftree)\n \n-        indexed_oval_defs = aggregate_elements_by_id(self.tree, self._get_checkid_string())\n+        indexed_oval_defs = aggregate_elements_by_id(\n+            self.tree, \".//{0}\".format(self._get_checkid_string()))\n \n         drop_oval_checks_extending_non_existing_checks(\n             self.tree, indexed_oval_defs)\n \n-        # Add new <reference source=\"CCE\" ref_id=\"CCE-ID\" /> element to those OVAL\n-        # checks having CCE ID already assigned in XCCDF for particular rule.\n-        # But add the <reference> only in the case CCE is in valid form!\n-        # Exit with failure if the assignment wasn't successful\n         self._add_cce_id_refs_to_oval_checks(xccdf_to_cce_id_mapping)\n \n         # Verify all by XCCDF referenced (local) OVAL checks are defined in OVAL file\n         # If not drop the <check-content> OVAL checksystem reference from XCCDF\n         self._ensure_by_xccdf_referenced_oval_def_is_defined_in_oval_file(\n             indexed_oval_defs)\n \n-        # Verify the XCCDF to OVAL datatype export matching constraints\n         check_and_correct_xccdf_to_oval_data_export_matching_constraints(self.xccdftree, self.tree)\n \n-        # Verify if CCE identifiers present in the XCCDF follow the required form\n-        # (either CCE-XXXX-X, or CCE-XXXXX-X). Drop from XCCDF those who don't follow it\n-        verify_correct_form_of_referenced_cce_identifiers(self.xccdftree)\n-\n     def _add_cce_id_refs_to_oval_checks(self, idmappingdict):\n-        #\n-        # For each XCCDF rule ID having <ident> CCE set and\n-        # having OVAL check implemented (remote OVAL isn't sufficient!)\n-        # add a new <reference> element into the OVAL definition having the\n-        # following form:\n-        #\n-        # <reference source=\"CCE\" ref_id=\"CCE-ID\" />\n-        #\n-        # where \"CCE-ID\" is the CCE identifier for that particular rule\n-        # retrieved from the XCCDF file\n-\n-        ovalrules = self.tree.findall(self._get_checkid_string())\n+        \"\"\"\n+        For each XCCDF rule ID having <ident> CCE set and\n+        having OVAL check implemented (remote OVAL isn't sufficient!)\n+        add a new <reference> element into the OVAL definition having the\n+        following form:\n+\n+        <reference source=\"CCE\" ref_id=\"CCE-ID\" />\n+\n+        where \"CCE-ID\" is the CCE identifier for that particular rule\n+        retrieved from the XCCDF file\n+        \"\"\"\n+        ovalrules = self.tree.findall(\".//{0}\".format(self._get_checkid_string()))\n         for rule in ovalrules:\n             ovalid = rule.get(\"id\")\n+            assert ovalid is not None, \\\n+                \"An OVAL rule doesn't have an ID\"\n+\n             ovaldesc = rule.find(\".//{%s}description\" % self.CHECK_NAMESPACE)\n-            # Assign <reference> CCE elements only to those OVAL checks whose\n-            # XCCDF rule ID has <ident> CCE set\n-            if (ovalid is None\n-                    or ovaldesc is None\n-                    or ovalid not in idmappingdict):\n+            assert ovaldesc is not None, \\\n+                \"Oval rule '{0}' doesn't have a description, which is mandatory\".format(ovalid)","path":"shared/utils/relabel-ids.py","position":null,"original_position":82,"commit_id":"bff97262066bacc6a55747e3aa19cacb193f0477","original_commit_id":"a9a2741c0b8b1da6e98933ead7388b0c6d1cc6c1","user":{"login":"mpreisler","id":753153,"avatar_url":"https://avatars1.githubusercontent.com/u/753153?v=4","gravatar_id":"","url":"https://api.github.com/users/mpreisler","html_url":"https://github.com/mpreisler","followers_url":"https://api.github.com/users/mpreisler/followers","following_url":"https://api.github.com/users/mpreisler/following{/other_user}","gists_url":"https://api.github.com/users/mpreisler/gists{/gist_id}","starred_url":"https://api.github.com/users/mpreisler/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mpreisler/subscriptions","organizations_url":"https://api.github.com/users/mpreisler/orgs","repos_url":"https://api.github.com/users/mpreisler/repos","events_url":"https://api.github.com/users/mpreisler/events{/privacy}","received_events_url":"https://api.github.com/users/mpreisler/received_events","type":"User","site_admin":false},"body":"OVAL","created_at":"2018-04-06T15:13:39Z","updated_at":"2018-04-06T15:13:39Z","html_url":"https://github.com/OpenSCAP/scap-security-guide/pull/2704#discussion_r179789632","pull_request_url":"https://api.github.com/repos/OpenSCAP/scap-security-guide/pulls/2704","author_association":"OWNER","_links":{"self":{"href":"https://api.github.com/repos/OpenSCAP/scap-security-guide/pulls/comments/179789632"},"html":{"href":"https://github.com/OpenSCAP/scap-security-guide/pull/2704#discussion_r179789632"},"pull_request":{"href":"https://api.github.com/repos/OpenSCAP/scap-security-guide/pulls/2704"}}},"pull_request":{"url":"https://api.github.com/repos/OpenSCAP/scap-security-guide/pulls/2704","id":179148767,"html_url":"https://github.com/OpenSCAP/scap-security-guide/pull/2704","diff_url":"https://github.com/OpenSCAP/scap-security-guide/pull/2704.diff","patch_url":"https://github.com/OpenSCAP/scap-security-guide/pull/2704.patch","issue_url":"https://api.github.com/repos/OpenSCAP/scap-security-guide/issues/2704","number":2704,"state":"open","locked":false,"title":"Refactoring of relabel-ids.py","user":{"login":"matejak","id":2823847,"avatar_url":"https://avatars2.githubusercontent.com/u/2823847?v=4","gravatar_id":"","url":"https://api.github.com/users/matejak","html_url":"https://github.com/matejak","followers_url":"https://api.github.com/users/matejak/followers","following_url":"https://api.github.com/users/matejak/following{/other_user}","gists_url":"https://api.github.com/users/matejak/gists{/gist_id}","starred_url":"https://api.github.com/users/matejak/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/matejak/subscriptions","organizations_url":"https://api.github.com/users/matejak/orgs","repos_url":"https://api.github.com/users/matejak/repos","events_url":"https://api.github.com/users/matejak/events{/privacy}","received_events_url":"https://api.github.com/users/matejak/received_events","type":"User","site_admin":false},"body":"The goal of this PR is to refactor the code - functionality should be preserved, but the internals may change.\r\n\r\nGoals to reach:\r\n\r\n* Remove unhelpful comments.\r\n* Streamline conditional statements.\r\n* Deduplicate code into functions.\r\n* Reduce indentation level of nested loops/if-statements.\r\n* Add argparse interface.\r\n\r\nGoals in question:\r\n\r\n* Raise and handle exceptions when some conditions are not met - make the operation more strict?","created_at":"2018-04-03T16:13:38Z","updated_at":"2018-04-06T15:13:39Z","closed_at":null,"merged_at":null,"merge_commit_sha":"28d1f2ef3a35e28738ac3aedbf2b5cca89a1b764","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":{"url":"https://api.github.com/repos/OpenSCAP/scap-security-guide/milestones/35","html_url":"https://github.com/OpenSCAP/scap-security-guide/milestone/35","labels_url":"https://api.github.com/repos/OpenSCAP/scap-security-guide/milestones/35/labels","id":3010060,"number":35,"title":"0.1.39","description":"","creator":{"login":"yuumasato","id":7460169,"avatar_url":"https://avatars0.githubusercontent.com/u/7460169?v=4","gravatar_id":"","url":"https://api.github.com/users/yuumasato","html_url":"https://github.com/yuumasato","followers_url":"https://api.github.com/users/yuumasato/followers","following_url":"https://api.github.com/users/yuumasato/following{/other_user}","gists_url":"https://api.github.com/users/yuumasato/gists{/gist_id}","starred_url":"https://api.github.com/users/yuumasato/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/yuumasato/subscriptions","organizations_url":"https://api.github.com/users/yuumasato/orgs","repos_url":"https://api.github.com/users/yuumasato/repos","events_url":"https://api.github.com/users/yuumasato/events{/privacy}","received_events_url":"https://api.github.com/users/yuumasato/received_events","type":"User","site_admin":false},"open_issues":60,"closed_issues":55,"state":"open","created_at":"2018-01-03T13:46:53Z","updated_at":"2018-04-06T14:39:53Z","due_on":"2018-05-02T07:00:00Z","closed_at":null},"commits_url":"https://api.github.com/repos/OpenSCAP/scap-security-guide/pulls/2704/commits","review_comments_url":"https://api.github.com/repos/OpenSCAP/scap-security-guide/pulls/2704/comments","review_comment_url":"https://api.github.com/repos/OpenSCAP/scap-security-guide/pulls/comments{/number}","comments_url":"https://api.github.com/repos/OpenSCAP/scap-security-guide/issues/2704/comments","statuses_url":"https://api.github.com/repos/OpenSCAP/scap-security-guide/statuses/bff97262066bacc6a55747e3aa19cacb193f0477","head":{"label":"matejak:relabel-ids-refactoring","ref":"relabel-ids-refactoring","sha":"bff97262066bacc6a55747e3aa19cacb193f0477","user":{"login":"matejak","id":2823847,"avatar_url":"https://avatars2.githubusercontent.com/u/2823847?v=4","gravatar_id":"","url":"https://api.github.com/users/matejak","html_url":"https://github.com/matejak","followers_url":"https://api.github.com/users/matejak/followers","following_url":"https://api.github.com/users/matejak/following{/other_user}","gists_url":"https://api.github.com/users/matejak/gists{/gist_id}","starred_url":"https://api.github.com/users/matejak/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/matejak/subscriptions","organizations_url":"https://api.github.com/users/matejak/orgs","repos_url":"https://api.github.com/users/matejak/repos","events_url":"https://api.github.com/users/matejak/events{/privacy}","received_events_url":"https://api.github.com/users/matejak/received_events","type":"User","site_admin":false},"repo":{"id":104354951,"name":"scap-security-guide","full_name":"matejak/scap-security-guide","owner":{"login":"matejak","id":2823847,"avatar_url":"https://avatars2.githubusercontent.com/u/2823847?v=4","gravatar_id":"","url":"https://api.github.com/users/matejak","html_url":"https://github.com/matejak","followers_url":"https://api.github.com/users/matejak/followers","following_url":"https://api.github.com/users/matejak/following{/other_user}","gists_url":"https://api.github.com/users/matejak/gists{/gist_id}","starred_url":"https://api.github.com/users/matejak/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/matejak/subscriptions","organizations_url":"https://api.github.com/users/matejak/orgs","repos_url":"https://api.github.com/users/matejak/repos","events_url":"https://api.github.com/users/matejak/events{/privacy}","received_events_url":"https://api.github.com/users/matejak/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/matejak/scap-security-guide","description":"Baseline compliance content in SCAP formats","fork":true,"url":"https://api.github.com/repos/matejak/scap-security-guide","forks_url":"https://api.github.com/repos/matejak/scap-security-guide/forks","keys_url":"https://api.github.com/repos/matejak/scap-security-guide/keys{/key_id}","collaborators_url":"https://api.github.com/repos/matejak/scap-security-guide/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/matejak/scap-security-guide/teams","hooks_url":"https://api.github.com/repos/matejak/scap-security-guide/hooks","issue_events_url":"https://api.github.com/repos/matejak/scap-security-guide/issues/events{/number}","events_url":"https://api.github.com/repos/matejak/scap-security-guide/events","assignees_url":"https://api.github.com/repos/matejak/scap-security-guide/assignees{/user}","branches_url":"https://api.github.com/repos/matejak/scap-security-guide/branches{/branch}","tags_url":"https://api.github.com/repos/matejak/scap-security-guide/tags","blobs_url":"https://api.github.com/repos/matejak/scap-security-guide/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/matejak/scap-security-guide/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/matejak/scap-security-guide/git/refs{/sha}","trees_url":"https://api.github.com/repos/matejak/scap-security-guide/git/trees{/sha}","statuses_url":"https://api.github.com/repos/matejak/scap-security-guide/statuses/{sha}","languages_url":"https://api.github.com/repos/matejak/scap-security-guide/languages","stargazers_url":"https://api.github.com/repos/matejak/scap-security-guide/stargazers","contributors_url":"https://api.github.com/repos/matejak/scap-security-guide/contributors","subscribers_url":"https://api.github.com/repos/matejak/scap-security-guide/subscribers","subscription_url":"https://api.github.com/repos/matejak/scap-security-guide/subscription","commits_url":"https://api.github.com/repos/matejak/scap-security-guide/commits{/sha}","git_commits_url":"https://api.github.com/repos/matejak/scap-security-guide/git/commits{/sha}","comments_url":"https://api.github.com/repos/matejak/scap-security-guide/comments{/number}","issue_comment_url":"https://api.github.com/repos/matejak/scap-security-guide/issues/comments{/number}","contents_url":"https://api.github.com/repos/matejak/scap-security-guide/contents/{+path}","compare_url":"https://api.github.com/repos/matejak/scap-security-guide/compare/{base}...{head}","merges_url":"https://api.github.com/repos/matejak/scap-security-guide/merges","archive_url":"https://api.github.com/repos/matejak/scap-security-guide/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/matejak/scap-security-guide/downloads","issues_url":"https://api.github.com/repos/matejak/scap-security-guide/issues{/number}","pulls_url":"https://api.github.com/repos/matejak/scap-security-guide/pulls{/number}","milestones_url":"https://api.github.com/repos/matejak/scap-security-guide/milestones{/number}","notifications_url":"https://api.github.com/repos/matejak/scap-security-guide/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/matejak/scap-security-guide/labels{/name}","releases_url":"https://api.github.com/repos/matejak/scap-security-guide/releases{/id}","deployments_url":"https://api.github.com/repos/matejak/scap-security-guide/deployments","created_at":"2017-09-21T13:57:44Z","updated_at":"2018-01-12T13:46:32Z","pushed_at":"2018-04-06T13:13:34Z","git_url":"git://github.com/matejak/scap-security-guide.git","ssh_url":"git@github.com:matejak/scap-security-guide.git","clone_url":"https://github.com/matejak/scap-security-guide.git","svn_url":"https://github.com/matejak/scap-security-guide","homepage":"https://www.open-scap.org/security-policies/scap-security-guide","size":21401,"stargazers_count":0,"watchers_count":0,"language":"XSLT","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"license":null,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"OpenSCAP:master","ref":"master","sha":"3398c06a4b42e4518479d5b1276b65fb2cf89125","user":{"login":"OpenSCAP","id":7439934,"avatar_url":"https://avatars1.githubusercontent.com/u/7439934?v=4","gravatar_id":"","url":"https://api.github.com/users/OpenSCAP","html_url":"https://github.com/OpenSCAP","followers_url":"https://api.github.com/users/OpenSCAP/followers","following_url":"https://api.github.com/users/OpenSCAP/following{/other_user}","gists_url":"https://api.github.com/users/OpenSCAP/gists{/gist_id}","starred_url":"https://api.github.com/users/OpenSCAP/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/OpenSCAP/subscriptions","organizations_url":"https://api.github.com/users/OpenSCAP/orgs","repos_url":"https://api.github.com/users/OpenSCAP/repos","events_url":"https://api.github.com/users/OpenSCAP/events{/privacy}","received_events_url":"https://api.github.com/users/OpenSCAP/received_events","type":"Organization","site_admin":false},"repo":{"id":19279458,"name":"scap-security-guide","full_name":"OpenSCAP/scap-security-guide","owner":{"login":"OpenSCAP","id":7439934,"avatar_url":"https://avatars1.githubusercontent.com/u/7439934?v=4","gravatar_id":"","url":"https://api.github.com/users/OpenSCAP","html_url":"https://github.com/OpenSCAP","followers_url":"https://api.github.com/users/OpenSCAP/followers","following_url":"https://api.github.com/users/OpenSCAP/following{/other_user}","gists_url":"https://api.github.com/users/OpenSCAP/gists{/gist_id}","starred_url":"https://api.github.com/users/OpenSCAP/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/OpenSCAP/subscriptions","organizations_url":"https://api.github.com/users/OpenSCAP/orgs","repos_url":"https://api.github.com/users/OpenSCAP/repos","events_url":"https://api.github.com/users/OpenSCAP/events{/privacy}","received_events_url":"https://api.github.com/users/OpenSCAP/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/OpenSCAP/scap-security-guide","description":"Baseline compliance content in SCAP formats","fork":false,"url":"https://api.github.com/repos/OpenSCAP/scap-security-guide","forks_url":"https://api.github.com/repos/OpenSCAP/scap-security-guide/forks","keys_url":"https://api.github.com/repos/OpenSCAP/scap-security-guide/keys{/key_id}","collaborators_url":"https://api.github.com/repos/OpenSCAP/scap-security-guide/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/OpenSCAP/scap-security-guide/teams","hooks_url":"https://api.github.com/repos/OpenSCAP/scap-security-guide/hooks","issue_events_url":"https://api.github.com/repos/OpenSCAP/scap-security-guide/issues/events{/number}","events_url":"https://api.github.com/repos/OpenSCAP/scap-security-guide/events","assignees_url":"https://api.github.com/repos/OpenSCAP/scap-security-guide/assignees{/user}","branches_url":"https://api.github.com/repos/OpenSCAP/scap-security-guide/branches{/branch}","tags_url":"https://api.github.com/repos/OpenSCAP/scap-security-guide/tags","blobs_url":"https://api.github.com/repos/OpenSCAP/scap-security-guide/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/OpenSCAP/scap-security-guide/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/OpenSCAP/scap-security-guide/git/refs{/sha}","trees_url":"https://api.github.com/repos/OpenSCAP/scap-security-guide/git/trees{/sha}","statuses_url":"https://api.github.com/repos/OpenSCAP/scap-security-guide/statuses/{sha}","languages_url":"https://api.github.com/repos/OpenSCAP/scap-security-guide/languages","stargazers_url":"https://api.github.com/repos/OpenSCAP/scap-security-guide/stargazers","contributors_url":"https://api.github.com/repos/OpenSCAP/scap-security-guide/contributors","subscribers_url":"https://api.github.com/repos/OpenSCAP/scap-security-guide/subscribers","subscription_url":"https://api.github.com/repos/OpenSCAP/scap-security-guide/subscription","commits_url":"https://api.github.com/repos/OpenSCAP/scap-security-guide/commits{/sha}","git_commits_url":"https://api.github.com/repos/OpenSCAP/scap-security-guide/git/commits{/sha}","comments_url":"https://api.github.com/repos/OpenSCAP/scap-security-guide/comments{/number}","issue_comment_url":"https://api.github.com/repos/OpenSCAP/scap-security-guide/issues/comments{/number}","contents_url":"https://api.github.com/repos/OpenSCAP/scap-security-guide/contents/{+path}","compare_url":"https://api.github.com/repos/OpenSCAP/scap-security-guide/compare/{base}...{head}","merges_url":"https://api.github.com/repos/OpenSCAP/scap-security-guide/merges","archive_url":"https://api.github.com/repos/OpenSCAP/scap-security-guide/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/OpenSCAP/scap-security-guide/downloads","issues_url":"https://api.github.com/repos/OpenSCAP/scap-security-guide/issues{/number}","pulls_url":"https://api.github.com/repos/OpenSCAP/scap-security-guide/pulls{/number}","milestones_url":"https://api.github.com/repos/OpenSCAP/scap-security-guide/milestones{/number}","notifications_url":"https://api.github.com/repos/OpenSCAP/scap-security-guide/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/OpenSCAP/scap-security-guide/labels{/name}","releases_url":"https://api.github.com/repos/OpenSCAP/scap-security-guide/releases{/id}","deployments_url":"https://api.github.com/repos/OpenSCAP/scap-security-guide/deployments","created_at":"2014-04-29T14:32:02Z","updated_at":"2018-04-06T10:01:40Z","pushed_at":"2018-04-06T13:13:36Z","git_url":"git://github.com/OpenSCAP/scap-security-guide.git","ssh_url":"git@github.com:OpenSCAP/scap-security-guide.git","clone_url":"https://github.com/OpenSCAP/scap-security-guide.git","svn_url":"https://github.com/OpenSCAP/scap-security-guide","homepage":"https://www.open-scap.org/security-policies/scap-security-guide","size":21249,"stargazers_count":375,"watchers_count":375,"language":"Python","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":209,"mirror_url":null,"archived":false,"open_issues_count":184,"license":{"key":"other","name":"Other","spdx_id":null,"url":null},"forks":209,"open_issues":184,"watchers":375,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/OpenSCAP/scap-security-guide/pulls/2704"},"html":{"href":"https://github.com/OpenSCAP/scap-security-guide/pull/2704"},"issue":{"href":"https://api.github.com/repos/OpenSCAP/scap-security-guide/issues/2704"},"comments":{"href":"https://api.github.com/repos/OpenSCAP/scap-security-guide/issues/2704/comments"},"review_comments":{"href":"https://api.github.com/repos/OpenSCAP/scap-security-guide/pulls/2704/comments"},"review_comment":{"href":"https://api.github.com/repos/OpenSCAP/scap-security-guide/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/OpenSCAP/scap-security-guide/pulls/2704/commits"},"statuses":{"href":"https://api.github.com/repos/OpenSCAP/scap-security-guide/statuses/bff97262066bacc6a55747e3aa19cacb193f0477"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"mpreisler"}}