openscap 0.1.0 → 0.1.1

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: c04e6a4f80a1b4543f0fec9f9b3e77dd212754ff
4
- data.tar.gz: 63b800808bc11cf29bc1913e9e707c241b30d288
3
+ metadata.gz: de8f677ade591343896be83be887fb9951ae0dff
4
+ data.tar.gz: e970e06de1f035553cc0dca86fcaacf7c0d28bd6
5
5
  SHA512:
6
- metadata.gz: 93c3b39ef2fe40f07a45e6a6a1c588e7dfb9b7a723df0855216560b1b140b65f8b12c33521586ed6b349237bc54a88a0a0e027ebfee96ad9b46dda44732f07d8
7
- data.tar.gz: cf83e53fac11ae9ffcab9aa7a68572c4d3766b13a1418ed57b73eeee595c6904bd061c52a976730e3010e9ab53ecd74626c62b7bee2f45db0057081262e70af3
6
+ metadata.gz: e7ff6530f527abe9f131fff313eb937f9e50eaec812eb0e084f57d1f1318fab5e9f778b0e3fb833ec01b39471353bec13e2adb162ac1c2c264ee2e73f58a124d
7
+ data.tar.gz: 98c6a0a6a5cb3e9f9dc494ee4e7ba0be5158de74073ccd1ee5aca9e597b2e9b717bf32d82503fd88e53178617994b5f0e23f76e8adbd62857a6139d0898fa2f1
data/README.md CHANGED
@@ -18,4 +18,5 @@ Sample Scanner Implementation
18
18
  s.profile = "xccdf_org.ssgproject.content_profile_common"
19
19
  s.evaluate
20
20
  s.export_results(rds_file:"results.rds.xml")
21
+ s.destroy
21
22
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.0
1
+ 0.1.1
@@ -14,6 +14,7 @@ module OpenSCAP
14
14
 
15
15
  class Session
16
16
  def initialize(input_filename)
17
+ raise OpenSCAPError, "No filename specified!" unless input_filename
17
18
  @input_filename = input_filename
18
19
  @s = OpenSCAP.xccdf_session_new(input_filename)
19
20
  if @s.null?
@@ -68,8 +69,9 @@ module OpenSCAP
68
69
  OpenSCAP.raise! unless OpenSCAP.xccdf_session_export_arf(@s) == 0
69
70
  end
70
71
 
71
- def finalize(s)
72
- OpenSCAP.xccdf_session_free(s.s)
72
+ def destroy
73
+ OpenSCAP.xccdf_session_free(@s)
74
+ @s = nil
73
75
  end
74
76
  end
75
77
  end
@@ -28,9 +28,11 @@ module OpenSCAP
28
28
  FileUtils.rm_rf workdir
29
29
  Dir.mkdir workdir
30
30
  Dir.chdir workdir
31
+ @s = nil
31
32
  end
32
33
 
33
34
  def cleanup
35
+ @s.destroy if @s
34
36
  Dir.chdir "../.."
35
37
  OpenSCAP.raise! if OpenSCAP.error?
36
38
  end
@@ -14,27 +14,27 @@ require 'common/testcase'
14
14
 
15
15
  class TestSessionDS < OpenSCAP::TestCase
16
16
  def test_sds_true
17
- s = OpenSCAP::Xccdf::Session.new("../data/sds-complex.xml")
18
- assert s.sds?
17
+ @s = OpenSCAP::Xccdf::Session.new("../data/sds-complex.xml")
18
+ assert @s.sds?
19
19
  end
20
20
 
21
21
  def test_session_load
22
- s = OpenSCAP::Xccdf::Session.new("../data/sds-complex.xml")
23
- s.load
24
- s.evaluate
22
+ @s = OpenSCAP::Xccdf::Session.new("../data/sds-complex.xml")
23
+ @s.load
24
+ @s.evaluate
25
25
  end
26
26
 
27
27
  def test_session_load_ds_comp
