4.0.0-alpha.42 • Published 1 year ago

dotsec v4.0.0-alpha.42

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

dotsec

The solution offers encryption and decryption of .env files to and from .sec files, the ability to run a command with the values of a .env/.sec file in its environment. The AWS plugin adds the ability to push selected .env/.sec entries to AWS Systems Manager Parameter Store and AWS Secrets Manager.

Currently there are two methods of encryption supported:

Why?

Environment variables are a great way to configure your application. However, they shouldn't be committed to your repository. This is because they often contain sensitive information, like passwords, API keys, and other secrets. This is where dotsec comes in. It allows you to encrypt your environment variables, and store them in a .sec file, which can be committed to your repository.

Features

  • Encryption of .env files to .sec files.
  • Decryption of .sec files to .env files.
  • Run a command with the values of a .env file in its environment.
  • Run a command with the values of a .sec file in its environment.
  • Push selected .env/.sec entries to AWS Systems Manager Parameter Store.
  • Push selected .env/.sec entries to AWS Secrets Manager.
  • Holds no opinion on how you should manage your organization's user roles and permissions, you know best.

AWS plugin

  • Supported KMS key types: symmetric and assymetric:
    • SYMMETRIC_DEFAULT
    • RSA_2048
      • RSAES_OAEP_SHA_256
    • RSA_3072
      • RSAES_OAEP_SHA_256
    • RSA_4096
      • RSAES_OAEP_SHA_256
    • SM2PKE

Requirements

  • For initialisation enough credentials for creating a KMS key, and alias.
  • For usage enough credentials for using the KMS key to encrypt and/or decrypt.
  • An AWS KMS key with an alias.

Installation

npm install --save-dev dotsec @dotsec/plugin-aws

Add the folowing to dotsec.config.ts:

import { DotsecPluginAws } from "@dotsec/plugin-aws";
import { DotsecConfig } from "dotsec";

export const dotsec: DotsecConfig<{ plugins: DotsecPluginAws }> = {
  defaults: {
    encryptionEngine: "aws",
  },
};

Usage

If you don't have a .env file, create one:

I_CAN_SEE="clearly now"
SINGING="in the rain"
I_BLESS_THE_RAINS="down in Africa"

Execute a command and use the values of a .env file in its environment

npx dotsec run --with-env node -e "console.log(process.env.I_BLESS_THE_RAINS)"

Encrypt a .env file to .sec

npx dotsec encrypt

Execute a command and use the values of a .sec file in its environment

npx dotsec run --with-sec node -e "console.log(process.env.I_BLESS_THE_RAINS)"

Decrypt a .sec file to .env

npx dotsec decrypt

Push selected .env entries to AWS Systems Manager Parameter Store

Edit the dotsec.config.ts file. Add the following to the aws object:

{
    ...
    variables: {
        "I_BLESS_THE_RAINS": {
            push: {
                aws: {
                    ssm: true
                }
            }
        }
    }
}

Run the following command:

npx dotsec push

You might want to set AWS_REGION before running the command. If you don't, the region will be set to eu-west-1.

FAQ

Is it safe to commit a .sec and dotsec.config.ts file alongside your code?

Yes it is. But it is up to you to make sure that access to the KMS key is restricted to the people who need to decrypt and/or encrypt the .sec file.

Should I use this in production?

We do, however, since this package is relatively new, I don't think you should.

Roadmap

  • Write some tests already.
  • Add support in-code use like dotsec.config()
  • Add support for Node preload modules like node -r dotsec/register index.js
  • Add watcher for .env file changes and automatically encrypt
  • Write guide on postinstall for npm/yarn/pnpm
  • Add chunking for encoding larger files with assymetric keys. Current limit is 4kb.
  • Add support for other encryption SDKs like GCP KMS, Azure Key Vault, etc.
  • Split up dotsec package in multiple packages, one for each encryption SDK.
  • Add support for pulling entries to GitHub actions secrets.

Limitations

  • The only supported encryption SDK is the AWS Encryption SDK. For now.
  • Assymetric keys are supported, but the encrypted file size is limited to the payload size of the key. Until chunking is implemented, that is.
  • AWS Secrets Manager secrets which are marked for deletion cannot be updated until the deletion is complete. As of writing, the minimum deletion time is 7 days. This means that if you want to update a deleted AWS Secrets Manager secret, you have to wait at least 7 days before you can update it again. This is a limitation of AWS Secrets Manager, not dotsec
