diff --git a/.rubocop.yml b/.rubocop.yml
index 97954c4..41852e1 100644
--- a/.rubocop.yml
+++ b/.rubocop.yml
@@ -27,12 +27,6 @@ Metrics/MethodLength:
Exclude:
- 'test/**/*'
-Style/HashSyntax:
- EnforcedStyle: hash_rockets
-
-Style/SymbolArray:
- EnforcedStyle: brackets
-
Naming/MethodParameterName:
Enabled: false
diff --git a/Rakefile b/Rakefile
index d827466..778307e 100644
--- a/Rakefile
+++ b/Rakefile
@@ -2,7 +2,7 @@
require 'bundler'
-Bundler::GemHelper.install_tasks :name => 'openscap'
+Bundler::GemHelper.install_tasks name: 'openscap'
task :test do
$LOAD_PATH.unshift('lib')
diff --git a/lib/openscap/ds/arf.rb b/lib/openscap/ds/arf.rb
index d7904d3..7254cbc 100644
--- a/lib/openscap/ds/arf.rb
+++ b/lib/openscap/ds/arf.rb
@@ -58,8 +58,8 @@ def html
attach_function :ds_rds_session_new_from_source, [:pointer], :pointer
attach_function :ds_rds_session_free, [:pointer], :void
- attach_function :ds_rds_session_select_report, [:pointer, :string], :pointer
- attach_function :ds_rds_session_replace_report_with_source, [:pointer, :pointer], :int
- attach_function :ds_rds_session_select_report_request, [:pointer, :string], :pointer
+ attach_function :ds_rds_session_select_report, %i[pointer string], :pointer
+ attach_function :ds_rds_session_replace_report_with_source, %i[pointer pointer], :int
+ attach_function :ds_rds_session_select_report_request, %i[pointer string], :pointer
attach_function :ds_rds_session_get_html_report, [:pointer], :pointer
end
diff --git a/lib/openscap/ds/sds.rb b/lib/openscap/ds/sds.rb
index 9642adb..ae88be3 100644
--- a/lib/openscap/ds/sds.rb
+++ b/lib/openscap/ds/sds.rb
@@ -43,6 +43,6 @@ def destroy
attach_function :ds_sds_session_new_from_source, [:pointer], :pointer
attach_function :ds_sds_session_free, [:pointer], :void
- attach_function :ds_sds_session_select_checklist, [:pointer, :string, :string, :string], :pointer
- attach_function :ds_sds_session_get_html_guide, [:pointer, :string], :string
+ attach_function :ds_sds_session_select_checklist, %i[pointer string string string], :pointer
+ attach_function :ds_sds_session_get_html_guide, %i[pointer string], :string
end
diff --git a/lib/openscap/source.rb b/lib/openscap/source.rb
index 9f50485..702bf9d 100644
--- a/lib/openscap/source.rb
+++ b/lib/openscap/source.rb
@@ -51,13 +51,13 @@ def create_from_memory(param)
end
attach_function :oscap_source_new_from_file, [:string], :pointer
- attach_function :oscap_source_new_from_memory, [:pointer, :int, :string], :pointer
+ attach_function :oscap_source_new_from_memory, %i[pointer int string], :pointer
attach_function :oscap_source_get_scap_type, [:pointer], :int
attach_function :oscap_source_free, [:pointer], :void
- attach_function :oscap_source_save_as, [:pointer, :string], :int
+ attach_function :oscap_source_save_as, %i[pointer string], :int
- callback :xml_reporter, [:string, :int, :string, :pointer], :int
- attach_function :oscap_source_validate, [:pointer, :xml_reporter, :pointer], :int
+ callback :xml_reporter, %i[string int string pointer], :int
+ attach_function :oscap_source_validate, %i[pointer xml_reporter pointer], :int
XmlReporterCallback = proc do |filename, line_number, error_message, e|
offset = e.get_string(0).length
msg = "#{filename}:#{line_number}: #{error_message}"
diff --git a/lib/openscap/text.rb b/lib/openscap/text.rb
index 6a1141c..89a9422 100644
--- a/lib/openscap/text.rb
+++ b/lib/openscap/text.rb
@@ -37,10 +37,10 @@ def destroy
end
attach_function :oscap_text_new, [], :pointer
- attach_function :oscap_text_set_text, [:pointer, :string], :bool
+ attach_function :oscap_text_set_text, %i[pointer string], :bool
attach_function :oscap_text_get_text, [:pointer], :string
attach_function :oscap_text_free, [:pointer], :void
- attach_function :oscap_textlist_get_preferred_plaintext, [:pointer, :string], :string
+ attach_function :oscap_textlist_get_preferred_plaintext, %i[pointer string], :string
attach_function :oscap_text_iterator_free, [:pointer], :void
end
diff --git a/lib/openscap/xccdf/fix.rb b/lib/openscap/xccdf/fix.rb
index fbf1acb..57ac09b 100644
--- a/lib/openscap/xccdf/fix.rb
+++ b/lib/openscap/xccdf/fix.rb
@@ -29,10 +29,10 @@ def content
def to_hash
{
- :id => id,
- :platform => platform,
- :system => fix_system,
- :content => content
+ id:,
+ platform:,
+ system: fix_system,
+ content:
}
end
end
diff --git a/lib/openscap/xccdf/reference.rb b/lib/openscap/xccdf/reference.rb
index c8335f1..0d61271 100644
--- a/lib/openscap/xccdf/reference.rb
+++ b/lib/openscap/xccdf/reference.rb
@@ -24,9 +24,9 @@ def html_link
def to_hash
{
- :title => title,
- :href => href,
- :html_link => html_link
+ title:,
+ href:,
+ html_link:
}
end
end
diff --git a/lib/openscap/xccdf/rule.rb b/lib/openscap/xccdf/rule.rb
index fc192c0..93d2f85 100644
--- a/lib/openscap/xccdf/rule.rb
+++ b/lib/openscap/xccdf/rule.rb
@@ -11,12 +11,12 @@ class Rule < Item
def severity
severity = OpenSCAP.xccdf_rule_get_severity(@raw)
severity_mapping = {
- :xccdf_level_not_defined => 'Not defined',
- :xccdf_unknown => 'Unknown',
- :xccdf_info => 'Info',
- :xccdf_low => 'Low',
- :xccdf_medium => 'Medium',
- :xccdf_high => 'High'
+ xccdf_level_not_defined: 'Not defined',
+ xccdf_unknown: 'Unknown',
+ xccdf_info: 'Info',
+ xccdf_low: 'Low',
+ xccdf_medium: 'Medium',
+ xccdf_high: 'High'
}
severity_mapping[severity] || severity_mapping[:xccdf_unknown]
end
diff --git a/lib/openscap/xccdf/session.rb b/lib/openscap/xccdf/session.rb
index 4202a79..3bb3af5 100644
--- a/lib/openscap/xccdf/session.rb
+++ b/lib/openscap/xccdf/session.rb
@@ -17,8 +17,8 @@ def sds?
def load(opts = {})
o = {
- :datastream_id => nil,
- :component_id => nil
+ datastream_id: nil,
+ component_id: nil
}.merge(opts)
if sds?
OpenSCAP.xccdf_session_set_datastream_id(@s, o[:datastream_id])
@@ -45,12 +45,12 @@ def remediate
def export_results(opts = {})
o = {
- :rds_file => nil,
- :xccdf_file => nil,
- :report_file => nil,
- :oval_results => false,
- :oval_variables => false,
- :engines_results => false
+ rds_file: nil,
+ xccdf_file: nil,
+ report_file: nil,
+ oval_results: false,
+ oval_variables: false,
+ engines_results: false
}.merge!(opts)
export_targets o
export
@@ -94,13 +94,13 @@ def export_targets(opts = {})
attach_function :xccdf_session_is_sds, [:pointer], :bool
- attach_function :xccdf_session_set_profile_id, [:pointer, :string], :bool
- attach_function :xccdf_session_set_datastream_id, [:pointer, :string], :void
- attach_function :xccdf_session_set_component_id, [:pointer, :string], :void
- attach_function :xccdf_session_set_arf_export, [:pointer, :string], :bool
- attach_function :xccdf_session_set_xccdf_export, [:pointer, :string], :bool
- attach_function :xccdf_session_set_report_export, [:pointer, :string], :bool
- attach_function :xccdf_session_set_oval_variables_export, [:pointer, :bool], :void
- attach_function :xccdf_session_set_oval_results_export, [:pointer, :bool], :void
- attach_function :xccdf_session_set_check_engine_plugins_results_export, [:pointer, :bool], :void
+ attach_function :xccdf_session_set_profile_id, %i[pointer string], :bool
+ attach_function :xccdf_session_set_datastream_id, %i[pointer string], :void
+ attach_function :xccdf_session_set_component_id, %i[pointer string], :void
+ attach_function :xccdf_session_set_arf_export, %i[pointer string], :bool
+ attach_function :xccdf_session_set_xccdf_export, %i[pointer string], :bool
+ attach_function :xccdf_session_set_report_export, %i[pointer string], :bool
+ attach_function :xccdf_session_set_oval_variables_export, %i[pointer bool], :void
+ attach_function :xccdf_session_set_oval_results_export, %i[pointer bool], :void
+ attach_function :xccdf_session_set_check_engine_plugins_results_export, %i[pointer bool], :void
end
diff --git a/lib/openscap/xccdf/tailoring.rb b/lib/openscap/xccdf/tailoring.rb
index 11a15d0..5b5c6d3 100644
--- a/lib/openscap/xccdf/tailoring.rb
+++ b/lib/openscap/xccdf/tailoring.rb
@@ -43,7 +43,7 @@ def profiles_init
end
end
- attach_function :xccdf_tailoring_import_source, [:pointer, :pointer], :pointer
+ attach_function :xccdf_tailoring_import_source, %i[pointer pointer], :pointer
attach_function :xccdf_tailoring_free, [:pointer], :void
attach_function :xccdf_tailoring_get_profiles, [:pointer], :pointer
diff --git a/lib/openscap/xccdf/testresult.rb b/lib/openscap/xccdf/testresult.rb
index 5124c9f..8461198 100644
--- a/lib/openscap/xccdf/testresult.rb
+++ b/lib/openscap/xccdf/testresult.rb
@@ -72,9 +72,9 @@ def score_init
while OpenSCAP.xccdf_score_iterator_has_more(scorit)
s = OpenSCAP.xccdf_score_iterator_next(scorit)
scores[OpenSCAP.xccdf_score_get_system(s)] = {
- :system => OpenSCAP.xccdf_score_get_system(s),
- :value => OpenSCAP.xccdf_score_get_score(s),
- :max => OpenSCAP.xccdf_score_get_maximum(s)
+ system: OpenSCAP.xccdf_score_get_system(s),
+ value: OpenSCAP.xccdf_score_get_score(s),
+ max: OpenSCAP.xccdf_score_get_maximum(s)
}
end
OpenSCAP.xccdf_score_iterator_free(scorit)
@@ -87,8 +87,8 @@ def score_init
attach_function :xccdf_result_free, [:pointer], :void
attach_function :xccdf_result_get_id, [:pointer], :string
attach_function :xccdf_result_get_profile, [:pointer], :string
- attach_function :xccdf_result_recalculate_scores, [:pointer, :pointer], :int
- attach_function :xccdf_result_export_source, [:pointer, :string], :pointer
+ attach_function :xccdf_result_recalculate_scores, %i[pointer pointer], :int
+ attach_function :xccdf_result_export_source, %i[pointer string], :pointer
attach_function :xccdf_result_get_rule_results, [:pointer], :pointer
attach_function :xccdf_rule_result_iterator_has_more, [:pointer], :bool
diff --git a/test/ds/arf_test.rb b/test/ds/arf_test.rb
index f7ed528..6306ad4 100644
--- a/test/ds/arf_test.rb
+++ b/test/ds/arf_test.rb
@@ -52,7 +52,7 @@ def test_new_memory
create_arf
raw_data = File.read(REPORT)
refute raw_data.empty?
- arf = OpenSCAP::DS::Arf.new :content => raw_data, :path => REPORT
+ arf = OpenSCAP::DS::Arf.new content: raw_data, path: REPORT
arf.destroy
end
@@ -62,7 +62,7 @@ def test_new_bz_memory
assert !raw_data.empty?
len = File.size(bziped_file)
FileUtils.rm bziped_file
- arf = OpenSCAP::DS::Arf.new :content => raw_data, :path => bziped_file, :length => len
+ arf = OpenSCAP::DS::Arf.new content: raw_data, path: bziped_file, length: len
arf.destroy
end
@@ -88,9 +88,9 @@ def new_arf
def create_arf
@s = OpenSCAP::Xccdf::Session.new('../data/sds-complex.xml')
- @s.load(:component_id => 'scap_org.open-scap_cref_second-xccdf.xml')
+ @s.load(component_id: 'scap_org.open-scap_cref_second-xccdf.xml')
@s.profile = 'xccdf_moc.elpmaxe.www_profile_1'
@s.evaluate
- @s.export_results(:rds_file => 'report.rds.xml')
+ @s.export_results(rds_file: 'report.rds.xml')
end
end
diff --git a/test/ds/sds_test.rb b/test/ds/sds_test.rb
index d7e2ff1..c541fd5 100644
--- a/test/ds/sds_test.rb
+++ b/test/ds/sds_test.rb
@@ -16,7 +16,7 @@ def test_new_non_sds
assert !@s.nil?
msg = nil
begin
- OpenSCAP::DS::Sds.new :source => @s
+ OpenSCAP::DS::Sds.new source: @s
assert false
rescue OpenSCAP::OpenSCAPError => e
msg = e.to_s
@@ -48,7 +48,7 @@ def tests_select_checklist_wrong
sds = new_sds
msg = nil
begin
- benchmark = sds.select_checklist! :datastream_id => 'wrong'
+ benchmark = sds.select_checklist! datastream_id: 'wrong'
assert false
rescue OpenSCAP::OpenSCAPError => e
msg = e.to_s
@@ -64,7 +64,7 @@ def new_sds
filename = '../data/sds-complex.xml'
@s = OpenSCAP::Source.new filename
assert !@s.nil?
- sds = OpenSCAP::DS::Sds.new :source => @s
+ sds = OpenSCAP::DS::Sds.new source: @s
assert !sds.nil?
sds
end
diff --git a/test/integration/arf_waiver_test.rb b/test/integration/arf_waiver_test.rb
index d8703ff..738bdc8 100644
--- a/test/integration/arf_waiver_test.rb
+++ b/test/integration/arf_waiver_test.rb
@@ -14,10 +14,10 @@ def test_waiver_and_score
assert_default_score tr.score, -1, 1
assert_default_score tr.score!(benchmark), -1, 1
- rr.override!(:new_result => :pass,
- :time => 'yesterday',
- :authority => 'John Hacker',
- :raw_text => 'This should have passed')
+ rr.override!(new_result: :pass,
+ time: 'yesterday',
+ authority: 'John Hacker',
+ raw_text: 'This should have passed')
assert rr.result == 'pass'
assert_default_score tr.score, -1, 1
@@ -85,7 +85,7 @@ def arf_init
@s = OpenSCAP::Xccdf::Session.new('../data/sds-complex.xml')
@s.load
@s.evaluate
- @s.export_results(:rds_file => 'report.rds.xml')
+ @s.export_results(rds_file: 'report.rds.xml')
OpenSCAP::DS::Arf.new('report.rds.xml')
end
end
diff --git a/test/source_test.rb b/test/source_test.rb
index 311116f..e6aa17a 100644
--- a/test/source_test.rb
+++ b/test/source_test.rb
@@ -24,7 +24,7 @@ def test_source_new_ok
def test_source_new_memory
raw_data = File.read('../data/xccdf.xml')
refute raw_data.empty?
- s = OpenSCAP::Source.new(:content => raw_data, :path => '/mytestpath')
+ s = OpenSCAP::Source.new(content: raw_data, path: '/mytestpath')
s.destroy
end
diff --git a/test/xccdf/benchmark_test.rb b/test/xccdf/benchmark_test.rb
index f73d0d1..c4493c5 100644
--- a/test/xccdf/benchmark_test.rb
+++ b/test/xccdf/benchmark_test.rb
@@ -78,12 +78,12 @@ def test_items_severity
def test_items_references
b = benchmark_from_file
install_hids_rule = b.items['xccdf_org.ssgproject.content_rule_install_hids']
- expected_references = [{ :title => 'SC-7',
- :href => 'http://csrc.nist.gov/publications/nistpubs/800-53-Rev3/sp800-53-rev3-final.pdf',
- :html_link => "SC-7" },
- { :title => '1263',
- :href => 'http://iase.disa.mil/cci/index.html',
- :html_link => "1263" }]
+ expected_references = [{ title: 'SC-7',
+ href: 'http://csrc.nist.gov/publications/nistpubs/800-53-Rev3/sp800-53-rev3-final.pdf',
+ html_link: "SC-7" },
+ { title: '1263',
+ href: 'http://iase.disa.mil/cci/index.html',
+ html_link: "1263" }]
assert_equal(expected_references, install_hids_rule.references.map(&:to_hash), 'Install hids references should be equal')
b.destroy
end
@@ -93,10 +93,10 @@ def test_items_fixes
login_defs_rule = b.items['xccdf_org.ssgproject.content_rule_accounts_minimum_age_login_defs']
expected_content = ["var_accounts_minimum_age_login_defs=\"\"\ngrep -q ^PASS_MIN_DAYS /etc/login.defs && \\\nsed -i \"s/PASS_MIN_DAYS.*/PASS_MIN_DAYS\\t$var_accounts_minimum_age_login_defs/g\" /etc/login.defs\nif ! [ $? -eq 0 ]\nthen\n echo -e \"PASS_MIN_DAYS\\t$var_accounts_minimum_age_login_defs\" >> /etc/login.defs\nfi\n"]
expected_hashes = [{
- :id => nil,
- :platform => nil,
- :content => expected_content.first,
- :system => 'urn:xccdf:fix:script:sh'
+ id: nil,
+ platform: nil,
+ content: expected_content.first,
+ system: 'urn:xccdf:fix:script:sh'
}]
assert_equal(expected_content, login_defs_rule.fixes.map(&:content), 'Fix content should match')
assert_equal(expected_hashes, login_defs_rule.fixes.map(&:to_hash), 'Fix hash should match')
diff --git a/test/xccdf/session_ds_test.rb b/test/xccdf/session_ds_test.rb
index f84716d..45a4986 100644
--- a/test/xccdf/session_ds_test.rb
+++ b/test/xccdf/session_ds_test.rb
@@ -17,7 +17,7 @@ def test_session_load
def test_session_load_ds_comp
@s = OpenSCAP::Xccdf::Session.new('../data/sds-complex.xml')
- @s.load(:datastream_id => 'scap_org.open-scap_datastream_tst2', :component_id => 'scap_org.open-scap_cref_second-xccdf.xml2')
+ @s.load(datastream_id: 'scap_org.open-scap_datastream_tst2', component_id: 'scap_org.open-scap_cref_second-xccdf.xml2')
@s.evaluate
end
@@ -25,7 +25,7 @@ def test_session_load_bad_datastream
@s = OpenSCAP::Xccdf::Session.new('../data/sds-complex.xml')
msg = nil
begin
- @s.load(:datastream_id => 'nonexistent')
+ @s.load(datastream_id: 'nonexistent')
assert false
rescue OpenSCAP::OpenSCAPError => e
msg = e.to_s
@@ -37,7 +37,7 @@ def test_session_load_bad_component
@s = OpenSCAP::Xccdf::Session.new('../data/sds-complex.xml')
msg = nil
begin
- @s.load(:component_id => 'nonexistent')
+ @s.load(component_id: 'nonexistent')
assert false
rescue OpenSCAP::OpenSCAPError => e
msg = e.to_s
@@ -47,7 +47,7 @@ def test_session_load_bad_component
def test_session_set_profile
@s = OpenSCAP::Xccdf::Session.new('../data/sds-complex.xml')
- @s.load(:component_id => 'scap_org.open-scap_cref_second-xccdf.xml')
+ @s.load(component_id: 'scap_org.open-scap_cref_second-xccdf.xml')
@s.profile = 'xccdf_moc.elpmaxe.www_profile_1'
@s.evaluate
end
@@ -69,40 +69,40 @@ def test_session_export_rds
@s = OpenSCAP::Xccdf::Session.new('../data/sds-complex.xml')
@s.load
@s.evaluate
- @s.export_results(:rds_file => 'report.rds.xml')
+ @s.export_results(rds_file: 'report.rds.xml')
assert_exported ['report.rds.xml']
end
def test_session_export_xccdf_results
@s = OpenSCAP::Xccdf::Session.new('../data/sds-complex.xml')
- @s.load(:component_id => 'scap_org.open-scap_cref_second-xccdf.xml')
+ @s.load(component_id: 'scap_org.open-scap_cref_second-xccdf.xml')
@s.profile = 'xccdf_moc.elpmaxe.www_profile_1'
@s.evaluate
- @s.export_results(:xccdf_file => 'result.xccdf.xml')
+ @s.export_results(xccdf_file: 'result.xccdf.xml')
assert_exported ['result.xccdf.xml']
end
def test_session_export_html_report
@s = OpenSCAP::Xccdf::Session.new('../data/sds-complex.xml')
- @s.load(:component_id => 'scap_org.open-scap_cref_second-xccdf.xml')
+ @s.load(component_id: 'scap_org.open-scap_cref_second-xccdf.xml')
@s.profile = 'xccdf_moc.elpmaxe.www_profile_1'
@s.evaluate
- @s.export_results(:report_file => 'report.html', :xccdf_file => 'result.xccdf.xml')
+ @s.export_results(report_file: 'report.html', xccdf_file: 'result.xccdf.xml')
assert_exported ['report.html', 'result.xccdf.xml']
end
def test_session_export_oval_variables
@s = OpenSCAP::Xccdf::Session.new('../data/sds-complex.xml')
- @s.load(:component_id => 'scap_org.open-scap_cref_second-xccdf.xml')
+ @s.load(component_id: 'scap_org.open-scap_cref_second-xccdf.xml')
@s.profile = 'xccdf_moc.elpmaxe.www_profile_1'
@s.evaluate
- @s.export_results(:oval_variables => true)
+ @s.export_results(oval_variables: true)
assert_exported []
end
def test_remediate
@s = OpenSCAP::Xccdf::Session.new('../data/sds-complex.xml')
- @s.load(:component_id => 'scap_org.open-scap_cref_second-xccdf.xml')
+ @s.load(component_id: 'scap_org.open-scap_cref_second-xccdf.xml')
@s.profile = 'xccdf_moc.elpmaxe.www_profile_1'
@s.evaluate
@s.remediate
diff --git a/test/xccdf/testresult_test.rb b/test/xccdf/testresult_test.rb
index 690de7b..af702bb 100644
--- a/test/xccdf/testresult_test.rb
+++ b/test/xccdf/testresult_test.rb
@@ -44,10 +44,10 @@ def test_override
tr = new_tr
rr = tr.rr['xccdf_org.ssgproject.content_rule_disable_prelink']
assert rr.result == 'fail'
- rr.override!(:new_result => :pass,
- :time => 'yesterday',
- :authority => 'John Hacker',
- :raw_text => 'We are testing prelink on this machine')
+ rr.override!(new_result: :pass,
+ time: 'yesterday',
+ authority: 'John Hacker',
+ raw_text: 'We are testing prelink on this machine')
assert rr.result == 'pass'
tr.destroy
end
@@ -67,10 +67,10 @@ def test_waive_and_score
rr = tr.rr['xccdf_org.ssgproject.content_rule_disable_prelink']
assert rr.result == 'fail'
- rr.override!(:new_result => :pass,
- :time => 'yesterday',
- :authority => 'John Hacker',
- :raw_text => 'We are testing prelink on this machine')
+ rr.override!(new_result: :pass,
+ time: 'yesterday',
+ authority: 'John Hacker',
+ raw_text: 'We are testing prelink on this machine')
assert rr.result == 'pass'
assert_default_score tr.score, 34, 35