2017-04-06 19:12:19 +00:00
|
|
|
# author: Viktor Yakovlyev
|
2017-04-28 10:50:26 +00:00
|
|
|
class AwsIamPasswordPolicy < Inspec.resource(1)
|
|
|
|
name 'aws_iam_password_policy'
|
2017-04-06 19:12:19 +00:00
|
|
|
desc 'Verifies iam password policy'
|
|
|
|
|
|
|
|
example "
|
2017-04-28 10:50:26 +00:00
|
|
|
describe aws_iam_password_policy do
|
2017-10-12 15:54:55 +00:00
|
|
|
its('requires_lowercase_characters?') { should be true }
|
2017-04-06 19:12:19 +00:00
|
|
|
end
|
|
|
|
|
2017-04-28 10:50:26 +00:00
|
|
|
describe aws_iam_password_policy do
|
2017-10-12 15:54:55 +00:00
|
|
|
its('requires_uppercase_characters?') { should be true }
|
2017-04-06 19:12:19 +00:00
|
|
|
end
|
|
|
|
"
|
|
|
|
|
|
|
|
def initialize(conn = AWSConnection.new)
|
|
|
|
@policy = conn.iam_resource.account_password_policy
|
|
|
|
rescue Aws::IAM::Errors::NoSuchEntity
|
|
|
|
@policy = nil
|
|
|
|
end
|
|
|
|
|
|
|
|
def exists?
|
|
|
|
!@policy.nil?
|
|
|
|
end
|
|
|
|
|
|
|
|
def requires_lowercase_characters?
|
|
|
|
@policy.require_lowercase_characters
|
|
|
|
end
|
|
|
|
|
|
|
|
def requires_uppercase_characters?
|
|
|
|
@policy.require_uppercase_characters
|
|
|
|
end
|
|
|
|
|
|
|
|
def minimum_password_length
|
|
|
|
@policy.minimum_password_length
|
|
|
|
end
|
|
|
|
|
|
|
|
def requires_numbers?
|
|
|
|
@policy.require_numbers
|
|
|
|
end
|
|
|
|
|
|
|
|
def requires_symbols?
|
|
|
|
@policy.require_symbols
|
|
|
|
end
|
|
|
|
|
|
|
|
def allows_users_to_change_password?
|
|
|
|
@policy.allow_users_to_change_password
|
|
|
|
end
|
2017-04-13 19:00:04 +00:00
|
|
|
|
|
|
|
def expires_passwords?
|
|
|
|
@policy.expire_passwords
|
|
|
|
end
|
|
|
|
|
|
|
|
def max_password_age
|
|
|
|
raise 'this policy does not expire passwords' unless expires_passwords?
|
|
|
|
@policy.max_password_age
|
|
|
|
end
|
2017-06-13 05:41:43 +00:00
|
|
|
|
|
|
|
def prevents_password_reuse?
|
|
|
|
!@policy.password_reuse_prevention.nil?
|
|
|
|
end
|
|
|
|
|
|
|
|
def number_of_passwords_to_remember
|
|
|
|
raise 'this policy does not prevent password reuse' \
|
|
|
|
unless prevents_password_reuse?
|
|
|
|
@policy.password_reuse_prevention
|
|
|
|
end
|
2017-06-29 10:03:20 +00:00
|
|
|
|
|
|
|
def to_s
|
|
|
|
'IAM Password-Policy'
|
|
|
|
end
|
2017-04-06 19:12:19 +00:00
|
|
|
end
|