4.0.0-alpha.39

1 year ago

4.0.0-alpha.38

1 year ago

4.0.0-alpha.37

1 year ago

4.0.0-alpha.36

1 year ago

4.0.0-alpha.31

1 year ago

4.0.0-alpha.30

1 year ago

4.0.0-alpha.35

1 year ago

4.0.0-alpha.34

1 year ago

4.0.0-alpha.33

1 year ago

4.0.0-alpha.32

1 year ago

4.0.0-alpha.28

1 year ago

4.0.0-alpha.27

1 year ago

4.0.0-alpha.29

1 year ago

4.0.0-alpha.23

1 year ago

4.0.0-alpha.42

1 year ago

4.0.0-alpha.41

1 year ago

4.0.0-alpha.40

1 year ago

4.0.0-alpha.21

1 year ago

4.0.0-alpha.17

2 years ago

4.0.0-alpha.15

2 years ago

4.0.0-alpha.19

2 years ago

4.0.0-alpha.9

2 years ago

4.0.0-alpha.7

2 years ago

4.0.0-alpha.8

2 years ago

4.0.0-alpha.5

2 years ago

4.0.0-alpha.6

2 years ago

4.0.0-alpha.3

2 years ago

4.0.0-alpha.4

2 years ago

4.0.0-alpha.1

2 years ago

4.0.0-alpha.2

2 years ago

4.0.0-alpha.0

2 years ago

2.0.0-alpha.0

2 years ago

2.0.0-alpha.1

2 years ago

1.0.0-alpha.19

2 years ago

1.0.0-alpha.16

2 years ago

1.0.0-alpha.15

2 years ago

1.0.0-alpha.18

2 years ago

1.0.0-alpha.17

2 years ago

1.0.0-alpha.12

2 years ago

1.0.0-alpha.11

2 years ago

1.0.0-alpha.14

2 years ago

1.0.0-alpha.13

2 years ago

1.0.0-alpha.21

2 years ago

1.0.0-alpha.20

2 years ago

1.0.0-alpha.27

2 years ago

1.0.0-alpha.26

2 years ago

1.0.0-alpha.29

2 years ago

1.0.0-alpha.28

2 years ago

1.0.0-alpha.23

2 years ago

1.0.0-alpha.22

2 years ago

1.0.0-alpha.25

2 years ago

1.0.0-alpha.24

2 years ago

1.0.0-alpha.30

2 years ago

1.0.0-alpha.32

2 years ago

1.0.0-alpha.31

2 years ago

1.0.0-alpha.38

2 years ago

1.0.0-alpha.37

2 years ago

1.0.0-alpha.39

2 years ago

1.0.0-alpha.34

2 years ago

1.0.0-alpha.33

2 years ago

1.0.0-alpha.36

2 years ago

1.0.0-alpha.35

2 years ago

1.0.0-alpha.41

2 years ago

1.0.0-alpha.40

2 years ago

1.0.0-alpha.43

2 years ago

1.0.0-alpha.42

2 years ago

1.0.0-alpha.44

2 years ago

1.0.0-alpha.9

2 years ago

1.0.0-alpha.8

2 years ago

1.0.0-alpha.7

2 years ago

1.0.0-alpha.6

2 years ago

1.0.0-alpha.10

2 years ago

3.0.0-alpha.1

2 years ago

1.0.0-alpha.5

2 years ago

3.0.0-alpha.0

2 years ago

1.0.0-alpha.4

2 years ago

1.0.0-alpha.3

2 years ago

3.0.0-alpha.2

2 years ago

1.0.0-alpha.2

2 years ago

1.0.0-alpha.1

2 years ago

1.0.0-alpha.0

2 years ago

0.10.1-alpha.0

2 years ago

0.10.1-alpha.2

2 years ago

0.10.1-alpha.1

2 years ago

0.10.1-alpha.3

2 years ago

0.10.0

3 years ago

0.9.0

3 years ago

0.8.0

3 years ago

0.5.0

3 years ago

0.4.0

3 years ago

0.7.0

3 years ago

0.6.0

3 years ago

0.3.0

3 years ago

0.2.0

3 years ago

0.1.1

3 years ago