Repository navigation
feat(guardduty): add Malware Protection plans and AWS::GuardDuty::MalwareProtectionPlan - #5373
Conversation
PR Summary by QodoAdd GuardDuty Malware Protection plans and CloudFormation provisioning
AI Description
Diagram
High-Level Assessment
Files changed (16)
|
Code Review by Qodo
1.
|
…wareProtectionPlan Adds CreateMalwareProtectionPlan, GetMalwareProtectionPlan, UpdateMalwareProtectionPlan, DeleteMalwareProtectionPlan and ListMalwareProtectionPlans, and routes plan ARNs through the shared tag operations. Adds a CloudFormation provisioner for AWS::GuardDuty::MalwareProtectionPlan. Ref and Fn::GetAtt MalwareProtectionPlanId return the plan id, and Arn, CreatedAt, Status and StatusReasons are set. Role, object prefixes, the tagging action and tags update in place; a different BucketName is rejected because the update API cannot change the bucket. Management plane only: no scan runs, so a plan stays ACTIVE. Closes floci-io#4657
- Apply a plan update all-or-nothing: validate every supplied field before storing any, so a rejected request no longer changes the role. - Page ListMalwareProtectionPlans by the last returned id instead of an offset, so deleting a plan between pages neither fails nor skips, and use the documented default page size of 100. - Restore a plan on a failed CloudFormation stack update from a snapshot taken before the first change, and delete a plan an update created in place of one deleted out of band. - Clear ObjectPrefixes and Actions on a stack update that drops them. - Apply the creation tag rules to the shared tag routes. - Require the role to be an IAM role ARN. - Use explicit types instead of var.
ff2b49f to
6fac825
Compare
6fac825 to
ab4e499
Compare
pgermosen
left a comment
There was a problem hiding this comment.
@upwardsolutions-inc thanks, this is a careful one. CI is red on CfnProvisionerFixtureTest though: the new provisioner can't be reached through CfnProvisionerFixture, so the builder needs a GuardDutyService field and setter (step 7 of AGENTS.md's CloudFormation checklist). The ECS waiter failure in the same shard looks unrelated.
Two small ones in GuardDutyController: the inline java.time.Instant.parse should be an import, and the Javadoc line you rewrote still has an em-dash, which AGENTS.md rules out.
|
Code review by qodo was updated up to the latest commit ab4e499 |
CfnProvisionerFixtureTest requires every provisioner to be reachable through a public Builder setter. Add a guardDuty(...) setter that registers GuardDutyMalwareProtectionPlanCfnProvisioner.
|
@upwardsolutions-inc thanks, the fixture wiring sorts out CI. The two from last time are still open: Two more. |
- Rolling back a stack update that recreated a plan deleted out of band now restores the prior plan's Arn, CreatedAt, Status and StatusReasons, not only its id, so Fn::GetAtt no longer names the deleted replacement. The out-of-band test now changes the plan's properties: unchanged resources are skipped on update, so it never reached the create before. - Plan tag keys are checked against GuardDuty's documented TagKey pattern (^(?!aws:)[a-zA-Z+-=._:/]+$) on creation and on TagResource. - The tag routes require the supplied ARN to equal the stored plan's ARN, so a matching plan id under another account, service or partition is ResourceNotFoundException. - The /malware-protection-plan routes move behind a @PreMatching filter that rewrites only guardduty-signed requests to /_guardduty, as DlmRouteFilter does, so path-style S3 requests for a bucket of that name reach S3.
…are-protection-plan # Conflicts: # src/test/java/io/github/hectorvent/floci/services/cloudformation/CfnProvisionerFixture.java # tools/docs/cfn_resource_types.yaml
… plan route Review on floci-io#5373: GuardDutyController used an inline java.time.Instant and its Javadoc carried an em-dash, which AGENTS.md rules out. The Javadoc's routing paragraph now names /malware-protection-plan next to /detector and /admin and says GuardDutyRouteFilter keeps a same-named S3 bucket reachable. The CloudFormation and plan integration tests import List and nullValue instead of spelling them out.
|
@pgermosen thanks for the second pass. All of these should be sorted now:
While I was in there I also made the tag routes require the full plan ARN to match, and moved the plan routes behind a small pre-matching filter like |
|
@pgermosen could you (or another maintainer) re-run the failed jobs on the latest CI run when you get a chance? https://github.com/floci-io/floci/actions/runs/38336484705 Both failures look like flakes unrelated to this change:
I don't have permission to re-run jobs on this repo. Thanks! |
|
@upwardsolutions-inc thanks, the tag-key pattern, the full rollback attributes and the full-ARN match on the tag routes all look right, and the filter is a better answer to the S3 collision than documenting it. One thing: Both CI failures are unrelated: the Cognito invitation test fails on main too (its hand-built JSON breaks when the temporary password contains |
Summary
GuardDuty had detectors, members and organization configuration but no Malware Protection plan operations, and
AWS::GuardDuty::MalwareProtectionPlanwas not provisioned. WithFLOCI_SERVICES_CLOUDFORMATION_ALLOW_STUB_UNSUPPORTED_RESOURCE_TYPES=falsea stack using it rolled back; by default it reportedCREATE_COMPLETEand created nothing.CreateMalwareProtectionPlan,GetMalwareProtectionPlan,UpdateMalwareProtectionPlan(PATCH),DeleteMalwareProtectionPlanandListMalwareProtectionPlans.arn:aws:guardduty:<region>:<account>:malware-protection-plan/<id>) work with the sharedTagResource,UntagResourceandListTagsForResourceroutes.RefandFn::GetAtt MalwareProtectionPlanIdreturn the plan id;Arn,CreatedAt,StatusandStatusReasonsare set. Role, object prefixes, the tagging action and tags update in place.GuardDutyMalwareScanStatustag is written and no scan-result event is published, so a plan staysACTIVEwith no status reasons. Scan emulation can follow separately.Behaviours worth a look in review:
ConflictException(409), unless it repeats the earlier request'sclientToken, which returns the existing plan. The conflict rule is inferred from AWS allowing one plan per bucket; it is not spelled out in the API reference.UpdateMalwareProtectionPlandoes not take it). ABucketNamechange in a stack update is rejected with aValidationErrorinstead of being silently ignored.createdAtis returned as epoch seconds, as the API reference types it as a timestamp.GuardDutyServiceconstructor is kept as an overload so existing fixtures are unchanged.Closes #4657
Type of change
feat:)AWS Compatibility
Request and response shapes, the
ACTIVE | WARNING | ERRORstatus values, the 5-prefix limit and tag rules follow those pages. Not checked against a real AWS account.Checklist
docs/services/guardduty.md; the CloudFormation table is regenerated (regen_cfn_resource_types.py --strictpasses)