Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
17ff4a5
feat(security): prepare single-scan plugin Decisions consumer
Patrick-Erichsen Nov 4, 2026
fba9211
fix(security): preserve old pinned package scan contract
Patrick-Erichsen Nov 4, 2026
0b50031
merge: retain post-acceptance Inspector monitoring from main
Patrick-Erichsen Nov 4, 2026
a6219be
fix(security): repair canonical fixtures and absent overview display
Patrick-Erichsen Nov 4, 2026
950c03b
fix(security): drain retired plugin queue heads without worker churn
Patrick-Erichsen Nov 4, 2026
ac58316
feat(security): qualify image-only plugin Decisions runtime
Patrick-Erichsen Nov 4, 2026
2334deb
fix(security): retain qualified Docker run custody and native provenance
Patrick-Erichsen Nov 4, 2026
1c2b193
fix(security): adapt scanner-only Codex verdicts and plugin job custody
Patrick-Erichsen Nov 6, 2026
77b640e
merge: integrate current main report-only Endor policy
Patrick-Erichsen Nov 6, 2026
9a4ab7b
fix(ci): preserve legacy setup before qualified plugin activation
Patrick-Erichsen Nov 6, 2026
f34953a
fix(security): honor native evidence metadata and Template lease family
Patrick-Erichsen Nov 6, 2026
4f14903
test(ci): narrow required plugin setup fixture
Patrick-Erichsen Nov 6, 2026
6502055
fix(security): preserve Template typed scanner requirements
Patrick-Erichsen Nov 6, 2026
bd32695
feat(security): bind EvidenceOnly rollout to qualified native runtime
Patrick-Erichsen Nov 6, 2026
acacb92
fix(security): run Template rescan evidence natively
Patrick-Erichsen Nov 6, 2026
bd83819
fix(security): retain scoped Docker connections in worker handoffs
Patrick-Erichsen Nov 6, 2026
8cff983
fix(security): pass verified publisher context to native judge
Patrick-Erichsen Nov 6, 2026
b72aadb
merge: reconcile publication recovery with scanner claim budgets
Patrick-Erichsen Nov 6, 2026
04338c6
Merge commit '058870872d581139041465e198b42fb463e0b52f' into simple-p…
Patrick-Erichsen Nov 6, 2026
0336d44
fix(security): preserve usable typed partial SkillSpector evidence
Patrick-Erichsen Nov 7, 2026
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
19 changes: 18 additions & 1 deletion .github/workflows/prepublication-publish-checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ jobs:
inputs['target-environment'] == 'test'))
name: Pre-publication publish checks shard ${{ matrix.shard }}
runs-on: ${{ inputs.runner || 'ubuntu-22.04' }}
timeout-minutes: 25
timeout-minutes: 100
environment: ${{ github.ref == 'refs/heads/staging' && 'Staging' || (github.ref == 'refs/heads/main' && inputs['target-environment'] == 'test' && 'Test' || 'Production') }}
strategy:
fail-fast: false
Expand All @@ -175,9 +175,14 @@ jobs:
PREPUBLICATION_REPORT_SCANNER_SOURCE: ${{ vars.PREPUBLICATION_REPORT_SCANNER_SOURCE || 'false' }}
# The runner is disposable and installs the reviewed, source-pinned host scanners below.
PREPUBLICATION_CLAWSCAN_SANDBOX: "off"
# Only plugins use Docker; skill-specific host settings remain intact.
PREPUBLICATION_CLAWSCAN_PLUGIN_SANDBOX: "docker"
PREPUBLICATION_TRUFFLEHOG_IMAGE: ${{ vars.PREPUBLICATION_TRUFFLEHOG_IMAGE || 'ghcr.io/trufflesecurity/trufflehog:3.95.6@sha256:96f8429082cb2d4ae73b1096dcdb2f5aa139881d97042b0c5e5fa226a392e056' }}
PREPUBLICATION_WORKER_ID: "github-actions:${{ github.run_id }}:${{ github.run_attempt }}:${{ matrix.shard }}"
steps:
- name: Reserve hosted worker drain deadline
run: echo "SECURITY_SCAN_WORKER_HOST_DEADLINE_MS=$(( $(date +%s) * 1000 + 100 * 60000 - 120000 ))" >> "$GITHUB_ENV"

- uses: actions/checkout@v7.0.1