28
- s = OpenSCAP::Xccdf::Session.new("../data/sds-complex.xml")
29
- s.load(datastream_id:"scap_org.open-scap_datastream_tst2", component_id:"scap_org.open-scap_cref_second-xccdf.xml2")
30
- s.evaluate
28
+ @s = OpenSCAP::Xccdf::Session.new("../data/sds-complex.xml")
29
+ @s.load(datastream_id:"scap_org.open-scap_datastream_tst2", component_id:"scap_org.open-scap_cref_second-xccdf.xml2")
30
+ @s.evaluate
31
31
  end
32
32
 
33
33
  def test_session_load_bad_datastream
34
- s = OpenSCAP::Xccdf::Session.new("../data/sds-complex.xml")
34
+ @s = OpenSCAP::Xccdf::Session.new("../data/sds-complex.xml")
35
35
  msg = nil
36
36
  begin
37
- s.load(datastream_id:"nonexistent")
37
+ @s.load(datastream_id:"nonexistent")
38
38
  assert false
39
39
  rescue OpenSCAP::OpenSCAPError => e
40
40
  msg = e.to_s
@@ -43,10 +43,10 @@ class TestSessionDS < OpenSCAP::TestCase
43
43
  end
44
44
 
45
45
  def test_session_load_bad_component
46
- s = OpenSCAP::Xccdf::Session.new("../data/sds-complex.xml")
46
+ @s = OpenSCAP::Xccdf::Session.new("../data/sds-complex.xml")
47
47
  msg = nil
48
48
  begin
49
- s.load(component_id:"nonexistent")
49
+ @s.load(component_id:"nonexistent")
50
50
  assert false
51
51
  rescue OpenSCAP::OpenSCAPError => e
52
52
  msg = e.to_s
@@ -55,18 +55,18 @@ class TestSessionDS < OpenSCAP::TestCase
55
55
  end
56
56
 
57
57
  def test_session_set_profile
58
- s = OpenSCAP::Xccdf::Session.new("../data/sds-complex.xml")
59
- s.load(component_id:"scap_org.open-scap_cref_second-xccdf.xml")
60
- s.profile = "xccdf_moc.elpmaxe.www_profile_1"
61
- s.evaluate
58
+ @s = OpenSCAP::Xccdf::Session.new("../data/sds-complex.xml")
59
+ @s.load(component_id:"scap_org.open-scap_cref_second-xccdf.xml")
60
+ @s.profile = "xccdf_moc.elpmaxe.www_profile_1"
61
+ @s.evaluate
62
62
  end
63
63
 
64
64
  def test_session_set_profile_bad
65
- s = OpenSCAP::Xccdf::Session.new("../data/sds-complex.xml")
66
- s.load
65
+ @s = OpenSCAP::Xccdf::Session.new("../data/sds-complex.xml")
66
+ @s.load
67
67
  msg = nil
68
68
  begin
69
- s.profile = "xccdf_moc.elpmaxe.www_profile_1"
69
+ @s.profile = "xccdf_moc.elpmaxe.www_profile_1"
70
70
  assert false
71
71
  rescue OpenSCAP::OpenSCAPError => e
72
72
  msg = e.to_s
@@ -75,46 +75,46 @@ class TestSessionDS < OpenSCAP::TestCase
75
75
  end
76
76
 
77
77
  def test_session_export_rds
78
- s = OpenSCAP::Xccdf::Session.new("../data/sds-complex.xml")
79
- s.load
80
- s.evaluate
81
- s.export_results(rds_file:"report.rds.xml")
78
+ @s = OpenSCAP::Xccdf::Session.new("../data/sds-complex.xml")
79
+ @s.load
80
+ @s.evaluate
81
+ @s.export_results(rds_file:"report.rds.xml")
82
82
  assert_exported ["report.rds.xml"]
83
83
  end
84
84
 
85
85
  def test_session_export_xccdf_results
