Introducing The Sweep: OX’s New Live Security Research Series
Register Now
Breaking: The 2026 Vulnpocalypse Hits PHP: Four Critical RCEs, but How Dangerous Are They?
Read the Report
Are you exposed? Connect your apps in minutes.
Scan your apps free

mocha-aws-secrets-manager

Latest version: v1.0.2

Overview

Last scanned
30 Nov 2026
Published
30 Nov 2026
npm package Publisher: alec-js
2 Stars
0 Forks
4 Versions
Shell Repo language

Scan summary

mocha-aws-secrets-manager was last scanned on 30 Nov 2026 at version 1.0.2. Risk score 0 of 100. No malicious behavior was detected.

  • Releases: 4 versions, all published on 30 Nov 2026.
  • Findings: No rules fired in version 1.0.2.

Versions

4 versions published
Versions and the rules that fired in each
VersionPublishedStatus
1.0.2 LATEST 30 Nov 2026 No rules fired
1.0.1 30 Nov 2026 No rules fired
1.0.0 30 Nov 2026 No rules fired
0.0.0-stage 30 Nov 2026 Not shown

No rules fired in 1.0.2

Findings

Findings for v1.0.2. The score is a capped sum of the weights of the rules that fired — not CVSS, not exploitability, and not a probability. It is not comparable across packages with different scan coverage.

The score describes 1.0.2; other versions have their own rules, not their own score.

README

The publisher’s own README, as collected from the registry.

Handle AWS Secrets easily with Mocha

Load your test secrets from AWS Secrets Manager into process.env, before Mocha loads your test files. Log in to AWS once a day, then run Mocha as usual: each run reads the latest version of the secret. No file on disk holds the secrets, and nobody needs to see them.

The same secret also works with Cypress and Playwright. Every package uses the same engine, aws-secrets-manager-core.

Table of Contents

  • How it works
  • Installation
  • Quick start
  • Read the secrets in your tests
  • Configuration
    • Options
    • Where the options come from
    • Login strategies
    • Credentials file
  • Log in to AWS
  • Where to put the register
  • Parallel mode and child processes
  • How the secret reaches process.env
  • Update a secret
  • Work offline with a local copy
  • Running on CI
  • Load the secret from your own code
  • What you see
  • Security notes

How it works

  1. You log in to AWS once a day: aws sso login --profile my-sso-profile. The session stays on your machine, and every terminal uses it.
  2. You run Mocha as usual. One line at the top of .mocharc.js reads the latest version of the secret, before Mocha loads a test file, and puts each key in process.env.
  3. Your tests read process.env.MY_KEY, also at the top level of a file. The logs print the key names, never a value.

Installation

npm install --save-dev mocha-aws-secrets-manager

You need:

  • Mocha 10 or later.
  • Node 22 or later. Mocha 12 itself needs Node 22.12 or later.
  • AWS credentials: an AWS SSO profile, which aws configure sso of the AWS CLI v2 creates, or one of the other login strategies.
  • A secret of the "key/value" type: a JSON object of key/value pairs. The package refuses a plaintext or binary secret, and never prints its value.

CI runs the end-to-end test on Mocha 12. Before the 1.0.0 release, it also passed on Mocha 10.0.0 and 11.8.0.

Quick start

1. Describe the secret. Create aws-secrets.config.js at the root of your project:

// aws-secrets.config.js
module.exports = {
  secretName: 'my-team/e2e', // the name or the full ARN
  region: 'eu-west-1',
  profile: 'my-sso-profile'
}

2. Load it. Put this line at the top of .mocharc.js:

// .mocharc.js
require('mocha-aws-secrets-manager/register')

module.exports = {
  // your Mocha options
}

In a package with "type": "module", a .js file is an ES module, which has no require. There, name the file .mocharc.cjs, or pass the register on the command line: mocha --require mocha-aws-secrets-manager/register.

3. Log in to AWS:

aws sso login --profile my-sso-profile

4. Run Mocha as usual: npx mocha.

Read the secrets in your tests

Each key of the secret is in process.env, as text:

// test/api.spec.js
const assert = require('node:assert')

const apiKey = process.env.API_KEY // the top level of a file works too

describe('the API', function () {
  it('answers with the key', async function () {
    const response = await fetch('https://api.example.com/me', { headers: { 'x-api-key': apiKey } })
    assert.equal(response.status, 200)
  })
})

