Skip to content

fix: support Socket CLI v2 settings directory layout#10

Open
dringrayson wants to merge 1 commit intoSocketDev:mainfrom
dringrayson:fix/cli-v2-settings-path
Open

fix: support Socket CLI v2 settings directory layout#10
dringrayson wants to merge 1 commit intoSocketDev:mainfrom
dringrayson:fix/cli-v2-settings-path

Conversation

@dringrayson
Copy link

@dringrayson dringrayson commented Feb 18, 2026

Summary

The Socket CLI v2 writes credentials to settings/config.json (a directory layout) instead of the legacy flat settings file. This causes the scanner to silently fall back to free/unauthenticated mode even when valid credentials exist from socket login.

Changes

  • Extracted API key resolution into src/resolve-api-key.ts (resolveApiKey()) for clarity and testability
  • Updated src/index.ts to import the new module
  • Both candidate settings paths are checked in order:
    1. <dataHome>/socket/settings (legacy flat file)
    2. <dataHome>/socket/settings/config.json (CLI v2 directory layout)
  • The first match wins, preserving full backward compatibility

Testing

Added test/resolve-api-key.test.ts with 7 test cases:

  • SOCKET_API_KEY env variable is used when set
  • Reads token from legacy flat settings file
  • Reads token from CLI v2 settings/config.json
  • Prefers legacy flat file over CLI v2 directory layout
  • Returns undefined when no settings exist
  • Throws on malformed settings file
  • Env variable takes precedence over settings file

All 22 tests pass (7 new + 15 existing).

Fixes #9

@dringrayson dringrayson force-pushed the fix/cli-v2-settings-path branch 2 times, most recently from fefaad1 to 4051bba Compare February 18, 2026 05:30
The Socket CLI v2 writes credentials to settings/config.json (a directory)
instead of a flat settings file. The scanner now checks both locations,
trying the legacy flat file first and falling back to the directory layout.

Extracted resolveApiKey() into its own module for testability and added
tests covering env variable, legacy flat file, CLI v2 directory layout,
precedence, missing settings, and malformed settings.

Fixes SocketDev#9
@dringrayson dringrayson force-pushed the fix/cli-v2-settings-path branch from 4051bba to a641337 Compare February 18, 2026 05:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Scanner fails to read credentials from Socket CLI v2 settings (directory vs file path mismatch)

1 participant