Skip to content

Commit

Permalink
Fix tolerance defaults to be nil if not specified (#154)
Browse files Browse the repository at this point in the history
* Set tolerance setting to nil unless specified, ignore any disabled/remediation if nil

* Change logic to account for zero case

* Add rescue

* Add changelog and version bump

* Dates are hard

---------

Co-authored-by: Garrett Adams <[email protected]>
  • Loading branch information
CyrodiilSavior and Garrett Adams authored Mar 14, 2023
1 parent c9d57d7 commit 1ed5a7e
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
* Tue Mar 14 2023 Garrett Adams <[email protected]> - 3.3.1
- Change enforcement tolerance to be nil if not specified, by default.
nil will ignore any remediation/disabled checks.

* Thu Feb 16 2023 Garrett Adams <[email protected]> - 3.3.0
- Add tolerance as hiera lookup. Confine checks that can be enforced
based on the tolerance setting.
Expand Down
7 changes: 6 additions & 1 deletion lib/puppetx/simp/compliance_mapper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,12 @@ def enforcement(key, context=self, options={"mode" => "value"}, &block)

begin
profile_list = Array(call_function('lookup', 'compliance_markup::enforcement', { 'default_value' => [] }))
options[:tolerance_setting] = Integer(call_function('lookup', 'compliance_markup::enforcement_tolerance_level', { 'default_value' => 40 }).to_i)
begin
tolerance_setting = call_function('lookup', 'compliance_markup::enforcement_tolerance_level')
rescue
tolerance_setting = nil
end
options[:tolerance_setting] = tolerance_setting.to_i unless tolerance_setting.nil?

unless profile_list == []
debug("debug: compliance_markup::enforcement set to #{profile_list}, attempting to enforce")
Expand Down
2 changes: 1 addition & 1 deletion metadata.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "simp-compliance_markup",
"version": "3.3.0",
"version": "3.3.1",
"author": "SIMP Team",
"summary": "Compliance-mapping annotation for Puppet code",
"license": "Apache-2.0",
Expand Down

0 comments on commit 1ed5a7e

Please sign in to comment.