-
Notifications
You must be signed in to change notification settings - Fork 69
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: rules are exported #482
Comments
From what I understand you would like to
Is that correct? The drawback with this approach is that unless you build your own package, it would be difficult to scale this across multiple applications without re-implementing the rule additions on each application (though it could be as simple as a copy and paste of the class) That being said, it could be a good opportunity to move the rule creation helper methods to a package with the rules. |
Yes that is correct. I found another variant to achieve something similar: |
Related to #482 Examples for rule imports ```typescript import { apigw } from 'cdk-nag/lib/rules' import { rules } from 'cdk-nag'; rules.apigw.APIGWAccessLogging apigw.APIGWAccessLogging ``` Example for creating a NagPack with an included rule ```typescript import { Stack, App, StackProps, IConstruct, CfnResource, Aspects } from '@aws-cdk/core'; import { Vpc } from '@aws-cdk/aws-ec2'; import { NagMessageLevel, NagPack, NagPackProps, rules } from 'cdk-nag'; class TestPack extends NagPack { constructor(props?: NagPackProps) { super(props); this.packName = 'Test'; } public visit(node: IConstruct): void { if (node instanceof CfnResource) { this.applyRule({ info: 'My brief info.', explanation: 'My detailed explanation.', level: NagMessageLevel.ERROR, rule: rules.vpc.VPCDefaultSecurityGroupClosed, node: node, }); } } } export class CdkTestStack extends Stack { constructor(scope: App, id: string, props?: StackProps) { super(scope, id, props); Aspects.of(this).add(new TestPack()) new Vpc(this, 'rVpc') } } ``` ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
Description
We have a custom set of requirements, but many of the already implemented rules are already super helpful.
Sadly the rules are not exported, so one would have to either copy them or implement them on your own.
Use Case
We have a custom set of rules that apply within our company. So we want to build a custom internal rule pack, combined of custom rules and already existing ones.
Proposed Solution
Export the rules, or make them available in a separate package.
Other information
Currently using the newly release v2 compatible version
Acknowledge
The text was updated successfully, but these errors were encountered: