Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

cdk-nag

Package Overview
Dependencies
Maintainers
0
Versions
1362
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cdk-nag

Check CDK v2 applications for best practices using a combination on available rule packs.

  • 2.28.148
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
139K
increased by30.2%
Maintainers
0
Weekly downloads
 
Created

What is cdk-nag?

The cdk-nag package is a tool for AWS Cloud Development Kit (CDK) that helps enforce best practices and compliance by running checks against CDK constructs. It provides a set of rules that can be applied to CDK applications to ensure they adhere to security, cost, and operational excellence guidelines.

What are cdk-nag's main functionalities?

Applying Rule Packs

This feature allows you to apply predefined rule packs, such as AWS Solutions Checks, to your CDK stacks. The code sample demonstrates how to add AWS Solutions Checks to a stack using the Aspects API.

const { AwsSolutionsChecks } = require('cdk-nag');
const { Aspects } = require('aws-cdk-lib');

const app = new cdk.App();
const stack = new cdk.Stack(app, 'MyStack');

Aspects.of(stack).add(new AwsSolutionsChecks());

Custom Rule Creation

This feature allows you to create custom rules to enforce specific compliance requirements. The code sample shows how to define a custom rule by implementing the visit method to check compliance for a specific CDK construct.

const { NagRuleCompliance, NagRuleResult } = require('cdk-nag');

class MyCustomRule {
  visit(node) {
    if (node instanceof SomeCdkConstruct) {
      // Custom logic to check compliance
      return NagRuleResult.COMPLIANT;
    }
    return NagRuleResult.NOT_APPLICABLE;
  }
}

Reporting

This feature provides the ability to generate compliance reports in various formats, such as JSON. The code sample demonstrates how to create a report for a stack and output it to a JSON file.

const { NagReportFormat, NagReport } = require('cdk-nag');

const report = new NagReport({
  format: NagReportFormat.JSON,
  outputPath: 'compliance-report.json'
});

report.generate(stack);
0

Keywords

FAQs

Package last updated on 23 Jun 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc