An open-source, faster Devin alternative
TypeScript
cve-swarm: add default-off Active scan toggle
Mohamed Habib via Computer386afef15d63
diff --git a/web/src/managed-agents/security/SecurityOnboarding.tsx b/web/src/managed-agents/security/SecurityOnboarding.tsxindex c9aee288..b74e07f0 100644--- a/web/src/managed-agents/security/SecurityOnboarding.tsx+++ b/web/src/managed-agents/security/SecurityOnboarding.tsx@@ -693,6 +693,10 @@ function PayloadBuilder({const [loginUrl, setLoginUrl] = useState('')const [loginUsername, setLoginUsername] = useState('')const [loginPassword, setLoginPassword] = useState('')+ // Active scan is opt-in, off by default. Off: passive fingerprint + static code+ // analysis, touching the target only with scan_surface. On: the cell may log+ // in, drive a browser and actively probe the named host.+ const [activeScan, setActiveScan] = useState(false)const [repositories, setRepositories] = useState<string[]>([])const [cveIds, setCveIds] = useState<string[]>([])const [preview, setPreview] = useState<string | null>(null)@@ -740,10 +744,11 @@ function PayloadBuilder({cveIds,model: DEFAULT_SWARM_MODEL,authenticated,+ activeScan,// Non-secret, so it may ride in the payload; the username/password do not....(loginUrl.trim() ? { loginUrl: loginUrl.trim() } : {}),}),- [target, declaration, repositories, cveIds, authenticated, loginUrl],+ [target, declaration, repositories, cveIds, authenticated, activeScan, loginUrl],)// Default to every connected repo the moment the list lands — the operator@@ -843,6 +848,27 @@ function PayloadBuilder({) : null}</Field>+ <label+ htmlFor="swarm-active-scan"+ className="flex cursor-pointer items-start gap-2.5 rounded-md border p-3 text-sm"+ >+ <Checkbox+ id="swarm-active-scan"+ checked={activeScan}+ onCheckedChange={(v) => setActiveScan(v === true)}+ className="mt-0.5"+ />+ <span>+ <span className="font-medium">Active scan</span>+ <span className="text-muted-foreground block">+ Off by default: the swarm fingerprints passively and proves reachability+ from your code. Turn on to let each agent log in with the test account,+ drive a browser and actively probe the target's routes to confirm real+ exposure. Required for the test login above to take effect.+ </span>+ </span>+ </label>+<Fieldlabel="Repositories"hint="Every repo from your GitHub install, selected by default. These are shared evidence — every CVE agent gets all of them cloned to investigate the target against."diff --git a/web/src/managed-agents/security/catalog.test.ts b/web/src/managed-agents/security/catalog.test.tsindex 1aed1d7c..c66ad2ed 100644--- a/web/src/managed-agents/security/catalog.test.ts+++ b/web/src/managed-agents/security/catalog.test.ts@@ -69,11 +69,14 @@ describe('swarm fan-out', () => {expect(prompt).toContain('scan_surface')})- it('seeds the cell with live feeds and keeps probing scoped to the target', () => {- const prompt = composeCellPrompt(payload, {- cveId: 'CVE-2026-1',- repositories: ['acme/web'],- })+ it('seeds the cell with live feeds and, in active mode, probes scoped to the target', () => {+ const prompt = composeCellPrompt(+ { ...payload, activeScan: true },+ {+ cveId: 'CVE-2026-1',+ repositories: ['acme/web'],+ },+ )expect(prompt).toContain('cve.now')expect(prompt).toContain('pwn.watch')expect(prompt).toContain('/workspace')@@ -84,6 +87,20 @@ describe('swarm fan-out', () => {expect(prompt).toContain('playwright')})+ it('defaults to a passive scan — no browser, no login, scan_surface only', () => {+ const prompt = composeCellPrompt(payload, {+ cveId: 'CVE-2026-1',+ repositories: ['acme/web'],+ })+ expect(prompt).toContain('Scan mode: PASSIVE')+ expect(prompt).toContain('scan_surface')+ // The active-only affordances must not leak into a passive run.+ expect(prompt).not.toContain('headless Chromium is preinstalled')+ expect(prompt).not.toContain('SWARM_LOGIN_USERNAME')+ // Still feed-seeded (reading public intel is not probing).+ expect(prompt).toContain('cve.now')+ })+it('drops target-only discovery steps when no target is given', () => {const prompt = composeCellPrompt({ ...payload, target: '' },@@ -93,9 +110,14 @@ describe('swarm fan-out', () => {expect(prompt).toContain('reachable in your code')})- it('tells the cell to log in when the scan is authenticated', () => {+ it('tells the cell to log in when the scan is authenticated and active', () => {const prompt = composeCellPrompt(- { ...payload, authenticated: true, loginUrl: 'https://app.example.com/login' },+ {+ ...payload,+ authenticated: true,+ activeScan: true,+ loginUrl: 'https://app.example.com/login',+ },{ cveId: 'CVE-2026-1', repositories: ['acme/web'] },)// Reads the creds from the environment, never carries them.@@ -105,13 +127,23 @@ describe('swarm fan-out', () => {expect(prompt).toContain('--no-sandbox')})- it('says nothing about logging in for an unauthenticated scan', () => {+ it('does not log in when credentials are given but the scan stays passive', () => {+ const prompt = composeCellPrompt(+ { ...payload, authenticated: true, loginUrl: 'https://app.example.com/login' },+ { cveId: 'CVE-2026-1', repositories: ['acme/web'] },+ )+ // Active scan is the gate: no active flag, no login, whatever the creds say.+ expect(prompt).not.toContain('SWARM_LOGIN_USERNAME')+ expect(prompt).not.toContain('throwaway test account')+ })++ it('says nothing about an authenticated login for an unauthenticated scan', () => {const prompt = composeCellPrompt(payload, {cveId: 'CVE-2026-1',repositories: ['acme/web'],})expect(prompt).not.toContain('SWARM_LOGIN_USERNAME')- expect(prompt).not.toContain('log in')+ expect(prompt).not.toContain('throwaway test account')})})diff --git a/web/src/managed-agents/security/catalog.ts b/web/src/managed-agents/security/catalog.tsindex bdd55632..e97b122e 100644--- a/web/src/managed-agents/security/catalog.ts+++ b/web/src/managed-agents/security/catalog.ts@@ -37,6 +37,12 @@ export type SwarmPayload = {// reads them from its environment at run time.readonly authenticated?: booleanreadonly loginUrl?: string+ // Active scan. Off by default: the swarm fingerprints passively and proves+ // reachability by reading code, touching the target with nothing but+ // scan_surface. On: the cell may log in, drive a browser and actively exercise+ // the mapped routes on the named host to prove exposure. The operator opts in+ // per run with the onboarding checkbox; the cell agent branches on this flag.+ readonly activeScan?: boolean}// Encrypted runtime-variable names the onboarding writes and every cell reads@@ -206,12 +212,31 @@ export function listManifestDocs(// evidence" reads identically everywhere. Scoped hard to the attested host — the// authorization boundary is the operator's ownership declaration, so probing// must never leave that one target.-export function discoveryLines(target: string): string[] {+// The one line that tells the cell which posture it is running in. The cell+// agent keys its hard rules off this: PASSIVE is the default and forbids login,+// browser-driven probing and intrusive traffic; ACTIVE opts into them, scoped to+// the named host. Stated explicitly so the posture is never inferred.+export function scanModeLine(activeScan: boolean): string {+ return activeScan+ ? 'Scan mode: ACTIVE — you may log in with the provided test account, drive a browser and actively exercise the mapped routes on the named target to prove exposure. Stay on that host.'+ : 'Scan mode: PASSIVE — fingerprint with scan_surface and prove reachability from the code only. Do not log in, drive a browser, or send intrusive traffic.'+}++export function discoveryLines(target: string, activeScan: boolean): string[] {if (!target) {return ['Read the repository clones to prove whether this CVE is reachable in your code, then save the finding with memory_save.',]}+ if (!activeScan) {+ return [+ 'Prove reachability passively — fingerprint and read, do not probe:',+ `- Fingerprint ${target} with scan_surface (public headers and files over https only). Stay on ${target}; never touch another host.`,+ '- Read the repository clones to derive their routes and dependencies, and judge whether this CVE is actually reachable in the code that host serves.',+ '- Do not log in, drive a browser, send payloads, or exercise routes — this is a passive scan.',+ '- Save the finding with memory_save.',+ ]+ }return ['Discover, do not just read:','- Read the repository clones to derive their real routes, parameters and auth flows — that map is what you probe.',@@ -254,11 +279,12 @@ export function composeCellPrompt(payload: SwarmPayload, cell: SwarmCell): strin? `Repositories available as evidence (investigate across all of them): ${cell.repositories.join(', ')}`: null,`Model: ${payload.model}`,+ payload.target ? scanModeLine(payload.activeScan ?? false) : null,'',...feedSeedingLines(),'',- ...authenticatedLoginLines(payload),- ...discoveryLines(payload.target),+ ...(payload.activeScan ? authenticatedLoginLines(payload) : []),+ ...discoveryLines(payload.target, payload.activeScan ?? false),'If the verdict is EXPOSED, open_fix_pull_request (dependency-only, single pin). Honor PUBLISH_ENABLED — dry run unless it is enabled.',].filter((line): line is string => line !== null)return lines.join('\n')@@ -465,10 +491,11 @@ export function composeLaunchPrompt(payload: SwarmPayload): string {`CVE seeds: ${cves}`,`Discovery angles to spread across the swarm: ${angles}`,`Model: ${payload.model}`,+ payload.target ? scanModeLine(payload.activeScan ?? false) : null,'',...feedSeedingLines(),'',- ...discoveryLines(payload.target),+ ...discoveryLines(payload.target, payload.activeScan ?? false),'For any EXPOSED verdict, open_fix_pull_request (dependency-only, single pin). Honor PUBLISH_ENABLED — dry run unless it is enabled.',].filter((line): line is string => line !== null)return lines.join('\n')