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

add wafv2 permissions #136

Merged
merged 20 commits into from Mar 17, 2021
Merged

add wafv2 permissions #136

merged 20 commits into from Mar 17, 2021

Conversation

markuman
Copy link
Contributor

@markuman markuman commented Mar 1, 2021

@markuman
Copy link
Contributor Author

markuman commented Mar 1, 2021

@jillr @tremble @mattclay

azure pipline blames the policy size.

oversized_policies

Any ideas on how to split it?
And a terminator class vor every module needs also to be created?

Copy link
Collaborator

@jillr jillr left a comment

Choose a reason for hiding this comment

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

We don't need a terminator class for every module but we do need one for every resource that isn't already covered. I only took a quick look at your PRs, looks like you have webacl and ipset resources which would need classes, did I miss any?

aws/policy/security-services.yaml Outdated Show resolved Hide resolved
aws/policy/security-services.yaml Outdated Show resolved Hide resolved
@markuman
Copy link
Contributor Author

looks like you have webacl and ipset resources which would need classes, did I miss any?

@jillr yes :)

  • web_acl
  • ip_set
  • rule_group
  • disassociate_web_acl and associate_web_acl

I've added a draft for WafV2IpSetRegion. But I've no idea and I'm a bit lost. I've no idea what to do with created_time method. Furthermore do I need to duplicate everything? Because all wafv2 methods require a scope, which can be REGIONALorCLOUDFRONT`

Copy link
Contributor

@tremble tremble left a comment

Choose a reason for hiding this comment

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

Re created:
list_ip_sets doesn't return any information about creation time. The DbTerminator class records the first time it sees an object and automatically approximates the age based off of this first encounter.

Re regional vs cloudfront:
_create generates a list of objects, each class can simply run both the boto3 list actions and combine the two lists.

aws/terminator/security_services.py Outdated Show resolved Hide resolved
aws/terminator/security_services.py Outdated Show resolved Hide resolved
@jillr
Copy link
Collaborator

jillr commented Mar 15, 2021

450 passes with the policies in this latest revision but the terminator classes still fail when a resource exists.

$ python3 cleanup.py --target WafV2IpSet --target WafV2RuleGroup --target WafV2WebAcl --stage dev -vvv -c
cleanup     : DEBUG    Config path: config.yml
cleanup     : DEBUG    located WafV2IpSet: count=0
cleanup     : DEBUG    located WafV2IpSet: count=0
cleanup     : DEBUG    located WafV2RuleGroup: count=1
cleanup     : ERROR    {"message": "exception processing resource type: <class 'terminator.security_services.WafV2RuleGroup'>", "traceback": "Traceback (most recent call last):\n  File \"/home/jill/src/aws-terminator/aws/terminator/__init__.py\", line 86, in cleanup_test_account\n    instances = terminator_type.create(credentials)\n  File \"/home/jill/src/aws-terminator/aws/terminator/security_services.py\", line 312, in create\n    item.update({\"Scope\": \"REGIONAL\"})\nAttributeError: 'WafV2RuleGroup' object has no attribute 'update'"}
cleanup     : DEBUG    located WafV2WebAcl: count=1
cleanup     : ERROR    {"message": "exception processing resource type: <class 'terminator.security_services.WafV2WebAcl'>", "traceback": "Traceback (most recent call last):\n  File \"/home/jill/src/aws-terminator/aws/terminator/__init__.py\", line 86, in cleanup_test_account\n    instances = terminator_type.create(credentials)\n  File \"/home/jill/src/aws-terminator/aws/terminator/security_services.py\", line 328, in create\n    item.update({\"Scope\": \"REGIONAL\"})\nAttributeError: 'WafV2WebAcl' object has no attribute 'update'"}

@markuman markuman requested a review from jillr March 17, 2021 15:20
Copy link
Collaborator

@jillr jillr left a comment

Choose a reason for hiding this comment

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

Tested locally, including a termination (I added a 2 minute age limit and used the tests in 450). Everything looks good to me now, thanks very much for this one @markuman!

Will deploy after merge.

@jillr jillr merged commit 560bb60 into mattclay:master Mar 17, 2021
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

3 participants