Skip to content

Commit 831604f

Browse files
pranavcodeantclaude
andcommitted
Apply CodeAnt review fixes for PR #48
- Guard login token writes against aborted sign-ins (env and config layers) - Apply MCP result-size limit to codeant_scans_start - Fix cloud scan history and auth-model docs in mcp.md Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
1 parent 847a753 commit 831604f

3 files changed

Lines changed: 13 additions & 4 deletions

File tree

‎mcp.md‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ The CodeAnt CLI ships an MCP (Model Context Protocol) server that exposes CodeAn
2020
| `codeant_hotlist_list` | read | Prioritized organization-wide Hotlist findings with stable IDs. |
2121
| `codeant_hotlist_get` | read | One complete Hotlist finding by stable ID. |
2222
| `codeant_findings_antipatterns` | read | Anti-pattern findings across selected or all organization repos (paged: `limit`, `offset`, `all`). |
23-
| `codeant_cloud_scan_history` | read | AWS/Azure/GCP CSPM, VM, or container scan history (newest 10 per provider, paged with `limit`/`offset`, without per-service rollups unless `full`). |
23+
| `codeant_cloud_scan_history` | read | AWS/Azure/GCP CSPM, VM, or container scan history (newest first, 10 per provider by default and up to 200, paged with `limit`/`offset`, without per-service rollups unless `full`). |
2424
| `codeant_cloud_findings_list` | read | Findings for one CSPM, VM, or container scan (paged: `limit`, `offset`, `all`; compliance mappings only with `full`). |
2525
| `codeant_cloud_finding_get` | read | Full detail for one cloud finding UID. |
2626
| `codeant_pentest_history` | read | Pentest engagement history (paged: `limit`, `offset`, `full`). |
@@ -203,7 +203,7 @@ CodeAnt's MCP server uses stdio + a packaged bundle, so the submission route is
203203

204204
Reviewer notes worth preparing:
205205

206-
- **Auth model.** Users sign in with the `codeant_login` tool (browser sign-in, token saved to `~/.codeant/config.json`) or paste a token into `user_config.api_token`. The token never leaves the user's machine — the bundle talks to the CodeAnt API (or the user's self-hosted URL) directly. No third-party OAuth flow needed.
206+
- **Auth model.** Users sign in with the `codeant_login` tool (browser sign-in, token saved to `~/.codeant/config.json`) or paste a token into `user_config.api_token`. The token is stored only on the user's machine (`~/.codeant/config.json`) and is sent only to the CodeAnt API (or the user's self-hosted URL) as a Bearer token — never to any third party. No third-party OAuth flow needed.
207207
- **Sandbox creds.** Email support@codeant.ai for a reviewer sandbox token; paste it into the submission form's reviewer-notes field along with an org slug that has scans + PRs to browse.
208208
- **Write tools.** Gated behind `user_config.read_only` (defaults to on). Reviewers can toggle off to test `codeant_scans_start` / `codeant_pr_resolve` / `codeant_api_request`.
209209

‎src/mcp/server.js‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -673,6 +673,12 @@ export function createMcpServer() {
673673
const attempt = { status: 'pending', loginUrl, browserOpened, controller };
674674
awaitLoginCompletion({ token, pollUrl, signal: controller.signal })
675675
.then(() => {
676+
// A cancelled login (logout or a newer sign-in aborted this one) must not
677+
// restore its token, even if the in-flight poll had already succeeded.
678+
if (controller.signal.aborted) {
679+
attempt.status = 'aborted';
680+
return;
681+
}
676682
attempt.status = 'success';
677683
attempt.token = token;
678684
// An explicit CODEANT_API_TOKEN would otherwise keep taking precedence over the new login.
@@ -791,7 +797,7 @@ export function createMcpServer() {
791797
async (input) => {
792798
try {
793799
const text = await captureStdout(() => runStartScan(input));
794-
return { content: [{ type: 'text', text: text || '{}' }] };
800+
return textResult(text || '{}');
795801
} catch (err) { return fail(err); }
796802
}
797803
);

‎src/utils/loginFlow.js‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,14 +56,17 @@ export async function awaitLoginCompletion({
5656
try {
5757
const response = await fetch(pollUrl);
5858
const data = await response.json();
59-
if (data.status === 'yes') {
59+
// Do not save the token if the login was aborted while this poll was in flight.
60+
if (data.status === 'yes' && !signal?.aborted) {
6061
setConfigValue('apiKeyV2', token);
6162
return { ok: true, token };
6263
}
6364
} catch {
6465
// Network blip — keep polling.
6566
}
6667

68+
if (signal?.aborted) throw new Error('Login aborted');
69+
6770
const remaining = deadline - Date.now();
6871
if (remaining <= 0) break;
6972
await new Promise((resolve) => {

0 commit comments

Comments
 (0)