Skip to content

Commit e9e1fa1

Browse files
committed
Merge branch 'main' of github.com:SocketDev/socket-cli into no-apply-fixes
2 parents c0e40f3 + 1cdbaaf commit e9e1fa1

File tree

60 files changed

+1144
-294
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

60 files changed

+1144
-294
lines changed

.config/rollup.sea.config.mjs

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
/**
2+
* Rollup configuration for building SEA bootstrap thin wrapper.
3+
* Compiles TypeScript bootstrap to CommonJS for Node.js SEA compatibility.
4+
*/
5+
6+
import path from 'node:path'
7+
import url from 'node:url'
8+
9+
import { babel as babelPlugin } from '@rollup/plugin-babel'
10+
import commonjsPlugin from '@rollup/plugin-commonjs'
11+
import { nodeResolve } from '@rollup/plugin-node-resolve'
12+
13+
const __dirname = path.dirname(url.fileURLToPath(import.meta.url))
14+
const rootDir = path.join(__dirname, '..')
15+
16+
export default {
17+
input:
18+
process.env.SEA_BOOTSTRAP || path.join(rootDir, 'src/sea/bootstrap.mts'),
19+
output: {
20+
file:
21+
process.env.SEA_OUTPUT || path.join(rootDir, 'dist/sea/bootstrap.cjs'),
22+
format: 'cjs',
23+
interop: 'auto',
24+
},
25+
external: [
26+
// Only externalize Node.js built-ins for the thin wrapper.
27+
/^node:/,
28+
],
29+
plugins: [
30+
nodeResolve({
31+
preferBuiltins: true,
32+
exportConditions: ['node'],
33+
}),
34+
babelPlugin({
35+
babelHelpers: 'runtime',
36+
babelrc: false,
37+
configFile: path.join(__dirname, 'babel.config.js'),
38+
extensions: ['.mjs', '.js', '.ts', '.mts'],
39+
}),
40+
commonjsPlugin(),
41+
],
42+
}

.github/workflows/lint.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,5 @@ permissions:
1212
contents: read
1313

1414
jobs:
15-
lint:
15+
lint-check:
1616
uses: SocketDev/socket-registry/.github/workflows/lint.yml@main

.github/workflows/provenance.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Provenance
1+
name: Publish to npm registry
22

33
on:
44
workflow_dispatch:

.github/workflows/socket-auto-pr.yml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Socket Fix
1+
name: Socket Fix Auto Pull Request
22

33
on:
44
schedule:
@@ -15,8 +15,12 @@ on:
1515
- '0'
1616
- '1'
1717

18+
permissions:
19+
contents: write
20+
pull-requests: write
21+
1822
jobs:
19-
fix:
23+
socket-auto-pr:
2024
uses: SocketDev/socket-registry/.github/workflows/socket-auto-pr.yml@main
2125
with:
2226
debug: ${{ inputs.debug }}

README.md

