aegisai-harness 0.77.0 → 0.79.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +1 -1
- package/README.md +1 -1
- package/ROADMAP.md +134 -0
- package/llms.txt +1 -1
- package/package.json +1 -1
- package/packaging/windows/installer.iss +2 -2
- package/scripts/repo-scan.js +27 -0
- package/src/audit_pipeline.js +138 -0
- package/src/conversation_templates.js +108 -0
- package/src/crawler.js +70 -0
- package/src/doc_convert.js +187 -0
- package/src/handoff.js +57 -0
- package/src/index.js +147 -23
- package/src/integrations/browser.js +30 -0
- package/src/mcp_inspect.js +96 -0
- package/src/mcp_server.js +32 -4
- package/src/model_compare.js +62 -1
- package/src/model_probes.js +146 -0
- package/src/remediation.js +85 -0
- package/src/secret_verify.js +96 -0
- package/src/skill_scan.js +97 -0
- package/src/tui.js +4 -17
- package/src/version.js +1 -1
- package/src/vision.js +42 -2
- package/src/vuln_templates.js +141 -0
- package/src/yaml_lite.js +103 -0
package/CHANGELOG.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to AegisAi Harness are documented here.
|
|
4
4
|
|
|
5
|
-
## [0.
|
|
5
|
+
## [0.79.0] - 2026-11-25
|
|
6
6
|
|
|
7
7
|
### Fixed
|
|
8
8
|
- Installation: Windows installer now preflights Node.js 22.13+ with actionable messages; launcher no longer hides npm failures, uses `--omit=dev`, and records a dependency marker. Inno uninstall removes stale `node_modules`/lockfiles; `install.ps1` preserves `data/` and handles GitHub source zips.
|
package/README.md
CHANGED
|
@@ -10,7 +10,7 @@ A **feature-rich, local-only AI agent harness** — OpenCode-class runtime, but
|
|
|
10
10
|
offline-first: no cloud dependencies, no telemetry. 66 milestones, ~200 modules,
|
|
11
11
|
257 tests, CI green.
|
|
12
12
|
|
|
13
|
-
> Status: v0.
|
|
13
|
+
> Status: v0.79.0 (see [ROADMAP.md](./ROADMAP.md)).
|
|
14
14
|
> **Successor to [aegisai-next](https://github.com/user6811992/aegisai-next)** — that project is deprecated; all features have been ported here.
|
|
15
15
|
> **Live docs:** https://user6811992.github.io/aegisai-harness/
|
|
16
16
|
|
package/ROADMAP.md
CHANGED
|
@@ -457,6 +457,140 @@ Feasibility: **H** = fits current JS architecture, **M** = needs external servic
|
|
|
457
457
|
- [x] Codex-style approval modes: suggest / auto-edit / full-auto — **H**
|
|
458
458
|
- [ ] Codex-style MCP server configuration patterns — **H** (covered)
|
|
459
459
|
|
|
460
|
+
## v0.78 — From nvidia, cloudflare, trufflesecurity, semgrep, cisco-talos, haydenschmitty, sandbox-quantum, plus re-scan of bytedance/openai/modelcontextprotocol
|
|
461
|
+
Feasibility: **H** = fits current JS architecture, **M** = needs external service/tool, **L** = native/platform-scale.
|
|
462
|
+
|
|
463
|
+
### LLM red-teaming (nvidia/garak)
|
|
464
|
+
- [ ] Model behaviour probe suite — hallucination, jailbreak, prompt-injection, data-leakage, toxicity probes run against the configured backend with scored pass/fail and a JSON report. Sits beside the existing code-pattern scanner (`vuln_scan`) and harness `adversarial` suite. — **H**
|
|
465
|
+
|
|
466
|
+
### Skill & plugin security (nvidia/SkillSpector)
|
|
467
|
+
- [ ] Dedicated skill scanner — extend `skill_eval` with SkillSpector-style rule classes: malicious patterns, prompt injection, data exfiltration intent, credential access, unsafe tool grants, obfuscation. Emit SARIF. — **H**
|
|
468
|
+
|
|
469
|
+
### Verified secret scanning (trufflesecurity/trufflehog)
|
|
470
|
+
- [ ] Detect **and verify** credentials — current tooling does regex/PII only. Add provider-aware verifiers (GitHub, Slack, AWS, Stripe, SendGrid, npm, OpenAI-style keys) that confirm liveness, with an explicit offline mode that reports `unverified`. — **H**
|
|
471
|
+
|
|
472
|
+
### Multi-phase security audit with independent verification (cloudflare/security-audit-skill)
|
|
473
|
+
- [ ] Audit pipeline upgrade — recon → candidate findings → **independent re-verification pass that drops false positives** → machine-readable SARIF/JSON with evidence per finding. Replaces the current single-pass `pentest_pipeline`. — **H**
|
|
474
|
+
|
|
475
|
+
### MCP testing & registry alignment (modelcontextprotocol/inspector, /registry)
|
|
476
|
+
- [ ] `mcp-inspect` command — deterministic MCP server tests: tool schema validity, error-path behaviour, resource/prompt round-trips, timeouts; machine-readable results. — **H**
|
|
477
|
+
- [ ] Align registry client with the official MCP registry API (`modelcontextprotocol/registry`) instead of the hand-rolled catalog. — **M**
|
|
478
|
+
|
|
479
|
+
### Cross-agent delegation (openai/codex-plugin-cc, openai/skills)
|
|
480
|
+
- [ ] External agent adapters — delegate a task to a locally installed `codex` / `claude` / `aider` CLI and capture the result as an evidence record. Complements `agents_as_tools` and `peer_review`. — **M**
|
|
481
|
+
- [ ] Codex skills catalog import — map the public skills catalog onto `skill_pkg`/`default_skills`. — **M**
|
|
482
|
+
|
|
483
|
+
### Visual grounding for computer use (bytedance/UI-TARS-desktop)
|
|
484
|
+
- [ ] Screenshot → vision → coordinate click — extend the CDP browser tools with `browser_screenshot`, `browser_click_at(x,y)` and a vision-model locator ("click the Submit button") using the existing `vision.js`. — **H**
|
|
485
|
+
|
|
486
|
+
### Plain-English architecture map (haydenschmitty/floorplan)
|
|
487
|
+
- [ ] Interactive architecture map page — render `code_map` as a navigable module/edge diagram in the web UI with plain-English summaries per module. — **H**
|
|
488
|
+
|
|
489
|
+
### Channels & trust (sandbox-quantum/switch, switch-trust-*)
|
|
490
|
+
- [ ] Microsoft Teams + Mattermost channel adapters — completes the IM set alongside Slack/Telegram/Discord/DingTalk/Feishu. — **M**
|
|
491
|
+
- [ ] Guardrail routing SDK surface — expose the guardrails/policy engine as a small documented JS API (`evaluate(tool, args)`) so external tools can reuse it. — **H**
|
|
492
|
+
- [ ] Project-wide symbol rename — LSP `rename` + apply-edits across the workspace. — **M**
|
|
493
|
+
|
|
494
|
+
### Malware & artifact hygiene (cisco-talos)
|
|
495
|
+
- [ ] Attachment malware scan — if `clamscan` is present, scan dropped/ingested files before the agent reads them; quarantine and report. — **M**
|
|
496
|
+
- [ ] Binary function similarity for RE — near-duplicate function detection across builds to support diffing patched binaries (feeds `re_index` / Ghidra workflow). — **M**
|
|
497
|
+
- [ ] Synthetic security log corpus (talos/EvidenceForge) — generated hunt datasets for testing `security_kb` and detection rules. — **H**
|
|
498
|
+
- [ ] IoC feed import (talos/IOCs) — load indicators into `security_kb` with hashes/domains/IPs for offline matching. — **H**
|
|
499
|
+
|
|
500
|
+
## v0.79 — From anthropics, openai, usestrix, projectdiscovery, microsoft, qybaihe
|
|
501
|
+
(`aquaticsecurity` returned 404 — org not found/renamed; nothing to mine.)
|
|
502
|
+
|
|
503
|
+
### Agent skills & plugins (anthropics/skills, claude-plugins-official)
|
|
504
|
+
- [ ] Align `SKILL.md` with the canonical Agent Skills schema (name, description, license, allowed-tools) and validate on import. — **H**
|
|
505
|
+
- [ ] Adopt the official plugin manifest shape for `plugin_marketplace` so third-party directories can be consumed. — **M**
|
|
506
|
+
- [ ] Domain plugin packs (legal/knowledge-work style bundles) as a first-class packaging unit. — **M**
|
|
507
|
+
|
|
508
|
+
### Multi-agent handoffs (openai/openai-agents-python)
|
|
509
|
+
- [ ] Handoff primitive — transfer the conversation (with context) from one agent to another, distinct from agents-as-tools. — **H**
|
|
510
|
+
|
|
511
|
+
### Pentest → remediation loop (usestrix/strix, usestrix/benchmarks)
|
|
512
|
+
- [ ] Remediation stage — after a finding, propose a patch, apply it in a worktree, re-run the probe to prove the fix, and record evidence. — **H**
|
|
513
|
+
- [ ] Pentest eval harness — deterministic target fixtures + expected findings, scored like `yasscore`. — **H**
|
|
514
|
+
- [ ] Package-install guard (supply-chain firewall) — policy check before `npm install`-style actions. — **M**
|
|
515
|
+
|
|
516
|
+
### Template-driven scanning & web recon (projectdiscovery)
|
|
517
|
+
- [ ] YAML template scanner (nuclei-style subset) — request templates with matchers/extractors, run against a target, emit SARIF. — **H**
|
|
518
|
+
- [ ] Endpoint crawler (katana-style) — crawl links + extract from JS, feed the pentest pipeline and `re_index`. — **H**
|
|
519
|
+
- [ ] HTTP probe tool (httpx-style) — status, title, headers, tech fingerprint for a list of URLs. — **H**
|
|
520
|
+
- [ ] OOB interaction channel (interactsh-style) for blind SSRF/XXE — needs an external collaborator or self-hosted listener. — **M**
|
|
521
|
+
- [ ] DNS/port enumeration adapters (subfinder/dnsx/naabu) behind the pentest profile. — **M**
|
|
522
|
+
|
|
523
|
+
### Document ingestion (microsoft/markitdown)
|
|
524
|
+
- [ ] Document → Markdown converter — PDF text, DOCX/XLSX/PPTX (OOXML zip+XML, zero deps), HTML, CSV; wire into attachments and `/api/file`. — **H**
|
|
525
|
+
- [ ] Playwright driver as an alternative browser backend to raw CDP. — **M**
|
|
526
|
+
|
|
527
|
+
### Cheap decision routing & generation skills (qybaihe/mu, codex-ppt)
|
|
528
|
+
- [ ] Tiny-model boolean router — route binary decisions (yes/no gates) to a small local model, with fallback to heuristics. — **H**
|
|
529
|
+
- [ ] Slide/deck skill — generate 16:9 PDF decks using the existing `pdf_writer`. — **H**
|
|
530
|
+
- [ ] Deterministic design-direction picker (hash-design pattern) — seeded choice among style presets for generated artifacts. — **L**
|
|
531
|
+
|
|
532
|
+
### Runtime defense for generated apps (qybaihe/bla)
|
|
533
|
+
- [ ] Opt-in guard injection for generated JS/TS/Electron apps (defensive scaffolding), reported as a build-time artefact. — **M**
|
|
534
|
+
|
|
535
|
+
|
|
536
|
+
### Batch 3 — next (v0.79)
|
|
537
|
+
| Item | Source | Feasibility |
|
|
538
|
+
|---|---|---|
|
|
539
|
+
| Model behaviour probe suite | nvidia/garak | H |
|
|
540
|
+
| Skill scanner rule classes + SARIF | nvidia/SkillSpector | H |
|
|
541
|
+
| Verified secret scanning | trufflesecurity/trufflehog | H |
|
|
542
|
+
| Multi-phase audit with independent verification | cloudflare/security-audit-skill | H |
|
|
543
|
+
| `mcp-inspect` deterministic MCP tests | modelcontextprotocol/inspector | H |
|
|
544
|
+
| Screenshot → vision → click | bytedance/UI-TARS-desktop | H |
|
|
545
|
+
| YAML template scanner (nuclei subset) | projectdiscovery/nuclei | H |
|
|
546
|
+
| Endpoint crawler | projectdiscovery/katana | H |
|
|
547
|
+
| Remediation loop (find → fix → re-verify) | usestrix/strix | H |
|
|
548
|
+
| Document → Markdown converter | microsoft/markitdown | H |
|
|
549
|
+
| Handoff primitive | openai/openai-agents-python | H |
|
|
550
|
+
| Conversation templates | prior backlog | H |
|
|
551
|
+
| Multi-model A/B across runs | prior backlog | H |
|
|
552
|
+
|
|
553
|
+
### Batch 4 — after
|
|
554
|
+
| Item | Source | Feasibility |
|
|
555
|
+
|---|---|---|
|
|
556
|
+
| HTTP probe tool (httpx-style) | projectdiscovery/httpx | H |
|
|
557
|
+
| Pentest eval harness | usestrix/benchmarks | H |
|
|
558
|
+
| Tiny-model boolean router | qybaihe/mu | H |
|
|
559
|
+
| Slide/deck skill (PDF) | qybaihe/codex-ppt | H |
|
|
560
|
+
| Canonical Agent Skills schema | anthropics/skills | H |
|
|
561
|
+
| Interactive architecture map page | haydenschmitty/floorplan | H |
|
|
562
|
+
| Guardrail routing API surface | sandbox-quantum/switch-trust | H |
|
|
563
|
+
| IoC feed import | cisco-talos/IOCs | H |
|
|
564
|
+
| Synthetic security log corpus | cisco-talos/EvidenceForge | H |
|
|
565
|
+
| Teams + Mattermost channels | sandbox-quantum/switch | M |
|
|
566
|
+
| External agent CLI adapters | openai/codex-plugin-cc | M |
|
|
567
|
+
| Official MCP registry alignment | modelcontextprotocol/registry | M |
|
|
568
|
+
| Codex skills catalog import | openai/skills | M |
|
|
569
|
+
| Attachment malware scan (`clamscan`) | cisco-talos/clamav | M |
|
|
570
|
+
| Project-wide symbol rename (LSP) | sandbox-quantum/bartleby | M |
|
|
571
|
+
| Binary function similarity | cisco-talos/binary_function_similarity | M |
|
|
572
|
+
| RAGFlow-style private retrieval | bytedance/deer-flow | M |
|
|
573
|
+
| Codex-style MCP config presets | openai/codex | H |
|
|
574
|
+
| Package-install guard | usestrix/firewall | M |
|
|
575
|
+
| OOB interaction channel | projectdiscovery/interactsh | M |
|
|
576
|
+
| DNS/port enumeration | projectdiscovery/subfinder+dnsx+naabu | M |
|
|
577
|
+
| Playwright browser driver | microsoft/playwright | M |
|
|
578
|
+
| Official plugin manifest | anthropics/claude-plugins-official | M |
|
|
579
|
+
| Domain plugin packs | anthropics/knowledge-work-plugins | M |
|
|
580
|
+
| Runtime defense scaffolding | qybaihe/bla | M |
|
|
581
|
+
| Plugin marketplace maturity | prior backlog | M |
|
|
582
|
+
| Mobile PWA polish | prior backlog | H |
|
|
583
|
+
|
|
584
|
+
### Batch 5 — polish / ecosystem
|
|
585
|
+
| Item | Source | Feasibility |
|
|
586
|
+
|---|---|---|
|
|
587
|
+
| Deterministic design-direction picker | qybaihe/hash-design | L |
|
|
588
|
+
| Community plugin ecosystem | prior backlog | ecosystem |
|
|
589
|
+
| Docs & tutorials | prior backlog | H |
|
|
590
|
+
| Performance optimization (large context) | prior backlog | H |
|
|
591
|
+
| Accessibility (ARIA, screen readers) | prior backlog | H |
|
|
592
|
+
| i18n | prior backlog | H |
|
|
593
|
+
|
|
460
594
|
## Non-goals
|
|
461
595
|
- Cloud-hosted backends as a requirement (local-first always).
|
|
462
596
|
- Telemetry or phone-home.
|
package/llms.txt
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# AegisAi Harness — agent-readable catalog
|
|
2
2
|
|
|
3
|
-
A feature-rich, local-only AI agent harness. CLI-first, offline-first. v0.
|
|
3
|
+
A feature-rich, local-only AI agent harness. CLI-first, offline-first. v0.79.0.
|
|
4
4
|
|
|
5
5
|
## Capabilities
|
|
6
6
|
- Multi-backend LLM adapter (Ollama + OpenAI-compatible + 18 providers)
|
package/package.json
CHANGED
|
@@ -4,13 +4,13 @@
|
|
|
4
4
|
[Setup]
|
|
5
5
|
AppId={{8F3D1B2A-6C4E-4B9A-9D21-AE615A010001}}
|
|
6
6
|
AppName=AegisAi Harness
|
|
7
|
-
AppVersion=0.
|
|
7
|
+
AppVersion=0.79.0
|
|
8
8
|
AppPublisher=AegisAi
|
|
9
9
|
AppPublisherURL=https://github.com/user6811992/aegisai-harness
|
|
10
10
|
DefaultDirName={autopf}\AegisAiHarness
|
|
11
11
|
DefaultGroupName=AegisAi Harness
|
|
12
12
|
OutputDir=..\..\dist
|
|
13
|
-
OutputBaseFilename=AegisAi-Harness-0.
|
|
13
|
+
OutputBaseFilename=AegisAi-Harness-0.79.0-Setup
|
|
14
14
|
Compression=lzma2
|
|
15
15
|
SolidCompression=yes
|
|
16
16
|
PrivilegesRequired=lowest
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
// scripts/repo-scan.js — list a GitHub org/user's top repos (public API).
|
|
2
|
+
const https = require('https');
|
|
3
|
+
function get(url) {
|
|
4
|
+
return new Promise((resolve, reject) => {
|
|
5
|
+
https.get(url, { headers: { 'User-Agent': 'aegisai-repo-scan', Accept: 'application/vnd.github+json' } }, (res) => {
|
|
6
|
+
let d = '';
|
|
7
|
+
res.on('data', (c) => { d += c; });
|
|
8
|
+
res.on('end', () => {
|
|
9
|
+
if (res.statusCode >= 400) return reject(new Error('HTTP ' + res.statusCode));
|
|
10
|
+
try { resolve(JSON.parse(d)); } catch (e) { reject(e); }
|
|
11
|
+
});
|
|
12
|
+
}).on('error', reject);
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
(async () => {
|
|
16
|
+
for (const u of process.argv.slice(2)) {
|
|
17
|
+
console.log('\n=== ' + u + ' ===');
|
|
18
|
+
try {
|
|
19
|
+
const repos = await get('https://api.github.com/users/' + u + '/repos?per_page=40&sort=updated');
|
|
20
|
+
const sorted = repos.slice().sort((a, b) => (b.stargazers_count || 0) - (a.stargazers_count || 0));
|
|
21
|
+
for (const r of sorted.slice(0, 10)) {
|
|
22
|
+
console.log(' ' + r.name + ' [*' + (r.stargazers_count || 0) + '] ' + (r.language || '-') + ' :: ' + (r.description || '').slice(0, 110));
|
|
23
|
+
}
|
|
24
|
+
} catch (e) { console.log(' error: ' + e.message); }
|
|
25
|
+
await new Promise((r) => setTimeout(r, 400));
|
|
26
|
+
}
|
|
27
|
+
})();
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
// src/audit_pipeline.js
|
|
2
|
+
// Multi-phase security audit: recon → candidate findings → INDEPENDENT verification → report.
|
|
3
|
+
// The verification pass re-derives each finding from scratch and drops anything it cannot
|
|
4
|
+
// reproduce, so single-pass false positives do not reach the report.
|
|
5
|
+
const fs = require('fs');
|
|
6
|
+
const path = require('path');
|
|
7
|
+
|
|
8
|
+
const PHASES = ['recon', 'candidates', 'verify', 'report'];
|
|
9
|
+
|
|
10
|
+
function walk(dir, files, depth) {
|
|
11
|
+
if ((depth || 0) > 8) return files;
|
|
12
|
+
let entries = [];
|
|
13
|
+
try { entries = fs.readdirSync(dir, { withFileTypes: true }); } catch (e) { return files; }
|
|
14
|
+
for (const e of entries) {
|
|
15
|
+
if (['node_modules', '.git', 'dist', 'build', 'coverage'].includes(e.name)) continue;
|
|
16
|
+
const p = path.join(dir, e.name);
|
|
17
|
+
if (e.isDirectory()) walk(p, files, (depth || 0) + 1);
|
|
18
|
+
else if (/\.(js|mjs|cjs|ts|tsx|jsx|py|go|rs|java|rb|php)$/i.test(e.name)) files.push(p);
|
|
19
|
+
}
|
|
20
|
+
return files;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
async function recon(root) {
|
|
24
|
+
const files = walk(root, [], 0);
|
|
25
|
+
const byExt = {};
|
|
26
|
+
for (const f of files) { const e = path.extname(f) || 'none'; byExt[e] = (byExt[e] || 0) + 1; }
|
|
27
|
+
return { root, files: files.length, byExt, languages: Object.keys(byExt) };
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
async function candidates(root) {
|
|
31
|
+
const out = [];
|
|
32
|
+
const secrets = require('./secret_verify');
|
|
33
|
+
const vuln = require('./vuln_scan');
|
|
34
|
+
const files = walk(root, [], 0);
|
|
35
|
+
for (const f of files.slice(0, 400)) {
|
|
36
|
+
let text = '';
|
|
37
|
+
try { text = fs.readFileSync(f, 'utf8'); } catch (e) { continue; }
|
|
38
|
+
if (text.length > 400000) continue;
|
|
39
|
+
// Candidate secrets (detection only; verification happens in the verify phase).
|
|
40
|
+
const s = await secrets.scan(text, { source: f, verify: false });
|
|
41
|
+
for (const x of s) out.push({ kind: 'secret', file: f, line: x.line, ruleId: x.ruleId, excerpt: x.redacted, raw: x.raw || null });
|
|
42
|
+
}
|
|
43
|
+
// Candidate code patterns via the existing scanner (it walks the tree itself).
|
|
44
|
+
try {
|
|
45
|
+
const v = vuln.scan(root);
|
|
46
|
+
for (const x of (v.findings || [])) {
|
|
47
|
+
out.push({ kind: 'code', file: path.resolve(root, x.file), line: x.line || 0, ruleId: 'vuln/' + String(x.label || 'pattern').toLowerCase().replace(/[^a-z0-9]+/g, '-'), excerpt: (x.code || '').slice(0, 160), raw: null, label: x.label });
|
|
48
|
+
}
|
|
49
|
+
} catch (e) {}
|
|
50
|
+
return out;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
// Independent verification: re-read the file and confirm the pattern still matches at
|
|
54
|
+
// the reported line. Anything that cannot be reproduced is dropped.
|
|
55
|
+
function verify(cands) {
|
|
56
|
+
const confirmed = [];
|
|
57
|
+
const dropped = [];
|
|
58
|
+
for (const c of cands) {
|
|
59
|
+
let text = '';
|
|
60
|
+
try { text = fs.readFileSync(c.file, 'utf8'); } catch (e) { dropped.push(Object.assign({ reason: 'file_unreadable' }, c)); continue; }
|
|
61
|
+
const lines = text.split(/\r?\n/);
|
|
62
|
+
const lineText = lines[(c.line || 1) - 1] || '';
|
|
63
|
+
const hay = c.kind === 'secret' ? c.excerpt : lineText;
|
|
64
|
+
let rule = null;
|
|
65
|
+
try {
|
|
66
|
+
if (c.kind === 'secret') {
|
|
67
|
+
const { PATTERNS } = require('./secret_verify');
|
|
68
|
+
rule = PATTERNS.find((p) => 'secret/' + p.id === c.ruleId);
|
|
69
|
+
} else {
|
|
70
|
+
const { RULES } = require('./skill_scan');
|
|
71
|
+
rule = RULES.find((r) => r.id === c.ruleId);
|
|
72
|
+
}
|
|
73
|
+
} catch (e) { rule = null; }
|
|
74
|
+
if (!rule && c.kind === 'code') {
|
|
75
|
+
// Unknown rule id: accept only if the recorded excerpt is still on the same line.
|
|
76
|
+
if (c.excerpt && lineText.includes(c.excerpt.slice(0, 40))) confirmed.push(Object.assign({ verified: true }, c));
|
|
77
|
+
else dropped.push(Object.assign({ reason: 'not_reproducible' }, c));
|
|
78
|
+
continue;
|
|
79
|
+
}
|
|
80
|
+
if (!rule) { dropped.push(Object.assign({ reason: 'rule_not_found' }, c)); continue; }
|
|
81
|
+
const re = new RegExp(rule.re.source, rule.re.flags.includes('g') ? rule.re.flags : rule.re.flags + 'g');
|
|
82
|
+
const target = c.kind === 'secret' ? text : lineText;
|
|
83
|
+
if (re.test(target)) confirmed.push(Object.assign({ verified: true }, c));
|
|
84
|
+
else dropped.push(Object.assign({ reason: 'not_reproducible' }, c));
|
|
85
|
+
}
|
|
86
|
+
return { confirmed, dropped };
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
async function run(root, opts) {
|
|
90
|
+
opts = opts || {};
|
|
91
|
+
const started = Date.now();
|
|
92
|
+
const r = await recon(root);
|
|
93
|
+
const cands = await candidates(root);
|
|
94
|
+
const v = verify(cands);
|
|
95
|
+
const bySeverity = { critical: 0, high: 0, medium: 0, low: 0 };
|
|
96
|
+
for (const c of v.confirmed) {
|
|
97
|
+
const sev = /secret/.test(c.ruleId) ? 'high' : 'medium';
|
|
98
|
+
bySeverity[sev] += 1;
|
|
99
|
+
}
|
|
100
|
+
// Never leak raw secret material in reports.
|
|
101
|
+
const scrub = (c) => { const o = Object.assign({}, c); delete o.raw; return o; };
|
|
102
|
+
return {
|
|
103
|
+
root,
|
|
104
|
+
phases: PHASES,
|
|
105
|
+
recon: r,
|
|
106
|
+
candidates: cands.length,
|
|
107
|
+
confirmed: v.confirmed.map(scrub),
|
|
108
|
+
dropped: v.dropped.map(scrub),
|
|
109
|
+
summary: {
|
|
110
|
+
candidates: cands.length,
|
|
111
|
+
confirmed: v.confirmed.length,
|
|
112
|
+
dropped: v.dropped.length,
|
|
113
|
+
falsePositiveRate: cands.length ? +(v.dropped.length / cands.length).toFixed(3) : 0,
|
|
114
|
+
bySeverity,
|
|
115
|
+
verdict: bySeverity.critical || bySeverity.high ? 'fail' : v.confirmed.length ? 'warn' : 'pass',
|
|
116
|
+
},
|
|
117
|
+
duration: Date.now() - started,
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
function toSarif(report) {
|
|
122
|
+
return {
|
|
123
|
+
version: '2.1.0',
|
|
124
|
+
$schema: 'https://json.schemastore.org/sarif-2.1.0.json',
|
|
125
|
+
runs: [{
|
|
126
|
+
tool: { driver: { name: 'aegisai-audit' } },
|
|
127
|
+
results: report.confirmed.map((c) => ({
|
|
128
|
+
ruleId: c.ruleId,
|
|
129
|
+
level: /secret/.test(c.ruleId) ? 'error' : 'warning',
|
|
130
|
+
message: { text: (c.kind === 'secret' ? 'Confirmed secret: ' + c.excerpt : 'Confirmed pattern: ' + c.ruleId) },
|
|
131
|
+
locations: [{ physicalLocation: { artifactLocation: { uri: String(c.file).replace(/\\/g, '/') }, region: { startLine: c.line || 1 } } }],
|
|
132
|
+
properties: { verified: true },
|
|
133
|
+
})),
|
|
134
|
+
}],
|
|
135
|
+
};
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
module.exports = { PHASES, run, recon, candidates, verify, toSarif };
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
// src/conversation_templates.js
|
|
2
|
+
// Reusable prompt/workflow templates for the chat UI and REPL.
|
|
3
|
+
const fs = require('fs');
|
|
4
|
+
const path = require('path');
|
|
5
|
+
const { DATA_DIR } = require('./core/config');
|
|
6
|
+
|
|
7
|
+
const BUILTIN = [
|
|
8
|
+
{
|
|
9
|
+
id: 'code-review',
|
|
10
|
+
name: 'Code review',
|
|
11
|
+
category: 'code',
|
|
12
|
+
description: 'Review the current diff for correctness, security, and style.',
|
|
13
|
+
body: 'Review the current changes.\n\nFocus on:\n1. Correctness and edge cases\n2. Security (injection, secrets, unsafe paths)\n3. Consistency with the surrounding code\n4. Tests that should exist\n\nReport findings as a short list with file:line references, then a verdict.',
|
|
14
|
+
},
|
|
15
|
+
{
|
|
16
|
+
id: 'bug-triage',
|
|
17
|
+
name: 'Bug triage',
|
|
18
|
+
category: 'debug',
|
|
19
|
+
description: 'Reproduce, isolate, and propose a minimal fix.',
|
|
20
|
+
body: 'Help me triage this bug:\n\n{{symptom}}\n\n1. Restate the expected vs actual behaviour.\n2. List the most likely causes, cheapest to test first.\n3. Propose the smallest experiment that distinguishes them.\n4. Once confirmed, propose a minimal fix and a regression test.',
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
id: 'refactor',
|
|
24
|
+
name: 'Refactor safely',
|
|
25
|
+
category: 'code',
|
|
26
|
+
description: 'Refactor with a verification step after each change.',
|
|
27
|
+
body: 'Refactor {{target}} without changing behaviour.\n\nRules:\n- One logical change at a time.\n- Run the relevant tests after each step.\n- Stop and report if a step cannot be verified.\n\nFinish with a summary of what moved and why.',
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
id: 'test-plan',
|
|
31
|
+
name: 'Test plan',
|
|
32
|
+
category: 'quality',
|
|
33
|
+
description: 'Derive a test plan from a feature description.',
|
|
34
|
+
body: 'Produce a test plan for: {{feature}}\n\nInclude happy paths, boundary cases, failure modes, and the cheapest way to cover each. Mark which are unit vs integration.',
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
id: 'security-audit',
|
|
38
|
+
name: 'Security audit',
|
|
39
|
+
category: 'security',
|
|
40
|
+
description: 'Structured audit with verification of each finding.',
|
|
41
|
+
body: 'Audit {{target}} for security issues.\n\nPhases:\n1. Recon — map the entry points.\n2. Candidates — list suspected issues with evidence.\n3. Verify — re-check each candidate independently; drop anything you cannot reproduce.\n4. Report — only confirmed issues, each with file:line, impact, and a fix.',
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
id: 'docs',
|
|
45
|
+
name: 'Write docs',
|
|
46
|
+
category: 'docs',
|
|
47
|
+
description: 'Generate reference docs for a module.',
|
|
48
|
+
body: 'Write reference documentation for {{module}}.\n\nCover purpose, public API with signatures, configuration, failure modes, and one runnable example. Keep it terse.',
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
id: 'release-notes',
|
|
52
|
+
name: 'Release notes',
|
|
53
|
+
category: 'docs',
|
|
54
|
+
description: 'Summarise changes since a tag.',
|
|
55
|
+
body: 'Write release notes since {{tag}}.\n\nGroup into Added / Changed / Fixed / Security. One line per user-visible change. Call out breaking changes first.',
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
id: 'debug-runtime',
|
|
59
|
+
name: 'Runtime debugging',
|
|
60
|
+
category: 'debug',
|
|
61
|
+
description: 'Instrument, reproduce, then fix.',
|
|
62
|
+
body: 'Debug this runtime failure: {{error}}\n\n1. Reproduce it deterministically.\n2. Add the minimum instrumentation needed to see the state.\n3. Identify the first point where reality diverges from expectation.\n4. Fix that point only, then re-run.',
|
|
63
|
+
},
|
|
64
|
+
];
|
|
65
|
+
|
|
66
|
+
function dir() { return path.join(DATA_DIR, 'templates'); }
|
|
67
|
+
|
|
68
|
+
function list() {
|
|
69
|
+
const out = BUILTIN.map((t) => Object.assign({ builtin: true }, t));
|
|
70
|
+
try {
|
|
71
|
+
for (const f of fs.readdirSync(dir())) {
|
|
72
|
+
if (!f.endsWith('.json')) continue;
|
|
73
|
+
try {
|
|
74
|
+
const t = JSON.parse(fs.readFileSync(path.join(dir(), f), 'utf8'));
|
|
75
|
+
if (t && t.id) out.push(Object.assign({ builtin: false }, t));
|
|
76
|
+
} catch (e) {}
|
|
77
|
+
}
|
|
78
|
+
} catch (e) {}
|
|
79
|
+
return out;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
function get(id) {
|
|
83
|
+
const found = list().find((t) => t.id === id);
|
|
84
|
+
return found || null;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
function save(tpl) {
|
|
88
|
+
const id = String((tpl && (tpl.id || tpl.name)) || '').trim().toLowerCase().replace(/[^a-z0-9]+/g, '-').replace(/^-|-$/g, '');
|
|
89
|
+
if (!id) throw Object.assign(new Error('template id required'), { status: 400 });
|
|
90
|
+
const record = { id, name: tpl.name || id, category: tpl.category || 'custom', description: tpl.description || '', body: tpl.body || '' };
|
|
91
|
+
fs.mkdirSync(dir(), { recursive: true });
|
|
92
|
+
fs.writeFileSync(path.join(dir(), id + '.json'), JSON.stringify(record, null, 2));
|
|
93
|
+
return record;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
function remove(id) {
|
|
97
|
+
try { fs.unlinkSync(path.join(dir(), id + '.json')); return { ok: true, id }; }
|
|
98
|
+
catch (e) { return { ok: false, id, error: String(e.message || e) }; }
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
function render(id, vars) {
|
|
102
|
+
const t = get(id);
|
|
103
|
+
if (!t) return null;
|
|
104
|
+
const body = String(t.body || '').replace(/\{\{\s*(\w+)\s*\}\}/g, (m, k) => (vars && vars[k] != null ? vars[k] : m));
|
|
105
|
+
return Object.assign({}, t, { rendered: body });
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
module.exports = { BUILTIN, list, get, save, remove, render };
|
package/src/crawler.js
ADDED
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
// src/crawler.js
|
|
2
|
+
// Endpoint crawler (katana-style, bounded): follows links and extracts URLs/paths
|
|
3
|
+
// from HTML and JavaScript. Same-origin by default; no auth bypass, no fuzzing.
|
|
4
|
+
const MAX_PAGES_DEFAULT = 30;
|
|
5
|
+
|
|
6
|
+
function extractLinks(html, baseUrl) {
|
|
7
|
+
const out = new Set();
|
|
8
|
+
const push = (raw) => {
|
|
9
|
+
if (!raw) return;
|
|
10
|
+
let u;
|
|
11
|
+
try { u = new URL(raw, baseUrl); } catch (e) { return; }
|
|
12
|
+
if (u.protocol !== 'http:' && u.protocol !== 'https:') return;
|
|
13
|
+
out.add(u.origin + u.pathname + (u.search || ''));
|
|
14
|
+
};
|
|
15
|
+
const hrefRe = /(?:href|src|action)\s*=\s*["']([^"'#]+)["']/gi;
|
|
16
|
+
let m;
|
|
17
|
+
while ((m = hrefRe.exec(html)) !== null) push(m[1]);
|
|
18
|
+
// Absolute URLs anywhere in the document (catches JS fetch/axios targets).
|
|
19
|
+
const urlRe = /https?:\/\/[^\s"'`<>()\\]+/g;
|
|
20
|
+
while ((m = urlRe.exec(html)) !== null) push(m[0]);
|
|
21
|
+
// Relative API paths in JS strings.
|
|
22
|
+
const apiRe = /["'`](\/[A-Za-z0-9_\-./]{2,120})["'`]/g;
|
|
23
|
+
while ((m = apiRe.exec(html)) !== null) push(m[1]);
|
|
24
|
+
return Array.from(out);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
function sameOrigin(u, base) {
|
|
28
|
+
try { return new URL(u).origin === new URL(base).origin; } catch (e) { return false; }
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
async function crawl(startUrl, opts) {
|
|
32
|
+
opts = opts || {};
|
|
33
|
+
const maxPages = opts.maxPages || MAX_PAGES_DEFAULT;
|
|
34
|
+
const sameSiteOnly = opts.sameOrigin !== false;
|
|
35
|
+
const seen = new Set();
|
|
36
|
+
const queue = [startUrl];
|
|
37
|
+
const pages = [];
|
|
38
|
+
const endpoints = new Set();
|
|
39
|
+
while (queue.length && pages.length < maxPages) {
|
|
40
|
+
const url = queue.shift();
|
|
41
|
+
if (!url || seen.has(url)) continue;
|
|
42
|
+
if (sameSiteOnly && !sameOrigin(url, startUrl)) continue;
|
|
43
|
+
seen.add(url);
|
|
44
|
+
let res;
|
|
45
|
+
try {
|
|
46
|
+
res = await fetch(url, { signal: AbortSignal.timeout(opts.timeoutMs || 10000), redirect: 'follow', headers: { 'User-Agent': 'aegisai-crawler' } });
|
|
47
|
+
} catch (e) {
|
|
48
|
+
pages.push({ url, error: String((e && e.message) || e) });
|
|
49
|
+
continue;
|
|
50
|
+
}
|
|
51
|
+
const type = res.headers.get('content-type') || '';
|
|
52
|
+
let body = '';
|
|
53
|
+
try { body = await res.text(); } catch (e) { body = ''; }
|
|
54
|
+
const found = /text\/html|javascript|application\/json/i.test(type) ? extractLinks(body, url) : [];
|
|
55
|
+
for (const f of found) {
|
|
56
|
+
if (sameSiteOnly && !sameOrigin(f, startUrl)) continue;
|
|
57
|
+
if (new URL(f).pathname !== new URL(url).pathname) endpoints.add(f);
|
|
58
|
+
if (!seen.has(f) && queue.length + pages.length < maxPages * 3) queue.push(f);
|
|
59
|
+
}
|
|
60
|
+
pages.push({ url, status: res.status, contentType: type, bytes: body.length, links: found.length });
|
|
61
|
+
}
|
|
62
|
+
return {
|
|
63
|
+
startUrl,
|
|
64
|
+
pages,
|
|
65
|
+
endpoints: Array.from(endpoints).sort(),
|
|
66
|
+
summary: { pages: pages.length, endpoints: endpoints.size, errors: pages.filter((p) => p.error).length },
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
module.exports = { crawl, extractLinks, sameOrigin };
|