-
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
Unique export file for security policy resource #2350
Conversation
Signed-off-by: Jared Quick <[email protected]>
lib/resources/security_policy.rb
Outdated
return skip_resource "Can't read security policy" if cmd.exit_status.to_i != 0 | ||
@content = cmd.stdout | ||
|
||
if @content.empty? && !file.empty? |
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.
This was removed as it seems to be legacy code. We don't have any local file
variable. In the future we could look into using the Train::File to capture the content of the policy.
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.
I think we should remove the content check completely. If the content is empty, we should not expect that to be okay, so it is probably a failure. Can we add a test that ensures the parsing is not crashing if we have an empty 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.
Nice fix, @jquick.
Signed-off-by: Jared Quick <[email protected]>
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.
Thank you @jquick
The SecurityPolicy resource has a potential race condition when exporting the policy. If two runners were both working on the SecurityPolicy resource one could delete the policy export file before the other finished the export. This would cause the policy test to fail on the second runner.
This change is to create a SecureRandom hex and append it to the policy export file. This resolves the issue as each instance will have its own unique file.
Signed-off-by: Jared Quick [email protected]