Skip to content
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

Adding custom rules and tests for issue #253 - AWS::IAM::User.LoginPr… #298

Merged
8 commits merged into from
Nov 16, 2019

Conversation

tmcelhattan
Copy link
Contributor

Adding custom rules and tests for issue #253 - AWS::IAM::User.LoginProfile password property rules

@tmcelhattan tmcelhattan requested a review from a user October 28, 2019 18:44

class IamUserLoginProfilePasswordResetRule < BaseRule
def rule_text
"IAM User Login Profile should exist and have PasswordResetRequired property set to true"
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

make sure to use single quotes if you don't need interpolation.


def audit_impl(cfn_model)
violating_iam_users = cfn_model.resources_by_type("AWS::IAM::User").select do |iam_user|
iam_user.loginProfile["PasswordResetRequired"].nil? || iam_user.loginProfile["PasswordResetRequired"].to_s == "false"
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

make sure to use the proper truthy? predicate here. cfn is "weakly typed" when it comes to boolean values

a few things:

  1. this code is going to fail when loginProfile isn't there. it's not a required field
  2. i'm not sure what the proper behavior is here.... i guess if there is a login profile, the password should be noecho and reset must be required?

Copy link

@ghost ghost left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fix up string interpolation/literal convention across the code (rubocop should catch this)

make sure the behavior is correct with a missing loginProfile

@tmcelhattan
Copy link
Contributor Author

@erickascic Also made some additional refactors here as well based on the MQbroker PR.

@ghost ghost merged commit 140d062 into master Nov 16, 2019
@ghost ghost deleted the feature/issue-253-iam-user-login-profile branch January 6, 2020 21:59
This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant