Repository navigation
Conversation
WalkthroughThis PR refactors authentication and hashing mechanisms across six scripts. It introduces Keychain-backed salt and license token retrieval, replaces SHA256 hashing with HMAC-SHA256 using a stored salt, removes API_KEY environment variable usage in favor of runtime license tokens, and converts an asynchronous spawn operation to synchronous in the session end flow. Changes
Estimated code review effort🎯 4 (Complex) | ⏱️ ~55 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 1 | ❌ 2❌ Failed checks (1 warning, 1 inconclusive)
✅ Passed checks (1 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (2)
skillmeter/scripts/transfer_conversation.js (1)
84-99:⚠️ Potential issue | 🟠 MajorAbort conversation upload when license token is missing.
This currently attempts network transfer without
Authorizationwhen token lookup fails. That creates avoidable unauthenticated calls and retry noise.🛠 Suggested guard
// Get license token for authorization const token = getLicenseToken(); + if (!token) { + reject(new Error("Missing license token")); + return; + } // Request options const options = { @@ headers: { "Content-Type": "application/json", "Content-Encoding": "gzip", "Content-Length": compressed.length, - ...(token && { Authorization: `Bearer ${token}` }), + Authorization: `Bearer ${token}`, }, };🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@skillmeter/scripts/transfer_conversation.js` around lines 84 - 99, The upload should abort if no license token is available: call getLicenseToken() and if token is falsy, stop the transfer (throw an Error or return early) before constructing the request options or initiating the network call; update the flow around token usage in transfer_conversation.js (where token is read and options are built) so Authorization is required and the request is not attempted without it.skillmeter/scripts/transfer_event.js (1)
41-56:⚠️ Potential issue | 🟠 MajorAbort event upload when license token is missing.
The request is still sent without auth if token retrieval fails. That should fail fast locally instead of performing unauthenticated transfer attempts.
🛠 Suggested guard
// Get license token for authorization const token = getLicenseToken(); + if (!token) { + reject(new Error("Missing license token")); + return; + } @@ headers: { "Content-Type": "application/x-ndjson", "Content-Encoding": "gzip", "Content-Length": compressed.length, - ...(token && { Authorization: `Bearer ${token}` }), + Authorization: `Bearer ${token}`, }, };🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@skillmeter/scripts/transfer_event.js` around lines 41 - 56, The code currently continues to build and send the POST even when getLicenseToken() returns no token; update the logic in transfer_event.js (surrounding getLicenseToken and options) to fail fast: after calling getLicenseToken(), if token is falsy throw or return an error and do not proceed to build the request or call the function that sends it (the code that constructs options and issues the POST using the options object); keep the Authorization header logic but add this explicit guard so no unauthenticated upload is attempted.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@skillmeter/scripts/logger.js`:
- Around line 86-87: The current check that sets const account =
process.env.USER || process.env.USERNAME || "" then returns null if (!account)
skips calling getFallbackHashSalt(), which allows downstream HMAC inputs to
collapse; change the logic so that when account is empty you call and use
getFallbackHashSalt() instead of returning null (i.e., replace the early return
with assigning account = getFallbackHashSalt() or similar), ensuring any code
that relies on account (HMAC generation) always receives a non-empty salt value;
update references around the account variable and the function that uses it so
callers no longer receive null.
- Around line 90-92: The Keychain invocations use shell-interpolated execSync
with the account variable (derived from process.env.USER / USERNAME) creating a
command-injection risk; replace all execSync usages in
skillmeter/scripts/logger.js that call the `security` binary (including the
calls that reference HASH_SALT_SERVICE and the `account` variable) with
argumentized execFileSync from child_process: import execFileSync (add to the
existing require on line 7), call execFileSync("security",
["find-generic-password", "-a", account, "-s", HASH_SALT_SERVICE, "-w"], {
encoding: "utf8", stdio: ["pipe","pipe","pipe"] }) (and similarly for other
`security` subcommands), remove any shell redirections like `2>/dev/null` and
instead handle stderr via options or try/catch to preserve previous behavior;
ensure every former template-string command (the ones using `account` and
HASH_SALT_SERVICE) is converted to this argument array form.
---
Outside diff comments:
In `@skillmeter/scripts/transfer_conversation.js`:
- Around line 84-99: The upload should abort if no license token is available:
call getLicenseToken() and if token is falsy, stop the transfer (throw an Error
or return early) before constructing the request options or initiating the
network call; update the flow around token usage in transfer_conversation.js
(where token is read and options are built) so Authorization is required and the
request is not attempted without it.
In `@skillmeter/scripts/transfer_event.js`:
- Around line 41-56: The code currently continues to build and send the POST
even when getLicenseToken() returns no token; update the logic in
transfer_event.js (surrounding getLicenseToken and options) to fail fast: after
calling getLicenseToken(), if token is falsy throw or return an error and do not
proceed to build the request or call the function that sends it (the code that
constructs options and issues the POST using the options object); keep the
Authorization header logic but add this explicit guard so no unauthenticated
upload is attempted.
ℹ️ Review info
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Disabled knowledge base sources:
- Linear integration is disabled
You can enable these sources in your CodeRabbit configuration.
📒 Files selected for processing (6)
skillmeter/scripts/logger.jsskillmeter/scripts/post_tool_use.jsskillmeter/scripts/session_end.jsskillmeter/scripts/transfer_conversation.jsskillmeter/scripts/transfer_event.jsskillmeter/scripts/user_prompt_submit.js
| const account = process.env.USER || process.env.USERNAME || ""; | ||
| if (!account) return null; |
There was a problem hiding this comment.
Do not skip salt fallback when account env vars are missing.
At Line 87, returning null bypasses getFallbackHashSalt(). Downstream HMAC calls can become empty-string hashes, collapsing distinct paths into the same value.
✅ Minimal fix
function getOrCreateHashSalt() {
const account = process.env.USER || process.env.USERNAME || "";
- if (!account) return null;
+ if (!account) return getFallbackHashSalt();🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@skillmeter/scripts/logger.js` around lines 86 - 87, The current check that
sets const account = process.env.USER || process.env.USERNAME || "" then returns
null if (!account) skips calling getFallbackHashSalt(), which allows downstream
HMAC inputs to collapse; change the logic so that when account is empty you call
and use getFallbackHashSalt() instead of returning null (i.e., replace the early
return with assigning account = getFallbackHashSalt() or similar), ensuring any
code that relies on account (HMAC generation) always receives a non-empty salt
value; update references around the account variable and the function that uses
it so callers no longer receive null.
| const result = execSync( | ||
| `security find-generic-password -a "${account}" -s "${HASH_SALT_SERVICE}" -w 2>/dev/null`, | ||
| { encoding: "utf8", stdio: ["pipe", "pipe", "pipe"] } |
There was a problem hiding this comment.
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
set -euo pipefail
echo "== Shell-interpolated keychain calls =="
rg -nP 'execSync\(\s*`security (find|add)-generic-password -a "\$\{account\}"' skillmeter/scripts/logger.js -C2 || true
echo
echo "== execFileSync usage in logger.js =="
rg -n '\bexecFileSync\b' skillmeter/scripts/logger.js || trueRepository: SkillBench-AI/skillmeter-claude-code-marketplace
Length of output: 170
🏁 Script executed:
#!/bin/bash
# Check file exists and get size
wc -l skillmeter/scripts/logger.js
# Read the relevant sections
echo "=== Lines 85-100 ==="
sed -n '85,100p' skillmeter/scripts/logger.js
echo
echo "=== Lines 100-110 ==="
sed -n '100,110p' skillmeter/scripts/logger.js
echo
echo "=== Lines 140-150 ==="
sed -n '140,150p' skillmeter/scripts/logger.js
echo
echo "=== Search for all execSync and execFileSync ==="
rg -n 'execSync|execFileSync' skillmeter/scripts/logger.js -A3 -B1Repository: SkillBench-AI/skillmeter-claude-code-marketplace
Length of output: 3038
Use argumentized execution for Keychain commands to prevent command injection.
account (derived from process.env.USER or process.env.USERNAME) is shell-interpolated in execSync calls at lines 90-92, 103-105, 143-145, and also at lines 35-37 and 49-51. Since execSync invokes a shell, the template literals create command injection vectors.
Replace all execSync calls with execFileSync for argumentized execution. Import execFileSync from child_process (line 7) and update each invocation to pass arguments as an array rather than interpolating into a command string:
🔧 Safer approach (use argumentized execution)
- const { execSync, spawn } = require("child_process");
+ const { execSync, execFileSync, spawn } = require("child_process");
- const result = execSync(
- `security find-generic-password -a "${account}" -s "${SERVICE_NAME}" -w 2>/dev/null`,
- { encoding: "utf8", stdio: ["pipe", "pipe", "pipe"] }
- );
+ const result = execFileSync(
+ "security",
+ ["find-generic-password", "-a", account, "-s", SERVICE_NAME, "-w"],
+ { encoding: "utf8", stdio: ["ignore", "pipe", "ignore"] }
+ );
- const result = execSync(
- `security find-generic-password -a "${account}" -s "${HASH_SALT_SERVICE}" -w 2>/dev/null`,
- { encoding: "utf8", stdio: ["pipe", "pipe", "pipe"] }
- );
+ const result = execFileSync(
+ "security",
+ ["find-generic-password", "-a", account, "-s", HASH_SALT_SERVICE, "-w"],
+ { encoding: "utf8", stdio: ["ignore", "pipe", "ignore"] }
+ );
- execSync(
- `security add-generic-password -a "${account}" -s "${HASH_SALT_SERVICE}" -w "${newSalt}" 2>/dev/null`,
- { stdio: ["pipe", "pipe", "pipe"] }
- );
+ execFileSync(
+ "security",
+ ["add-generic-password", "-a", account, "-s", HASH_SALT_SERVICE, "-w", newSalt],
+ { stdio: ["ignore", "ignore", "ignore"] }
+ );
- const result = execSync(
- `security find-generic-password -a "${account}" -s "${LICENSE_SERVICE}" -w 2>/dev/null`,
- { encoding: "utf8", stdio: ["pipe", "pipe", "pipe"] }
- );
+ const result = execFileSync(
+ "security",
+ ["find-generic-password", "-a", account, "-s", LICENSE_SERVICE, "-w"],
+ { encoding: "utf8", stdio: ["ignore", "pipe", "ignore"] }
+ );Also applies to: 35-37, 49-51
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@skillmeter/scripts/logger.js` around lines 90 - 92, The Keychain invocations
use shell-interpolated execSync with the account variable (derived from
process.env.USER / USERNAME) creating a command-injection risk; replace all
execSync usages in skillmeter/scripts/logger.js that call the `security` binary
(including the calls that reference HASH_SALT_SERVICE and the `account`
variable) with argumentized execFileSync from child_process: import execFileSync
(add to the existing require on line 7), call execFileSync("security",
["find-generic-password", "-a", account, "-s", HASH_SALT_SERVICE, "-w"], {
encoding: "utf8", stdio: ["pipe","pipe","pipe"] }) (and similarly for other
`security` subcommands), remove any shell redirections like `2>/dev/null` and
instead handle stderr via options or try/catch to preserve previous behavior;
ensure every former template-string command (the ones using `account` and
HASH_SALT_SERVICE) is converted to this argument array form.
Summary by CodeRabbit
Release Notes
New Features
Refactor