An open API service indexing awesome lists of open source software.

https://github.com/nashaddams/audit

Audit JSR, deno.land, NPM, and ESM packges with Deno
https://github.com/nashaddams/audit

audit auditing deno esm jsr npm

Last synced: 28 days ago
JSON representation

Audit JSR, deno.land, NPM, and ESM packges with Deno

Awesome Lists containing this project

README

        

# audit

[![JSR](https://jsr.io/badges/@nashaddams/audit)](https://jsr.io/@nashaddams/audit)
[![JSR score](https://jsr.io/badges/@nashaddams/audit/score)](https://jsr.io/@nashaddams/audit)
[![main](https://github.com/nashaddams/audit/actions/workflows/tests.yml/badge.svg)](https://github.com/nashaddams/audit/actions)

A tool for auditing [JSR](https://jsr.io), [deno.land](https://deno.land/x),
[NPM](https://www.npmjs.com), and [ESM](https://esm.sh) packages with
[Deno](https://deno.com) utilizing the
[GitHub Advisory Database](https://github.com/advisories).

## Workflow

- Extract the packages from a given lock file
- Resolve the corresponding GitHub repositories
- JSR via `api.jsr.io`
- deno.land via `cdn.deno.land`
- NPM & ESM via `registry.npmjs.org`
- Fetch published vulnerabilities via `api.github.io`
- Create a report

## Usage

### Via `deno run`

```sh
deno run -A jsr:@nashaddams/audit [--help]
```

Running this command will print the audit results to the console, create a
report in the output directory, and return an exit code indicating if
vulnerabilities have been found and matched (`1`) or not (`0`).

### Via `import`

Alternatively, `audit` can also be imported and used as a library function:

```ts
import { audit, runAudit } from "@nashaddams/audit";

audit(options?: AuditOptions);
runAudit(); // CLI wrapper for `audit`
```

See [the docs](https://jsr.io/@nashaddams/audit/doc) for further details.

### HTML report

The `report` subcommand serves the generated audit report:

```sh
deno run -A jsr:@nashaddams/audit report
```

### Ignoring vulnerabilities

Vulnerabilities for a specific package can be excluded by adding the package
name and CVE ID(s) or GHSA ID(s) to the `audit.json` configuration file:

```json
{
"ignore": {
"@std/bytes": ["CVE-2024-12345"],
"@std/cli": ["GHSA-1234-fwm1-12wm"]
}
}
```

### Granular `run` permissions

For convenience, the previous `run` instructions use the `-A` permission flag
which grants all permissions to `audit`. Alternatively, granular flags can be
passed instead:

| Command | Permissions |
| -------------- | -------------------------------------------------------------------------------------------------------------------------------------------------- |
| `audit` | `-RW=.`
`-E=OUTPUT_DIR,CONFIG_FILE,GITHUB_TOKEN,NO_COLOR,FORCE_COLOR,TERM`
`-N=api.jsr.io,cdn.deno.land,registry.npmjs.org,api.github.com` |
| `audit report` | `-R=.`
`-E=OUTPUT_DIR,CONFIG_FILE,GITHUB_TOKEN,NO_COLOR,FORCE_COLOR,TERM`
`-N=0.0.0.0` |

Details

| Permission | Usage |
| ------------------------------------------------------------------ | ------------------------------------------------------------------------------------------ |
| `-R=.` | Read the lock file and audit report. |
| `-W=.` | Write the audit report. |
| `-E=OUTPUT_DIR,CONFIG_FILE,GITHUB_TOKEN,NO_COLOR,FORCE_COLOR,TERM` | Used for audit configurations, authenticated GitHub API requests and the terminal spinner. |
| `-N=api.jsr.io,cdn.deno.land,registry.npmjs.org,api.github.com` | Fetch the package information, and GitHub security advisories. |
| `-N=0.0.0.0` | Serve the generated audit report. |