getSecrets() returns the secret with its original types: a number stays a number, an object stays an object.

const { getSecrets } = require('mocha-aws-secrets-manager')

it('reads the limits', function () {
  const { apiKey, limits } = getSecrets()
})

getSecrets() reads the memory of the process that loaded the secret, else the AWS_SECRETS_JSON variable that it inherited. It throws when the register did not run.

Configuration

Options
Option Required Default Meaning
secretName Yes The secret name, or its full ARN.
region Yes The AWS region of the secret.
strategy No multi How to get AWS credentials. See Login strategies.
profile No The AWS SSO profile of the profile strategy.
pathToCredentials No The file of the credentials strategy. See Credentials file.
kmsKeyId No The KMS key that updateSecret sends with the new value. Needed for a secret of another AWS account.
localDir No The folder of the local copy. See Work offline with a local copy.
baseDir No process.cwd() Where the search for the configuration file starts.
silent No false Hides the progress lines. The status line, the warnings and the errors still print.
logger No stderr An object with info, warn and error that gets the progress and status lines. With the register, set it in the configuration file: the warnings about skipped keys still go to stderr.
override No false Replaces a variable that already holds another value. See How the secret reaches process.env.
allowUnsafeKeys No [] The keys that make programs run code, to put in process.env all the same, such as ['NODE_OPTIONS'].
Where the options come from

Three sources. A later source wins over an earlier one:

  1. The configuration file: aws-secrets.config.js, aws-secrets.config.cjs, aws-secrets.config.mjs or aws-secrets.config.json.
  2. The options in your code, when you load the secret from your own code.
  3. The environment variables, so CI can change a value on the command line:
Variable Option
AWS_SECRETS_NAME secretName
AWS_SECRETS_REGION region
AWS_SECRETS_PROFILE profile
AWS_SSO_STRATEGY strategy
AWS_SECRETS_LOCAL_DIR localDir
ENV_LOG_MODE=silent silent: true

For example: AWS_SSO_STRATEGY=unset npx mocha.

About the configuration file:

  • Put it in the folder where you run Mocha, or in a parent folder up to the root of the repository, the folder with .git. Outside a repository, the search stops at the nearest folder with package.json. The nearest folder wins. In one folder, the first file in the order above wins.
  • A .js, .cjs or .mjs file exports the options, or a function, sync or async, that returns them.
  • A relative localDir or pathToCredentials starts from the folder of the file.
  • All the options can go in the file:
// aws-secrets.config.js
module.exports = {
  secretName: 'my-team/e2e', // required
  region: 'eu-west-1', // required
  strategy: 'multi', // profile | default | unset | credentials | multi
  profile: 'my-sso-profile',
  pathToCredentials: 'aws-credentials.json',
  localDir: '.secrets',
  silent: false,
  override: false,
  allowUnsafeKeys: []
}

A missing secretName or region, or an unknown strategy, stops the run with an error that names the key and where to set it. A blank string counts as missing:

"secretName" is missing. Set it in one of: aws-secrets.config.js, aws-secrets.config.cjs, aws-secrets.config.mjs, aws-secrets.config.json in the base folder or a parent folder; the options passed to loadSecrets(); the environment variable AWS_SECRETS_NAME.
Login strategies
Strategy Where the credentials come from
profile The AWS SSO profile in profile.
default The AWS SSO profile named default.
unset The default credential chain of the AWS SDK: the profile in AWS_PROFILE when it is set, else the AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY and AWS_SESSION_TOKEN variables, then the shared AWS files, then a container or instance role. It reads every profile type. Use it on CI.
credentials The file in pathToCredentials.
multi (default) Tries profile, default, unset, then credentials, and stops at the first that works. When all fail, the error gives the reason of each one.
  • profile and default read AWS SSO profiles only. For a profile with keys, a role or a credential_process, use unset and set AWS_PROFILE to the profile name.
  • multi moves on after any error, also when the login works and the secret does not exist. A later attempt can then read the secret with other credentials. Set the strategy to see the AWS error of one login.
Credentials file

The credentials strategy reads a JSON or JavaScript file:

