@aigis-ai/cli 2.0.2 → 2.1.1
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/README.md +94 -45
- package/bin/aigis.js +139 -8
- package/content/resolvers/triggers.json +363 -41
- package/content/skills/areas/audit-logging.md +33 -0
- package/content/skills/areas/bias-monitoring.md +34 -0
- package/content/skills/areas/confidence-scoring.md +23 -0
- package/content/skills/areas/data-integrity.md +25 -0
- package/content/skills/areas/eu-ai-act-art-13-deployer-transparency.md +133 -0
- package/content/skills/areas/eu-ai-act-art-50-transparency-disclosure.md +134 -0
- package/content/skills/areas/eu-ai-act-art-73-incident-reporting.md +149 -0
- package/content/skills/areas/eu-ai-act-art-9-risk-management.md +141 -0
- package/content/skills/areas/fallback-patterns.md +28 -0
- package/content/skills/areas/human-oversight.md +38 -0
- package/content/skills/areas/input-validation.md +27 -0
- package/content/skills/areas/monitoring.md +29 -0
- package/content/skills/areas/prompt-security.md +29 -0
- package/content/templates/eu-ai-act-annex-iv.md +193 -0
- package/docs/frontmatter-schema.md +75 -0
- package/docs/screenshots/README.md +17 -0
- package/docs/screenshots/agent-flow.png +0 -0
- package/docs/screenshots/setup.png +0 -0
- package/docs/screenshots/verify.png +0 -0
- package/lib/auto-verify.js +70 -1
- package/lib/build.js +101 -12
- package/lib/classify.js +8 -2
- package/lib/init.js +269 -5
- package/lib/jurisdiction.js +137 -0
- package/lib/report.js +331 -0
- package/package.json +1 -1
- package/scripts/area-controls-baseline.json +188 -0
- package/scripts/area-frontmatter.schema.json +61 -0
- package/scripts/validate-area-frontmatter.js +228 -0
- package/aigis-ai-cli-2.0.1.tgz +0 -0
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* v2.1 — Jurisdiction filtering for areas and brief content.
|
|
3
|
+
*
|
|
4
|
+
* The classify layer (lib/classify.js) is jurisdiction-blind: it produces
|
|
5
|
+
* the universe of conceptually-relevant areas given a trait set. The
|
|
6
|
+
* jurisdiction filter is applied at the consumer layer (CLI commands +
|
|
7
|
+
* brief assembly) to enforce: "show EU AI Act content only to EU users."
|
|
8
|
+
*
|
|
9
|
+
* Three pure functions:
|
|
10
|
+
* - getUserJurisdictions(traits)
|
|
11
|
+
* → Set of jurisdiction codes derived from `jurisdiction-*` traits
|
|
12
|
+
*
|
|
13
|
+
* - filterAreasByJurisdiction(areas, userJurisdictions)
|
|
14
|
+
* → Drops areas whose frontmatter declares a `jurisdiction:` list
|
|
15
|
+
* that does not intersect with userJurisdictions. Areas without
|
|
16
|
+
* a jurisdiction field are universal — kept regardless.
|
|
17
|
+
*
|
|
18
|
+
* - stripJurisdictionGatedSections(content, userJurisdictions)
|
|
19
|
+
* → Removes `## EU AI Act extensions` heading sections from area
|
|
20
|
+
* content when user is not in EU jurisdiction. Convention: that
|
|
21
|
+
* specific heading is the marker for jurisdiction-gated content
|
|
22
|
+
* inside otherwise-universal areas.
|
|
23
|
+
*
|
|
24
|
+
* No I/O. No global state. Same inputs → same outputs.
|
|
25
|
+
*/
|
|
26
|
+
|
|
27
|
+
const fs = require('fs');
|
|
28
|
+
const path = require('path');
|
|
29
|
+
const matter = require('gray-matter');
|
|
30
|
+
|
|
31
|
+
const AREAS_DIR = path.join(__dirname, '..', 'content', 'skills', 'areas');
|
|
32
|
+
|
|
33
|
+
// Map from trait id → jurisdiction code stored in frontmatter `jurisdiction:`.
|
|
34
|
+
// The trait `jurisdiction-eu` corresponds to the area frontmatter value `eu`.
|
|
35
|
+
// Add new mappings here as new jurisdictions are introduced.
|
|
36
|
+
const TRAIT_TO_JURISDICTION = {
|
|
37
|
+
'jurisdiction-eu': 'eu',
|
|
38
|
+
'jurisdiction-us-regulated': 'us-regulated',
|
|
39
|
+
// 'jurisdiction-global' deliberately omitted: it is a meta-trait declaring
|
|
40
|
+
// worldwide scope and does not gate any specific jurisdiction-tagged area.
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Derive the user's jurisdiction set from their resolved trait set.
|
|
45
|
+
* Returns a Set<string> of jurisdiction codes (matching what frontmatter
|
|
46
|
+
* `jurisdiction:` arrays use).
|
|
47
|
+
*/
|
|
48
|
+
function getUserJurisdictions(traits) {
|
|
49
|
+
const out = new Set();
|
|
50
|
+
for (const t of traits || []) {
|
|
51
|
+
const j = TRAIT_TO_JURISDICTION[t];
|
|
52
|
+
if (j) out.add(j);
|
|
53
|
+
}
|
|
54
|
+
return out;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Read an area's frontmatter `jurisdiction:` field. Returns:
|
|
59
|
+
* - null if the area has no jurisdiction field (universal)
|
|
60
|
+
* - Array<string> if it has one (gated)
|
|
61
|
+
* - null on missing file or parse failure (fail-open: don't drop areas
|
|
62
|
+
* because of an I/O quirk; classify already pulled them)
|
|
63
|
+
*/
|
|
64
|
+
function readAreaJurisdictions(areaId) {
|
|
65
|
+
try {
|
|
66
|
+
const filepath = path.join(AREAS_DIR, `${areaId}.md`);
|
|
67
|
+
if (!fs.existsSync(filepath)) return null;
|
|
68
|
+
const fm = matter(fs.readFileSync(filepath, 'utf8')).data;
|
|
69
|
+
if (!fm.jurisdiction) return null;
|
|
70
|
+
return Array.isArray(fm.jurisdiction) ? fm.jurisdiction : null;
|
|
71
|
+
} catch (_) {
|
|
72
|
+
return null;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* Filter an array of area ids by the user's jurisdiction set.
|
|
78
|
+
* - Areas with no `jurisdiction:` frontmatter field are kept (universal).
|
|
79
|
+
* - Areas with `jurisdiction:` are kept only if at least one of their
|
|
80
|
+
* declared jurisdictions is in userJurisdictions.
|
|
81
|
+
*
|
|
82
|
+
* Returns a new array preserving original order.
|
|
83
|
+
*/
|
|
84
|
+
function filterAreasByJurisdiction(areas, userJurisdictions) {
|
|
85
|
+
const userJ = userJurisdictions instanceof Set
|
|
86
|
+
? userJurisdictions
|
|
87
|
+
: new Set(userJurisdictions || []);
|
|
88
|
+
return areas.filter((area) => {
|
|
89
|
+
const declared = readAreaJurisdictions(area);
|
|
90
|
+
if (!declared) return true; // universal area
|
|
91
|
+
return declared.some((j) => userJ.has(j));
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* Convention-based filter: removes the `## EU AI Act extensions` heading
|
|
97
|
+
* section (and everything beneath it until the next `## ` heading or EOF)
|
|
98
|
+
* from area content when the user is not in EU jurisdiction.
|
|
99
|
+
*
|
|
100
|
+
* If user IS in EU jurisdiction, content is returned unchanged.
|
|
101
|
+
*
|
|
102
|
+
* Used by brief assembly when inlining existing-area content for
|
|
103
|
+
* non-EU users — strips the EU-specific extension while preserving the
|
|
104
|
+
* universal procedure.
|
|
105
|
+
*/
|
|
106
|
+
function stripJurisdictionGatedSections(content, userJurisdictions) {
|
|
107
|
+
const userJ = userJurisdictions instanceof Set
|
|
108
|
+
? userJurisdictions
|
|
109
|
+
: new Set(userJurisdictions || []);
|
|
110
|
+
if (userJ.has('eu')) return content; // EU user — keep the section
|
|
111
|
+
// Line-by-line walker: enter "skip mode" on `## EU AI Act extensions`,
|
|
112
|
+
// exit when the next `## ` heading appears (any other H2). Handles both
|
|
113
|
+
// mid-document and EOF cases without relying on `\Z` (Python-only).
|
|
114
|
+
const lines = content.split('\n');
|
|
115
|
+
const out = [];
|
|
116
|
+
let inEuSection = false;
|
|
117
|
+
for (const line of lines) {
|
|
118
|
+
if (/^## EU AI Act extensions\s*$/.test(line)) {
|
|
119
|
+
inEuSection = true;
|
|
120
|
+
continue;
|
|
121
|
+
}
|
|
122
|
+
if (inEuSection && /^## /.test(line)) {
|
|
123
|
+
inEuSection = false;
|
|
124
|
+
}
|
|
125
|
+
if (!inEuSection) out.push(line);
|
|
126
|
+
}
|
|
127
|
+
// Collapse 3+ consecutive newlines down to 2 (cleanup after removal).
|
|
128
|
+
return out.join('\n').replace(/\n{3,}/g, '\n\n');
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
module.exports = {
|
|
132
|
+
TRAIT_TO_JURISDICTION,
|
|
133
|
+
getUserJurisdictions,
|
|
134
|
+
readAreaJurisdictions,
|
|
135
|
+
filterAreasByJurisdiction,
|
|
136
|
+
stripJurisdictionGatedSections,
|
|
137
|
+
};
|
package/lib/report.js
ADDED
|
@@ -0,0 +1,331 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* v2.1 — `aigis report` audit-ready compliance documentation.
|
|
3
|
+
*
|
|
4
|
+
* Compiles a structured audit report from `aigis verify --auto` results across
|
|
5
|
+
* one or more areas. Output is the multi-framework traceability artifact:
|
|
6
|
+
* for each area, what was implemented, what verified, what evidence exists,
|
|
7
|
+
* and which framework controls (OWASP, NIST, ISO 42001, EU AI Act) the
|
|
8
|
+
* implementation satisfies.
|
|
9
|
+
*
|
|
10
|
+
* Entry points:
|
|
11
|
+
* - buildReport({ projectDir, areas, jurisdictions, version, timestamp })
|
|
12
|
+
* → structured report object (no I/O for output; caller renders)
|
|
13
|
+
* - formatReportMarkdown(reportObj)
|
|
14
|
+
* → audit-ready markdown
|
|
15
|
+
* - formatReportJSON(reportObj)
|
|
16
|
+
* → JSON.stringify-able tree
|
|
17
|
+
*
|
|
18
|
+
* Aigis writes nothing into the user's source code. The report is OUTPUT,
|
|
19
|
+
* intended for the user to write to a file (via shell redirect or --output)
|
|
20
|
+
* and submit/file as part of audit prep. This is consistent with the v2.0
|
|
21
|
+
* principle: Aigis produces text; the user/agent decides what to do with it.
|
|
22
|
+
*
|
|
23
|
+
* No LLM calls. No external HTTP. Deterministic — same project + same options
|
|
24
|
+
* (modulo timestamp) produces identical report.
|
|
25
|
+
*/
|
|
26
|
+
|
|
27
|
+
const fs = require('fs');
|
|
28
|
+
const path = require('path');
|
|
29
|
+
const matter = require('gray-matter');
|
|
30
|
+
const { autoVerifyArea } = require('./auto-verify');
|
|
31
|
+
|
|
32
|
+
const AREAS_DIR = path.join(__dirname, '..', 'content', 'skills', 'areas');
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Run verify on each requested area, aggregate into a structured report tree.
|
|
36
|
+
*
|
|
37
|
+
* @param {Object} opts
|
|
38
|
+
* @param {string} opts.projectDir — absolute path to project to verify
|
|
39
|
+
* @param {string[]} opts.areas — area ids to evaluate
|
|
40
|
+
* @param {string[]} opts.jurisdictions — e.g. ['eu']; gates EU AI Act citations
|
|
41
|
+
* @param {string} opts.version — aigis version string for the report header
|
|
42
|
+
* @param {Date} opts.timestamp — injectable for tests
|
|
43
|
+
* @returns {Object} report tree
|
|
44
|
+
*/
|
|
45
|
+
function buildReport({ projectDir, areas, jurisdictions = [], version = null, timestamp = null } = {}) {
|
|
46
|
+
if (!projectDir) throw new Error('buildReport: projectDir is required');
|
|
47
|
+
if (!Array.isArray(areas) || areas.length === 0) {
|
|
48
|
+
throw new Error('buildReport: areas must be a non-empty array of area ids');
|
|
49
|
+
}
|
|
50
|
+
const ts = (timestamp || new Date()).toISOString();
|
|
51
|
+
const ver = version || readPackageVersion();
|
|
52
|
+
|
|
53
|
+
const perArea = [];
|
|
54
|
+
let aggOwasp = new Set();
|
|
55
|
+
let aggNist = new Set();
|
|
56
|
+
let aggIso = new Set();
|
|
57
|
+
let aggEu = new Set();
|
|
58
|
+
let totalAutoPass = 0, totalAutoFail = 0, totalOverclaims = 0, totalJudgment = 0;
|
|
59
|
+
let areasFullyPassing = 0;
|
|
60
|
+
|
|
61
|
+
for (const area of areas) {
|
|
62
|
+
let result;
|
|
63
|
+
try {
|
|
64
|
+
result = autoVerifyArea(area, projectDir, { jurisdictions });
|
|
65
|
+
} catch (e) {
|
|
66
|
+
perArea.push({
|
|
67
|
+
area,
|
|
68
|
+
status: 'ERROR',
|
|
69
|
+
error: e.message,
|
|
70
|
+
cited_controls: null,
|
|
71
|
+
auto_checks: {},
|
|
72
|
+
overclaim_checks: {},
|
|
73
|
+
judgment_checks: {},
|
|
74
|
+
evidence: [],
|
|
75
|
+
});
|
|
76
|
+
continue;
|
|
77
|
+
}
|
|
78
|
+
const s = result.summary;
|
|
79
|
+
const status = s.auto_fail === 0 && s.overclaims_raised === 0
|
|
80
|
+
? (s.auto_total > 0 ? 'PASS' : 'NO_CHECKS')
|
|
81
|
+
: (s.auto_pass > 0 ? 'PARTIAL' : 'FAIL');
|
|
82
|
+
if (status === 'PASS') areasFullyPassing++;
|
|
83
|
+
|
|
84
|
+
// Aggregate cited controls.
|
|
85
|
+
if (result.cited_controls) {
|
|
86
|
+
for (const v of result.cited_controls.owasp) aggOwasp.add(v);
|
|
87
|
+
for (const v of result.cited_controls.nist) aggNist.add(v);
|
|
88
|
+
for (const v of result.cited_controls.iso42001) aggIso.add(v);
|
|
89
|
+
for (const v of result.cited_controls.eu_ai_act) aggEu.add(v);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
totalAutoPass += s.auto_pass;
|
|
93
|
+
totalAutoFail += s.auto_fail;
|
|
94
|
+
totalOverclaims += s.overclaims_raised;
|
|
95
|
+
totalJudgment += s.judgment_required;
|
|
96
|
+
|
|
97
|
+
// Collect evidence — file:line snippets from PASS auto checks.
|
|
98
|
+
const evidence = [];
|
|
99
|
+
for (const [checkId, r] of Object.entries(result.auto_checks)) {
|
|
100
|
+
if (r.status !== 'PASS') continue;
|
|
101
|
+
for (const e of (r.evidence || []).slice(0, 3)) {
|
|
102
|
+
evidence.push({ check_id: checkId, file: e.file, line: e.line, snippet: e.snippet });
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
perArea.push({
|
|
107
|
+
area,
|
|
108
|
+
title: readAreaTitle(area),
|
|
109
|
+
status,
|
|
110
|
+
summary: s,
|
|
111
|
+
cited_controls: result.cited_controls,
|
|
112
|
+
auto_checks: result.auto_checks,
|
|
113
|
+
overclaim_checks: result.overclaim_checks,
|
|
114
|
+
judgment_checks: result.judgment_checks,
|
|
115
|
+
evidence,
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
return {
|
|
120
|
+
generated_at: ts,
|
|
121
|
+
aigis_version: ver,
|
|
122
|
+
project_dir: projectDir,
|
|
123
|
+
user_jurisdictions: [...(jurisdictions || [])].sort(),
|
|
124
|
+
areas_requested: [...areas],
|
|
125
|
+
summary: {
|
|
126
|
+
areas_evaluated: areas.length,
|
|
127
|
+
areas_fully_passing: areasFullyPassing,
|
|
128
|
+
total_auto_pass: totalAutoPass,
|
|
129
|
+
total_auto_fail: totalAutoFail,
|
|
130
|
+
total_overclaims_raised: totalOverclaims,
|
|
131
|
+
total_judgment_required: totalJudgment,
|
|
132
|
+
cross_framework_coverage: {
|
|
133
|
+
owasp_count: aggOwasp.size,
|
|
134
|
+
nist_count: aggNist.size,
|
|
135
|
+
iso42001_count: aggIso.size,
|
|
136
|
+
eu_ai_act_count: aggEu.size,
|
|
137
|
+
},
|
|
138
|
+
cross_framework_citations: {
|
|
139
|
+
owasp: [...aggOwasp].sort(),
|
|
140
|
+
nist: [...aggNist].sort(),
|
|
141
|
+
iso42001: [...aggIso].sort(),
|
|
142
|
+
eu_ai_act: [...aggEu].sort(),
|
|
143
|
+
},
|
|
144
|
+
},
|
|
145
|
+
per_area: perArea,
|
|
146
|
+
};
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
/** Format the structured report as audit-ready markdown. */
|
|
150
|
+
function formatReportMarkdown(report) {
|
|
151
|
+
const L = [];
|
|
152
|
+
L.push(`# Aigis Compliance Report`);
|
|
153
|
+
L.push('');
|
|
154
|
+
L.push(`> Generated: ${report.generated_at}`);
|
|
155
|
+
L.push(`> Aigis version: ${report.aigis_version}`);
|
|
156
|
+
L.push(`> Project: \`${report.project_dir}\``);
|
|
157
|
+
if (report.user_jurisdictions.length > 0) {
|
|
158
|
+
L.push(`> Jurisdictions in scope: ${report.user_jurisdictions.join(', ')}`);
|
|
159
|
+
} else {
|
|
160
|
+
L.push(`> Jurisdictions in scope: (none — pass \`--jurisdiction eu\` to surface EU AI Act citations)`);
|
|
161
|
+
}
|
|
162
|
+
L.push('');
|
|
163
|
+
L.push(`> *This report is content output. Aigis writes nothing into your source code. The agent and the user remain responsible for what is submitted to auditors.*`);
|
|
164
|
+
L.push('');
|
|
165
|
+
|
|
166
|
+
// ── Summary ─────────────────────────────────────────────────────────────
|
|
167
|
+
const s = report.summary;
|
|
168
|
+
L.push(`## Summary`);
|
|
169
|
+
L.push('');
|
|
170
|
+
L.push(`- Areas evaluated: **${s.areas_evaluated}**`);
|
|
171
|
+
L.push(`- Areas fully passing (no FAIL, no OVERCLAIM): **${s.areas_fully_passing} / ${s.areas_evaluated}**`);
|
|
172
|
+
L.push(`- Auto-checks: **${s.total_auto_pass} PASS, ${s.total_auto_fail} FAIL** across all areas`);
|
|
173
|
+
L.push(`- Overclaim recognizers raised: **${s.total_overclaims_raised}**`);
|
|
174
|
+
L.push(`- Judgment items requiring agent/human review: **${s.total_judgment_required}**`);
|
|
175
|
+
L.push('');
|
|
176
|
+
L.push(`### Cross-framework coverage`);
|
|
177
|
+
L.push('');
|
|
178
|
+
L.push(`| Framework | Citations across all areas |`);
|
|
179
|
+
L.push(`|---|---:|`);
|
|
180
|
+
L.push(`| OWASP LLM Top 10 | ${s.cross_framework_coverage.owasp_count} |`);
|
|
181
|
+
L.push(`| NIST AI RMF | ${s.cross_framework_coverage.nist_count} |`);
|
|
182
|
+
L.push(`| ISO/IEC 42001 | ${s.cross_framework_coverage.iso42001_count} |`);
|
|
183
|
+
L.push(`| EU AI Act | ${s.cross_framework_coverage.eu_ai_act_count}${report.user_jurisdictions.includes('eu') ? '' : ' _(not surfaced — no EU jurisdiction)_'} |`);
|
|
184
|
+
L.push('');
|
|
185
|
+
|
|
186
|
+
// ── Per-area results ────────────────────────────────────────────────────
|
|
187
|
+
L.push(`## Per-area results`);
|
|
188
|
+
L.push('');
|
|
189
|
+
for (const a of report.per_area) {
|
|
190
|
+
L.push(`### ${a.area}`);
|
|
191
|
+
if (a.title) L.push(`*${a.title}*`);
|
|
192
|
+
L.push('');
|
|
193
|
+
if (a.status === 'ERROR') {
|
|
194
|
+
L.push(`**Status: ERROR** — ${a.error}`);
|
|
195
|
+
L.push('');
|
|
196
|
+
continue;
|
|
197
|
+
}
|
|
198
|
+
L.push(`**Status: ${a.status}**`);
|
|
199
|
+
L.push('');
|
|
200
|
+
L.push(`Verify breakdown: ${a.summary.auto_pass}/${a.summary.auto_total} auto checks PASS, ${a.summary.overclaims_raised} overclaims raised, ${a.summary.judgment_required} judgment item${a.summary.judgment_required === 1 ? '' : 's'}`);
|
|
201
|
+
L.push('');
|
|
202
|
+
|
|
203
|
+
// Cited controls
|
|
204
|
+
if (a.cited_controls) {
|
|
205
|
+
const c = a.cited_controls;
|
|
206
|
+
const total = c.owasp.length + c.nist.length + c.iso42001.length + c.eu_ai_act.length;
|
|
207
|
+
if (total > 0) {
|
|
208
|
+
L.push(`**Controls in scope:**`);
|
|
209
|
+
if (c.owasp.length > 0) L.push(`- OWASP LLM Top 10: ${c.owasp.map((v) => `\`${v}\``).join(', ')}`);
|
|
210
|
+
if (c.nist.length > 0) L.push(`- NIST AI RMF: ${c.nist.map((v) => `\`${v}\``).join(', ')}`);
|
|
211
|
+
if (c.iso42001.length > 0) L.push(`- ISO/IEC 42001: ${c.iso42001.map((v) => `\`${v}\``).join(', ')}`);
|
|
212
|
+
if (c.eu_ai_act.length > 0) L.push(`- EU AI Act: ${c.eu_ai_act.map((v) => `\`${v}\``).join(', ')}`);
|
|
213
|
+
L.push('');
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
// Evidence
|
|
218
|
+
if (a.evidence.length > 0) {
|
|
219
|
+
L.push(`**Evidence (file:line excerpts from PASS checks, max 3 per check):**`);
|
|
220
|
+
L.push('');
|
|
221
|
+
for (const e of a.evidence) {
|
|
222
|
+
const snippet = e.snippet.length > 120 ? e.snippet.slice(0, 117) + '…' : e.snippet;
|
|
223
|
+
L.push(`- \`${e.check_id}\` — \`${e.file}:${e.line}\` — \`${snippet.replace(/`/g, '\\`')}\``);
|
|
224
|
+
}
|
|
225
|
+
L.push('');
|
|
226
|
+
} else if (a.summary.auto_pass > 0) {
|
|
227
|
+
L.push(`*Evidence collected but not surfaced here (PASS checks without grep-able evidence — e.g. config-file presence checks).*`);
|
|
228
|
+
L.push('');
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
// Open gaps for this area
|
|
232
|
+
const fails = Object.entries(a.auto_checks).filter(([, r]) => r.status === 'FAIL');
|
|
233
|
+
const overclaims = Object.entries(a.overclaim_checks).filter(([, r]) => r.raised);
|
|
234
|
+
if (fails.length > 0 || overclaims.length > 0) {
|
|
235
|
+
L.push(`**Open items in this area:**`);
|
|
236
|
+
L.push('');
|
|
237
|
+
for (const [id, r] of fails) {
|
|
238
|
+
L.push(`- ❌ FAIL \`${id}\` — ${r.desc || ''}`);
|
|
239
|
+
}
|
|
240
|
+
for (const [id, r] of overclaims) {
|
|
241
|
+
L.push(`- ⚠ OVERCLAIM \`${id}\` — ${r.desc || ''} _(recognizer: ${r.recognizer})_`);
|
|
242
|
+
}
|
|
243
|
+
L.push('');
|
|
244
|
+
}
|
|
245
|
+
L.push('---');
|
|
246
|
+
L.push('');
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
// ── Aggregated open gaps section ────────────────────────────────────────
|
|
250
|
+
const allFails = [];
|
|
251
|
+
const allOverclaims = [];
|
|
252
|
+
for (const a of report.per_area) {
|
|
253
|
+
for (const [id, r] of Object.entries(a.auto_checks || {})) {
|
|
254
|
+
if (r.status === 'FAIL') allFails.push({ area: a.area, id, desc: r.desc });
|
|
255
|
+
}
|
|
256
|
+
for (const [id, r] of Object.entries(a.overclaim_checks || {})) {
|
|
257
|
+
if (r.raised) allOverclaims.push({ area: a.area, id, desc: r.desc, recognizer: r.recognizer });
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
if (allFails.length > 0 || allOverclaims.length > 0) {
|
|
261
|
+
L.push(`## Aggregated open gaps`);
|
|
262
|
+
L.push('');
|
|
263
|
+
if (allFails.length > 0) {
|
|
264
|
+
L.push(`### FAIL (${allFails.length})`);
|
|
265
|
+
L.push('');
|
|
266
|
+
for (const f of allFails) {
|
|
267
|
+
L.push(`- **\`${f.area}\` / \`${f.id}\`** — ${f.desc || ''}`);
|
|
268
|
+
}
|
|
269
|
+
L.push('');
|
|
270
|
+
}
|
|
271
|
+
if (allOverclaims.length > 0) {
|
|
272
|
+
L.push(`### OVERCLAIM (${allOverclaims.length})`);
|
|
273
|
+
L.push('');
|
|
274
|
+
for (const o of allOverclaims) {
|
|
275
|
+
L.push(`- **\`${o.area}\` / \`${o.id}\`** — ${o.desc || ''} _(recognizer: ${o.recognizer})_`);
|
|
276
|
+
}
|
|
277
|
+
L.push('');
|
|
278
|
+
}
|
|
279
|
+
} else {
|
|
280
|
+
L.push(`## Aggregated open gaps`);
|
|
281
|
+
L.push('');
|
|
282
|
+
L.push(`_No FAIL or OVERCLAIM signals across the evaluated areas._`);
|
|
283
|
+
L.push('');
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
// ── Methodology ─────────────────────────────────────────────────────────
|
|
287
|
+
L.push(`## Methodology`);
|
|
288
|
+
L.push('');
|
|
289
|
+
L.push(`This report was generated by \`aigis report\` (v${report.aigis_version}) running deterministic regex-based scanners (\`aigis verify <area> --auto\`) against the project at \`${report.project_dir}\`.`);
|
|
290
|
+
L.push('');
|
|
291
|
+
L.push(`- **Scanner**: heuristic regex patterns over project source files. Matches drive PASS / FAIL. See \`content/index/auto-verify-rules.json\` for the rule definitions.`);
|
|
292
|
+
L.push(`- **Overclaim recognizers**: targeted detectors for known anti-patterns (e.g. kill switches that re-arm on restart). When raised, the literal check passes but a stricter operational bar may not.`);
|
|
293
|
+
L.push(`- **Judgment items**: not auto-gradable. The agent (or auditor) must evaluate.`);
|
|
294
|
+
L.push(`- **Cross-framework citations**: each area's \`controls\` frontmatter declares which OWASP / NIST / ISO 42001 / EU AI Act controls it satisfies. Citations are surfaced when the area's auto checks PASS (or PARTIAL — flagged accordingly).`);
|
|
295
|
+
L.push(`- **Jurisdiction gating**: EU AI Act citations are only surfaced when \`--jurisdiction eu\` was passed. This report's "Jurisdictions in scope" header documents what was requested.`);
|
|
296
|
+
L.push(`- **Determinism**: same project + same options + same Aigis version produces byte-identical reports (modulo the timestamp line).`);
|
|
297
|
+
L.push('');
|
|
298
|
+
L.push(`This report is content output. It is not a certification. EU AI Act conformity assessment requires notified-body involvement; this report is preparation material.`);
|
|
299
|
+
L.push('');
|
|
300
|
+
|
|
301
|
+
return L.join('\n');
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
function formatReportJSON(report) {
|
|
305
|
+
return JSON.stringify(report, null, 2);
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
function readAreaTitle(areaId) {
|
|
309
|
+
try {
|
|
310
|
+
const filepath = path.join(AREAS_DIR, `${areaId}.md`);
|
|
311
|
+
if (!fs.existsSync(filepath)) return null;
|
|
312
|
+
const fm = matter(fs.readFileSync(filepath, 'utf8')).data;
|
|
313
|
+
return fm.title || null;
|
|
314
|
+
} catch (_) {
|
|
315
|
+
return null;
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
let _cachedVersion = null;
|
|
320
|
+
function readPackageVersion() {
|
|
321
|
+
if (_cachedVersion) return _cachedVersion;
|
|
322
|
+
try {
|
|
323
|
+
const pkg = JSON.parse(fs.readFileSync(path.join(__dirname, '..', 'package.json'), 'utf8'));
|
|
324
|
+
_cachedVersion = pkg.version || 'unknown';
|
|
325
|
+
} catch (_) {
|
|
326
|
+
_cachedVersion = 'unknown';
|
|
327
|
+
}
|
|
328
|
+
return _cachedVersion;
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
module.exports = { buildReport, formatReportMarkdown, formatReportJSON };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aigis-ai/cli",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.1.1",
|
|
4
4
|
"description": "AI governance guardrails for coding agents. Framework-aligned security and compliance patterns from NIST AI RMF, OWASP Top 10 for LLMs, and ISO/IEC 42001.",
|
|
5
5
|
"main": "bin/aigis.js",
|
|
6
6
|
"bin": {
|
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
{
|
|
2
|
+
"audit-logging": {
|
|
3
|
+
"owasp": [],
|
|
4
|
+
"nist": [
|
|
5
|
+
"MEASURE-2.8",
|
|
6
|
+
"MANAGE-4.1",
|
|
7
|
+
"MANAGE-4.3"
|
|
8
|
+
],
|
|
9
|
+
"iso42001": [
|
|
10
|
+
"Clause-9.1",
|
|
11
|
+
"Annex-A.6"
|
|
12
|
+
]
|
|
13
|
+
},
|
|
14
|
+
"bias-monitoring": {
|
|
15
|
+
"owasp": [],
|
|
16
|
+
"nist": [
|
|
17
|
+
"MAP-2.3",
|
|
18
|
+
"MEASURE-2.11",
|
|
19
|
+
"MEASURE-3.1"
|
|
20
|
+
],
|
|
21
|
+
"iso42001": [
|
|
22
|
+
"Clause-6.1",
|
|
23
|
+
"Annex-C"
|
|
24
|
+
]
|
|
25
|
+
},
|
|
26
|
+
"confidence-scoring": {
|
|
27
|
+
"owasp": [
|
|
28
|
+
"LLM09"
|
|
29
|
+
],
|
|
30
|
+
"nist": [
|
|
31
|
+
"MAP-2.2",
|
|
32
|
+
"MEASURE-2.5",
|
|
33
|
+
"MEASURE-2.9"
|
|
34
|
+
],
|
|
35
|
+
"iso42001": [
|
|
36
|
+
"Annex-A.8"
|
|
37
|
+
]
|
|
38
|
+
},
|
|
39
|
+
"data-integrity": {
|
|
40
|
+
"owasp": [
|
|
41
|
+
"LLM04"
|
|
42
|
+
],
|
|
43
|
+
"nist": [
|
|
44
|
+
"MAP-2.3",
|
|
45
|
+
"MEASURE-2.6"
|
|
46
|
+
],
|
|
47
|
+
"iso42001": [
|
|
48
|
+
"Annex-A.7"
|
|
49
|
+
]
|
|
50
|
+
},
|
|
51
|
+
"explainability": {
|
|
52
|
+
"owasp": [],
|
|
53
|
+
"nist": [
|
|
54
|
+
"MEASURE-2.8",
|
|
55
|
+
"MEASURE-2.9"
|
|
56
|
+
],
|
|
57
|
+
"iso42001": [
|
|
58
|
+
"Annex-A.8",
|
|
59
|
+
"Clause-7.4"
|
|
60
|
+
]
|
|
61
|
+
},
|
|
62
|
+
"fallback-patterns": {
|
|
63
|
+
"owasp": [],
|
|
64
|
+
"nist": [
|
|
65
|
+
"MEASURE-2.6",
|
|
66
|
+
"MANAGE-2.3",
|
|
67
|
+
"MANAGE-2.4"
|
|
68
|
+
],
|
|
69
|
+
"iso42001": [
|
|
70
|
+
"Clause-8.2"
|
|
71
|
+
]
|
|
72
|
+
},
|
|
73
|
+
"human-oversight": {
|
|
74
|
+
"owasp": [
|
|
75
|
+
"LLM06"
|
|
76
|
+
],
|
|
77
|
+
"nist": [
|
|
78
|
+
"MAP-3.5",
|
|
79
|
+
"MANAGE-1.3",
|
|
80
|
+
"MANAGE-4.1"
|
|
81
|
+
],
|
|
82
|
+
"iso42001": [
|
|
83
|
+
"Annex-A.9",
|
|
84
|
+
"Clause-8.4"
|
|
85
|
+
]
|
|
86
|
+
},
|
|
87
|
+
"input-validation": {
|
|
88
|
+
"owasp": [
|
|
89
|
+
"LLM01"
|
|
90
|
+
],
|
|
91
|
+
"nist": [
|
|
92
|
+
"MEASURE-2.7",
|
|
93
|
+
"MANAGE-1.3"
|
|
94
|
+
],
|
|
95
|
+
"iso42001": [
|
|
96
|
+
"Clause-8.2",
|
|
97
|
+
"Annex-A.6"
|
|
98
|
+
]
|
|
99
|
+
},
|
|
100
|
+
"monitoring": {
|
|
101
|
+
"owasp": [],
|
|
102
|
+
"nist": [
|
|
103
|
+
"MEASURE-2.4",
|
|
104
|
+
"MEASURE-3.1",
|
|
105
|
+
"MANAGE-4.1",
|
|
106
|
+
"MANAGE-4.2"
|
|
107
|
+
],
|
|
108
|
+
"iso42001": [
|
|
109
|
+
"Clause-9.1",
|
|
110
|
+
"Clause-10"
|
|
111
|
+
]
|
|
112
|
+
},
|
|
113
|
+
"output-sanitization": {
|
|
114
|
+
"owasp": [
|
|
115
|
+
"LLM05"
|
|
116
|
+
],
|
|
117
|
+
"nist": [
|
|
118
|
+
"MEASURE-2.6",
|
|
119
|
+
"MEASURE-2.7"
|
|
120
|
+
],
|
|
121
|
+
"iso42001": [
|
|
122
|
+
"Clause-8.2"
|
|
123
|
+
]
|
|
124
|
+
},
|
|
125
|
+
"pii-handling": {
|
|
126
|
+
"owasp": [
|
|
127
|
+
"LLM02"
|
|
128
|
+
],
|
|
129
|
+
"nist": [
|
|
130
|
+
"MAP-2.1",
|
|
131
|
+
"MEASURE-2.10"
|
|
132
|
+
],
|
|
133
|
+
"iso42001": [
|
|
134
|
+
"Annex-A.7",
|
|
135
|
+
"Annex-A.4"
|
|
136
|
+
]
|
|
137
|
+
},
|
|
138
|
+
"prompt-security": {
|
|
139
|
+
"owasp": [
|
|
140
|
+
"LLM07"
|
|
141
|
+
],
|
|
142
|
+
"nist": [
|
|
143
|
+
"MEASURE-2.7",
|
|
144
|
+
"MEASURE-2.8"
|
|
145
|
+
],
|
|
146
|
+
"iso42001": [
|
|
147
|
+
"Clause-8.2"
|
|
148
|
+
]
|
|
149
|
+
},
|
|
150
|
+
"rag-security": {
|
|
151
|
+
"owasp": [
|
|
152
|
+
"LLM08"
|
|
153
|
+
],
|
|
154
|
+
"nist": [
|
|
155
|
+
"MEASURE-2.7"
|
|
156
|
+
],
|
|
157
|
+
"iso42001": [
|
|
158
|
+
"Clause-8.2",
|
|
159
|
+
"Annex-A.7"
|
|
160
|
+
]
|
|
161
|
+
},
|
|
162
|
+
"rate-limiting": {
|
|
163
|
+
"owasp": [
|
|
164
|
+
"LLM10"
|
|
165
|
+
],
|
|
166
|
+
"nist": [
|
|
167
|
+
"MEASURE-2.6",
|
|
168
|
+
"MANAGE-2.4"
|
|
169
|
+
],
|
|
170
|
+
"iso42001": [
|
|
171
|
+
"Clause-8.2"
|
|
172
|
+
]
|
|
173
|
+
},
|
|
174
|
+
"supply-chain": {
|
|
175
|
+
"owasp": [
|
|
176
|
+
"LLM03"
|
|
177
|
+
],
|
|
178
|
+
"nist": [
|
|
179
|
+
"GOVERN-6.1",
|
|
180
|
+
"GOVERN-6.2",
|
|
181
|
+
"MANAGE-3.1",
|
|
182
|
+
"MANAGE-3.2"
|
|
183
|
+
],
|
|
184
|
+
"iso42001": [
|
|
185
|
+
"Annex-A.10"
|
|
186
|
+
]
|
|
187
|
+
}
|
|
188
|
+
}
|