-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(checks): migrate AWS iam to Rego
Signed-off-by: Nikita Pivkin <[email protected]>
- Loading branch information
Showing
107 changed files
with
1,798 additions
and
2,173 deletions.
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
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
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
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
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
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
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
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
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
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
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
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,47 @@ | ||
# METADATA | ||
# title: Credentials which are no longer used should be disabled. | ||
# description: | | ||
# CIS recommends that you remove or deactivate all credentials that have been unused in 90 days or more. Disabling or removing unnecessary credentials reduces the window of opportunity for credentials associated with a compromised or abandoned account to be used. | ||
# scope: package | ||
# schemas: | ||
# - input: schema["cloud"] | ||
# related_resources: | ||
# - https://console.aws.amazon.com/iam/ | ||
# custom: | ||
# id: AVD-AWS-0144 | ||
# avd_id: AVD-AWS-0144 | ||
# provider: aws | ||
# service: iam | ||
# severity: MEDIUM | ||
# short_code: disable-unused-credentials | ||
# recommended_action: Disable credentials which are no longer used. | ||
# frameworks: | ||
# cis-aws-1.2: | ||
# - "1.3" | ||
# input: | ||
# selector: | ||
# - type: cloud | ||
# subtypes: | ||
# - service: iam | ||
# provider: aws | ||
package builtin.aws.iam.aws0144 | ||
|
||
import rego.v1 | ||
|
||
import data.lib.iam | ||
|
||
days_to_check = 90 | ||
|
||
deny contains res if { | ||
some user in input.aws.iam.users | ||
iam.user_is_inactive(user, days_to_check) | ||
res := result.new("User has not logged in for >90 days.", user) | ||
} | ||
|
||
deny contains res if { | ||
some user in input.aws.iam.users | ||
not iam.user_is_inactive(user, days_to_check) | ||
some key in user.accesskeys | ||
iam.key_is_unused(key, days_to_check) | ||
res := result.new(sprintf("User access key %q has not been used in >90 days", [key.accesskeyid.value]), user) | ||
} |
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,46 @@ | ||
# METADATA | ||
# title: Disabling or removing unnecessary credentials will reduce the window of opportunity for credentials associated with a compromised or abandoned account to be used. | ||
# description: | | ||
# AWS IAM users can access AWS resources using different types of credentials, such as passwords or access keys. It is recommended that all credentials that have been unused in45 or greater days be deactivated or removed. | ||
# scope: package | ||
# schemas: | ||
# - input: schema["cloud"] | ||
# related_resources: | ||
# - https://console.aws.amazon.com/iam/ | ||
# custom: | ||
# id: AVD-AWS-0166 | ||
# avd_id: AVD-AWS-0166 | ||
# provider: aws | ||
# service: iam | ||
# severity: LOW | ||
# short_code: disable-unused-credentials-45-days | ||
# recommended_action: Disable credentials which are no longer used. | ||
# frameworks: | ||
# cis-aws-1.4: | ||
# - "1.12" | ||
# input: | ||
# selector: | ||
# - type: cloud | ||
# subtypes: | ||
# - service: iam | ||
# provider: aws | ||
package builtin.aws.iam.aws0166 | ||
|
||
import data.lib.iam | ||
import rego.v1 | ||
|
||
days_to_check = 45 | ||
|
||
deny contains res if { | ||
some user in input.aws.iam.users | ||
iam.user_is_inactive(user, days_to_check) | ||
res := result.new("User has not logged in for >45 days.", user) | ||
} | ||
|
||
deny contains res if { | ||
some user in input.aws.iam.users | ||
not iam.user_is_inactive(user, days_to_check) | ||
some key in user.accesskeys | ||
iam.key_is_unused(key, days_to_check) | ||
res := result.new(sprintf("User access key %q has not been used in >45 days", [key.accesskeyid.value]), user) | ||
} |
Oops, something went wrong.