Skip to content

Commit 32754b4

Browse files
dontiruniliapologithub-actions
authored
feat: Go support (cdklabs#992)
* feat: Go support * ci: remove ssh publishing * Update .projenrc.js Co-authored-by: Eli Polonsky <[email protected]> * chore: self mutation Signed-off-by: github-actions <[email protected]> Signed-off-by: github-actions <[email protected]> Co-authored-by: Eli Polonsky <[email protected]> Co-authored-by: github-actions <[email protected]>
1 parent 3a447be commit 32754b4

File tree

7 files changed

+117
-32
lines changed

7 files changed

+117
-32
lines changed

.github/workflows/build.yml

+25
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.github/workflows/release.yml

+33
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.mergify.yml

+2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.projen/tasks.json

+12
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.projenrc.js

+5
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,11 @@ const project = new awscdk.AwsCdkConstructLibrary({
2929
mavenArtifactId: 'cdknag',
3030
mavenEndpoint: 'https://s01.oss.sonatype.org',
3131
},
32+
publishToGo: {
33+
moduleName: 'github.com/cdklabs/cdk-nag-go',
34+
gitUserName: 'cdklabs-automation',
35+
gitUserEmail: '[email protected]',
36+
},
3237
projenUpgradeSecret: 'PROJEN_GITHUB_TOKEN',
3338
autoApproveOptions: {
3439
allowedUsernames: ['cdklabs-automation'],

README.md

+36-32
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,15 @@ SPDX-License-Identifier: Apache-2.0
99
[![npm version](https://img.shields.io/npm/v/cdk-nag)](https://www.npmjs.com/package/cdk-nag)
1010
[![Maven version](https://img.shields.io/maven-central/v/io.github.cdklabs/cdknag)](https://search.maven.org/search?q=a:cdknag)
1111
[![NuGet version](https://img.shields.io/nuget/v/Cdklabs.CdkNag)](https://www.nuget.org/packages/Cdklabs.CdkNag)
12+
[![Go version](https://img.shields.io/github/go-mod/go-version/cdklabs/cdk-nag-go?color=blue&filename=cdknag%2Fgo.mod)](https://github.com/cdklabs/cdk-nag-go)
13+
14+
[![View on Construct Hub](https://constructs.dev/badge?package=cdk-nag)](https://constructs.dev/packages/cdk-nag)
1215

1316
Check CDK applications or [CloudFormation templates](#using-on-cloudformation-templates) for best practices using a combination of available rule packs. Inspired by [cfn_nag](https://github.com/stelligent/cfn_nag).
1417

1518
Check out [this blog post](https://aws.amazon.com/blogs/devops/manage-application-security-and-compliance-with-the-aws-cloud-development-kit-and-cdk-nag/) for a guided overview!
1619

17-
![](cdk_nag.gif)
20+
![demo](cdk_nag.gif)
1821

1922
## Available Packs
2023

@@ -261,7 +264,6 @@ You would see the following error on synth/deploy
261264

262265
## Suppressing `aws-cdk-lib/pipelines` Violations
263266

264-
265267
The [aws-cdk-lib/pipelines.CodePipeline](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.pipelines.CodePipeline.html) construct and its child constructs are not guaranteed to be "Visited" by `Aspects`, as they are not added during the "Construction" phase of the [cdk lifecycle](https://docs.aws.amazon.com/cdk/v2/guide/apps.html#lifecycle). Because of this behavior, you may experience problems such as rule violations not appearing or the inability to suppress violations on these constructs.
266268

267269
You can remediate these rule violation and suppression problems by forcing the pipeline construct creation forward by calling `.buildPipeline()` on your `CodePipeline` object. Otherwise you may see errors such as:
@@ -286,44 +288,46 @@ const app = new App();
286288
new ExamplePipeline(app, 'example-cdk-pipeline');
287289
Aspects.of(app).add(new AwsSolutionsChecks({ verbose: true }));
288290
app.synth();
289-
```
290-
291-
`example-pipeline.ts`
292-
293-
```ts
291+
292+
````
293+
294+
`example-pipeline.ts`
295+
296+
```ts
294297
import { Stack, StackProps } from 'aws-cdk-lib';
295298
import { Repository } from 'aws-cdk-lib/aws-codecommit';
296299
import { CodePipeline, CodePipelineSource, ShellStep } from 'aws-cdk-lib/pipelines';
297300
import { NagSuppressions } from 'cdk-nag';
298301
import { Construct } from 'constructs';
299302
300303
export class ExamplePipeline extends Stack {
301-
constructor(scope: Construct, id: string, props?: StackProps) {
302-
super(scope, id, props);
303-
304-
const exampleSynth = new ShellStep('ExampleSynth', {
305-
commands: ['yarn build --frozen-lockfile'],
306-
input: CodePipelineSource.codeCommit(new Repository(this, 'ExampleRepo', { repositoryName: 'ExampleRepo' }), 'main'),
307-
});
308-
309-
const ExamplePipeline = new CodePipeline(this, 'ExamplePipeline', {
310-
synth: exampleSynth,
311-
});
312-
313-
// Force the pipeline construct creation forward before applying suppressions.
314-
// @See https://github.com/aws/aws-cdk/issues/18440
315-
ExamplePipeline.buildPipeline();
316-
317-
// The path suppression will error if you comment out "ExamplePipeline.buildPipeline();""
318-
NagSuppressions.addResourceSuppressionsByPath(this, '/example-cdk-pipeline/ExamplePipeline/Pipeline/ArtifactsBucket/Resource', [
319-
{
320-
id: 'AwsSolutions-S1',
321-
reason: 'Because I said so',
322-
},
323-
]);
324-
}
304+
constructor(scope: Construct, id: string, props?: StackProps) {
305+
super(scope, id, props);
306+
307+
const exampleSynth = new ShellStep('ExampleSynth', {
308+
commands: ['yarn build --frozen-lockfile'],
309+
input: CodePipelineSource.codeCommit(new Repository(this, 'ExampleRepo', { repositoryName: 'ExampleRepo' }), 'main'),
310+
});
311+
312+
const ExamplePipeline = new CodePipeline(this, 'ExamplePipeline', {
313+
synth: exampleSynth,
314+
});
315+
316+
// Force the pipeline construct creation forward before applying suppressions.
317+
// @See https://github.com/aws/aws-cdk/issues/18440
318+
ExamplePipeline.buildPipeline();
319+
320+
// The path suppression will error if you comment out "ExamplePipeline.buildPipeline();""
321+
NagSuppressions.addResourceSuppressionsByPath(this, '/example-cdk-pipeline/ExamplePipeline/Pipeline/ArtifactsBucket/Resource', [
322+
{
323+
id: 'AwsSolutions-S1',
324+
reason: 'Because I said so',
325+
},
326+
]);
325327
}
326-
```
328+
}
329+
````
330+
327331
</details>
328332
329333
## Rules and Property Overrides

package.json

+4
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)