Repository navigation
fix: keep the API token and settings socket-cli passes Coana out of the build tools it runs - #1725
Conversation
5c212c4 to
598a93c
Compare
598a93c to
700fbd3
Compare
PR SummaryHigh Risk Overview
Reachability drops Tests cover context JSON for pinned Coana, legacy env for old versions, repo-name handling, and that socket-cli-only env keys stay out of Coana's environment. Reviewed by Cursor Bugbot for commit 700fbd3. Configure here. |
Oskar Haarklou Veileborg (BarrensZeppelin)
left a comment
There was a problem hiding this comment.
Simplification review: reuse, simplification, efficiency and altitude. Nothing here is a blocker. The inline comments are ordered roughly by importance.
Outside this PR's scope, for the longer-term design the description mentions:
- Only the
socket logintoken is kept out of the build tools. A user's ownSOCKET_CLI_API_TOKEN,SOCKET_SECURITY_API_TOKENorGITHUB_TOKENstill reaches Coana throughuserEnv, and from there the build tools. That is the usual CI setup. The changelog wording is accurate, but the root fix is Coana starting build tools with a scrubbed environment. - Shadow npm has the same pattern.
src/shadow/npm-base.mts:184andsrc/shadow/npm/install.mts:92still spreadconstants.processEnvinto npm, whose lifecycle scripts run untrusted code. One shared helper that builds the environment for children running build or install code would give Coana and npm the same policy.
Checked and fine: every Coana spawn goes through spawnCoana (including the three socket fix calls), threading the version out of getCoanaCliDir is necessary because the cache directory is content-addressed, contextVariables needs its filter, and nothing the diff adds is slower in a way that matters.
d0498e0 to
59c5124
Compare
|
[agent] Thanks for the review. On the two points outside the PR:
|
Oskar Haarklou Veileborg (BarrensZeppelin)
left a comment
There was a problem hiding this comment.
[agent] One cleanup outside this diff: spawnSocketCli in test/utils.mts:211-228 lists the four token variable names by hand, twice, to keep them out of the test environment. It could build those exclusions from SOCKET_CLI_API_TOKEN_VARIABLES (it also drops SOCKET_CLI_API_BASE_URL and SOCKET_CLI_ORG_SLUG, which would stay explicit), so a name added to or removed from the list doesn't leave the test helper out of date.
59c5124 to
9ef8c0d
Compare
|
[agent] Fixed in 9ef8c0d - |
9ef8c0d to
49c5ac5
Compare
Oskar Haarklou Veileborg (BarrensZeppelin)
left a comment
There was a problem hiding this comment.
LGTM
I don't know if the test failure needs looking into?
Coana passes its environment on to the build tools and package managers it runs. It now removes the variables it reads (the API token, organization, API base URL, proxy, User-Agent, CLI version and repository name) at startup, so socket-cli sets only those for it. socket-cli also leaves out the other variables it reads the token from (SOCKET_SECURITY_API_TOKEN, SOCKET_SECURITY_API_KEY, SOCKET_CLI_API_KEY) and SOCKET_CLI_CONFIG, which can carry one; Coana reads none of them. It no longer adds its own normalised settings (constants.processEnv) to Coana's environment, nor the branch name, which Coana does not read.
49c5ac5 to
549e452
Compare
|
[agent] Thanks. The failure was real, not flake: |
Heads up, reviewer
Coana passes its environment to the build tools and package managers it runs, so today the Socket API token we give Coana reaches every Gradle/Maven plugin and npm install script in the user's project.
This PR doesn't change how we pass settings to Coana: it's the same 7 variables as on v1.x. The fix is on Coana's side (coana-tech/coana-package-manager#2774): Coana deletes those variables at startup, before it starts anything. Socket CLI's part is small:
SOCKET_BRANCH_NAME, which Coana never read.SOCKET_SECURITY_API_TOKEN,SOCKET_SECURITY_API_KEY,SOCKET_CLI_API_KEY). Coana doesn't know those names, so it can't delete them.LLM Description written by Claude Code:claude-opus-5-5
Coana passes its environment on to the build tools and package managers it runs, so the API token and the other settings socket-cli sets for Coana reached them too. Coana now removes the variables it reads at startup (coana-tech/coana-package-manager#2774). socket-cli sets only those for it, and leaves out the other variables it reads the token from, which Coana doesn't read.
Merge and release only with the whole stack, after
COANA_CLI_VERSIONis bumped to a Coana release with the Coana Socket facts stack (coana-tech/coana-package-manager#2791, #2774–#2779 and #2792, then #2780 and #2788 for socket fix and #2785, #2781, #2786 and #2793 for reachability) and SocketDev/depscan#30549 (serves Coana'sfactscomponent) is deployed. Until the bump, the token still reaches the tools: the pinned Coana 15.15.0 leaves the variables in place.Details
SOCKET_CLI_API_TOKEN,SOCKET_ORG_SLUG,SOCKET_CLI_API_BASE_URL,SOCKET_CLI_API_PROXY,SOCKET_CALLER_USER_AGENT,SOCKET_CLI_VERSIONandSOCKET_REPO_NAME; unset ones leave the user's own.SOCKET_SECURITY_API_TOKEN,SOCKET_SECURITY_API_KEY,SOCKET_CLI_API_KEYandSOCKET_CLI_CONFIG(which can carry a token) are left out, as Coana gets the token inSOCKET_CLI_API_TOKEN. A build that reads one of these itself no longer sees it under Coana.SOCKET_BRANCH_NAMEis no longer set; Coana doesn't read it.NODE_COMPILE_CACHE, still reach Coana throughbin/cli.js; keeping those out is a separate change./proc.Stack
Changelog
In
CHANGELOG.mdunder[Unreleased]:Fixed
socket loginor the environment, and the other settings socket-cli passes to Coana no longer reach the build tools and package managers Coana runs.🤖 Generated with Claude Code