{"action":"created","comment":{"url":"https://api.github.com/repos/theforeman/smart_proxy_openscap/pulls/comments/42367841","id":42367841,"diff_hunk":"@@ -0,0 +1,33 @@\n+module Proxy::OpenSCAP\n+  class StoreArfFS\n+    include ::Proxy::Log\n+    def store(cn, id, data)\n+      raise NotImplementedError\n+    end\n+\n+    private\n+\n+    def store_arf(spool_arf_dir, data)\n+      filename = Digest::SHA256.hexdigest data\n+      target_path = spool_arf_dir + filename\n+      File.open(target_path,'w') { |f| f.write(data) }\n+      target_path\n+    end\n+\n+    def validate_id(id)\n+      raise Proxy::OpenSCAP::OpenSCAPException.new \"Malformed policy ID\" unless /[\\d]+/ =~ id","path":"lib/smart_proxy_openscap/store_arf_fs.rb","position":18,"original_position":18,"commit_id":"e4cff7332def39a0c1e2a22bdcdbb295adafbeba","original_commit_id":"e4cff7332def39a0c1e2a22bdcdbb295adafbeba","user":{"login":"ares","id":109773,"avatar_url":"https://avatars.githubusercontent.com/u/109773?v=3","gravatar_id":"","url":"https://api.github.com/users/ares","html_url":"https://github.com/ares","followers_url":"https://api.github.com/users/ares/followers","following_url":"https://api.github.com/users/ares/following{/other_user}","gists_url":"https://api.github.com/users/ares/gists{/gist_id}","starred_url":"https://api.github.com/users/ares/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ares/subscriptions","organizations_url":"https://api.github.com/users/ares/orgs","repos_url":"https://api.github.com/users/ares/repos","events_url":"https://api.github.com/users/ares/events{/privacy}","received_events_url":"https://api.github.com/users/ares/received_events","type":"User","site_admin":false},"body":"2 things - raising exception without making an instance, regexp  matches also 'a1a' string as valid id\r\n\r\n`raise Proxy::OpenSCAP::OpenSCAPException, 'Malformed policy ID' unless /\\A\\d+\\Z/ =~ id`","created_at":"2015-10-19T13:06:48Z","updated_at":"2015-10-19T13:06:48Z","html_url":"https://github.com/theforeman/smart_proxy_openscap/pull/17#discussion_r42367841","pull_request_url":"https://api.github.com/repos/theforeman/smart_proxy_openscap/pulls/17","_links":{"self":{"href":"https://api.github.com/repos/theforeman/smart_proxy_openscap/pulls/comments/42367841"},"html":{"href":"https://github.com/theforeman/smart_proxy_openscap/pull/17#discussion_r42367841"},"pull_request":{"href":"https://api.github.com/repos/theforeman/smart_proxy_openscap/pulls/17"}}},"pull_request":{"url":"https://api.github.com/repos/theforeman/smart_proxy_openscap/pulls/17","id":44524285,"html_url":"https://github.com/theforeman/smart_proxy_openscap/pull/17","diff_url":"https://github.com/theforeman/smart_proxy_openscap/pull/17.diff","patch_url":"https://github.com/theforeman/smart_proxy_openscap/pull/17.patch","issue_url":"https://api.github.com/repos/theforeman/smart_proxy_openscap/issues/17","number":17,"state":"open","locked":false,"title":"parse arf reports to json, upload to foreman","user":{"login":"shlomizadok","id":433583,"avatar_url":"https://avatars.githubusercontent.com/u/433583?v=3","gravatar_id":"","url":"https://api.github.com/users/shlomizadok","html_url":"https://github.com/shlomizadok","followers_url":"https://api.github.com/users/shlomizadok/followers","following_url":"https://api.github.com/users/shlomizadok/following{/other_user}","gists_url":"https://api.github.com/users/shlomizadok/gists{/gist_id}","starred_url":"https://api.github.com/users/shlomizadok/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/shlomizadok/subscriptions","organizations_url":"https://api.github.com/users/shlomizadok/orgs","repos_url":"https://api.github.com/users/shlomizadok/repos","events_url":"https://api.github.com/users/shlomizadok/events{/privacy}","received_events_url":"https://api.github.com/users/shlomizadok/received_events","type":"User","site_admin":false},"body":"So here is what I did:\r\n* ARF xml file is parsed into json with `openscap_report_parser`\r\n* It is uploaded to foreman [can't test now, as `foreman_openscap` side is not ready yet\r\n* If upload fails, the arf xml is saved in the spool.\r\n* When spool is triggered it parses the xml and uploads to foreman\r\n\r\nAdditionally, I have separated `openscap_lib.rb` to classes. Each class is responsible to do something else (e.g., download scap content, post to foreman, parse xml to json, etc.)\r\n\r\nCode in the current state is not mergeable as we need to accomplish the work on the foreman side.\r\nWhat can you test:\r\n1. Code review,\r\n2. JSON is generated and is posted to foreman\r\n3. On failure it is save to spool directory\r\n4. `smart-proxy-openscap-send` creates a json and sends to foreman\r\n","created_at":"2015-09-09T08:49:28Z","updated_at":"2015-10-19T13:06:48Z","closed_at":null,"merged_at":null,"merge_commit_sha":"d944be379fc80e1c13e0e49b523060ed9653898d","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/theforeman/smart_proxy_openscap/pulls/17/commits","review_comments_url":"https://api.github.com/repos/theforeman/smart_proxy_openscap/pulls/17/comments","review_comment_url":"https://api.github.com/repos/theforeman/smart_proxy_openscap/pulls/comments{/number}","comments_url":"https://api.github.com/repos/theforeman/smart_proxy_openscap/issues/17/comments","statuses_url":"https://api.github.com/repos/theforeman/smart_proxy_openscap/statuses/e4cff7332def39a0c1e2a22bdcdbb295adafbeba","head":{"label":"shlomizadok:parse_reports","ref":"parse_reports","sha":"e4cff7332def39a0c1e2a22bdcdbb295adafbeba","user":{"login":"shlomizadok","id":433583,"avatar_url":"https://avatars.githubusercontent.com/u/433583?v=3","gravatar_id":"","url":"https://api.github.com/users/shlomizadok","html_url":"https://github.com/shlomizadok","followers_url":"https://api.github.com/users/shlomizadok/followers","following_url":"https://api.github.com/users/shlomizadok/following{/other_user}","gists_url":"https://api.github.com/users/shlomizadok/gists{/gist_id}","starred_url":"https://api.github.com/users/shlomizadok/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/shlomizadok/subscriptions","organizations_url":"https://api.github.com/users/shlomizadok/orgs","repos_url":"https://api.github.com/users/shlomizadok/repos","events_url":"https://api.github.com/users/shlomizadok/events{/privacy}","received_events_url":"https://api.github.com/users/shlomizadok/received_events","type":"User","site_admin":false},"repo":{"id":27426452,"name":"smart_proxy_openscap","full_name":"shlomizadok/smart_proxy_openscap","owner":{"login":"shlomizadok","id":433583,"avatar_url":"https://avatars.githubusercontent.com/u/433583?v=3","gravatar_id":"","url":"https://api.github.com/users/shlomizadok","html_url":"https://github.com/shlomizadok","followers_url":"https://api.github.com/users/shlomizadok/followers","following_url":"https://api.github.com/users/shlomizadok/following{/other_user}","gists_url":"https://api.github.com/users/shlomizadok/gists{/gist_id}","starred_url":"https://api.github.com/users/shlomizadok/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/shlomizadok/subscriptions","organizations_url":"https://api.github.com/users/shlomizadok/orgs","repos_url":"https://api.github.com/users/shlomizadok/repos","events_url":"https://api.github.com/users/shlomizadok/events{/privacy}","received_events_url":"https://api.github.com/users/shlomizadok/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/shlomizadok/smart_proxy_openscap","description":"OpenSCAP plug-in for Foreman's smart-proxy.","fork":true,"url":"https://api.github.com/repos/shlomizadok/smart_proxy_openscap","forks_url":"https://api.github.com/repos/shlomizadok/smart_proxy_openscap/forks","keys_url":"https://api.github.com/repos/shlomizadok/smart_proxy_openscap/keys{/key_id}","collaborators_url":"https://api.github.com/repos/shlomizadok/smart_proxy_openscap/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/shlomizadok/smart_proxy_openscap/teams","hooks_url":"https://api.github.com/repos/shlomizadok/smart_proxy_openscap/hooks","issue_events_url":"https://api.github.com/repos/shlomizadok/smart_proxy_openscap/issues/events{/number}","events_url":"https://api.github.com/repos/shlomizadok/smart_proxy_openscap/events","assignees_url":"https://api.github.com/repos/shlomizadok/smart_proxy_openscap/assignees{/user}","branches_url":"https://api.github.com/repos/shlomizadok/smart_proxy_openscap/branches{/branch}","tags_url":"https://api.github.com/repos/shlomizadok/smart_proxy_openscap/tags","blobs_url":"https://api.github.com/repos/shlomizadok/smart_proxy_openscap/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/shlomizadok/smart_proxy_openscap/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/shlomizadok/smart_proxy_openscap/git/refs{/sha}","trees_url":"https://api.github.com/repos/shlomizadok/smart_proxy_openscap/git/trees{/sha}","statuses_url":"https://api.github.com/repos/shlomizadok/smart_proxy_openscap/statuses/{sha}","languages_url":"https://api.github.com/repos/shlomizadok/smart_proxy_openscap/languages","stargazers_url":"https://api.github.com/repos/shlomizadok/smart_proxy_openscap/stargazers","contributors_url":"https://api.github.com/repos/shlomizadok/smart_proxy_openscap/contributors","subscribers_url":"https://api.github.com/repos/shlomizadok/smart_proxy_openscap/subscribers","subscription_url":"https://api.github.com/repos/shlomizadok/smart_proxy_openscap/subscription","commits_url":"https://api.github.com/repos/shlomizadok/smart_proxy_openscap/commits{/sha}","git_commits_url":"https://api.github.com/repos/shlomizadok/smart_proxy_openscap/git/commits{/sha}","comments_url":"https://api.github.com/repos/shlomizadok/smart_proxy_openscap/comments{/number}","issue_comment_url":"https://api.github.com/repos/shlomizadok/smart_proxy_openscap/issues/comments{/number}","contents_url":"https://api.github.com/repos/shlomizadok/smart_proxy_openscap/contents/{+path}","compare_url":"https://api.github.com/repos/shlomizadok/smart_proxy_openscap/compare/{base}...{head}","merges_url":"https://api.github.com/repos/shlomizadok/smart_proxy_openscap/merges","archive_url":"https://api.github.com/repos/shlomizadok/smart_proxy_openscap/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/shlomizadok/smart_proxy_openscap/downloads","issues_url":"https://api.github.com/repos/shlomizadok/smart_proxy_openscap/issues{/number}","pulls_url":"https://api.github.com/repos/shlomizadok/smart_proxy_openscap/pulls{/number}","milestones_url":"https://api.github.com/repos/shlomizadok/smart_proxy_openscap/milestones{/number}","notifications_url":"https://api.github.com/repos/shlomizadok/smart_proxy_openscap/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/shlomizadok/smart_proxy_openscap/labels{/name}","releases_url":"https://api.github.com/repos/shlomizadok/smart_proxy_openscap/releases{/id}","created_at":"2014-12-02T10:04:55Z","updated_at":"2015-04-16T13:47:47Z","pushed_at":"2015-10-18T09:59:00Z","git_url":"git://github.com/shlomizadok/smart_proxy_openscap.git","ssh_url":"git@github.com:shlomizadok/smart_proxy_openscap.git","clone_url":"https://github.com/shlomizadok/smart_proxy_openscap.git","svn_url":"https://github.com/shlomizadok/smart_proxy_openscap","homepage":"","size":601,"stargazers_count":0,"watchers_count":0,"language":"Ruby","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"theforeman:master","ref":"master","sha":"ce0b2da543dd119926336e3e88172c870c2c487a","user":{"login":"theforeman","id":1439844,"avatar_url":"https://avatars.githubusercontent.com/u/1439844?v=3","gravatar_id":"","url":"https://api.github.com/users/theforeman","html_url":"https://github.com/theforeman","followers_url":"https://api.github.com/users/theforeman/followers","following_url":"https://api.github.com/users/theforeman/following{/other_user}","gists_url":"https://api.github.com/users/theforeman/gists{/gist_id}","starred_url":"https://api.github.com/users/theforeman/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/theforeman/subscriptions","organizations_url":"https://api.github.com/users/theforeman/orgs","repos_url":"https://api.github.com/users/theforeman/repos","events_url":"https://api.github.com/users/theforeman/events{/privacy}","received_events_url":"https://api.github.com/users/theforeman/received_events","type":"Organization","site_admin":false},"repo":{"id":21616058,"name":"smart_proxy_openscap","full_name":"theforeman/smart_proxy_openscap","owner":{"login":"theforeman","id":1439844,"avatar_url":"https://avatars.githubusercontent.com/u/1439844?v=3","gravatar_id":"","url":"https://api.github.com/users/theforeman","html_url":"https://github.com/theforeman","followers_url":"https://api.github.com/users/theforeman/followers","following_url":"https://api.github.com/users/theforeman/following{/other_user}","gists_url":"https://api.github.com/users/theforeman/gists{/gist_id}","starred_url":"https://api.github.com/users/theforeman/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/theforeman/subscriptions","organizations_url":"https://api.github.com/users/theforeman/orgs","repos_url":"https://api.github.com/users/theforeman/repos","events_url":"https://api.github.com/users/theforeman/events{/privacy}","received_events_url":"https://api.github.com/users/theforeman/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/theforeman/smart_proxy_openscap","description":"OpenSCAP plug-in for Foreman's smart-proxy.","fork":false,"url":"https://api.github.com/repos/theforeman/smart_proxy_openscap","forks_url":"https://api.github.com/repos/theforeman/smart_proxy_openscap/forks","keys_url":"https://api.github.com/repos/theforeman/smart_proxy_openscap/keys{/key_id}","collaborators_url":"https://api.github.com/repos/theforeman/smart_proxy_openscap/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/theforeman/smart_proxy_openscap/teams","hooks_url":"https://api.github.com/repos/theforeman/smart_proxy_openscap/hooks","issue_events_url":"https://api.github.com/repos/theforeman/smart_proxy_openscap/issues/events{/number}","events_url":"https://api.github.com/repos/theforeman/smart_proxy_openscap/events","assignees_url":"https://api.github.com/repos/theforeman/smart_proxy_openscap/assignees{/user}","branches_url":"https://api.github.com/repos/theforeman/smart_proxy_openscap/branches{/branch}","tags_url":"https://api.github.com/repos/theforeman/smart_proxy_openscap/tags","blobs_url":"https://api.github.com/repos/theforeman/smart_proxy_openscap/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/theforeman/smart_proxy_openscap/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/theforeman/smart_proxy_openscap/git/refs{/sha}","trees_url":"https://api.github.com/repos/theforeman/smart_proxy_openscap/git/trees{/sha}","statuses_url":"https://api.github.com/repos/theforeman/smart_proxy_openscap/statuses/{sha}","languages_url":"https://api.github.com/repos/theforeman/smart_proxy_openscap/languages","stargazers_url":"https://api.github.com/repos/theforeman/smart_proxy_openscap/stargazers","contributors_url":"https://api.github.com/repos/theforeman/smart_proxy_openscap/contributors","subscribers_url":"https://api.github.com/repos/theforeman/smart_proxy_openscap/subscribers","subscription_url":"https://api.github.com/repos/theforeman/smart_proxy_openscap/subscription","commits_url":"https://api.github.com/repos/theforeman/smart_proxy_openscap/commits{/sha}","git_commits_url":"https://api.github.com/repos/theforeman/smart_proxy_openscap/git/commits{/sha}","comments_url":"https://api.github.com/repos/theforeman/smart_proxy_openscap/comments{/number}","issue_comment_url":"https://api.github.com/repos/theforeman/smart_proxy_openscap/issues/comments{/number}","contents_url":"https://api.github.com/repos/theforeman/smart_proxy_openscap/contents/{+path}","compare_url":"https://api.github.com/repos/theforeman/smart_proxy_openscap/compare/{base}...{head}","merges_url":"https://api.github.com/repos/theforeman/smart_proxy_openscap/merges","archive_url":"https://api.github.com/repos/theforeman/smart_proxy_openscap/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/theforeman/smart_proxy_openscap/downloads","issues_url":"https://api.github.com/repos/theforeman/smart_proxy_openscap/issues{/number}","pulls_url":"https://api.github.com/repos/theforeman/smart_proxy_openscap/pulls{/number}","milestones_url":"https://api.github.com/repos/theforeman/smart_proxy_openscap/milestones{/number}","notifications_url":"https://api.github.com/repos/theforeman/smart_proxy_openscap/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/theforeman/smart_proxy_openscap/labels{/name}","releases_url":"https://api.github.com/repos/theforeman/smart_proxy_openscap/releases{/id}","created_at":"2014-07-08T14:36:02Z","updated_at":"2015-05-19T14:39:37Z","pushed_at":"2015-10-18T09:59:00Z","git_url":"git://github.com/theforeman/smart_proxy_openscap.git","ssh_url":"git@github.com:theforeman/smart_proxy_openscap.git","clone_url":"https://github.com/theforeman/smart_proxy_openscap.git","svn_url":"https://github.com/theforeman/smart_proxy_openscap","homepage":"","size":967,"stargazers_count":0,"watchers_count":0,"language":"Ruby","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":7,"mirror_url":null,"open_issues_count":1,"forks":7,"open_issues":1,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/theforeman/smart_proxy_openscap/pulls/17"},"html":{"href":"https://github.com/theforeman/smart_proxy_openscap/pull/17"},"issue":{"href":"https://api.github.com/repos/theforeman/smart_proxy_openscap/issues/17"},"comments":{"href":"https://api.github.com/repos/theforeman/smart_proxy_openscap/issues/17/comments"},"review_comments":{"href":"https://api.github.com/repos/theforeman/smart_proxy_openscap/pulls/17/comments"},"review_comment":{"href":"https://api.github.com/repos/theforeman/smart_proxy_openscap/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/theforeman/smart_proxy_openscap/pulls/17/commits"},"statuses":{"href":"https://api.github.com/repos/theforeman/smart_proxy_openscap/statuses/e4cff7332def39a0c1e2a22bdcdbb295adafbeba"}}}}