From 5a6002f709d420f42eece50a42353ad28be718f5 Mon Sep 17 00:00:00 2001 From: Alex Pop Date: Tue, 7 May 2019 10:28:15 +0100 Subject: [PATCH 1/2] Add apache library from core inspec as it was deprecated in inspec 4 Signed-off-by: Alex Pop --- libraries/apache.rb | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 libraries/apache.rb diff --git a/libraries/apache.rb b/libraries/apache.rb new file mode 100644 index 0000000..523e850 --- /dev/null +++ b/libraries/apache.rb @@ -0,0 +1,44 @@ +# encoding: utf-8 +# copyright: 2015, Vulcano Security GmbH + +class Apache < Inspec.resource(1) + name 'apache' + supports platform: 'unix' + desc 'Use the apache InSpec audit resource to retrieve Apache environment settings.' + example <<~EXAMPLE + describe apache do + its ('service') { should cmp 'apache2' } + end + + describe apache do + its ('conf_dir') { should cmp '/etc/apache2' } + end + + describe apache do + its ('conf_path') { should cmp '/etc/apache2/apache2.conf' } + end + + describe apache do + its ('user') { should cmp 'www-data' } + end + EXAMPLE + + attr_reader :service, :conf_dir, :conf_path, :user + def initialize + if inspec.os.debian? + @service = 'apache2' + @conf_dir = '/etc/apache2/' + @conf_path = File.join @conf_dir, 'apache2.conf' + @user = 'www-data' + else + @service = 'httpd' + @conf_dir = '/etc/httpd/' + @conf_path = File.join @conf_dir, '/conf/httpd.conf' + @user = 'apache' + end + end + + def to_s + 'Apache Environment' + end +end From 70084354828b1cb1b848cf54c44ba6c1d08f64d2 Mon Sep 17 00:00:00 2001 From: Alex Pop Date: Tue, 7 May 2019 10:54:45 +0100 Subject: [PATCH 2/2] add frozen_string_literal Signed-off-by: Alex Pop --- libraries/apache.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libraries/apache.rb b/libraries/apache.rb index 523e850..6d6308c 100644 --- a/libraries/apache.rb +++ b/libraries/apache.rb @@ -1,4 +1,5 @@ -# encoding: utf-8 +# frozen_string_literal: true + # copyright: 2015, Vulcano Security GmbH class Apache < Inspec.resource(1)