All files / src/packs aws-prototyping.ts

100% Statements 9/9
100% Branches 1/1
100% Functions 3/3
100% Lines 9/9

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32      2x 2x   2x           2x   3x 3x           12x 3x 333x                
/*! Copyright [Amazon.com](http://amazon.com/), Inc. or its affiliates. All Rights Reserved.
SPDX-License-Identifier: Apache-2.0 */
 
import { CfnResource } from "aws-cdk-lib";
import { NagPack, NagPackProps } from "cdk-nag";
import { IConstruct } from "constructs";
import { PackName, RuleMetadata } from "./aws-prototyping-rules";
 
/**
 * Check best practices for prototypes
 *
 */
export class AwsPrototypingChecks extends NagPack {
  constructor(props?: NagPackProps) {
    super(props);
    this.packName = PackName;
  }
  /**
   * Check if CfnResource and apply rules
   */
  public visit(node: IConstruct): void {
    if (node instanceof CfnResource) {
      RuleMetadata.forEach((rule) => {
        this.applyRule({
          ...rule,
          node,
        });
      });
    }
  }
}