Skip to content
Merged
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
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@
!/assets/fleet/
!/bin/
!/docs/
!/docs/commands/
!/docs/commands/**
!/docs/dynamic-sbom-inference-settings.md
!/patches/
!/scripts/
Expand Down
8 changes: 6 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,19 @@ socket --help

### Commands

See the [Command reference](docs/commands/README.md) for usage guides.

- `socket npm [args...]` and `socket npx [args...]` - Wraps npm/npx with Socket security scanning

- `socket fix` - Fix CVEs in dependencies

- `socket optimize` - Optimize dependencies with [`@socketregistry`](https://github.com/SocketDev/socket-registry) overrides
- `socket organization dependencies` (alias: `socket org deps`) - List dependencies recorded for your organization

- `socket cdxgen [command]` - Run [cdxgen](https://cyclonedx.github.io/cdxgen/#/?id=getting-started) for SBOM generation

- `socket patch <command>` - Apply, manage, and rollback Socket security patches for vulnerable dependencies
- `socket patch` - Scan for, apply, and manage Socket security patches for vulnerable dependencies

- `socket optimize` - Optimize dependencies with [`@socketregistry`](https://github.com/SocketDev/socket-registry) overrides

#### Patch subcommands

Expand Down
23 changes: 23 additions & 0 deletions docs/commands/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Command reference

Guides for Socket CLI commands:

- [npm](npm.md)
- [npx](npx.md)
- [fix](fix.md)
- [optimize](optimize.md)
- [Organization dependencies](organization-dependencies.md)
- [cdxgen](cdxgen.md)
- [patch](patch/README.md)
- [ci](ci.md)

Patch subcommands:

- [scan](patch/scan.md)
- [get](patch/get.md)
- [apply](patch/apply.md)
- [rollback](patch/rollback.md)
- [list](patch/list.md)
- [remove](patch/remove.md)
- [setup](patch/setup.md)
- [repair](patch/repair.md)
16 changes: 16 additions & 0 deletions docs/commands/cdxgen.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# `socket cdxgen`

With the npm-installed Socket CLI, generate a CycloneDX software bill of
materials (SBOM) for the current project.

```sh
socket cdxgen --output socket-cdx.json
```

The default lifecycle is `pre-build`, which reads dependency metadata
without running project installs. Run `socket cdxgen --help` for cdxgen
options, including `--type` to select a project type.

Standalone binaries have a separate set of capabilities. They can display
local cdxgen help even when SBOM generation is disabled in the build.
Use the npm-installed CLI to run the example above.
12 changes: 12 additions & 0 deletions docs/commands/ci.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# `socket ci`

Run a security scan in CI. This alias for `socket scan create --report`
uses the default organization for your Socket API token and exits with a
nonzero status if the scan fails your security policy.

```sh
socket ci
```

Use `--auto-manifest` to include locally generated manifests for supported
projects. Run `socket ci --help` for all options.
38 changes: 38 additions & 0 deletions docs/commands/fix.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# `socket fix`

Find vulnerable dependencies and calculate upgrades for the current project.
The Socket API token needs the `fixes:list`, `full-scans:create`, and
`packages:list` permissions.

In local mode, preview fixes or apply them to your working directory.

```sh
# Preview fixes for all vulnerabilities
socket fix --all --no-apply-fixes

# Apply fixes for all vulnerabilities
socket fix --all

# Apply a fix for a specific vulnerability in another directory
socket fix ./path/to/project --id CVE-2021-23337
```

`--no-apply-fixes` only affects local mode. Use either `--all` or `--id`. The
`--id` flag accepts CVE IDs, GHSA IDs, or package URLs (PURLs). A bare
`socket fix` still processes all vulnerabilities in local mode and prints a
deprecation warning.

To open GitHub pull requests from CI, set these variables.

- `CI`
- `SOCKET_CLI_GITHUB_TOKEN` or `GITHUB_TOKEN`
- `SOCKET_CLI_GIT_USER_NAME`
- `SOCKET_CLI_GIT_USER_EMAIL`

The command also needs to resolve the repository from `GITHUB_REPOSITORY` or
the Git remote named `origin`. If any of the listed CI variables are missing,
the command runs in local mode. Use `--autopilot` to enable auto-merge for
pull requests the command opens.

Run `socket fix --help` for options to filter ecosystems and package managers,
limit version changes, or choose how version ranges are updated.
18 changes: 18 additions & 0 deletions docs/commands/npm.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# `socket npm`

Run npm through Socket's package security checks.

```sh
socket npm install
socket npm exec cowsay
```

`--help` shows the wrapper help. `--dry-run` exits before running npm. The
wrapper filters out Socket flags but forwards `--json` to npm.

The wrapper can use Socket's default public API token. A custom token needs
the `packages:list` permission.

Run `socket wrapper on` to add both `npm` and `npx` aliases to a supported Bash
or Zsh startup file. Open a new terminal or run the `source` command printed
by Socket to activate the aliases in your current shell.
17 changes: 17 additions & 0 deletions docs/commands/npx.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# `socket npx`

Run npx through Socket's package security checks.

```sh
socket npx cowsay
socket npx cowsay@1.6.0 hello
```

`--help` shows the wrapper help. `--dry-run` exits before running npx.

The wrapper can use Socket's default public API token. A custom token needs
the `packages:list` permission.

Run `socket wrapper on` to add both `npm` and `npx` aliases to a supported Bash
or Zsh startup file. Open a new terminal or run the `source` command printed
by Socket to activate the aliases in your current shell.
15 changes: 15 additions & 0 deletions docs/commands/optimize.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# `socket optimize`

Add or update `@socketregistry` package overrides in the current project. The
command requires a valid `package.json` and a nonempty lockfile. It updates
the lockfile when needed.

```sh
socket optimize
socket optimize ./path/to/project --pin
```

By default, overrides apply to production and development dependencies. Use
`--prod` to limit them to production dependencies on supported package
managers. Bun and Yarn Berry do not support `--prod`. Use `--pin` to pin
overrides to the latest version.
26 changes: 26 additions & 0 deletions docs/commands/organization-dependencies.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Organization dependencies

`socket organization dependencies` lists dependencies recorded for your
organization. You can also use `socket org deps` or `socket deps`.

`--limit` sets the maximum number of dependencies returned and defaults to
50. Use `--offset` to skip dependencies.

```sh
socket org deps
socket org deps --limit 20 --offset 10 --json
```

With `--json`, dependency rows are in `data.rows`. A `data.end` value of
`true` indicates there are no more results.

Use `--purls` to filter by package URL (PURL). Separate PURLs with commas or
repeat the flag to search for multiple packages. The `pkg:` prefix is optional.

```sh
socket org deps --purls 'npm/minimist@0.0.4,pkg:pypi/requests'
```

Include a version to match that version or omit it to match all indexed
versions. Partial matches, wildcards, version ranges, qualifiers, and
subpaths are unsupported.
14 changes: 14 additions & 0 deletions docs/commands/patch/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# `socket patch`

Manage Socket security patches for dependencies. Patch records are stored in
`.socket/manifest.json` by default.

```sh
socket patch scan
socket patch get <uuid> --org <slug> --save-only
socket patch apply
```

See the guides for [scanning](scan.md), [downloading](get.md), [applying](apply.md),
[rolling back](rollback.md), [listing](list.md), [removing](remove.md),
[postinstall setup](setup.md), and [repairing the patch cache](repair.md).
12 changes: 12 additions & 0 deletions docs/commands/patch/apply.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# `socket patch apply`

Apply patches recorded in the project manifest. The default manifest is
`.socket/manifest.json`:

```sh
socket patch apply
```

Use `--dry-run` to verify that patches can be applied without changing files.
Run `socket patch apply --help` for offline, global-package, and output
options.
12 changes: 12 additions & 0 deletions docs/commands/patch/get.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# `socket patch get`

Download a security patch by UUID, CVE, GHSA, PURL, or package name. By
default, the command downloads and applies the selected patch:

```sh
socket patch get <uuid> --org <slug>
```

Use `--save-only` to download without applying. Use `--one-off` to apply a
patch immediately without saving it in `.socket/`.
Run `socket patch get --help` for identifier and confirmation options.
11 changes: 11 additions & 0 deletions docs/commands/patch/list.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# `socket patch list`

List patches recorded in the project manifest:

```sh
socket patch list
socket patch list --json
```

Use `--cwd` to select a project directory or `--manifest-path` to select a
different manifest. Run `socket patch list --help` for all options.
12 changes: 12 additions & 0 deletions docs/commands/patch/remove.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# `socket patch remove`

Remove a patch by PURL or patch UUID. The command rolls back the patch's file
changes before removing its manifest entry:

```sh
socket patch remove <purl-or-uuid>
```

Use `--skip-rollback` to remove only the manifest entry and leave the
installed files as they are. Run `socket patch remove --help` for confirmation
and global-package options.
12 changes: 12 additions & 0 deletions docs/commands/patch/repair.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# `socket patch repair`

Download missing patch blobs into the local cache and remove unused blobs
from that cache. Repair only changes the patch cache.

```sh
socket patch repair
```

Use `--dry-run` to preview changes, `--download-only` to skip cleanup, or
`--offline` to clean up without network access.
Run `socket patch repair --help` for all options.
12 changes: 12 additions & 0 deletions docs/commands/patch/rollback.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# `socket patch rollback`

Restore files changed by patches:

```sh
socket patch rollback
socket patch rollback <purl-or-uuid>
```

Without an identifier, the command rolls back all patches in the manifest. Use
`--dry-run` to verify the rollback without changing files. Run
`socket patch rollback --help` for one-off and global-package options.
12 changes: 12 additions & 0 deletions docs/commands/patch/scan.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# `socket patch scan`

Find available Socket security patches for installed packages in the current
project:

```sh
socket patch scan
```

Use `--cwd` to choose a project directory, `--global` to scan globally
installed npm packages, or `--ecosystems` to restrict the scan. Use `--json`
for machine-readable output. Run `socket patch scan --help` for all options.
13 changes: 13 additions & 0 deletions docs/commands/patch/setup.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# `socket patch setup`

Configure patches to reapply after package installs. For npm projects, setup
prepends `socket patch apply --silent --ecosystems npm` to `postinstall`
scripts and can update nested `package.json` files.

```sh
socket patch setup --dry-run
socket patch setup
```

Use `--dry-run` to preview the changes or `--yes` to skip the confirmation
prompt. Run `socket patch setup --help` for all options.
Loading