{
  "accessKeyId": "AKIA...",
  "secretAccessKey": "...",
  "sessionToken": "..."
}
  • sessionToken is needed for temporary credentials only. A long-term IAM user key has none.
  • A .js or .cjs file exports the object with module.exports, an .mjs file with export default.
  • The package reads the file again at each run, so it sees changed credentials.
  • Keep the file outside your repository, or add it to .gitignore.

Log in to AWS

The package never logs you in. It uses the login that the AWS CLI keeps.

Once a day with AWS SSO
aws configure sso                          # one time: creates the profile
aws sso login --profile my-sso-profile     # once a day
  • The session lasts as long as your AWS administrator set: 8 hours by default.
  • The AWS CLI keeps it in ~/.aws/sso/cache, so one login serves every terminal and every runner on the machine: Mocha, Playwright, Cypress and the AWS CLI.
  • When the session ends, the run stops. The first line of the error says so and gives the command to copy: aws sso login --profile my-sso-profile.
Or let a script log you in

aws-secrets-manager-core, which this package installs, ships two login scripts. Each one logs you in only when needed, then runs your command:

Method Copy this file What it runs
AWS SSO node_modules/aws-secrets-manager-core/sh/sso/aws_authenticate.sh aws_sso.sh: logs you in when your SSO session has ended.
Assume role node_modules/aws-secrets-manager-core/sh/assume_role/aws_authenticate.sh aws_assume_role.sh: assumes the role of the environment, and logs you in when needed.
  1. Copy the file into your project once:

    cp node_modules/aws-secrets-manager-core/sh/sso/aws_authenticate.sh .

    With pnpm, run pnpm add -D aws-secrets-manager-core first: pnpm puts only your direct dependencies at the top of node_modules.

  2. Fill in your settings in the copy, AWS_PROFILE_<ENV> and ACCOUNT_ID_<ENV> for each environment, and commit it.

  3. Start Mocha through it:

    {
      "scripts": {
        "test": "bash aws_authenticate.sh test \"npx mocha\""
      }
    }

The first argument names the environment: test picks AWS_PROFILE_TEST and ACCOUNT_ID_TEST. Use letters, digits and _ only. The second argument is the command, as one argument. The script splits it on spaces and runs the words without a shell: quotes inside the command, && and VAR=value do not work, and a * expands to the names of the files in the current folder. Put such a command in an npm script, and pass "npm run <script>".

  • Your copy holds only your settings. It runs the login script of the installed package, so npm update brings its fixes. Nothing is downloaded at run time.
  • Read the scripts before the first run, because they run with your AWS credentials.
  • sh aws_authenticate.sh works too: the copy starts again with bash.
  • On Windows, keep LF line ends with this line in your .gitattributes: *.sh text eol=lf.

The core README gives all the details: the assume-role settings, the tools that the scripts install, and WSL.

Where to put the register

The register loads the secret synchronously: the next line of .mocharc.js, every --require module and every test file can read process.env.MY_KEY, also at the top level of a file or in a describe body.

Put it first, and before dotenv:

// .mocharc.js
require('mocha-aws-secrets-manager/register')
require('dotenv').config() // optional, and after the register

module.exports = {
  // your Mocha options
}

OX Radar and Response Center

Find threats in your stack.

OX Radar can check high-priority threats, like critical package CVEs, against your context.

Each incident is marked Detected or Not Detected with a remediation plan and proof all tracked in the Response Center.

Where it’s listed

The probe returned only these fields for this server — auth requirement, protocol and tool list weren’t observed, so they’re not shown (never guessed).

  • npm mocha-aws-secrets-manager

References

The publisher’s own links, as the registry reports them. These are not sources for the assessment on this page.

Powered by Read the latest findings

Scan your whole stack

Group 1261154050 1
Group 1261154050
 

From OX Research Newsroom

Copy of Template Design OX Blog (1)
Research

Thousands Of GitHub Accounts Hijacked With wfx-loot CI Secret Stealing Malware Via GitHub Actions & npm

The 2026 Vulnpocalypse Hits PHP: Four Critical RCEs, but How Dangerous Are They?
Vulnerability Insights

The 2026 Vulnpocalypse Hits PHP: Four Critical RCEs, but How Dangerous Are They?

Cry2Wolf: How to Tell a Real Bug from a Nothingburger
AI & VibeSec

Cry2Wolf: Not Every Branded Bug Deserves a Fire Drill

Frame 2085668439 (1)
Group 1261154229