fix: support Socket CLI v2 settings directory layout#10
Open
dringrayson wants to merge 1 commit intoSocketDev:mainfrom
Open
fix: support Socket CLI v2 settings directory layout#10dringrayson wants to merge 1 commit intoSocketDev:mainfrom
dringrayson wants to merge 1 commit intoSocketDev:mainfrom
Conversation
fefaad1 to
4051bba
Compare
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
4051bba to
a641337
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The Socket CLI v2 writes credentials to
settings/config.json(a directory layout) instead of the legacy flatsettingsfile. This causes the scanner to silently fall back to free/unauthenticated mode even when valid credentials exist fromsocket login.Changes
src/resolve-api-key.ts(resolveApiKey()) for clarity and testabilitysrc/index.tsto import the new module<dataHome>/socket/settings(legacy flat file)<dataHome>/socket/settings/config.json(CLI v2 directory layout)Testing
Added
test/resolve-api-key.test.tswith 7 test cases:SOCKET_API_KEYenv variable is used when setsettings/config.jsonAll 22 tests pass (7 new + 15 existing).
Fixes #9