Skip to content

Commit 7b60839

Browse files
committed
Fix help banner display for --help flag
Skip forwarding --help, --help-full, and --version flags to Python CLI to ensure Node.js CLI banner is displayed before showing help output. This fixes 10 failing tests that expected the Socket banner in stderr. Update test snapshots to reflect Node.js CLI help output.
1 parent b16189f commit 7b60839

File tree

11 files changed

+203
-1028
lines changed

11 files changed

+203
-1028
lines changed

src/commands/cli.test.mts

Lines changed: 61 additions & 106 deletions
Original file line numberDiff line numberDiff line change
@@ -17,115 +17,70 @@ describe('socket root command', async () => {
1717
async cmd => {
1818
const { code, stderr, stdout } = await spawnSocketCli(binCliPath, cmd)
1919
expect(stdout).toMatchInlineSnapshot(`
20-
"usage: socketcli [-h] [--api-token <token>] [--repo <owner/repo>]
21-
[--repo-is-public] [--branch <name>] [--integration <type>]
22-
[--owner <name>] [--pr-number <number>]
23-
[--commit-message <message>] [--commit-sha <sha>]
24-
[--committers [<name> ...]] [--target-path <path>]
25-
[--sbom-file <path>] [--license-file-name <string>]
26-
[--save-submitted-files-list <path>]
27-
[--save-manifest-tar <path>] [--files <json>]
28-
[--sub-path <path>] [--workspace-name <name>]
29-
[--excluded-ecosystems EXCLUDED_ECOSYSTEMS]
30-
[--default-branch] [--pending-head] [--generate-license]
31-
[--enable-debug] [--enable-json] [--enable-sarif]
32-
[--disable-overview] [--exclude-license-details]
33-
[--allow-unverified] [--disable-security-issue]
34-
[--ignore-commit-files] [--disable-blocking] [--enable-diff]
35-
[--scm <type>] [--timeout <seconds>]
36-
[--include-module-folders] [--version]
37-
38-
The Socket Security CLI will get the head scan for the provided repo from
39-
Socket, create a new one, and then report any alerts introduced by the
40-
changes. Any new alerts will cause the CLI to exit with a non-Zero exit code
41-
(1 for error alerts, 5 for warnings).
42-
43-
options:
44-
-h, --help show this help message and exit
45-
--version show program's version number and exit
46-
47-
Authentication:
48-
--api-token <token> Socket Security API token (can also be set via
49-
SOCKET_SECURITY_API_KEY env var)
50-
51-
Repository:
52-
--repo <owner/repo> Repository name in owner/repo format
53-
--repo-is-public If set it will flag a new repository creation as
54-
public. Defaults to false.
55-
--branch <name> Branch name
56-
57-
Integration:
58-
--integration <type> Integration type of api, github, gitlab, azure, or
59-
bitbucket. Defaults to api
60-
--owner <name> Name of the integration owner, defaults to the socket
61-
organization slug
62-
63-
Pull Request and Commit:
64-
--pr-number <number> Pull request number
65-
--commit-message <message>
66-
Commit message
67-
--commit-sha <sha> Commit SHA
68-
--committers [<name> ...]
69-
Committer for the commit (comma separated)
70-
71-
Path and File:
72-
--target-path <path> Target path for analysis
73-
--sbom-file <path> SBOM file path
74-
--license-file-name <string>
75-
SBOM file path
76-
--save-submitted-files-list <path>
77-
Save list of submitted file names to JSON file for
78-
debugging purposes
79-
--save-manifest-tar <path>
80-
Save all manifest files to a compressed tar.gz archive
81-
with original directory structure
82-
--files <json> Files to analyze (JSON array string)
83-
--sub-path <path> Sub-path within target-path for manifest file scanning
84-
(can be specified multiple times). All sub-paths will
85-
be combined into a single workspace scan while
86-
preserving git context from target-path
87-
--workspace-name <name>
88-
Workspace name suffix to append to repository name
89-
(repo-name-workspace_name)
90-
--excluded-ecosystems EXCLUDED_ECOSYSTEMS
91-
List of ecosystems to exclude from analysis (JSON
92-
array string)
93-
94-
Branch and Scan Configuration:
95-
--default-branch Make this branch the default branch
96-
--pending-head If true, the new scan will be set as the branch's head
97-
scan
98-
--include-module-folders
99-
Enabling including module folders like node_modules
100-
101-
Output Configuration:
102-
--generate-license Generate license information
103-
--enable-debug Enable debug logging
104-
--enable-json Output in JSON format
105-
--enable-sarif Enable SARIF output of results instead of table or
106-
JSON format
107-
--disable-overview Disable overview output
108-
--exclude-license-details
109-
Exclude license details from the diff report (boosts
110-
performance for large repos)
111-
112-
Security Configuration:
113-
--allow-unverified Allow unverified packages
114-
--disable-security-issue
115-
Disable security issue checks
116-
117-
Advanced Configuration:
118-
--ignore-commit-files
119-
Ignore commit files
120-
--disable-blocking Disable blocking mode
121-
--enable-diff Enable diff mode even when using --integration api
122-
(forces diff mode without SCM integration)
123-
--scm <type> Source control management type
124-
--timeout <seconds> Timeout in seconds for API requests"
20+
"CLI for Socket.dev
21+
22+
Usage
23+
$ socket <command>
24+
$ socket scan create --json
25+
$ socket package score npm lodash --markdown
26+
27+
Note: All commands have their own --help
28+
29+
Main commands
30+
socket login Setup Socket CLI with an API token and defaults
31+
socket scan create Create a new Socket scan and report
32+
socket npm/lodash@4.17.21 Request the Socket score of a package
33+
socket fix Fix CVEs in dependencies
34+
socket optimize Optimize dependencies with @socketregistry overrides
35+
socket cdxgen Run cdxgen for SBOM generation
36+
socket ci Alias for \`socket scan create --report\` (creates report and exits with error if unhealthy)
37+
38+
Socket API
39+
analytics Look up analytics data
40+
audit-log Look up the audit log for an organization
41+
organization Manage Socket organization account details
42+
package Look up published package details
43+
repository Manage registered repositories
44+
scan Manage Socket scans
45+
threat-feed [Beta] View the threat-feed
46+
47+
Local tools
48+
manifest Generate a dependency manifest for certain ecosystems
49+
npm Wraps npm with Socket security scanning
50+
npx Wraps npx with Socket security scanning
51+
raw-npm Run npm without the Socket wrapper
52+
raw-npx Run npx without the Socket wrapper
53+
54+
CLI configuration
55+
config Manage Socket CLI configuration
56+
install Install Socket CLI tab completion
57+
login Socket API login and CLI setup
58+
logout Socket API logout
59+
uninstall Uninstall Socket CLI tab completion
60+
whoami Check Socket CLI authentication status
61+
wrapper Enable or disable the Socket npm/npx wrapper
62+
63+
Options
64+
Note: All commands have these flags even when not displayed in their help
65+
66+
--compact-header Use compact single-line header format (auto-enabled in CI)
67+
--config Override the local config with this JSON
68+
--dry-run Run without uploading
69+
--help Show help
70+
--help-full Show full help including environment variables
71+
--no-banner Hide the Socket banner
72+
--no-spinner Hide the console spinner
73+
--version Print the app version
74+
75+
Environment variables [more...]
76+
Use --help-full to view all environment variables"
12577
`)
12678
expect(`\n ${stderr}`).toMatchInlineSnapshot(`
12779
"
128-
"
80+
_____ _ _ /---------------
81+
| __|___ ___| |_ ___| |_ | CLI: <redacted>
82+
|__ | * | _| '_| -_| _| | token: <redacted>, org: <redacted>
83+
|_____|___|___|_,_|___|_|.dev | Command: \`socket\`, cwd: <redacted>"
12984
`)
13085

13186
expect(code, 'explicit help should exit with code 0').toBe(0)

src/commands/config/cmd-config.test.mts

Lines changed: 19 additions & 105 deletions
Original file line numberDiff line numberDiff line change
@@ -16,115 +16,29 @@ describe('socket config', async () => {
1616
async cmd => {
1717
const { code, stderr, stdout } = await spawnSocketCli(binCliPath, cmd)
1818
expect(stdout).toMatchInlineSnapshot(`
19-
"usage: socketcli [-h] [--api-token <token>] [--repo <owner/repo>]
20-
[--repo-is-public] [--branch <name>] [--integration <type>]
21-
[--owner <name>] [--pr-number <number>]
22-
[--commit-message <message>] [--commit-sha <sha>]
23-
[--committers [<name> ...]] [--target-path <path>]
24-
[--sbom-file <path>] [--license-file-name <string>]
25-
[--save-submitted-files-list <path>]
26-
[--save-manifest-tar <path>] [--files <json>]
27-
[--sub-path <path>] [--workspace-name <name>]
28-
[--excluded-ecosystems EXCLUDED_ECOSYSTEMS]
29-
[--default-branch] [--pending-head] [--generate-license]
30-
[--enable-debug] [--enable-json] [--enable-sarif]
31-
[--disable-overview] [--exclude-license-details]
32-
[--allow-unverified] [--disable-security-issue]
33-
[--ignore-commit-files] [--disable-blocking] [--enable-diff]
34-
[--scm <type>] [--timeout <seconds>]
35-
[--include-module-folders] [--version]
19+
"Manage Socket CLI configuration
20+
21+
Usage
22+
$ socket config <command>
23+
24+
Commands
25+
auto Automatically discover and set the correct value config item
26+
get Get the value of a local CLI config item
27+
list Show all local CLI config items and their values
28+
set Update the value of a local CLI config item
29+
unset Clear the value of a local CLI config item
3630
37-
The Socket Security CLI will get the head scan for the provided repo from
38-
Socket, create a new one, and then report any alerts introduced by the
39-
changes. Any new alerts will cause the CLI to exit with a non-Zero exit code
40-
(1 for error alerts, 5 for warnings).
41-
42-
options:
43-
-h, --help show this help message and exit
44-
--version show program's version number and exit
45-
46-
Authentication:
47-
--api-token <token> Socket Security API token (can also be set via
48-
SOCKET_SECURITY_API_KEY env var)
49-
50-
Repository:
51-
--repo <owner/repo> Repository name in owner/repo format
52-
--repo-is-public If set it will flag a new repository creation as
53-
public. Defaults to false.
54-
--branch <name> Branch name
55-
56-
Integration:
57-
--integration <type> Integration type of api, github, gitlab, azure, or
58-
bitbucket. Defaults to api
59-
--owner <name> Name of the integration owner, defaults to the socket
60-
organization slug
61-
62-
Pull Request and Commit:
63-
--pr-number <number> Pull request number
64-
--commit-message <message>
65-
Commit message
66-
--commit-sha <sha> Commit SHA
67-
--committers [<name> ...]
68-
Committer for the commit (comma separated)
69-
70-
Path and File:
71-
--target-path <path> Target path for analysis
72-
--sbom-file <path> SBOM file path
73-
--license-file-name <string>
74-
SBOM file path
75-
--save-submitted-files-list <path>
76-
Save list of submitted file names to JSON file for
77-
debugging purposes
78-
--save-manifest-tar <path>
79-
Save all manifest files to a compressed tar.gz archive
80-
with original directory structure
81-
--files <json> Files to analyze (JSON array string)
82-
--sub-path <path> Sub-path within target-path for manifest file scanning
83-
(can be specified multiple times). All sub-paths will
84-
be combined into a single workspace scan while
85-
preserving git context from target-path
86-
--workspace-name <name>
87-
Workspace name suffix to append to repository name
88-
(repo-name-workspace_name)
89-
--excluded-ecosystems EXCLUDED_ECOSYSTEMS
90-
List of ecosystems to exclude from analysis (JSON
91-
array string)
92-
93-
Branch and Scan Configuration:
94-
--default-branch Make this branch the default branch
95-
--pending-head If true, the new scan will be set as the branch's head
96-
scan
97-
--include-module-folders
98-
Enabling including module folders like node_modules
99-
100-
Output Configuration:
101-
--generate-license Generate license information
102-
--enable-debug Enable debug logging
103-
--enable-json Output in JSON format
104-
--enable-sarif Enable SARIF output of results instead of table or
105-
JSON format
106-
--disable-overview Disable overview output
107-
--exclude-license-details
108-
Exclude license details from the diff report (boosts
109-
performance for large repos)
110-
111-
Security Configuration:
112-
--allow-unverified Allow unverified packages
113-
--disable-security-issue
114-
Disable security issue checks
115-
116-
Advanced Configuration:
117-
--ignore-commit-files
118-
Ignore commit files
119-
--disable-blocking Disable blocking mode
120-
--enable-diff Enable diff mode even when using --integration api
121-
(forces diff mode without SCM integration)
122-
--scm <type> Source control management type
123-
--timeout <seconds> Timeout in seconds for API requests"
31+
Options
32+
33+
--no-banner Hide the Socket banner
34+
--no-spinner Hide the console spinner"
12435
`)
12536
expect(`\n ${stderr}`).toMatchInlineSnapshot(`
12637
"
127-
"
38+
_____ _ _ /---------------
39+
| __|___ ___| |_ ___| |_ | CLI: <redacted>
40+
|__ | * | _| '_| -_| _| | token: <redacted>, org: <redacted>
41+
|_____|___|___|_,_|___|_|.dev | Command: \`socket config\`, cwd: <redacted>"
12842
`)
12943

13044
expect(code, 'explicit help should exit with code 0').toBe(0)

0 commit comments

Comments
 (0)