- uses: ./.github/actions/setup-bun
Expand Down Expand Up @@ -226,7 +231,18 @@ jobs:
set -euo pipefail
sh scripts/security/install-clawscan-scanners.sh aig

- name: Prepare qualified plugin Docker runtime
run: |
set -eu
. scripts/security/clawscan-install-source.sh
if [ "$(cat scripts/security/clawscan-source-commit.txt)" != "$qualified_source_commit" ]; then
echo 'Default source has no qualified plugin Docker runtime; retaining legacy setup.'
exit 0
fi
sh scripts/security/install-clawscan-scanners.sh aig-mcp

- name: Run Test pre-publication publish worker
timeout-minutes: 75
if: github.ref == 'refs/heads/main' && inputs['target-environment'] == 'test'
env:
CODEX_API_KEY: ${{ secrets.CODEX_API_KEY || secrets.OPENAI_API_KEY }}
Expand All @@ -251,6 +267,7 @@ jobs:
unset worker_token

- name: Run pre-publication publish worker
timeout-minutes: 75
if: github.ref != 'refs/heads/main' || inputs['target-environment'] != 'test'
env:
CODEX_API_KEY: ${{ secrets.CODEX_API_KEY || secrets.OPENAI_API_KEY }}
Expand Down
18 changes: 17 additions & 1 deletion .github/workflows/security-scan-codex.yml
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ jobs:
name: Codex security scan ${{ matrix.lane }} shard ${{ matrix.shard }}
# Match the qualified recovery image; Ubuntu24.04 AppArmor blocks judge bwrap setup.
runs-on: ubuntu-22.04
timeout-minutes: 60
timeout-minutes: 125
environment: ${{ (inputs.environment == 'Test' || github.event.client_payload.environment == 'test') && 'Test' || 'Production' }}
concurrency:
# Bulk assignments must not wait behind ordinary queue workers on the same shard.
Expand Down Expand Up @@ -102,12 +102,17 @@ jobs:
CODEX_SECURITY_SCAN_ENDOR_IMAGE: ${{ vars.CODEX_SECURITY_SCAN_ENDOR_IMAGE }}
# The runner is disposable and installs the reviewed, source-pinned host scanners below.
CODEX_SECURITY_SCAN_CLAWSCAN_SANDBOX: "off"
# Only plugins use Docker; skill-specific host settings remain intact.
CODEX_SECURITY_SCAN_CLAWSCAN_PLUGIN_SANDBOX: "docker"
CODEX_SECURITY_SCAN_LEASE_MINUTES: "60"
CODEX_SECURITY_SCAN_DIAGNOSTICS_DIR: codex-security-scan-diagnostics-${{ matrix.shard }}
CODEX_SECURITY_SCAN_SHARD: ${{ matrix.shard }}
CODEX_SECURITY_SCAN_WORKER_ID: "github-actions:${{ github.run_id }}:${{ github.run_attempt }}:${{ matrix.shard }}"
SKILLSPECTOR_PROVIDER: openai
steps:
- name: Reserve hosted worker drain deadline
run: echo "SECURITY_SCAN_WORKER_HOST_DEADLINE_MS=$(( $(date +%s) * 1000 + 125 * 60000 - 120000 ))" >> "$GITHUB_ENV"

- uses: actions/checkout@v7.0.1

- name: Check Test scan target
Expand Down Expand Up @@ -172,6 +177,16 @@ jobs:
set -euo pipefail
sh scripts/security/install-clawscan-scanners.sh aig

- name: Prepare qualified plugin Docker runtime
run: |
set -eu
. scripts/security/clawscan-install-source.sh
if [ "$(cat scripts/security/clawscan-source-commit.txt)" != "$qualified_source_commit" ]; then
echo 'Default source has no qualified plugin Docker runtime; retaining legacy setup.'
exit 0
fi
sh scripts/security/install-clawscan-scanners.sh aig-mcp

- name: Install SkillSpector
run: |
set -euo pipefail
Expand All @@ -183,6 +198,7 @@ jobs:
run: printf '%s' "$OPENAI_API_KEY" | codex login --with-api-key

