{"action":"created","comment":{"url":"https://api.github.com/repos/theforeman/smart_proxy_openscap/pulls/comments/126408973","pull_request_review_id":48888032,"id":126408973,"diff_hunk":"@@ -1,111 +1,42 @@\n # encoding=utf-8\n-require 'openscap'\n-require 'openscap/ds/arf'\n-require 'openscap/xccdf/testresult'\n-require 'openscap/xccdf/ruleresult'\n-require 'openscap/xccdf/rule'\n-require 'openscap/xccdf/fix'\n-require 'openscap/xccdf/benchmark'\n-require 'json'\n-require 'iconv' if RUBY_VERSION.start_with? '1.8'\n+require 'tempfile'\n \n module Proxy::OpenSCAP\n   class Parse\n-    def initialize(arf_data)\n-      OpenSCAP.oscap_init\n-      size         = arf_data.size\n-      @arf_digest  = Digest::SHA256.hexdigest(arf_data)\n-      @arf         = OpenSCAP::DS::Arf.new(:content => arf_data, :path => 'arf.xml.bz2', :length => size)\n-      @test_result  = @arf.test_result\n-\n-      @results      = @test_result.rr\n-      @sds          = @arf.report_request\n-      bench_source = @sds.select_checklist!\n-      @benchmark    = OpenSCAP::Xccdf::Benchmark.new(bench_source)\n-      @items        = @benchmark.items\n-    end\n-\n-    def cleanup\n-      @test_result.destroy if @test_result\n-      @benchmark.destroy if @benchmark\n-      @sds.destroy if @sds\n-      @arf.destroy if @arf\n-      OpenSCAP.oscap_cleanup\n-    end\n-\n-    def as_json\n-      parse_report.to_json\n-    end\n-\n-    private\n-\n-    def parse_report\n-      report        = {}\n-      report[:logs] = []\n-      passed        = 0\n-      failed        = 0\n-      othered         = 0\n-      @results.each do |rr_id, result|\n-        next if result.result == 'notapplicable' || result.result == 'notselected'\n-        # get rules and their results\n-        rule_data = @items[rr_id]\n-        report[:logs] << populate_result_data(rr_id, result.result, rule_data)\n-        # create metrics for the results\n-        case result.result\n-          when 'pass', 'fixed'\n-            passed += 1\n-          when 'fail'\n-            failed += 1\n-          else\n-            othered += 1\n-        end\n+    include ::Proxy::Log\n+    include ::Proxy::Util\n+\n+    def initialize(cname, policy_id, date)\n+      @cname = cname\n+      @policy_id = policy_id\n+      @date = date\n+    end\n+\n+    def as_json(arf_data)\n+      in_file = nil\n+      json_file = nil\n+      begin\n+        in_file = Tempfile.new(filename, \"/var/tmp\")\n+        in_file.write arf_data\n+        json_file = Tempfile.new(\"#{filename}-json-\", \"/var/tmp\")\n+\n+        shell_command \"#{script_location} #{in_file.path} #{json_file.path}\"\n+        json = File.read(json_file)","path":"lib/smart_proxy_openscap/openscap_report_parser.rb","position":81,"original_position":81,"commit_id":"4ec552c8b210fcca2b8f89d55c0e4b71e16d7ffa","original_commit_id":"4ec552c8b210fcca2b8f89d55c0e4b71e16d7ffa","user":{"login":"ares","id":109773,"avatar_url":"https://avatars3.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":"I think the code should be more robust, the json might be corrupted (in case the script fails) so `rescue` block with explaining message might help","created_at":"2017-07-10T12:37:38Z","updated_at":"2017-07-10T12:56:43Z","html_url":"https://github.com/theforeman/smart_proxy_openscap/pull/51#discussion_r126408973","pull_request_url":"https://api.github.com/repos/theforeman/smart_proxy_openscap/pulls/51","_links":{"self":{"href":"https://api.github.com/repos/theforeman/smart_proxy_openscap/pulls/comments/126408973"},"html":{"href":"https://github.com/theforeman/smart_proxy_openscap/pull/51#discussion_r126408973"},"pull_request":{"href":"https://api.github.com/repos/theforeman/smart_proxy_openscap/pulls/51"}}},"pull_request":{"url":"https://api.github.com/repos/theforeman/smart_proxy_openscap/pulls/51","id":128136436,"html_url":"https://github.com/theforeman/smart_proxy_openscap/pull/51","diff_url":"https://github.com/theforeman/smart_proxy_openscap/pull/51.diff","patch_url":"https://github.com/theforeman/smart_proxy_openscap/pull/51.patch","issue_url":"https://api.github.com/repos/theforeman/smart_proxy_openscap/issues/51","number":51,"state":"open","locked":false,"title":"Fixes #20164 - Use a separate script to parse reports","user":{"login":"xprazak2","id":2664090,"avatar_url":"https://avatars2.githubusercontent.com/u/2664090?v=3","gravatar_id":"","url":"https://api.github.com/users/xprazak2","html_url":"https://github.com/xprazak2","followers_url":"https://api.github.com/users/xprazak2/followers","following_url":"https://api.github.com/users/xprazak2/following{/other_user}","gists_url":"https://api.github.com/users/xprazak2/gists{/gist_id}","starred_url":"https://api.github.com/users/xprazak2/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/xprazak2/subscriptions","organizations_url":"https://api.github.com/users/xprazak2/orgs","repos_url":"https://api.github.com/users/xprazak2/repos","events_url":"https://api.github.com/users/xprazak2/events{/privacy}","received_events_url":"https://api.github.com/users/xprazak2/received_events","type":"User","site_admin":false},"body":"TODO:\r\n- [ ] test  on production machine if everything loads correctly\r\n- [x] tests\r\n\r\n`shell_command` and `popen` methods are not available in 6.2, so we have to add them when cherry picking for downstream.","created_at":"2017-06-29T12:14:09Z","updated_at":"2017-07-10T12:56:43Z","closed_at":null,"merged_at":null,"merge_commit_sha":"888152093d0f3ecfe09ad77f6bc62396f9b63be3","assignee":null,"assignees":[],"requested_reviewers":[],"milestone":null,"commits_url":"https://api.github.com/repos/theforeman/smart_proxy_openscap/pulls/51/commits","review_comments_url":"https://api.github.com/repos/theforeman/smart_proxy_openscap/pulls/51/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/51/comments","statuses_url":"https://api.github.com/repos/theforeman/smart_proxy_openscap/statuses/4ec552c8b210fcca2b8f89d55c0e4b71e16d7ffa","head":{"label":"xprazak2:parse-script","ref":"parse-script","sha":"4ec552c8b210fcca2b8f89d55c0e4b71e16d7ffa","user":{"login":"xprazak2","id":2664090,"avatar_url":"https://avatars2.githubusercontent.com/u/2664090?v=3","gravatar_id":"","url":"https://api.github.com/users/xprazak2","html_url":"https://github.com/xprazak2","followers_url":"https://api.github.com/users/xprazak2/followers","following_url":"https://api.github.com/users/xprazak2/following{/other_user}","gists_url":"https://api.github.com/users/xprazak2/gists{/gist_id}","starred_url":"https://api.github.com/users/xprazak2/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/xprazak2/subscriptions","organizations_url":"https://api.github.com/users/xprazak2/orgs","repos_url":"https://api.github.com/users/xprazak2/repos","events_url":"https://api.github.com/users/xprazak2/events{/privacy}","received_events_url":"https://api.github.com/users/xprazak2/received_events","type":"User","site_admin":false},"repo":{"id":40126259,"name":"smart_proxy_openscap","full_name":"xprazak2/smart_proxy_openscap","owner":{"login":"xprazak2","id":2664090,"avatar_url":"https://avatars2.githubusercontent.com/u/2664090?v=3","gravatar_id":"","url":"https://api.github.com/users/xprazak2","html_url":"https://github.com/xprazak2","followers_url":"https://api.github.com/users/xprazak2/followers","following_url":"https://api.github.com/users/xprazak2/following{/other_user}","gists_url":"https://api.github.com/users/xprazak2/gists{/gist_id}","starred_url":"https://api.github.com/users/xprazak2/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/xprazak2/subscriptions","organizations_url":"https://api.github.com/users/xprazak2/orgs","repos_url":"https://api.github.com/users/xprazak2/repos","events_url":"https://api.github.com/users/xprazak2/events{/privacy}","received_events_url":"https://api.github.com/users/xprazak2/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/xprazak2/smart_proxy_openscap","description":"OpenSCAP plug-in for Foreman's smart-proxy.","fork":true,"url":"https://api.github.com/repos/xprazak2/smart_proxy_openscap","forks_url":"https://api.github.com/repos/xprazak2/smart_proxy_openscap/forks","keys_url":"https://api.github.com/repos/xprazak2/smart_proxy_openscap/keys{/key_id}","collaborators_url":"https://api.github.com/repos/xprazak2/smart_proxy_openscap/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/xprazak2/smart_proxy_openscap/teams","hooks_url":"https://api.github.com/repos/xprazak2/smart_proxy_openscap/hooks","issue_events_url":"https://api.github.com/repos/xprazak2/smart_proxy_openscap/issues/events{/number}","events_url":"https://api.github.com/repos/xprazak2/smart_proxy_openscap/events","assignees_url":"https://api.github.com/repos/xprazak2/smart_proxy_openscap/assignees{/user}","branches_url":"https://api.github.com/repos/xprazak2/smart_proxy_openscap/branches{/branch}","tags_url":"https://api.github.com/repos/xprazak2/smart_proxy_openscap/tags","blobs_url":"https://api.github.com/repos/xprazak2/smart_proxy_openscap/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/xprazak2/smart_proxy_openscap/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/xprazak2/smart_proxy_openscap/git/refs{/sha}","trees_url":"https://api.github.com/repos/xprazak2/smart_proxy_openscap/git/trees{/sha}","statuses_url":"https://api.github.com/repos/xprazak2/smart_proxy_openscap/statuses/{sha}","languages_url":"https://api.github.com/repos/xprazak2/smart_proxy_openscap/languages","stargazers_url":"https://api.github.com/repos/xprazak2/smart_proxy_openscap/stargazers","contributors_url":"https://api.github.com/repos/xprazak2/smart_proxy_openscap/contributors","subscribers_url":"https://api.github.com/repos/xprazak2/smart_proxy_openscap/subscribers","subscription_url":"https://api.github.com/repos/xprazak2/smart_proxy_openscap/subscription","commits_url":"https://api.github.com/repos/xprazak2/smart_proxy_openscap/commits{/sha}","git_commits_url":"https://api.github.com/repos/xprazak2/smart_proxy_openscap/git/commits{/sha}","comments_url":"https://api.github.com/repos/xprazak2/smart_proxy_openscap/comments{/number}","issue_comment_url":"https://api.github.com/repos/xprazak2/smart_proxy_openscap/issues/comments{/number}","contents_url":"https://api.github.com/repos/xprazak2/smart_proxy_openscap/contents/{+path}","compare_url":"https://api.github.com/repos/xprazak2/smart_proxy_openscap/compare/{base}...{head}","merges_url":"https://api.github.com/repos/xprazak2/smart_proxy_openscap/merges","archive_url":"https://api.github.com/repos/xprazak2/smart_proxy_openscap/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/xprazak2/smart_proxy_openscap/downloads","issues_url":"https://api.github.com/repos/xprazak2/smart_proxy_openscap/issues{/number}","pulls_url":"https://api.github.com/repos/xprazak2/smart_proxy_openscap/pulls{/number}","milestones_url":"https://api.github.com/repos/xprazak2/smart_proxy_openscap/milestones{/number}","notifications_url":"https://api.github.com/repos/xprazak2/smart_proxy_openscap/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/xprazak2/smart_proxy_openscap/labels{/name}","releases_url":"https://api.github.com/repos/xprazak2/smart_proxy_openscap/releases{/id}","deployments_url":"https://api.github.com/repos/xprazak2/smart_proxy_openscap/deployments","created_at":"2015-08-03T13:28:36Z","updated_at":"2015-08-03T13:28:36Z","pushed_at":"2017-07-10T09:12:42Z","git_url":"git://github.com/xprazak2/smart_proxy_openscap.git","ssh_url":"git@github.com:xprazak2/smart_proxy_openscap.git","clone_url":"https://github.com/xprazak2/smart_proxy_openscap.git","svn_url":"https://github.com/xprazak2/smart_proxy_openscap","homepage":"","size":495,"stargazers_count":0,"watchers_count":0,"language":"Ruby","has_issues":false,"has_projects":true,"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":"0b0408ec807916f4a4b815caae23895f32a7828b","user":{"login":"theforeman","id":1439844,"avatar_url":"https://avatars1.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://avatars1.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}","deployments_url":"https://api.github.com/repos/theforeman/smart_proxy_openscap/deployments","created_at":"2014-07-08T14:36:02Z","updated_at":"2016-12-12T16:14:08Z","pushed_at":"2017-07-10T12:03:24Z","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":492,"stargazers_count":2,"watchers_count":2,"language":"Ruby","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":15,"mirror_url":null,"open_issues_count":2,"forks":15,"open_issues":2,"watchers":2,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/theforeman/smart_proxy_openscap/pulls/51"},"html":{"href":"https://github.com/theforeman/smart_proxy_openscap/pull/51"},"issue":{"href":"https://api.github.com/repos/theforeman/smart_proxy_openscap/issues/51"},"comments":{"href":"https://api.github.com/repos/theforeman/smart_proxy_openscap/issues/51/comments"},"review_comments":{"href":"https://api.github.com/repos/theforeman/smart_proxy_openscap/pulls/51/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/51/commits"},"statuses":{"href":"https://api.github.com/repos/theforeman/smart_proxy_openscap/statuses/4ec552c8b210fcca2b8f89d55c0e4b71e16d7ffa"}}}}
{"actor":{"display_login":"ares"}}