Class: Inspec::Resources::AuditPolicy
- Inherits:
-
Object
- Object
- Inspec::Resources::AuditPolicy
- Defined in:
- lib/inspec/resources/audit_policy.rb
Instance Method Summary collapse
- #method_missing(method) ⇒ Object
-
#resource_id ⇒ Object
Since this resource does not have any unique identifier for resource, sending the Auditpol command as UUID.
- #to_s ⇒ Object
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method) ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/inspec/resources/audit_policy.rb', line 36 def method_missing(method) key = method.to_s # expected result: # Machine Name,Policy Target,Subcategory,Subcategory GUID,Inclusion Setting,Exclusion Setting # WIN-MB8NINQ388J,System,Kerberos Authentication Service,{0CCE9242-69AE-11D9-BED3-505054503030},No Auditing, auditpol_cmd = "Auditpol /get /subcategory:'#{key}' /r" result ||= inspec.command(auditpol_cmd) unless result.exit_status == 0 error = result.stdout + "\n" + result.stderr raise Inspec::Exceptions::ResourceFailed, "Error while executing #{auditpol_cmd} command: #{error}" end # find line target = nil result.stdout.each_line do |s| target = s.strip if s =~ /\b.*#{key}.*\b/ end # extract value values = nil unless target.nil? # split csv values and return value values = target.split(",")[4] end values end |
Instance Method Details
#resource_id ⇒ Object
Since this resource does not have any unique identifier for resource, sending the Auditpol command as UUID.
67 68 69 |
# File 'lib/inspec/resources/audit_policy.rb', line 67 def resource_id "audit_policy" end |
#to_s ⇒ Object
71 72 73 |
# File 'lib/inspec/resources/audit_policy.rb', line 71 def to_s "Audit Policy" end |