-
Notifications
You must be signed in to change notification settings - Fork 103
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
Lamps/password policy #169
Conversation
@@ -0,0 +1,69 @@ | |||
module Nexpose | |||
require 'json' |
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 is not needed here. As lib/nexpose.rb
takes care of it.
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 disagree. It's good practice to require anything used within the same file. We don't do it much in the gem today, but if we moved to it we could start doing things like lazy loading files.
It's a matter of debate, but it's perfectly harmless to leave since it will only do the work once.
There should be a method to list policies as well. |
module Nexpose | ||
require 'json' | ||
# Configuration structure for password policies. | ||
class Password_policy < APIObject |
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.
looking at the file name - the name of the class should be PasswordPolicy.
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.
Rectified this.
@adevitt-r7 Stylistic note — we should be consistently using |
attr_accessor :digits | ||
attr_accessor :specialChars | ||
|
||
def initialize(policyName:, minLength:, maxLength:, specialChars:, capitals:, digits:) |
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.
let's refactor all the attrs, and method arguments to use snake_case instead of camelCase
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'd leave #to_h
since it is used for the #to_json
conversion. We'd want to use the same keys there.
uri = '/api/2.1/password_policy/' | ||
resp = AJAX.get(nsc, uri, AJAX::CONTENT_TYPE::JSON) | ||
hash = JSON.parse(resp, symbolize_names: true) | ||
from_hash(hash) |
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.
@adevitt-r7 this needs to be self.from_hash
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.
@sgreen-r7 @adevitt-r7 Oops, merged before seeing this addressed missing there was still an open comment (the other two open comments are opinions).
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.
@adevitt-r7 Fixed by 86b9010 (from @sgreen-r7).
@adevitt-r7 awesome, let's . When should this get merged down? |
@erran-r7 Password policies are going with Odin |
GEM changes required for NEX-43065: [Password Policy Administration] Customized Password Policies.