- name: Run Codex security worker
timeout-minutes: 100
env:
CODEX_API_KEY: ${{ secrets.CODEX_API_KEY || secrets.OPENAI_API_KEY }}
DEFAULT_BASE_URL: https://api.openai.com/v1
Expand Down
2 changes: 2 additions & 0 deletions convex/lib/packageReadProjection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ export type ReleaseLike = {
verification?: Doc<"packageReleases">["verification"];
extractedPackageJson?: Doc<"packageReleases">["extractedPackageJson"];
sha256hash?: string;
aigAnalysis?: Doc<"packageReleases">["aigAnalysis"];
skillSpectorAnalysis?: Doc<"packageReleases">["skillSpectorAnalysis"];
endorAnalysis?: Doc<"packageReleases">["endorAnalysis"];
llmAnalysis?: Doc<"packageReleases">["llmAnalysis"];
Expand Down Expand Up @@ -126,6 +127,7 @@ export function toPackageVersionResponse(release: ReleaseLike, packageName: stri
verification,
artifact: toReleaseArtifact(release, packageName),
sha256hash: release.sha256hash ?? null,
...(release.aigAnalysis ? { aigAnalysis: release.aigAnalysis } : {}),
skillSpectorAnalysis: release.skillSpectorAnalysis ?? null,
...(release.endorAnalysis ? { endorAnalysis: release.endorAnalysis } : {}),
llmAnalysis: release.llmAnalysis ?? null,
Expand Down
72 changes: 72 additions & 0 deletions convex/lib/pluginScanRouting.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
import { ConvexError } from "convex/values";
import type { Doc } from "../_generated/dataModel";
import type { MutationCtx, QueryCtx } from "../_generated/server";
import { reusableAigAnalysis } from "./aigAnalysis";

export function isSingleScanPlugin(family: Doc<"packages">["family"] | undefined) {
return family === "code-plugin" || family === "bundle-plugin";
}

/** Automatic plugin work supplements the admitted verdict; it never re-judges it. */
export function isExplicitPluginScanSource(source: Doc<"securityScanJobs">["source"]) {
return source === "manual" || source === "bulk-rescan";
}

export function assertPluginScanEvidence(
llmAnalysis: Doc<"packageReleases">["llmAnalysis"],
aigAnalysis: Doc<"packageReleases">["aigAnalysis"],
expectedCheck?: "clean" | "blocked",
) {
const status = llmAnalysis?.status.trim().toLowerCase();
const verdict = (llmAnalysis?.verdict ?? status)?.trim().toLowerCase();
if (
!llmAnalysis ||
!Number.isFinite(llmAnalysis.checkedAt) ||
!["clean", "benign", "suspicious", "malicious"].includes(verdict ?? "") ||
!["completed", "clean", "benign", "suspicious", "malicious"].includes(status ?? "") ||
// The production c3cfaf15 package lane never executes AIG. Preserve that
// historical/pinned contract; any supplied AIG must be usable. The new MCP
// lane requires scanner provenance in the worker and is still fenced off.
(aigAnalysis !== undefined && !reusableAigAnalysis(aigAnalysis)) ||
(expectedCheck === "clean" && verdict === "malicious") ||
(expectedCheck === "blocked" && verdict !== "malicious")
) {
throw new ConvexError(
"Plugin scans require completed ClawScan and A.I.G evidence matching the publication decision.",
);
}
}

/** Legacy automatic plugin ClawScan work has no authority to adjudicate a release. */
export async function isRetiredAutomaticPluginScan(
ctx: Pick<QueryCtx, "db">,
job: Doc<"securityScanJobs">,
) {
if (
job.targetKind !== "packageRelease" ||
!job.packageReleaseId ||
job.scanMode === "endor-report-only" ||
isExplicitPluginScanSource(job.source)
)
return false;
const release = await ctx.db.get(job.packageReleaseId);
const pkg = release ? await ctx.db.get(release.packageId) : null;
return isSingleScanPlugin(pkg?.family);
}

/** Retain the row and prior error/evidence, but remove it from active queue indexes. */
export async function terminalizeRetiredAutomaticPluginScan(
ctx: Pick<MutationCtx, "db">,
job: Doc<"securityScanJobs">,
now: number,
) {
await ctx.db.patch(job._id, {
status: "failed",
lastError: job.lastError ?? "Automatic plugin ClawScan retired; explicit rescan required",
completedAt: job.completedAt ?? now,
leaseToken: undefined,
leaseExpiresAt: undefined,
workerId: undefined,
updatedAt: now,
});
}
46 changes: 46 additions & 0 deletions convex/lib/securityWorkerBudgets.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import { describe, expect, it } from "vitest";
import {
canAdmitSecurityScan,
pluginScanBudget,
publicationCheckLeaseMs,
securityScanLeaseMs,
securityWorkerDeadline,
} from "./securityWorkerBudgets";

const minute = 60_000;
describe("plugin scan deadline hierarchy", () => {
it("covers native MCP 30m, judge 20m, overview 5m and process/container cleanup", () => {
expect(pluginScanBudget.subprocessMs).toBe(60 * minute);
expect(pluginScanBudget.subprocessMs).toBeGreaterThan((30 + 20 + 5) * minute);
expect(pluginScanBudget.publicationJobMs).toBe(65 * minute);
expect(publicationCheckLeaseMs("package", "code-plugin")).toBe(70 * minute);
expect(publicationCheckLeaseMs("package", "bundle-plugin")).toBe(70 * minute);
expect(publicationCheckLeaseMs("package", undefined)).toBe(70 * minute);
expect(publicationCheckLeaseMs("skill", undefined)).toBe(30 * minute);
expect(publicationCheckLeaseMs("package", "claw")).toBe(30 * minute);
});
it("covers sequential optional Endor plus MCP in explicit rescans without extending skill/report-only leases", () => {
expect(pluginScanBudget.manualJobMs).toBe(85 * minute);
expect(securityScanLeaseMs("packageRelease", undefined, minute)).toBe(90 * minute);
expect(securityScanLeaseMs("packageRelease", "endor-report-only", minute)).toBe(minute);
expect(securityScanLeaseMs("skillVersion", undefined, minute)).toBe(minute);
expect(securityScanLeaseMs("skillVersion", undefined, 120 * minute)).toBe(60 * minute);
});
it("refuses late claims including the first, while permitting already claimed work to drain", () => {
expect(canAdmitSecurityScan(0, 15 * minute, 75 * minute, 65 * minute)).toBe(true);
expect(canAdmitSecurityScan(10 * minute, 15 * minute, 75 * minute, 65 * minute)).toBe(true);
expect(canAdmitSecurityScan(10 * minute + 1, 15 * minute, 75 * minute, 65 * minute)).toBe(
false,
);
expect(canAdmitSecurityScan(0, 15 * minute, 60 * minute, 65 * minute)).toBe(false);
expect(canAdmitSecurityScan(15 * minute, 15 * minute, 100 * minute, 65 * minute)).toBe(false);
});
});

it("deducts setup time from hosted drain coverage and rejects malformed deadlines", () => {
expect(securityWorkerDeadline(40 * minute, 75 * minute, String(98 * minute))).toBe(98 * minute);
expect(canAdmitSecurityScan(40 * minute, 55 * minute, 98 * minute, 65 * minute)).toBe(false);
expect(securityWorkerDeadline(0, 75 * minute, String(98 * minute))).toBe(75 * minute);
expect(securityWorkerDeadline(0, 75 * minute, undefined)).toBe(75 * minute);
expect(() => securityWorkerDeadline(0, 75 * minute, "invalid")).toThrow("Invalid hosted");
});
57 changes: 57 additions & 0 deletions convex/lib/securityWorkerBudgets.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
// Plugin-only native MCP gets 30m; judge (20m) and optional overview (5m)
// are sequential native stages. Never reuse the skill subprocess timeout here.
const minute = 60_000;
export const pluginScanBudget = {
subprocessMs: 60 * minute,
// Includes TruffleHog, artifact preparation, report/commit and cleanup headroom.
publicationJobMs: 65 * minute,
publicationLeaseMs: 70 * minute,
// Explicit rescans can run optional Endor (20m) before ClawScan.
manualJobMs: 85 * minute,
manualLeaseMs: 90 * minute,
publicationWorkerMs: 75 * minute,
manualWorkerMs: 100 * minute,
} as const;

export function publicationCheckLeaseMs(kind: string, family: string | undefined) {
// Historical package attempts without family still need conservative custody.
return kind === "package" && family !== "claw"
? pluginScanBudget.publicationLeaseMs
: 30 * minute;
}

export function securityScanLeaseMs(
targetKind: string,
scanMode: string | undefined,
requested: number,
) {
const legacyLease = Math.max(minute, Math.min(requested, 60 * minute));
return targetKind === "packageRelease" && scanMode !== "endor-report-only"
? Math.max(legacyLease, pluginScanBudget.manualLeaseMs)
: legacyLease;
}

// The claim window is not a kill deadline: stop admission early enough for the
// largest admissible job to drain before the separate hosted worker step ends.
export function canAdmitSecurityScan(
now: number,
claimDeadline: number,
workerDeadline: number,
drainMs: number,
) {
return now < claimDeadline && now + drainMs <= workerDeadline;
}

// Hosted jobs publish their absolute deadline before setup. Slow installation must
// reduce admission, not let the worker assume it still owns a fresh full window.
export function securityWorkerDeadline(
startedAt: number,
workerBudgetMs: number,
hostDeadline: string | undefined,
) {
if (!hostDeadline) return startedAt + workerBudgetMs;
const parsed = Number(hostDeadline);
if (!Number.isSafeInteger(parsed) || parsed <= 0)
throw new Error("Invalid hosted security worker deadline");
return Math.min(startedAt + workerBudgetMs, parsed);
}
5 changes: 5 additions & 0 deletions convex/maintenance.publishRecovery.runtime.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -852,6 +852,11 @@ describe("targeted recovery of expired finalizing uploads (#4234)", () => {
expect(after.checks).toEqual(before.checks);
expect(after.checkFailureCount).toBe(before.checkFailureCount);
expect(after.checkClaimLastError).toBe(before.checkClaimLastError);
// Conflict integration: retain targeted recovery error/evidence while
// applying the consumer's conservative package versus skill claim budget.
expect(after.checkClaimExpiresAt! - after.checkClaimedAt!).toBe(
(kind === "package" ? 70 : 30) * 60_000,
);
const target = await t.run((ctx) =>
ctx.db.get((ids.skillVersionId ?? ids.packageReleaseId)!),
);
Expand Down
14 changes: 14 additions & 0 deletions convex/packagePublishRecovery.runtime.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -640,6 +640,8 @@ it("terminalizes full-action finalization after publisher membership is lost", a
attemptId,
claimId: "scanner",
artifactFingerprint: "c".repeat(64),
clawscanAnalysis: { status: "clean", verdict: "benign", checkedAt: Date.now() },
aigAnalysis: { status: "clean", issueCount: 0, findings: [], checkedAt: Date.now() },
trufflehog: { status: "clean" },
clawscan: { status: "clean" },
});
Expand Down Expand Up @@ -667,6 +669,12 @@ it.each(["trufflehog", "clawscan"] as const)(
attemptId,
claimId: "scanner",
artifactFingerprint: "c".repeat(64),
clawscanAnalysis: {
status: scanner === "clawscan" ? "malicious" : "clean",
verdict: scanner === "clawscan" ? "malicious" : "benign",
checkedAt: Date.now(),
},
aigAnalysis: { status: "clean", issueCount: 0, findings: [], checkedAt: Date.now() },
trufflehog: { status: scanner === "trufflehog" ? "blocked" : "clean" },
clawscan: { status: scanner === "clawscan" ? "blocked" : "clean" },
});
Expand Down Expand Up @@ -702,6 +710,8 @@ it("finalizes a second successor through the complete action and replays its res
attemptId,
claimId: "scanner",
artifactFingerprint: "c".repeat(64),
clawscanAnalysis: { status: "clean", verdict: "benign", checkedAt: Date.now() },
aigAnalysis: { status: "clean", issueCount: 0, findings: [], checkedAt: Date.now() },
trufflehog: { status: "clean" },
clawscan: { status: "clean" },
});
Expand Down Expand Up @@ -904,6 +914,8 @@ it.each(["none", "membership", "token", "archive-digest"] as const)(
attemptId,
claimId: "fresh-scanner",
artifactFingerprint: "c".repeat(64),
clawscanAnalysis: { status: "clean", verdict: "benign", checkedAt: Date.now() },
aigAnalysis: { status: "clean", issueCount: 0, findings: [], checkedAt: Date.now() },
trufflehog: { status: "clean", summary: "Fresh secret scan" },
clawscan: { status: "clean", summary: "Fresh policy scan" },
});
Expand Down Expand Up @@ -1309,6 +1321,8 @@ it.each(
attemptId: successorId,
claimId: "successor-scan",
artifactFingerprint: original.attempt.artifactFingerprint,
clawscanAnalysis: { status: "clean", verdict: "benign", checkedAt: Date.now() },
aigAnalysis: { status: "clean", issueCount: 0, findings: [], checkedAt: Date.now() },
trufflehog: { status: "clean" },
clawscan: { status: "clean" },
});
Expand Down
Loading
Loading