-
Notifications
You must be signed in to change notification settings - Fork 681
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Require a key attribute for the key_rsa resource (#2891)
Bug Fix #2865 * Defining an attribute without a default value generates a stacktrace * Fix string quotes * Moved logic out of the initilize method. * Refactoring for better clarity. * Fixing trailing white spaces Signed-off-by: Omar J Irizarry <[email protected]>
- Loading branch information
1 parent
0c3bec2
commit a278ae9
Showing
2 changed files
with
18 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
module PkeyReader | ||
def read_pkey(filecontent, passphrase) | ||
raise_if_default(passphrase) | ||
|
||
OpenSSL::PKey.read(filecontent, passphrase) | ||
rescue OpenSSL::PKey::PKeyError | ||
raise Inspec::Exceptions::ResourceFailed, 'passphrase error' | ||
end | ||
|
||
def raise_if_default(passphrase) | ||
if passphrase.is_a? Inspec::Attribute::DEFAULT_ATTRIBUTE | ||
raise Inspec::Exceptions::ResourceFailed, 'Please provide default value for attribute' | ||
end | ||
end | ||
end |