npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

secure-cdk

v0.1.11

Published

Security abstraction for AWS CDK library. Create AWS resources with best security practices applied for you.

Downloads

33

Readme

Security abstraction for AWS CDK library. Create AWS resources with best security practices applied for you.

npm version npm

Description

The purpose of this package is to enforce best security practices for AWS services. It uses AWS CDK under the hood to create resources and won't work without it.

You may find that some of the rules are too strict for your use cases, but you always have a possibility of explicitly overriding them. If you do that, you will get a warning that will remind you about the security violations.

Installation

npm i secure-cdk --save-dev

or

yarn add secure-cdk -D

Usage

S3 Bucket

By using SecureBucket class instead of the AWS's Bucket construct, you are getting the following properties set by default.

| Property | Value | Description | AWS CDK Default | | --- | --- | --- | --- | | enforceSSL | true | Enforces SSL for requests. | false | | publicReadAccess | false | Grants public read access to all objects in the bucket. | false | | encryption | Encrypted (S3 managed) | The kind of server-side encryption to apply to this bucket. | Unencrypted |

import { SecureBucket } from 'secure-cdk';

const mySiteBucket = new SecureBucket(this, 'my-bucket', {
  bucketName: 'my-bucket-name',
  websiteIndexDocument: 'index.html'
});

CloudFront Distribution

Security wrapper for Distribution construct.

| Property | Value | Description | AWS CDK Default | | --- | --- | --- | --- | | minimumProtocolVersion | TLS_V1_2_2021 | The minimum version of the SSL protocol that you want CloudFront to use for HTTPS connections. | TLS_V1_2_2021 |

createSecureBehavior is a function used to create preconfigured behaviors for CloudFront distributions.

| Property | Value | Description | AWS CDK Default | | --- | --- | --- | --- | | viewerProtocolPolicy | HTTPS_ONLY | The protocol that viewers can use to access the files controlled by this behavior. | ALLOW_ALL |

import { createSecureBehavior, SecureDistribution } from 'secure-cdk';

const distribution = new SecureDistribution(this, 'my-distribution', {
  defaultBehavior: createSecureBehavior({
    origin: new S3Origin(mySiteBucket)
  })
});

IAM Role (PolicyStatement)

Security wrapper for PolicyStatement construct. Does not set default properties, however warns when:

  • * passed in actions property;
  • <resource>:* passed in actions property;
  • * passed in resources property;
  • .addResources called with *;
  • .addActions called with * or <resource>:*;
import { Effect } from '@aws-cdk/aws-iam';
import { SecurePolicyStatement } from 'secure-cdk';

const policyStatement = new SecurePolicyStatement(this, 'my-policy-statement', {
  actions: ['cloudfront:*'],
  resources: ['*'],
  effect: Effect.ALLOW
});
// or
policyStatement.addActions('*');
policyStatement.addResources('*');

TODO

  • [ ] Alternative automatic checker (extensions of a Stack);
  • [ ] Centralized warning system to awoid warning duplication;
  • [ ] Inclusion of resource identifier in warning;