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

feat(codepipeline-actions): support InspectorEcrImageScanAction and InspectorSourceCodeScanAction actions #33378

Open
wants to merge 24 commits into
base: main
Choose a base branch
from

Conversation

go-to-k
Copy link
Contributor

@go-to-k go-to-k commented Feb 11, 2025

Issue # (if applicable)

Closes #33377.

Reason for this change

AWS CodePipeline introduces new build action: InspectorScan action.

Description of changes

Add InspectorEcrImageScanAction and InspectorSourceCodeScanAction classes that extends BaseInspectorScan class.

The BaseInspectorScan class that extends Action class to aws-codepipeline-actions module.

Describe any new or updated permissions being added

Description of how you validated changes

Both unit and integ tests

Checklist


By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license

@aws-cdk-automation aws-cdk-automation requested a review from a team February 11, 2025 08:00
@github-actions github-actions bot added feature-request A feature should be added or improved. p2 distinguished-contributor [Pilot] contributed 50+ PRs to the CDK labels Feb 11, 2025
Copy link
Collaborator

@aws-cdk-automation aws-cdk-automation left a comment

Choose a reason for hiding this comment

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

(This review is outdated)

Copy link

codecov bot commented Feb 11, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 81.00%. Comparing base (c400e0e) to head (779d8e3).
Report is 47 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #33378      +/-   ##
==========================================
+ Coverage   80.92%   81.00%   +0.07%     
==========================================
  Files         236      238       +2     
  Lines       14256    14271      +15     
  Branches     2491     2492       +1     
==========================================
+ Hits        11537    11560      +23     
+ Misses       2434     2425       -9     
- Partials      285      286       +1     
Flag Coverage Δ
suite.unit 81.00% <ø> (+0.07%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Components Coverage Δ
packages/aws-cdk 79.92% <ø> (+0.18%) ⬆️
packages/aws-cdk-lib/core 82.16% <ø> (-0.05%) ⬇️

@go-to-k go-to-k changed the title feat(codepipeline-actions): support InspectorScan invoke action feat(codepipeline-actions): support InspectorScan action Feb 11, 2025
@go-to-k go-to-k changed the title feat(codepipeline-actions): support InspectorScan action feat(codepipeline-actions): support EcrImageScanAction and SourceCodeScanAction action Feb 11, 2025
@go-to-k go-to-k changed the title feat(codepipeline-actions): support EcrImageScanAction and SourceCodeScanAction action feat(codepipeline-actions): support EcrImageScanAction and SourceCodeScanAction actions Feb 11, 2025
@go-to-k go-to-k changed the title feat(codepipeline-actions): support EcrImageScanAction and SourceCodeScanAction actions feat(codepipeline-actions): support InspectorEcrImageScanAction and InspectorSourceCodeScanAction actions Feb 11, 2025
@github-actions github-actions bot added the effort/medium Medium work item – several days of effort label Feb 14, 2025
Comment on lines +97 to +107
test('can get variables', () => {
// WHEN
const inspectorEcrImageScanAction = new cpactions.InspectorEcrImageScanAction({
actionName: 'InspectorScan',
output: scanOutput,
repository,
});

// THEN
expect(inspectorEcrImageScanAction.variables.highestScannedSeverity).toMatch(/^#{\${Token\[TOKEN\.[0-9]*\]}.HighestScannedSeverity}$/);
});
Copy link
Contributor Author

@go-to-k go-to-k Feb 14, 2025

Choose a reason for hiding this comment

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

This and other common code are about the common behavior of the base class.

But as users are not aware of the base class because they call the subclasses directly, and in case there are any changes by contributors, it is also confirmation for regressions in the subclasses. Therefore, the tests in inspector-ecr-image-scan-action.test.ts and inspector-source-code-scan-action.test.ts are partially identical.
This also makes the test useful even if the base class is deleted and each class is implemented independently in the future.

@go-to-k go-to-k marked this pull request as ready for review February 14, 2025 14:35
@aws-cdk-automation aws-cdk-automation dismissed their stale review February 14, 2025 14:37

✅ Updated pull request passes all PRLinter validations. Dismissing previous PRLinter review.

Copy link
Collaborator

@aws-cdk-automation aws-cdk-automation left a comment

Choose a reason for hiding this comment

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

(This review is outdated)

@aws-cdk-automation aws-cdk-automation dismissed their stale review February 14, 2025 15:09

✅ Updated pull request passes all PRLinter validations. Dismissing previous PRLinter review.

Copy link
Collaborator

@aws-cdk-automation aws-cdk-automation left a comment

Choose a reason for hiding this comment

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

(This review is outdated)

@go-to-k
Copy link
Contributor Author

go-to-k commented Feb 14, 2025

Exemption Request:

❌ CodeCov is indicating a drop in code coverage

Should already have written unit tests that cover the code I have added.

@aws-cdk-automation aws-cdk-automation added the pr-linter/exemption-requested The contributor has requested an exemption to the PR Linter feedback. label Feb 14, 2025
@aws-cdk-automation aws-cdk-automation dismissed their stale review February 14, 2025 15:46

✅ Updated pull request passes all PRLinter validations. Dismissing previous PRLinter review.

Copy link
Collaborator

@aws-cdk-automation aws-cdk-automation left a comment

Choose a reason for hiding this comment

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

The pull request linter fails with the following errors:

❌ CodeCov is indicating a drop in code coverage

If you believe this pull request should receive an exemption, please comment and provide a justification. A comment requesting an exemption should contain the text Exemption Request. Additionally, if clarification is needed, add Clarification Request to a comment.

✅ A exemption request has been requested. Please wait for a maintainer's review.

@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: AutoBuildv2Project1C6BFA3F-wQm2hXv2jqQv
  • Commit ID: 779d8e3
  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@aws-cdk-automation aws-cdk-automation added the pr/needs-community-review This PR needs a review from a Trusted Community Member or Core Team Member. label Feb 14, 2025
Comment on lines +14 to +16
* Valid values are medium | high | critical.
*/
readonly highestScannedSeverity: string;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is not input to the construct, but output from the pipeline, which is a string formatted with the variableExpression method. Therefore, it cannot be an enum.

Comment on lines +57 to +63
// This permission was not listed in the above reference, but without it,
// an error would occur since `ecr get-login-password` is executed in the action.
options.role.addToPrincipalPolicy(new iam.PolicyStatement({
resources: ['*'],
actions: [
'ecr:GetAuthorizationToken',
],
Copy link
Contributor Author

@go-to-k go-to-k Feb 17, 2025

Choose a reason for hiding this comment

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

The error message by CFn requested a wildcard for resources.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
distinguished-contributor [Pilot] contributed 50+ PRs to the CDK effort/medium Medium work item – several days of effort feature-request A feature should be added or improved. p2 pr/needs-community-review This PR needs a review from a Trusted Community Member or Core Team Member. pr-linter/exemption-requested The contributor has requested an exemption to the PR Linter feedback.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

codepipeline-actions: support InspectorScan action
2 participants