-
Notifications
You must be signed in to change notification settings - Fork 682
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fixing issue with security policy always returning nil #321
Conversation
@loaded = true | ||
|
||
# delete temp file | ||
cmd = inspec.command('Remove-Item win_secpol.cfg') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please ensure that we delete it before we return. Even if we have an error, we should at least try to the file.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You got it. I'll get that in.
@jeremymv2 thanks for bringing this up. I like to move to Get-Content instead of |
@chris-rock I'm testing with: platforms: - name: win-2012r2-standard-amd64-nocm driver: box: opentable/win-2012r2-standard-amd64-nocm box_url: https://atlas.hashicorp.com/opentable/boxes/win-2012r2-standard-amd64-nocm/versions/1.0.0/providers/virtualbox.box |
@chris-rock Added an ensure block to always delete the file. Tested and works on a windows 2012R2 image. |
@jeremymv2 that is great. Could you do me one favor and add windows platform as a separate PR to our integration tests https://github.com/chef/inspec/blob/master/test/integration/.kitchen.yml? On top of this PR I would like to have an integration test added as well to ensure we do not miss this again. Let me know if you need help. |
@jeremymv2 One idea that came up in my head: At the point we wrote this resource we had no script resource available in InSpec. Now, it may be easier to just write a simple powershell script. Similar to https://github.com/chef/inspec/blob/f092ba3ac3790d074fc0a458cc4f5e3dc4d4e54d/lib/resources/registry_key.rb#L93-L108 That would reduce the calls to one request instead of three. What do you think? |
@chris-rock added a simple integration test for security_policy which should catch this root issue if it occurs again in the future. A couple of other things: |
@jeremymv2 Great work and thanks for the improvement. Regarding the integration tests: we started some work in #314 to make this work for Windows. I invite you to contribute more tests and especially to improve the Windows support. |
When travis shows green light, I am going to merge it. Please rebase your improvements on the latest master. |
Fixing issue with security policy always returning nil
All of the Security Policies were evaluating to nil.
This fixes the issues and allows it to work correctly.
I imagine this wasn't caught earlier due to a file artifact (win_secpol.cfg) being left around from a manual execution of the secedit export command.
Here is an example of what happens when trying to evaluate any security_policy: