foreman_scap_client 0.0.1 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 15205a7c18ff85a94f61b981371aa71a3c43a0fc
4
- data.tar.gz: 9bf4fc5dbc1da692ff04c784cd6e416917780e90
3
+ metadata.gz: 5b4d4dd8bf085915d51de9a3b8993afcc6c7c259
4
+ data.tar.gz: f4be78a5d61d4f0933e7c90efbaf8a9fd55b242d
5
5
  SHA512:
6
- metadata.gz: bbfa743c2b79a4ad70c0377248d3a21b1c9fb4ee564ffdb70a740526c2fdd20ff38eeef4dfbd8311d539abe0c1a3d9713194a08f0ca74501c0e09d6cd76289f7
7
- data.tar.gz: 8df3c993f82a023dcb878fddad12908fa6ce9e560e7c1911519a7c6abf629905724589b6d3bbc6e61163481180dd4008ef73e1d7175f58f93c5ee34959c2522f
6
+ metadata.gz: 75fccbb8a011963834e16f114b59243b6148db0b986c7b7007f7057fc09f7f11e3e5dc7462f7ae1e9f395833502c85c4b85f6ed51727981e2a311b3dae67f4ab
7
+ data.tar.gz: ad33e2a6fd14a931c2128fccc683c8f0b45a7f7741459ec5a8d5f44af536842949d9aecb686b266223b4529adcc9a84c2ba986b71aef1582331b4d92bbf5aec0
@@ -14,6 +14,7 @@ module ForemanScapClient
14
14
  Dir.mktmpdir do |dir|
15
15
  @tmp_dir = dir
16
16
  scan
17
+ bzip
17
18
  upload
18
19
  end
19
20
  end
@@ -31,7 +32,7 @@ module ForemanScapClient
31
32
  def scan
32
33
  puts "DEBUG: running: " + scan_command
33
34
  result = `#{scan_command}`
34
- if $?.success?
35
+ if $?.success? || $?.exitstatus == 2
35
36
  @report = results_path
36
37
  else
37
38
  puts 'Scan failed'
@@ -44,8 +45,12 @@ module ForemanScapClient
44
45
  "#{@tmp_dir}/results.xml"
45
46
  end
46
47
 
48
+ def results_bzip_path
49
+ "#{results_path}.bz2"
50
+ end
51
+
47
52
  def scan_command
48
- if config[[@policy_id]] && config[@policy_id][:profile] && !config[@policy_id][:profile].empty?
53
+ if config[@policy_id] && config[@policy_id][:profile] && !config[@policy_id][:profile].empty?
49
54
  profile = "--profile #{config[@policy_id][:profile]}"
50
55
  else
51
56
  profile = ''
@@ -53,6 +58,20 @@ module ForemanScapClient
53
58
  "oscap xccdf eval #{profile} --results-arf #{results_path} #{config[@policy_id][:content_path]}"
54
59
  end
55
60
 
61
+ def bzip_command
62
+ "/usr/bin/bzip2 #{results_path}"
63
+ end
64
+
65
+ def bzip
66
+ puts 'DEBUG: running: ' + bzip_command
67
+ result = `#{bzip_command}`
68
+ if !$?.success?
69
+ puts 'bzip failed'
70
+ puts results
71
+ exit(2)
72
+ end
73
+ end
74
+
56
75
  def upload
57
76
  uri = URI.parse(upload_uri)
58
77
  puts "Uploading results to #{uri}"
@@ -70,7 +89,7 @@ module ForemanScapClient
70
89
  end
71
90
 
72
91
  request = Net::HTTP::Put.new uri.path
73
- request.body = File.read(results_path)
92
+ request.body = File.read(results_bzip_path)
74
93
  request['Content-Type'] = 'text/xml'
75
94
  request['Content-Encoding'] = 'x-bzip2'
76
95
  begin
@@ -1,3 +1,3 @@
1
1
  module ForemanScapClient
2
- VERSION = "0.0.1"
2
+ VERSION = "0.1.0"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: foreman_scap_client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Marek Hulan
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2015-01-22 00:00:00.000000000 Z
12
+ date: 2015-02-05 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler
@@ -74,7 +74,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
74
74
  - - '>='
75
75
  - !ruby/object:Gem::Version
76
76
  version: '0'
77
- requirements: []
77
+ requirements:
78
+ - /usr/bin/bzip2
78
79
  rubyforge_project:
79
80
  rubygems_version: 2.0.3
80
81
  signing_key: