-
Notifications
You must be signed in to change notification settings - Fork 55
[K9VULN-15718] Add datadog_agentless_saas.yaml to attach agentless scanning permissions to the integration role #316
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
Open
k3nz0
wants to merge
6
commits into
master
Choose a base branch
from
moez.ezzeddine/agentless-delegate-role-saas
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
2425ab1
feat(aws_quickstart): add datadog_agentless_delegate_role_saas.yaml f…
k3nz0 55e46e9
refactor(aws_quickstart): attach SaaS scanning permissions as managed…
k3nz0 270a369
rename datadog_agentless_delegate_role_saas.yaml to datadog_agentless…
k3nz0 badd744
feat(aws_quickstart): forward saas_scanning_policy_arn in agentless A…
k3nz0 326a2f4
chore(aws_quickstart): bump version to v4.14.0
k3nz0 01e90de
feat(aws_quickstart): make DatadogIntegrationRoleName required in dat…
k3nz0 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,293 @@ | ||
| # version: v<VERSION_PLACEHOLDER> | ||
| AWSTemplateFormatVersion: '2010-09-09' | ||
| Description: Attaches Datadog Agentless Scanning permissions for SaaS-mode deployments to the Datadog integration role. | ||
| Parameters: | ||
| AccountId: | ||
| Type: String | ||
| Description: The current AWS account ID. This parameter is for validation purposes only, and may be left empty. | ||
| AllowedPattern: "|[0-9]{12}" | ||
| Default: "" | ||
|
|
||
| DatadogAPIKey: | ||
| Type: String | ||
| AllowedPattern: "[0-9a-f]{32}" | ||
| Description: API key for the Datadog account | ||
| NoEcho: true | ||
|
|
||
| DatadogAPPKey: | ||
| Type: String | ||
| AllowedPattern: "([0-9a-f]{40})|(ddapp_[a-zA-Z0-9]{34})" | ||
| Description: Application key for the Datadog account | ||
| NoEcho: true | ||
|
|
||
| DatadogSite: | ||
| Type: String | ||
| Description: >- | ||
| The Datadog site to use for the Datadog Agentless Scanner. | ||
| Allowed values: datadoghq.com, datadoghq.eu, us3.datadoghq.com, us5.datadoghq.com, | ||
| ap1.datadoghq.com, ap2.datadoghq.com. | ||
| Default: datadoghq.com | ||
|
|
||
| AgentlessVulnerabilityScanning: | ||
| Type: String | ||
| AllowedValues: | ||
| - true | ||
| - false | ||
| Description: Enable Agentless Vulnerability Scanning (hosts, containers, and Lambda functions). | ||
| Default: false | ||
|
|
||
| AgentlessSensitiveDataScanning: | ||
| Type: String | ||
| AllowedValues: | ||
| - true | ||
| - false | ||
| Description: Enable Agentless Scanning of datastores (S3 buckets). | ||
| Default: false | ||
|
|
||
| AgentlessComplianceHostScanning: | ||
| Type: String | ||
| AllowedValues: | ||
| - true | ||
| - false | ||
| Description: Enable Agentless Compliance Scanning for hosts. | ||
| Default: false | ||
|
|
||
| DatadogIntegrationRoleName: | ||
| Type: String | ||
| Description: >- | ||
| The name of the IAM role used by the Datadog AWS integration. In SaaS mode, Datadog assumes this | ||
| role directly to perform agentless scans. The SecurityAudit policy is also attached to this role. | ||
| AllowedPattern: '[\w+=,.@-]{1,64}' | ||
|
|
||
| Rules: | ||
| MustMatchAccountId: | ||
| AssertDescription: 'Checking that AccountId matches the current AWS account ID' | ||
| Assertions: | ||
| - Assert: !Or [!Equals [!Ref AccountId, !Ref AWS::AccountId], !Equals [!Ref AccountId, ""]] | ||
| AssertDescription: >- | ||
| The current AWS account ID does not match the AWS account selected in Datadog. | ||
| Please log in to the AWS account where you want to set up Datadog Agentless Scanning and try again. | ||
|
|
||
| Resources: | ||
| DatadogAgentlessSaaSScanningPolicy: | ||
| Type: AWS::IAM::ManagedPolicy | ||
| Properties: | ||
| Description: Policy for Datadog Agentless Scanning in SaaS mode. | ||
| Roles: | ||
| - !Ref DatadogIntegrationRoleName | ||
| PolicyDocument: | ||
| Version: '2012-10-17' | ||
| Statement: | ||
| - Action: 'ec2:CreateTags' | ||
| Effect: Allow | ||
| Resource: | ||
| - 'arn:aws:ec2:*:*:volume/*' | ||
| - 'arn:aws:ec2:*:*:snapshot/*' | ||
| - 'arn:aws:ec2:*:*:image/*' | ||
| Condition: | ||
| StringEquals: | ||
| 'ec2:CreateAction': | ||
| - CreateSnapshot | ||
| - CreateVolume | ||
| - CopySnapshot | ||
| - CopyImage | ||
| - Action: 'ec2:CreateSnapshot' | ||
| Effect: Allow | ||
| Resource: 'arn:aws:ec2:*:*:volume/*' | ||
| Condition: | ||
| StringNotEquals: | ||
| 'aws:ResourceTag/DatadogAgentlessScanner': 'false' | ||
| - Action: 'ec2:CopySnapshot' | ||
| Effect: Allow | ||
| Resource: 'arn:aws:ec2:*:*:snapshot/snap-*' | ||
| - Action: 'ec2:CopySnapshot' | ||
| Effect: Allow | ||
| Resource: 'arn:aws:ec2:*:*:snapshot/${*}' | ||
| Condition: | ||
| 'ForAllValues:StringLike': | ||
| 'aws:TagKeys': DatadogAgentlessScanner* | ||
| StringEquals: | ||
| 'aws:RequestTag/DatadogAgentlessScanner': 'true' | ||
| - Action: 'ec2:CreateSnapshot' | ||
| Effect: Allow | ||
| Resource: 'arn:aws:ec2:*:*:snapshot/*' | ||
| Condition: | ||
| 'ForAllValues:StringLike': | ||
| 'aws:TagKeys': DatadogAgentlessScanner* | ||
| StringEquals: | ||
| 'aws:RequestTag/DatadogAgentlessScanner': 'true' | ||
| - Action: 'ec2:DeleteSnapshot' | ||
| Effect: Allow | ||
| Resource: 'arn:aws:ec2:*:*:snapshot/*' | ||
| Condition: | ||
| StringEquals: | ||
| 'aws:ResourceTag/DatadogAgentlessScanner': 'true' | ||
| - Action: 'ec2:DescribeSnapshots' | ||
| Effect: Allow | ||
| Resource: '*' | ||
| - Action: 'kms:CreateGrant' | ||
| Effect: Allow | ||
| Resource: 'arn:aws:kms:*:*:key/*' | ||
| Condition: | ||
| 'ForAnyValue:StringEquals': | ||
| 'kms:EncryptionContextKeys': 'aws:ebs:id' | ||
| StringLike: | ||
| 'kms:ViaService': 'ec2.*.amazonaws.com' | ||
| Bool: | ||
| 'kms:GrantIsForAWSResource': true | ||
| - Action: 'kms:DescribeKey' | ||
| Effect: Allow | ||
| Resource: 'arn:aws:kms:*:*:key/*' | ||
| - Action: 'ec2:DeregisterImage' | ||
| Effect: Allow | ||
| Resource: 'arn:aws:ec2:*:*:image/*' | ||
| Condition: | ||
| StringEquals: | ||
| 'aws:ResourceTag/DatadogAgentlessScanner': 'true' | ||
| - Action: | ||
| - 'ebs:ListSnapshotBlocks' | ||
| - 'ebs:ListChangedBlocks' | ||
| - 'ebs:GetSnapshotBlock' | ||
| Effect: Allow | ||
| Resource: 'arn:aws:ec2:*:*:snapshot/*' | ||
| Condition: | ||
| StringEquals: | ||
| 'aws:ResourceTag/DatadogAgentlessScanner': 'true' | ||
| - Action: 'ec2:DescribeSnapshots' | ||
| Effect: Allow | ||
| Resource: '*' | ||
| - Action: 'ec2:DescribeVolumes' | ||
| Effect: Allow | ||
| Resource: '*' | ||
| - Action: 'kms:Decrypt' | ||
| Effect: Allow | ||
| Resource: 'arn:aws:kms:*:*:key/*' | ||
| Condition: | ||
| 'ForAnyValue:StringEquals': | ||
| 'kms:EncryptionContextKeys': 'aws:ebs:id' | ||
| StringLike: | ||
| 'kms:ViaService': 'ec2.*.amazonaws.com' | ||
| - Action: 'kms:DescribeKey' | ||
| Effect: Allow | ||
| Resource: 'arn:aws:kms:*:*:key/*' | ||
| - Action: 'lambda:GetFunction' | ||
| Effect: Allow | ||
| Resource: 'arn:aws:lambda:*:*:function:*' | ||
| Condition: | ||
| StringNotEquals: | ||
| 'aws:ResourceTag/DatadogAgentlessScanner': 'false' | ||
| - Action: 'lambda:GetLayerVersion' | ||
| Effect: Allow | ||
| Resource: 'arn:aws:lambda:*:*:layer:*:*' | ||
| Condition: | ||
| StringNotEquals: | ||
| 'aws:ResourceTag/DatadogAgentlessScanner': 'false' | ||
| - Action: | ||
| - "ecr:GetAuthorizationToken" | ||
| Effect: Allow | ||
| Resource: "*" | ||
| - Action: | ||
| - "ecr:GetDownloadUrlForLayer" | ||
| - "ecr:BatchGetImage" | ||
| Condition: | ||
| StringNotEquals: | ||
| "ecr:ResourceTag/DatadogAgentlessScanner": "false" | ||
| Effect: Allow | ||
| Resource: "arn:aws:ecr:*:*:repository/*" | ||
| - Action: 's3:GetObject' | ||
| Effect: Allow | ||
| Resource: 'arn:aws:s3:::*/*' | ||
| - Action: 's3:ListBucket' | ||
| Effect: Allow | ||
| Resource: 'arn:aws:s3:::*' | ||
| - Action: | ||
| - 'kms:Decrypt' | ||
| - 'kms:GenerateDataKey' | ||
| Effect: Allow | ||
| Resource: 'arn:aws:kms:*:*:key/*' | ||
| Condition: | ||
| StringLike: | ||
| 'kms:ViaService': 's3.*.amazonaws.com' | ||
|
|
||
| LambdaExecutionRoleDatadogAgentlessAPICall: | ||
| Type: AWS::IAM::Role | ||
| Properties: | ||
| AssumeRolePolicyDocument: | ||
| Version: "2012-10-17" | ||
| Statement: | ||
| - Effect: Allow | ||
| Principal: | ||
| Service: | ||
| - lambda.amazonaws.com | ||
| Action: | ||
| - sts:AssumeRole | ||
| Path: "/" | ||
| ManagedPolicyArns: | ||
| - !Sub "arn:${AWS::Partition}:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole" | ||
|
|
||
| SecurityAuditPolicyAttachmentPermissions: | ||
| Type: AWS::IAM::RolePolicy | ||
| Properties: | ||
| RoleName: !Ref LambdaExecutionRoleDatadogAgentlessAPICall | ||
| PolicyName: SecurityAuditPolicyAttachmentPermissions | ||
| PolicyDocument: | ||
| Version: '2012-10-17' | ||
| Statement: | ||
| - Effect: Allow | ||
| Action: | ||
| - iam:ListAttachedRolePolicies | ||
| Resource: !Sub "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/${DatadogIntegrationRoleName}" | ||
| - Effect: Allow | ||
| Action: | ||
| - iam:AttachRolePolicy | ||
| Resource: !Sub "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/${DatadogIntegrationRoleName}" | ||
| Condition: | ||
| ArnEquals: | ||
| 'iam:PolicyARN': | ||
| - !Sub "arn:${AWS::Partition}:iam::aws:policy/SecurityAudit" | ||
|
|
||
| DatadogAgentlessAPICall: | ||
| Type: "Custom::DatadogAgentlessAPICall" | ||
| Properties: | ||
| ServiceToken: !GetAtt "DatadogAgentlessAPICallFunction.Arn" | ||
| TemplateVersion: "<VERSION_PLACEHOLDER>" | ||
| APIKey: !Ref "DatadogAPIKey" | ||
| APPKey: !Ref "DatadogAPPKey" | ||
| DatadogSite: !Ref "DatadogSite" | ||
| AccountId: !Ref "AWS::AccountId" | ||
| VulnerabilityScanning: !Ref "AgentlessVulnerabilityScanning" | ||
| SensitiveData: !Ref "AgentlessSensitiveDataScanning" | ||
| ComplianceHost: !Ref "AgentlessComplianceHostScanning" | ||
| IntegrationRoleName: !Ref "DatadogIntegrationRoleName" | ||
| Partition: !Ref "AWS::Partition" | ||
| # Optional parameters | ||
| SaaSScanningPolicyArn: !Ref "DatadogAgentlessSaaSScanningPolicy" | ||
|
|
||
| DatadogAgentlessAPICallFunction: | ||
| Type: "AWS::Lambda::Function" | ||
| Properties: | ||
| Description: A function to call the Datadog Agentless API. | ||
| Role: !GetAtt LambdaExecutionRoleDatadogAgentlessAPICall.Arn | ||
| Handler: "index.handler" | ||
| LoggingConfig: | ||
| ApplicationLogLevel: "INFO" | ||
| LogFormat: "JSON" | ||
| Runtime: "python3.13" | ||
| Timeout: 30 | ||
| Code: | ||
| ZipFile: | | ||
| <ZIPFILE_PLACEHOLDER> | ||
|
|
||
| Metadata: | ||
| AWS::CloudFormation::Interface: | ||
| ParameterGroups: | ||
| - Label: | ||
| default: "Required" | ||
| Parameters: | ||
| - DatadogIntegrationRoleName | ||
| - Label: | ||
| default: "Advanced" | ||
| Parameters: | ||
| - AgentlessSensitiveDataScanning | ||
| - AgentlessComplianceHostScanning | ||
| - AccountId | ||
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1 @@ | ||
| v4.13.0 | ||
| v4.14.0 |
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should we keep this?