Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
bump: minor
---

### Added

- control-claude-code's `cli/account.mjs` handles API-key auth. When `claude auth status --json` reports `authMethod` `api_key` with no email and no organization, it prints the one line `none: API-key auth has no signed-in account` and exits 0 ([#13760](https://github.com/melodic-software/claude-code-plugins/issues/13760)). Drive's contract defines no `none:` output for a `values:` source, so its mask post-check reads that line as one literal value to scan for. Any other auth method with no email or organization still exits 1 with nothing on stdout.
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ Read-only commands drive runs from this control skill. Every other driving comma

| Command | Flags | Prints | Exit codes |
|---|---|---|---|
| `cli/account.mjs` | none | The signed-in email and organization name from `claude auth status --json`, one per line, for the `## Mask` `values:` line. It never writes them to a file | 0 printed; 1 `claude auth status` failed or named neither; 2 an argument was given |
| `cli/account.mjs` | none | The signed-in email and organization name from `claude auth status --json`, one per line, for the `## Mask` `values:` line. It never writes them to a file. Under API-key auth (`authMethod` `api_key`) with neither, it prints the one line `none: API-key auth has no signed-in account` | 0 printed; 1 `claude auth status` failed, or named neither under any other auth method; 2 an argument was given |
10 changes: 6 additions & 4 deletions plugins/harness-ops/skills/control-claude-code/cli/account.mjs

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.

The pr-verify verifier failed head cf8c4f2474c63995be8bed201f08709fc6c2d45e. What it wrote, as data:

