Skip to content

Commit

Permalink
(SIMP-6706) Fix trailing newline in custom profile (#100)
Browse files Browse the repository at this point in the history
Custom profiles had issues where a trailing newline would not be
present when joining on an Array. Now append a trailing newline in all
cases in case of a badly formatted template or Array join.

SIMP-6706 #close
  • Loading branch information
trevor-vaughan authored and lnemsick-simp committed Jun 25, 2019
1 parent 3546c04 commit a6b5439
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 6 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
* Tue Jun 25 2019 Trevor Vaughan <[email protected]> - 8.3.2-0
- Fix an issue where trailing newlines may not be present on custom rule
profiles, particularly with rules defined in an Array.

* Thu May 02 2019 Liz Nemsick <[email protected]> - 8.3.1-0
- Fix a breaking change inadvertantly introduced into auditd::rule
in which the auditd class was no longer included when an auditd::rule
Expand Down
2 changes: 1 addition & 1 deletion manifests/config/audit_profiles/custom.pp
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,6 @@
$_idx = auditd::get_array_index($_short_name, $auditd::config::profiles)

file { "/etc/audit/rules.d/50_${_idx}_${_short_name}_base.rules":
content => $_custom_rules
content => "${_custom_rules}\n"
}
}
2 changes: 1 addition & 1 deletion metadata.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "simp-auditd",
"version": "8.3.1",
"version": "8.3.2",
"author": "SIMP Team",
"summary": "A SIMP puppet module for managing auditd and audispd",
"license": "Apache-2.0",
Expand Down
8 changes: 4 additions & 4 deletions spec/classes/config/audit_profiles/custom_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class auditd::config ( $profiles = ['custom'] ){}
}}

it { is_expected.to compile.with_all_deps }
it { is_expected.to contain_file('/etc/audit/rules.d/50_00_custom_base.rules').with_content(params[:rules].join("\n")) }
it { is_expected.to contain_file('/etc/audit/rules.d/50_00_custom_base.rules').with_content(params[:rules].join("\n") + "\n") }
end

context 'when using templates' do
Expand All @@ -43,7 +43,7 @@ class auditd::config ( $profiles = ['custom'] ){}
}

it { is_expected.to compile.with_all_deps }
it { is_expected.to contain_file('/etc/audit/rules.d/50_00_custom_base.rules').with_content('EPP!') }
it { is_expected.to contain_file('/etc/audit/rules.d/50_00_custom_base.rules').with_content("EPP!\n") }
end

context 'with ERB template specified' do
Expand All @@ -60,7 +60,7 @@ class auditd::config ( $profiles = ['custom'] ){}
}

it { is_expected.to compile.with_all_deps }
it { is_expected.to contain_file('/etc/audit/rules.d/50_00_custom_base.rules').with_content('ERB!') }
it { is_expected.to contain_file('/etc/audit/rules.d/50_00_custom_base.rules').with_content("ERB!\n") }
end

context 'with an invalid template name specified' do
Expand Down Expand Up @@ -107,7 +107,7 @@ class auditd::config (
}}

it { is_expected.to compile.with_all_deps }
it { is_expected.to contain_file('/etc/audit/rules.d/50_01_custom_base.rules').with_content(params[:rules].join("\n")) }
it { is_expected.to contain_file('/etc/audit/rules.d/50_01_custom_base.rules').with_content(params[:rules].join("\n") + "\n") }
end
end
end
Expand Down

0 comments on commit a6b5439

Please sign in to comment.