Skip to content

aws_iam_policy_sid #155

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

Merged
merged 3 commits into from
Aug 10, 2021
Merged

Conversation

Rihoj
Copy link
Contributor

@Rihoj Rihoj commented Aug 9, 2021

add invalid sid rules fixes #149

This should loop through all SIDs in a policy and make sure all of them fit the pattern.

return err
}
policy := unMarshaledPolicy.(map[string]interface{})
statements := policy["Statement"].([]interface{})
Copy link
Member

Choose a reason for hiding this comment

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

Casting interface{} can cause panic. In this case, it's a good idea to declare a structure for the policy and unmarshal it there.
https://gobyexample.com/json

if r.validCharacters.MatchString(statement["Sid"].(string)) == false {
runner.EmitIssueOnExpr(
r,
"The policy's sid contains invalid characters.",
Copy link
Member

Choose a reason for hiding this comment

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

The error message should clearly indicate why it is invalid. Perhaps it would be nice to include a regexp pattern.

@Rihoj
Copy link
Contributor Author

Rihoj commented Aug 9, 2021

@wata727 those should be fixed. Thank you for the feedback.

@wata727 wata727 merged commit ccdd4aa into terraform-linters:master Aug 10, 2021
@wata727
Copy link
Member

wata727 commented Aug 10, 2021

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

rule: aws_iam_policy_document - Sid string check
2 participants