What it wrote (26 lines)
Summary: Refs #13760, part 3 of #13757. Its one done-when item asks for driver.test.mjs to pass with
  both the account.mjs cases and the key-auth fixture cases. The PR body says which part it delivers
  (account.mjs printing a `none:` line and exiting 0 under API-key auth) and lists what remains (the
  key-auth /status fixture and its maskCells test), so the partial delivery is properly scoped.
  driver.test.mjs runs through its wrapper, and test-bash (0) passed on the judged head
  (https://github.com/melodic-software/claude-code-plugins/actions/runs/42262412199/job/128046072077),
  so the four new account tests ran and passed. The accountValues refactor keeps its signature and
  return value, so existing callers are unaffected. The problem is that the part does not hold up on
  its own. Drive's contract defines no `none:` output for a `values:` source, so it reads the line
  as one literal value to mask. The PR's own changelog fragment says so, and the PR's review thread
  on that line was adjudicated as a finding that stands and is still open. The effect is that a mask
  source which used to fail under key auth now resolves. Before this change, captures under key auth
  were never publishable. Now they can be published, and no key-auth fixture or maskCells test yet
  shows that the mask covers what a key-auth /status screen shows. That loosens the mask post-check
  before its evidence exists.
- plugins/harness-ops/skills/control-claude-code/cli/account.mjs:15: printing a `none:` line and
  exiting 0 under `api_key` makes drive's mask source resolve to a dummy literal value, so key-auth
  captures can become publishable without masking being proven for key-auth /status rows. Either
  keep exit 1 for api_key until the key-auth fixture and its maskCells test land, or add that
  fixture and test in this PR so the issue's done-when item is delivered whole.
- plugins/harness-ops/skills/control-claude-code/cli/account.mjs:15: the `none:` stdout convention
  does not exist in drive's contract for `values:` sources
  (plugins/app-control/reference/control-skill.md,
  plugins/app-control/skills/drive/reference/evidence.md), so the sentinel is read as a literal
  value. Define that convention in the drive contract or drop the sentinel. Do not ship output that
  only works by accident.

Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
#!/usr/bin/env node
// Prints the signed-in account's email and organization name, one per line, for
// drive's mask post-check (SKILL.md `## Mask` `values:`). Reads only; see README.md.
import { accountValues } from '../driver/driver.mjs';
import { authStatus, statusValues } from '../driver/driver.mjs';

const args = process.argv.slice(2);
if (args.length) {
console.error(`account takes no arguments: ${args.join(' ')}`);
process.exit(2);
}
try {
const values = accountValues();
if (!values.length) throw new Error('claude auth status names no email or organization');
console.log(values.join('\n'));
const status = authStatus();
const values = statusValues(status);
if (values.length) console.log(values.join('\n'));
else if (status?.authMethod === 'api_key') console.log('none: API-key auth has no signed-in account');

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.

This loosens the publish gate before the key-auth mask has been checked against a real screen.

Before: under API-key auth account.mjs exited 1. Drive's post-check treats a values: source that fails as unresolved: "A source that fails or yields no value leaves every capture not-checked" (plugins/app-control/skills/drive/reference/evidence.md:81-82). So no screenshot or video from a key-auth session could be published.

Now: it exits 0 and prints one line. Nothing in drive gives a none: line from a values: command any special meaning. Both the contract and the post-check read that stdout as "one value per line" (plugins/app-control/reference/control-skill.md:219, evidence.md:80). The line none: API-key auth has no signed-in account therefore counts as a resolved literal value.

What a key-auth run gets:

  • Any capture whose sidecar passes the scan becomes applied, so publishable: true (evidence.md:93-104).
  • That check covers only the ## Mask regexes and the generic credential pattern.
  • The PR's own Remaining work says no real key-auth /status screen was checked against those masks, and there is no fixture or maskCells test for one.
  • Any key-auth-only row not covered by those patterns would now pass. Examples: an API key source or helper path, a base URL, or a Console organization shown in a form the Organization: regex does not match. Before this change such a capture was blocked.

Possible fixes (either one):

  • Keep exit 1 for api_key until the key-auth fixture and its no-values maskCells test land.
  • Or update drive's post-check and the contract in control-skill.md to define a none: line from a values: source. The rule should say a none: line means the source resolved with no values, and must not be read as a literal value. Land that together with the fixture, so the gate opens only once the masks are shown to cover the key-auth screen.

severity: IMPORTANT

claude-lane: claude-security-review

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

pr-unblock / address-feedback: UNCERTAIN, left open

Evidence: plugins/harness-ops/skills/control-claude-code/cli/account.mjs:15, plugins/app-control/skills/drive/reference/evidence.md:81, plugins/app-control/skills/drive/reference/evidence.md:102

The mechanism checks out. account.mjs:15 now exits 0 with one stdout line under api_key auth, where it used to exit 1. Drive reads that line as a literal value (evidence.md:79-82), so the source resolves, and a capture whose sidecar scan finds no hit can become applied and publishable (evidence.md:93-104). Before this change, a key-auth run left every capture not-checked. The code cannot settle whether the Mask regexes and the generic credential pattern cover every key-auth-only row on a real /status screen: there is no key-auth fixture or maskCells test. Neither suggested fix fits one scoped change in this round. Restoring exit 1 for api_key would undo the behaviour issue #13760 asks for, which is a decision for a person. Defining a none: line for values: sources needs plugins/app-control/reference/control-skill.md and plugins/app-control/skills/drive/reference/evidence.md, and the path check refuses both as outside this round's scope. Leaving this open for a person to choose between gating api_key until a key-auth fixture lands and landing the drive contract change with that fixture.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

pr-unblock / adjudicate-feedback: the finding stands

A fresh-context adjudicator read the review comment, the locations both sides cited and the code at c5fefa8ccf039b206bcb510cf24d1a52f16f576d, without the fixing lane's reasoning, and found that the finding holds. The next address-feedback round fixes it; a round that leaves this thread open again ends the lane in a failing status.

Evidence: plugins/harness-ops/skills/control-claude-code/cli/account.mjs:15, plugins/app-control/skills/drive/reference/evidence.md:81, plugins/app-control/skills/drive/reference/evidence.md:102

Comment thread
melodic-automation-lanes[bot] marked this conversation as resolved.
Resolved
else throw new Error('claude auth status names no email or organization');
} catch (err) {
console.error(`account: ${err.message}`);
process.exit(1);
Expand Down
18 changes: 13 additions & 5 deletions plugins/harness-ops/skills/control-claude-code/driver/driver.mjs

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.

The pr-verify verifier failed head cf8c4f2474c63995be8bed201f08709fc6c2d45e. What it wrote about this file, as data:

- plugins/harness-ops/skills/control-claude-code/driver/driver.mjs:72: authStatus's default env
  comes from buildLaunch, which deletes ANTHROPIC_API_KEY, so under CI key auth `claude auth status`
  may never report `api_key` and the new branch may never run live. Either resolve this or state it
  in the remaining work.

Original file line number Diff line number Diff line change
Expand Up @@ -589,22 +589,30 @@ export function readMasks(text) {
* `env`: the session's launch environment, else an attended launch's. The output is never
* echoed, so no value reaches a log or an error message.
*/
export function accountValues(env = buildLaunch({ pluginDir: '.' }, process.env).env) {
export function accountValues(env) {
return statusValues(authStatus(env));
}

/** The email and organization name an `authStatus` result names, each once. */
export function statusValues(status) {
const values = [status?.email, status?.orgName].filter((v) => typeof v === 'string' && v.trim());
return [...new Set(values)];
}

/** `claude auth status --json`, parsed, run in `env` as `accountValues` runs it. */
export function authStatus(env = buildLaunch({ pluginDir: '.' }, process.env).env) {
const run = spawnSync('claude', ['auth', 'status', '--json'], {
env,
encoding: 'utf8',
timeout: 30_000,
shell: process.platform === 'win32',
});
if (run.error) throw new Error('claude auth status did not run; cannot read the signed-in account to mask it');
let status;
try {
status = JSON.parse(run.stdout);
return JSON.parse(run.stdout);
} catch {
throw new Error('claude auth status printed no JSON; cannot read the signed-in account to mask it');
}
const values = [status?.email, status?.orgName].filter((v) => typeof v === 'string' && v.trim());
return [...new Set(values)];
}

const unitsOf = (cell) => cell.char.length;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
// prerequisites checker's probe rule (the pattern is a regular expression run
// over the probe's output).
import assert from 'node:assert/strict';
import { spawnSync } from 'node:child_process';
import { chmodSync, existsSync, mkdirSync, mkdtempSync, readdirSync, readFileSync, rmSync, statSync, writeFileSync } from 'node:fs';
import { tmpdir } from 'node:os';
import { delimiter, dirname, join } from 'node:path';
Expand Down Expand Up @@ -1107,6 +1108,48 @@ test('a masked frame that never redraws fails the screenshot with no capture and
}
});

// ---- account ----

const ACCOUNT = join(HERE, '..', 'cli', 'account.mjs');

/** cli/account.mjs run with a stub claude whose `auth status --json` prints `status`. */
function account(status) {
const box = sandbox();
writeFileSync(join(box.bin, 'claude'), `#!/bin/sh\nprintf '%s\\n' '${status}'\n`, { mode: 0o755 });
try {
return spawnSync(process.execPath, [ACCOUNT], {
env: { ...process.env, PATH: `${box.bin}${delimiter}${process.env.PATH}` },
encoding: 'utf8',
});
} finally {
rmSync(box.root, { recursive: true, force: true });
}
}

test('account prints the signed-in email and organization, one per line', posixOnly, () => {
const run = account(JSON.stringify({ loggedIn: true, authMethod: 'claude.ai', email: 'user@example.com', orgName: 'Example Org' }));
assert.equal(run.status, 0, run.stderr);
assert.equal(run.stdout, 'user@example.com\nExample Org\n');
});

test('account prints one none: line and exits 0 for API-key auth with no email or organization', posixOnly, () => {
const run = account(JSON.stringify({ loggedIn: true, authMethod: 'api_key' }));
assert.equal(run.status, 0, run.stderr);
assert.equal(run.stdout, 'none: API-key auth has no signed-in account\n');
});

test('account exits 1 with empty stdout for an OAuth session with no email or organization', posixOnly, () => {
const run = account(JSON.stringify({ loggedIn: true, authMethod: 'claude.ai' }));
assert.equal(run.status, 1);
assert.equal(run.stdout, '');
});

test('account exits 1 with empty stdout when claude auth status prints no JSON', posixOnly, () => {
const run = account('not json');
assert.equal(run.status, 1);
assert.equal(run.stdout, '');
});

// ---- changed plugins ----

test('plugins names each changed plugin once, in order, and nothing for a file outside a plugin', () => {
Expand Down
Loading