[K9VULN-11615] Add SecurityAudit policy attachment to agentless scanning templates#275
Open
[K9VULN-11615] Add SecurityAudit policy attachment to agentless scanning templates#275
Conversation
Enhance the existing agentless API call Lambda to ensure the SecurityAudit AWS managed policy is attached to the Datadog integration role during stack creation. This is required for agentless scanning to work, even when CSPM or Resource Collection are not explicitly enabled. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
boto3 is available in the Lambda runtime but not in CI. Move the import inside ensure_security_audit_policy so the module loads without boto3, and mock it in tests via sys.modules. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
92d77ab to
f103ee6
Compare
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
datadog_agentless_api_call.pyLambda to attach theSecurityAuditAWS managed policy to the Datadog integration role during stack creation, which is required for agentless scanningensure_security_audit_policy()function that checks if SecurityAudit is already attached (idempotent) and attaches it if missing, with graceful skip when no role name is providediam:ListAttachedRolePolicies,iam:AttachRolePolicyrestricted to SecurityAudit ARN) to the Lambda execution role in all three agentless templatesDatadogIntegrationRoleNameparameter is optional — when empty, the IAM policy resource is not created and the Lambda skips attachmentTemplates modified
datadog_agentless_scanning.yaml— IAM policy + custom resource propertiesdatadog_agentless_delegate_role.yaml— parameter + condition + IAM policy + custom resource properties + metadatadatadog_agentless_delegate_role_stackset.yaml— same as delegate roleTest plan
ensure_security_audit_policy: already-attached, not-attached, empty role name, error propagation, GovCloud partition)cfn-linton all three modified YAML templatesdatadog_agentless_scanning.yamland verify SecurityAudit is attached to integration roleDatadogIntegrationRoleName— verify graceful skipDatadogIntegrationRoleName— verify attachment🤖 Generated with Claude Code