Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,12 @@ npx is-my-node-vulnerable

It's strongly recommended to include this as a step in the app CI.

By default, the vulnerability data is cached on disk. Use `--no-cache` to avoid filesystem operations (e.g. on a read-only filesystem):

```
npx is-my-node-vulnerable --no-cache
```

> [!NOTE]
> For retro-compatibility enthusiasts: This module supports Node.js versions >= v0.12.
> However, npx does not work with those older versions, so you'll need to install the
Expand Down Expand Up @@ -96,6 +102,14 @@ import { isNodeVulnerable } from 'is-my-node-vulnerable'
await isNodeVulnerable('19.0.0', 'linux') // true
```

By default, the vulnerability data is cached on disk. To make the check work in constrained environments (e.g. read-only filesystem), set `cache: false` to avoid filesystem operations. The data is then downloaded on every call.

```js
import { isNodeVulnerable } from 'is-my-node-vulnerable'

await isNodeVulnerable('19.0.0', 'linux', { cache: false }) // true
```

[Node.js Security Database]: https://github.com/nodejs/security-wg/tree/main/vuln


Expand Down Expand Up @@ -130,3 +144,14 @@ Optionally, you can define the platform with the argument `platform` to limit th
node-version: "22.15.0"
platform: "linux"
```

To avoid filesystem operations, set `cache` to `false`:

```yml
- uses: actions/checkout@v3
- name: Check Node.js
uses: nodejs/is-my-node-vulnerable@v1
with:
node-version: "22.15.0"
cache: false
```
3 changes: 2 additions & 1 deletion action.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@ async function run () {
// Inputs
const nodeVersion = core.getInput('node-version', { required: true })
const platform = core.getInput('platform', { required: false })
const cache = core.getBooleanInput('cache', { required: false })

core.info(`Checking Node.js version ${nodeVersion} with platform ${platform}...`)
const isVulnerable = await isNodeVulnerable(nodeVersion, platform)
const isVulnerable = await isNodeVulnerable(nodeVersion, platform, { cache })
if (isVulnerable) {
core.setFailed(`Node.js version ${nodeVersion} is vulnerable. Please upgrade!`)
} else {
Expand Down
4 changes: 4 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ inputs:
platform:
description: 'Platform to check'
required: false
cache:
description: 'Cache vulnerability data on disk. Set to false to avoid filesystem operations'
required: false
default: 'true'

# https://actions-cool.github.io/github-action-branding/
branding:
Expand Down
Loading
Loading