86
- s = OpenSCAP::Xccdf::Session.new("../data/sds-complex.xml")
87
- s.load(component_id:"scap_org.open-scap_cref_second-xccdf.xml")
88
- s.profile = "xccdf_moc.elpmaxe.www_profile_1"
89
- s.evaluate
90
- s.export_results(xccdf_file:"result.xccdf.xml")
86
+ @s = OpenSCAP::Xccdf::Session.new("../data/sds-complex.xml")
87
+ @s.load(component_id:"scap_org.open-scap_cref_second-xccdf.xml")
88
+ @s.profile = "xccdf_moc.elpmaxe.www_profile_1"
89
+ @s.evaluate
90
+ @s.export_results(xccdf_file:"result.xccdf.xml")
91
91
  assert_exported ["result.xccdf.xml"]
92
92
  end
93
93
 
94
94
  def test_session_export_html_report
95
- s = OpenSCAP::Xccdf::Session.new("../data/sds-complex.xml")
96
- s.load(component_id:"scap_org.open-scap_cref_second-xccdf.xml")
97
- s.profile = "xccdf_moc.elpmaxe.www_profile_1"
98
- s.evaluate
99
- s.export_results(report_file:"report.html", xccdf_file:"result.xccdf.xml")
95
+ @s = OpenSCAP::Xccdf::Session.new("../data/sds-complex.xml")
96
+ @s.load(component_id:"scap_org.open-scap_cref_second-xccdf.xml")
97
+ @s.profile = "xccdf_moc.elpmaxe.www_profile_1"
98
+ @s.evaluate
99
+ @s.export_results(report_file:"report.html", xccdf_file:"result.xccdf.xml")
100
100
  assert_exported ["report.html", "result.xccdf.xml"]
101
101
  end
102
102
 
103
103
  def test_session_export_oval_variables
104
- s = OpenSCAP::Xccdf::Session.new("../data/sds-complex.xml")
105
- s.load(component_id:"scap_org.open-scap_cref_second-xccdf.xml")
106
- s.profile = "xccdf_moc.elpmaxe.www_profile_1"
107
- s.evaluate
108
- s.export_results(oval_variables:true)
104
+ @s = OpenSCAP::Xccdf::Session.new("../data/sds-complex.xml")
105
+ @s.load(component_id:"scap_org.open-scap_cref_second-xccdf.xml")
106
+ @s.profile = "xccdf_moc.elpmaxe.www_profile_1"
107
+ @s.evaluate
108
+ @s.export_results(oval_variables:true)
109
109
  assert_exported []
110
110
  end
111
111
 
112
112
  def test_remediate
113
- s = OpenSCAP::Xccdf::Session.new("../data/sds-complex.xml")
114
- s.load(component_id:"scap_org.open-scap_cref_second-xccdf.xml")
115
- s.profile = "xccdf_moc.elpmaxe.www_profile_1"
116
- s.evaluate
117
- s.remediate
113
+ @s = OpenSCAP::Xccdf::Session.new("../data/sds-complex.xml")
114
+ @s.load(component_id:"scap_org.open-scap_cref_second-xccdf.xml")
115
+ @s.profile = "xccdf_moc.elpmaxe.www_profile_1"
116
+ @s.evaluate
117
+ @s.remediate
118
118
  end
119
119
 
120
120
  def assert_exported(files)
@@ -24,8 +24,19 @@ class TestSession < OpenSCAP::TestCase
24
24
  assert msg.start_with?("Unable to open file: ''"), "Message was: " + msg
25
25
  end
26
26
 
27
+ def test_session_new_nil
28
+ msg = nil
29
+ begin
30
+ s = OpenSCAP::Xccdf::Session.new(nil)
31
+ assert false
32
+ rescue OpenSCAP::OpenSCAPError => e
33
+ msg = e.to_s
34
+ end
35
+ assert msg.start_with?("No filename specified!"), "Message was: " + msg
36
+ end
37
+
27
38
  def test_sds_false
28
- s = OpenSCAP::Xccdf::Session.new("../data/xccdf.xml")
29
- assert ! s.sds?
39
+ @s = OpenSCAP::Xccdf::Session.new("../data/xccdf.xml")
40
+ assert ! @s.sds?
30
41
  end
31
42
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: openscap
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Šimon Lukašík
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-04-22 00:00:00.000000000 Z
11
+ date: 2014-07-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler