Skip to content

dev - #8

Merged
minarc merged 6 commits into
mainfrom
dev
Mar 4, 2026
Merged

dev#8
minarc merged 6 commits into
mainfrom
dev

Conversation

@minarc

@minarc minarc commented Mar 3, 2026 •

Copy link
Copy Markdown
Contributor
  • ✨(logger): add tool_result to filtered content
  • ✨ implement salted hmac-sha256 hashing
  • ✨(skillmeter): implement keychain license token
  • ✨(skillmeter): add transfer status logging
  • ♻️(skillmeter): improve chat transfer reliability

Summary by CodeRabbit

Release Notes

  • New Features

    • Added secure credential storage leveraging platform keychain (macOS) with automatic local fallback
    • Introduced license token-based authentication for data transfer operations
  • Refactor

    • Replaced API key authentication with license token authorization across services
    • Enhanced cryptographic hashing with salt-based mechanisms for improved data security

@minarc
minarc requested a review from jhunlee-dev March 3, 2026 08:30
@coderabbitai

coderabbitai Bot commented Mar 3, 2026 •

Copy link
Copy Markdown
Contributor

Walkthrough

This 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

Cohort / File(s) Summary
Hashing and Salt Management
skillmeter/scripts/logger.js
Introduces getOrCreateHashSalt() for Keychain/file-based salt retrieval, getLicenseToken() for license JWT retrieval from Keychain, and hashHmac() for HMAC-SHA256 computation. Removes hashSha256 from exports. Adds internal hashForFilename() helper and updates getOffsetFilePath() to use the new hashing approach. Message filtering extended to preserve tool_result entries.
File Path Hashing Updates
skillmeter/scripts/post_tool_use.js, skillmeter/scripts/user_prompt_submit.js
Replace hashSha256 with hashHmac for file path hashing; import new getOrCreateHashSalt and hashHmac functions. Retrieve and pass hash salt to hashing calls for HMAC computation instead of plain SHA256.
License Token Authorization
skillmeter/scripts/transfer_conversation.js, skillmeter/scripts/transfer_event.js
Replace API_KEY environment variable with runtime license token retrieved via getLicenseToken(). Update Authorization headers to use Bearer token pattern, conditioned on token presence. Remove API_KEY variable usage entirely.
Session End Data Transfer
skillmeter/scripts/session_end.js
Convert asynchronous spawn to synchronous spawnSync for conversation data transfer with 8000 ms timeout. Add pre-transfer license token validation and log errors if token is missing. Remove detached/unref patterns and add explicit stdio handling.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~55 minutes

Possibly related PRs

Poem

🐰 With salts now locked in systems grand,

And tokens fetched with steady hand,

The hashes dance with HMAC's grace,

While spawns sync up the transfer race,

A rabbit cheers the auth refine! 🔐✨

🚥 Pre-merge checks | ✅ 1 | ❌ 2

❌ Failed checks (1 warning, 1 inconclusive)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 76.92% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Title check ❓ Inconclusive The pull request title 'dev' is vague and generic, using a non-descriptive term that does not convey meaningful information about the changeset. Replace the title with a clear, specific summary of the main change, such as 'Implement salted HMAC hashing and keychain-backed license token retrieval' or 'Add keychain integration and salted HMAC-SHA256 hashing for improved security'.
✅ Passed checks (1 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch dev

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 | 🟠 Major

Abort conversation upload when license token is missing.

This currently attempts network transfer without Authorization when 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 | 🟠 Major

Abort 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.

📥 Commits

Reviewing files that changed from the base of the PR and between 176d2cf and c76d60c.

📒 Files selected for processing (6)
  • skillmeter/scripts/logger.js
  • skillmeter/scripts/post_tool_use.js
  • skillmeter/scripts/session_end.js
  • skillmeter/scripts/transfer_conversation.js
  • skillmeter/scripts/transfer_event.js
  • skillmeter/scripts/user_prompt_submit.js

Comment on lines +86 to +87
const account = process.env.USER || process.env.USERNAME || "";
if (!account) return null;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

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.

Comment on lines +90 to +92
const result = execSync(
`security find-generic-password -a "${account}" -s "${HASH_SALT_SERVICE}" -w 2>/dev/null`,
{ encoding: "utf8", stdio: ["pipe", "pipe", "pipe"] }

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🔴 Critical

🧩 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 || true

Repository: 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 -B1

Repository: 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.

@minarc
minarc merged commit 22af745 into main Mar 4, 2026
1 check was pending
@coderabbitai coderabbitai Bot mentioned this pull request Mar 11, 2026
3 tasks done
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.

1 participant