Lines changed: 37 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
[![Socket Badge](https://socket.dev/api/badge/npm/package/socket)](https://socket.dev/npm/package/socket)
44
[![Follow @SocketSecurity](https://img.shields.io/twitter/follow/SocketSecurity?style=social)](https://twitter.com/SocketSecurity)
55

6-
> CLI tool for [Socket.dev]
6+
CLI for [Socket.dev] security analysis
77

88
## Usage
99

@@ -14,97 +14,78 @@ socket --help
1414

1515
## Commands
1616

17-
- `socket npm [args...]` and `socket npx [args...]` - Wraps `npm` and `npx` to
18-
integrate [Socket.dev] and preempt installation of alerted packages using the
19-
builtin resolution of `npm` to precisely determine package installations
17+
- `socket npm [args...]` and `socket npx [args...]` - Wraps npm/npx with Socket security scanning
2018

21-
- `socket optimize` - Optimize dependencies with
22-
[`@socketregistry`](https://github.com/SocketDev/socket-registry) overrides
23-
_(👀 [our blog post](https://socket.dev/blog/introducing-socket-optimize))_
19+
- `socket fix` - Fix CVEs in dependencies
2420

25-
- `--pin` - Pin overrides to their latest version
26-
- `--prod` - Add overrides for only production dependencies
21+
- `socket optimize` - Optimize dependencies with [`@socketregistry`](https://github.com/SocketDev/socket-registry) overrides
2722

28-
- `socket cdxgen [command]` - Call out to
29-
[cdxgen](https://cyclonedx.github.io/cdxgen/#/?id=getting-started). See
30-
[their documentation](https://cyclonedx.github.io/cdxgen/#/CLI?id=getting-help)
31-
for commands.
23+
- `socket cdxgen [command]` - Run [cdxgen](https://cyclonedx.github.io/cdxgen/#/?id=getting-started) for SBOM generation
3224

3325
## Aliases
3426

3527
All aliases support the flags and arguments of the commands they alias.
3628

37-
- `socket ci` - alias for `socket scan create --report` which creates a report for the current directory and quits with an exit code if the result is unhealthy
29+
- `socket ci` - Alias for `socket scan create --report` (creates report and exits with error if unhealthy)
3830

3931
## Flags
4032

4133
### Output flags
4234

43-
- `--json` - Outputs result as JSON which can be piped into [`jq`](https://stedolan.github.io/jq/) and other tools
44-
- `--markdown` - Outputs result as Markdown which can be copied into issues, pull requests, or chats
35+
- `--json` - Output as JSON
36+
- `--markdown` - Output as Markdown
4537

4638
### Other flags
4739

48-
- `--dry-run` - Run a command without uploading anything
49-
- `--debug` - Output additional debug
50-
- `--help` - Prints help documentation
51-
- `--max-old-space-size` - Set Node's V8 [`--max-old-space-size`](https://nodejs.org/api/cli.html#--max-old-space-sizesize-in-mib) option
52-
- `--max-semi-space-size` - Set Node's V8 [`--max-semi-space-size`](https://nodejs.org/api/cli.html#--max-semi-space-sizesize-in-mib) option
53-
- `--version` - Prints the Socket CLI version
40+
- `--dry-run` - Run without uploading
41+
- `--debug` - Show debug output
42+
- `--help` - Show help
43+
- `--max-old-space-size` - Set Node.js memory limit
44+
- `--max-semi-space-size` - Set Node.js heap size
45+
- `--version` - Show version
5446

5547
## Configuration files
5648

57-
Socket CLI reads and uses data from a
58-
[`socket.yml` file](https://docs.socket.dev/docs/socket-yml) in the folder you
59-
run it in. It supports the version 2 of the `socket.yml` file format and makes
60-
use of the `projectIgnorePaths` to excludes files when creating a report.
49+
Socket CLI reads [`socket.yml`](https://docs.socket.dev/docs/socket-yml) configuration files.
50+
Supports version 2 format with `projectIgnorePaths` for excluding files from reports.
6151

6252
## Environment variables
6353

64-
- `SOCKET_CLI_API_TOKEN` - Set the Socket API token
65-
- `SOCKET_CLI_CONFIG` - A JSON stringified Socket configuration object
66-
- `SOCKET_CLI_GITHUB_API_URL` - Change the base URL for GitHub REST API calls
67-
- `SOCKET_CLI_GIT_USER_EMAIL` - The git config `user.email` used by Socket CLI<br>
68-
*Defaults:* `github-actions[bot]@users.noreply.github.com`<br>
69-
- `SOCKET_CLI_GIT_USER_NAME` - The git config `user.name` used by Socket CLI<br>
70-
*Defaults:* `github-actions[bot]`<br>
71-
- `SOCKET_CLI_GITHUB_TOKEN` - A classic or fine-grained [GitHub personal access token](https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/managing-your-personal-access-tokens) with the "repo" scope or read/write permissions set for "Contents" and "Pull Request"<br>
72-
*Aliases:* `GITHUB_TOKEN`<br>
73-
- `SOCKET_CLI_NO_API_TOKEN` - Make the default API token `undefined`
74-
- `SOCKET_CLI_NPM_PATH` - The absolute location of the npm directory
75-
- `SOCKET_CLI_ORG_SLUG` - Specify the Socket organization slug<br><br>
76-
- `SOCKET_CLI_ACCEPT_RISKS` - Accept risks of a Socket wrapped npm/npx run
77-
- `SOCKET_CLI_VIEW_ALL_RISKS` - View all risks of a Socket wrapped npm/npx run
54+
- `SOCKET_CLI_API_TOKEN` - Socket API token
55+
- `SOCKET_CLI_CONFIG` - JSON configuration object
56+
- `SOCKET_CLI_GITHUB_API_URL` - GitHub API base URL
57+
- `SOCKET_CLI_GIT_USER_EMAIL` - Git user email (default: `github-actions[bot]@users.noreply.github.com`)
58+
- `SOCKET_CLI_GIT_USER_NAME` - Git user name (default: `github-actions[bot]`)
59+
- `SOCKET_CLI_GITHUB_TOKEN` - GitHub token with repo access (alias: `GITHUB_TOKEN`)
60+
- `SOCKET_CLI_NO_API_TOKEN` - Disable default API token
61+
- `SOCKET_CLI_NPM_PATH` - Path to npm directory
62+
- `SOCKET_CLI_ORG_SLUG` - Socket organization slug
63+
- `SOCKET_CLI_ACCEPT_RISKS` - Accept npm/npx risks
64+
- `SOCKET_CLI_VIEW_ALL_RISKS` - Show all npm/npx risks
7865

7966
## Contributing
8067

81-
### Setup
82-
83-
To run locally execute the following commands:
68+
Run locally:
8469

8570
```
8671
npm install
8772
npm run build
8873
npm exec socket
8974
```
9075

91-
### Environment variables for development
76+
### Development environment variables
9277

93-
- `SOCKET_CLI_API_BASE_URL` - Change the base URL for Socket API calls<br>
94-
*Defaults:* The "apiBaseUrl" value of socket/settings local app data if present, else `https://api.socket.dev/v0/`<br>
95-
- `SOCKET_CLI_API_PROXY` - Set the proxy Socket API requests are routed through, e.g. if set to<br>
96-
[`http://127.0.0.1:9090`](https://docs.proxyman.io/troubleshooting/couldnt-see-any-requests-from-3rd-party-network-libraries), then all request are passed through that proxy<br>
97-
*Aliases:* `HTTPS_PROXY`, `https_proxy`, `HTTP_PROXY`, and `http_proxy`<br>
98-
- `SOCKET_CLI_API_TIMEOUT` - Set the timeout in milliseconds for Socket API requests
99-
- `SOCKET_CLI_DEBUG` - Enable debug logging in Socket CLI
100-
- `DEBUG` - Enable debug logging based on the [`debug`](https://socket.dev/npm/package/debug) package
78+
- `SOCKET_CLI_API_BASE_URL` - API base URL (default: `https://api.socket.dev/v0/`)
79+
- `SOCKET_CLI_API_PROXY` - Proxy for API requests (aliases: `HTTPS_PROXY`, `https_proxy`, `HTTP_PROXY`, `http_proxy`)
80+
- `SOCKET_CLI_API_TIMEOUT` - API request timeout in milliseconds
81+
- `SOCKET_CLI_DEBUG` - Enable debug logging
82+
- `DEBUG` - Enable [`debug`](https://socket.dev/npm/package/debug) package logging
10183

10284
## See also
10385

104-
- [Announcement blog post](https://socket.dev/blog/announcing-socket-cli-preview)
105-
- [Socket API Reference](https://docs.socket.dev/reference) - The API used by Socket CLI
106-
- [Socket GitHub App](https://github.com/apps/socket-security) - The plug-and-play GitHub App
107-
- [`@socketsecurity/sdk`](https://github.com/SocketDev/socket-sdk-js) - The SDK used by Socket CLI
86+
- [Socket API Reference](https://docs.socket.dev/reference)
87+
- [Socket GitHub App](https://github.com/apps/socket-security)
88+
- [`@socketsecurity/sdk`](https://github.com/SocketDev/socket-sdk-js)
10889

10990
[Socket.dev]: https://socket.dev/
11091

package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@
3636
"build:dist": "pnpm build:dist:src && pnpm build:dist:types",
3737
"build:dist:src": "run-p -c clean:dist clean:external && dotenvx -q run -f .env.local -- rollup -c .config/rollup.dist.config.mjs",
3838
"build:dist:types": "pnpm clean:dist:types && tsgo --project tsconfig.dts.json",
39+
"build:sea": "node src/sea/build-sea.mts",
40+
"build:sea:internal:bootstrap": "rollup -c .config/rollup.sea.config.mjs",
3941
"check": "pnpm check:lint && pnpm check:tsc",
4042
"check:lint": "dotenvx -q run -f .env.local -- eslint --report-unused-disable-directives .",
4143
"check:tsc": "tsgo",
@@ -167,6 +169,7 @@
167169
"open": "10.2.0",
168170
"oxlint": "1.15.0",
169171
"pony-cause": "2.1.11",
172+
"postject": "1.0.0-alpha.6",
170173
"registry-auth-token": "5.1.0",
171174
"registry-url": "7.2.0",
172175
"rollup": "4.50.1",

0 commit comments

Comments
 (0)