@aigis-ai/cli 1.0.3 → 2.0.2
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/CONTRIBUTING.md +53 -0
- package/README.md +58 -188
- package/SKILL.md +20 -55
- package/aigis-ai-cli-2.0.1.tgz +0 -0
- package/bin/aigis.js +446 -59
- package/content/index/audit-scan.md +21 -207
- package/content/index/auto-verify-rules.json +439 -0
- package/content/index/context-rules.json +90 -0
- package/content/resolvers/triggers.json +229 -0
- package/content/{implement → skills/areas}/audit-logging.md +5 -0
- package/content/skills/areas/fallback-patterns.md +200 -0
- package/content/skills/areas/input-validation.md +380 -0
- package/content/skills/areas/pii-handling.md +189 -0
- package/content/skills/areas/rate-limiting.md +246 -0
- package/content/skills/core.md +62 -0
- package/content/skills/infrastructure/logging.md +202 -0
- package/content/skills/infrastructure/rate-limiting.md +169 -0
- package/content/skills/infrastructure/secrets.md +167 -0
- package/content/skills/workflows/fastapi-llm.md +86 -0
- package/docs/resolvers.md +114 -0
- package/lib/auto-verify.js +378 -0
- package/lib/build.js +629 -0
- package/lib/checksum.js +39 -0
- package/lib/fetch.js +164 -9
- package/lib/init.js +141 -93
- package/lib/keywords.js +92 -130
- package/lib/special-recognizers.js +370 -0
- package/package.json +1 -1
- package/scripts/baseline-cursorrules.snapshot.txt +30 -0
- package/scripts/bootstrap-step-6-bench.js +85 -0
- package/scripts/check-content-sync.js +91 -0
- package/scripts/triggers.schema.json +50 -0
- package/scripts/validate-triggers.js +176 -0
- package/content/implement/fallback-patterns.md +0 -190
- package/content/implement/input-validation.md +0 -212
- package/content/implement/pii-handling.md +0 -207
- package/content/implement/rate-limiting.md +0 -217
- /package/content/{implement → skills/areas}/bias-monitoring.md +0 -0
- /package/content/{implement → skills/areas}/confidence-scoring.md +0 -0
- /package/content/{implement → skills/areas}/data-integrity.md +0 -0
- /package/content/{implement → skills/areas}/explainability.md +0 -0
- /package/content/{implement → skills/areas}/human-oversight.md +0 -0
- /package/content/{implement → skills/areas}/monitoring.md +0 -0
- /package/content/{implement → skills/areas}/output-sanitization.md +0 -0
- /package/content/{implement → skills/areas}/prompt-security.md +0 -0
- /package/content/{implement → skills/areas}/rag-security.md +0 -0
- /package/content/{implement → skills/areas}/supply-chain.md +0 -0
|
@@ -1,13 +1,17 @@
|
|
|
1
1
|
---
|
|
2
2
|
id: audit-scan
|
|
3
3
|
title: Aigis codebase audit scan prompt
|
|
4
|
-
version: "
|
|
5
|
-
purpose: Structured instructions for an agent to scan
|
|
4
|
+
version: "2.0"
|
|
5
|
+
purpose: Structured instructions for an agent to scan a codebase and detect system traits. Control-by-control evaluation is produced separately by `aigis audit --traits <detected>` so the denominator is deterministic.
|
|
6
6
|
---
|
|
7
7
|
|
|
8
|
-
# AIGIS CODEBASE AUDIT
|
|
8
|
+
# AIGIS CODEBASE AUDIT (DISCOVERY)
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
This prompt covers three phases: project inventory, trait detection, and classify handoff.
|
|
11
|
+
|
|
12
|
+
**Control-by-control evaluation (formerly Phases 4-5) is no longer in this prompt.** Once Phase 3 identifies the traits, run `aigis audit --traits <detected-traits>` to get the scoped checklist. That command emits only the pattern areas recommended by `classify` and prints an explicit total-check denominator, so two runs on the same system produce the same scoring scope.
|
|
13
|
+
|
|
14
|
+
Complete every section in order.
|
|
11
15
|
|
|
12
16
|
---
|
|
13
17
|
|
|
@@ -188,216 +192,26 @@ Record the output:
|
|
|
188
192
|
|
|
189
193
|
---
|
|
190
194
|
|
|
191
|
-
## PHASE 4:
|
|
192
|
-
|
|
193
|
-
For each implement file recommended by the classification, check whether the patterns are ALREADY implemented in the codebase. This is the gap analysis.
|
|
194
|
-
|
|
195
|
-
### 4.1 Input validation (if recommended)
|
|
196
|
-
|
|
197
|
-
| # | Control | What to look for in the code | Status | Evidence |
|
|
198
|
-
|---|---------|------------------------------|--------|----------|
|
|
199
|
-
| V1 | Input length check | A function or middleware that checks character count or token count of user input BEFORE it reaches the LLM call | PASS / FAIL / PARTIAL | [file:line or "not found"] |
|
|
200
|
-
| V2 | System/user prompt separation | LLM calls using structured messages array with role: "system" and role: "user" as separate objects, NOT string concatenation | PASS / FAIL / PARTIAL | [file:line] |
|
|
201
|
-
| V3 | Character sanitization | A function stripping control characters, null bytes, zero-width Unicode from user input before LLM processing | PASS / FAIL / PARTIAL | [file:line] |
|
|
202
|
-
| V4 | Output schema validation | LLM response being parsed and validated against a defined schema (pydantic, zod, ajv, JSON schema) before downstream use | PASS / FAIL / PARTIAL | [file:line] |
|
|
203
|
-
| V5 | Injection pattern detection | Any pattern matching or classification of user input for known injection phrases, even if just logging | PASS / FAIL / PARTIAL | [file:line] |
|
|
204
|
-
|
|
205
|
-
### 4.2 Output sanitization (if recommended)
|
|
206
|
-
|
|
207
|
-
| # | Control | What to look for | Status | Evidence |
|
|
208
|
-
|---|---------|------------------|--------|----------|
|
|
209
|
-
| V1 | HTML encoding of LLM output | LLM output being escaped/encoded before rendering in any web context | PASS / FAIL / PARTIAL | |
|
|
210
|
-
| V2 | Parameterized DB queries | Any database operations using LLM output use parameterized queries, not string interpolation | PASS / FAIL / PARTIAL | |
|
|
211
|
-
| V3 | Code execution sandboxing | If LLM generates code that is executed, it runs in a sandbox (subprocess, vm, container) not eval/exec | PASS / FAIL / PARTIAL | |
|
|
212
|
-
| V4 | Content type validation | LLM response content type is checked before use (is it valid JSON? is it a number? is it within allowed enum?) | PASS / FAIL / PARTIAL | |
|
|
213
|
-
|
|
214
|
-
### 4.3 PII handling (if recommended)
|
|
215
|
-
|
|
216
|
-
| # | Control | What to look for | Status | Evidence |
|
|
217
|
-
|---|---------|------------------|--------|----------|
|
|
218
|
-
| V1 | PII redaction before LLM | A function detecting and replacing PII (regex, NER model, or library) that runs BEFORE user data is sent to the LLM | PASS / FAIL / PARTIAL | |
|
|
219
|
-
| V2 | Data minimization | Only specific needed fields are extracted and sent to the LLM, not entire database records or user profiles | PASS / FAIL / PARTIAL | |
|
|
220
|
-
| V3 | Output PII filtering | LLM response is scanned for PII before being returned to the user or stored | PASS / FAIL / PARTIAL | |
|
|
221
|
-
| V4 | Separated data stores | PII is stored in a different location or with different access controls than the data the LLM can access | PASS / FAIL / PARTIAL | |
|
|
222
|
-
| V5 | Redacted logging | Log entries containing LLM inputs/outputs have PII redacted or hashed, not stored in plaintext | PASS / FAIL / PARTIAL | |
|
|
223
|
-
|
|
224
|
-
### 4.4 Prompt security (if recommended)
|
|
225
|
-
|
|
226
|
-
| # | Control | What to look for | Status | Evidence |
|
|
227
|
-
|---|---------|------------------|--------|----------|
|
|
228
|
-
| V1 | No secrets in prompts | System prompts do not contain API keys, passwords, database credentials, or tokens | PASS / FAIL / PARTIAL | |
|
|
229
|
-
| V2 | Minimal prompt content | System prompts contain behavioral instructions only, not detailed business logic, pricing, or internal processes | PASS / FAIL / PARTIAL | |
|
|
230
|
-
| V3 | Leakage detection | There is some check on LLM output for system prompt content echoing back | PASS / FAIL / PARTIAL | |
|
|
231
|
-
| V4 | Server-side rule enforcement | Business rules (output length, topic restrictions, format requirements) are enforced in code, not just in the prompt | PASS / FAIL / PARTIAL | |
|
|
232
|
-
|
|
233
|
-
### 4.5 Human oversight (if recommended)
|
|
234
|
-
|
|
235
|
-
| # | Control | What to look for | Status | Evidence |
|
|
236
|
-
|---|---------|------------------|--------|----------|
|
|
237
|
-
| V1 | Tool allowlist | If LLM has tools/functions, they are defined as an explicit list (not dynamically generated or unrestricted) | PASS / FAIL / PARTIAL | |
|
|
238
|
-
| V2 | Write operation approval | Database writes, API calls, emails, or other state-changing actions triggered by LLM require human confirmation or are logged with review capability | PASS / FAIL / PARTIAL | |
|
|
239
|
-
| V3 | Action rate limiting | There are limits on how many actions the LLM can take per time window | PASS / FAIL / PARTIAL | |
|
|
240
|
-
| V4 | Override mechanism | API responses or UI include a way for humans to override or escalate AI decisions | PASS / FAIL / PARTIAL | |
|
|
241
|
-
| V5 | Confidence gating | Low-confidence outputs are flagged or routed to human review rather than auto-processed | PASS / FAIL / PARTIAL | |
|
|
242
|
-
|
|
243
|
-
### 4.6 Supply chain (if recommended)
|
|
244
|
-
|
|
245
|
-
| # | Control | What to look for | Status | Evidence |
|
|
246
|
-
|---|---------|------------------|--------|----------|
|
|
247
|
-
| V1 | Model version pinning | LLM API calls specify an exact model version (e.g., "gpt-4o-2024-11-20") not a floating alias (e.g., "gpt-4o") | PASS / FAIL / PARTIAL | |
|
|
248
|
-
| V2 | Version tracking in logs | Model version is recorded in logs or response metadata for every LLM call | PASS / FAIL / PARTIAL | |
|
|
249
|
-
| V3 | Regression test suite | There are tests that evaluate LLM output quality that could be run against a new model version | PASS / FAIL / PARTIAL | |
|
|
250
|
-
| V4 | Fallback provider | There is a secondary LLM provider or fallback behavior defined for when the primary provider fails | PASS / FAIL / PARTIAL | |
|
|
251
|
-
|
|
252
|
-
### 4.7 Data integrity (if recommended)
|
|
253
|
-
|
|
254
|
-
| # | Control | What to look for | Status | Evidence |
|
|
255
|
-
|---|---------|------------------|--------|----------|
|
|
256
|
-
| V1 | Data provenance tracking | Documents or data entering the system have their source, ingestion time, and checksums recorded | PASS / FAIL / PARTIAL | |
|
|
257
|
-
| V2 | Pre-embedding validation | Data is validated (source check, content check, freshness check) before being embedded into a vector store | PASS / FAIL / PARTIAL | |
|
|
258
|
-
| V3 | Training data versioning | Fine-tuning or training datasets are versioned and checksummed | PASS / FAIL / PARTIAL | |
|
|
259
|
-
| V4 | Distribution monitoring | There is monitoring for changes in embedding or output distributions after data updates | PASS / FAIL / PARTIAL | |
|
|
260
|
-
| V5 | Batch rollback capability | There is a mechanism to roll back a batch of ingested data if it's found to be compromised | PASS / FAIL / PARTIAL | |
|
|
261
|
-
|
|
262
|
-
### 4.8 RAG security (if recommended)
|
|
263
|
-
|
|
264
|
-
| # | Control | What to look for | Status | Evidence |
|
|
265
|
-
|---|---------|------------------|--------|----------|
|
|
266
|
-
| V1 | Vector DB access control | Vector database queries include access control filters (department, role, classification level) | PASS / FAIL / PARTIAL | |
|
|
267
|
-
| V2 | Tenant isolation | In multi-tenant systems, vector queries always filter by tenant ID | PASS / FAIL / PARTIAL | |
|
|
268
|
-
| V3 | Retrieved content validation | Retrieved results are filtered by relevance score threshold and checked for suspicious content | PASS / FAIL / PARTIAL | |
|
|
269
|
-
| V4 | Embedding endpoint protection | The embedding generation endpoint has authentication and rate limiting | PASS / FAIL / PARTIAL | |
|
|
270
|
-
| V5 | Permission inheritance | Embeddings carry the access permissions of their source documents | PASS / FAIL / PARTIAL | |
|
|
271
|
-
|
|
272
|
-
### 4.9 Confidence scoring (if recommended)
|
|
273
|
-
|
|
274
|
-
| # | Control | What to look for | Status | Evidence |
|
|
275
|
-
|---|---------|------------------|--------|----------|
|
|
276
|
-
| V1 | Confidence metadata | AI responses include a confidence score or level (high/medium/low) in the output | PASS / FAIL / PARTIAL | |
|
|
277
|
-
| V2 | Grounding verification | For RAG systems, there is a check that LLM claims are supported by retrieved sources | PASS / FAIL / PARTIAL | |
|
|
278
|
-
| V3 | Recommendation framing | AI output is presented as a suggestion/recommendation, not as a definitive fact, in any user-facing display | PASS / FAIL / PARTIAL | |
|
|
279
|
-
| V4 | Source attribution | When RAG is used, the response includes references to the source documents | PASS / FAIL / PARTIAL | |
|
|
280
|
-
|
|
281
|
-
### 4.10 Rate limiting (if recommended)
|
|
282
|
-
|
|
283
|
-
| # | Control | What to look for | Status | Evidence |
|
|
284
|
-
|---|---------|------------------|--------|----------|
|
|
285
|
-
| V1 | Per-user rate limits | LLM endpoints have rate limiting per user or per API key | PASS / FAIL / PARTIAL | |
|
|
286
|
-
| V2 | Token budget | There are daily or per-request token limits configured | PASS / FAIL / PARTIAL | |
|
|
287
|
-
| V3 | Cost monitoring | There is monitoring or alerting on LLM API costs | PASS / FAIL / PARTIAL | |
|
|
288
|
-
| V4 | Request timeout | LLM calls have a timeout configured | PASS / FAIL / PARTIAL | |
|
|
289
|
-
|
|
290
|
-
### 4.11 Audit logging (if recommended)
|
|
291
|
-
|
|
292
|
-
| # | Control | What to look for | Status | Evidence |
|
|
293
|
-
|---|---------|------------------|--------|----------|
|
|
294
|
-
| V1 | Structured log entries | Every LLM interaction produces a structured log with trace ID, timestamp, model version, token counts | PASS / FAIL / PARTIAL | |
|
|
295
|
-
| V2 | Trace ID propagation | A trace/correlation ID is generated per request and passed through all components | PASS / FAIL / PARTIAL | |
|
|
296
|
-
| V3 | Decision logging | AI-influenced decisions are logged with the decision, confidence, and context | PASS / FAIL / PARTIAL | |
|
|
297
|
-
| V4 | No raw PII in logs | Log entries do not contain unredacted personal information | PASS / FAIL / PARTIAL | |
|
|
298
|
-
|
|
299
|
-
### 4.12 Bias monitoring (if recommended)
|
|
300
|
-
|
|
301
|
-
| # | Control | What to look for | Status | Evidence |
|
|
302
|
-
|---|---------|------------------|--------|----------|
|
|
303
|
-
| V1 | Fairness metadata in logs | Logs include fields that enable fairness analysis (claim type, region, channel, input language) without collecting protected characteristics directly | PASS / FAIL / PARTIAL | |
|
|
304
|
-
| V2 | Distribution monitoring | There is analysis or dashboarding of output distributions across different segments | PASS / FAIL / PARTIAL | |
|
|
305
|
-
| V3 | Periodic fairness reporting | There is a scheduled process or script that generates fairness reports | PASS / FAIL / PARTIAL | |
|
|
306
|
-
| V4 | Override pattern analysis | Human override rates are tracked and analyzed for patterns across segments | PASS / FAIL / PARTIAL | |
|
|
307
|
-
|
|
308
|
-
### 4.13 Fallback patterns (if recommended)
|
|
309
|
-
|
|
310
|
-
| # | Control | What to look for | Status | Evidence |
|
|
311
|
-
|---|---------|------------------|--------|----------|
|
|
312
|
-
| V1 | Default safe response | There is a defined fallback response returned when the LLM fails or returns invalid output | PASS / FAIL / PARTIAL | |
|
|
313
|
-
| V2 | Circuit breaker | There is a circuit breaker that stops calling the LLM after repeated failures | PASS / FAIL / PARTIAL | |
|
|
314
|
-
| V3 | Kill switch | There is a mechanism to disable the AI system without deploying new code (feature flag, config toggle, environment variable) | PASS / FAIL / PARTIAL | |
|
|
315
|
-
| V4 | Exception handling | All LLM calls are wrapped in try/catch with defined fallback behavior (no unhandled crashes) | PASS / FAIL / PARTIAL | |
|
|
316
|
-
|
|
317
|
-
### 4.14 Monitoring (if recommended)
|
|
318
|
-
|
|
319
|
-
| # | Control | What to look for | Status | Evidence |
|
|
320
|
-
|---|---------|------------------|--------|----------|
|
|
321
|
-
| V1 | Key metrics tracking | Latency, error rate, token usage, and/or cost are being tracked via monitoring tools or custom dashboards | PASS / FAIL / PARTIAL | |
|
|
322
|
-
| V2 | Drift detection | There is comparison of recent output distributions against a baseline | PASS / FAIL / PARTIAL | |
|
|
323
|
-
| V3 | User feedback mechanism | Users can flag bad AI outputs (thumbs down, disagree button, feedback form) | PASS / FAIL / PARTIAL | |
|
|
324
|
-
| V4 | Incident logging | There is a structured process for logging and tracking AI-related incidents | PASS / FAIL / PARTIAL | |
|
|
325
|
-
|
|
326
|
-
### 4.15 Explainability (if recommended)
|
|
327
|
-
|
|
328
|
-
| # | Control | What to look for | Status | Evidence |
|
|
329
|
-
|---|---------|------------------|--------|----------|
|
|
330
|
-
| V1 | Decision explanations | The system generates human-readable explanations for its AI-driven outputs | PASS / FAIL / PARTIAL | |
|
|
331
|
-
| V2 | Model card | There is documentation describing the model's purpose, limitations, and performance characteristics | PASS / FAIL / PARTIAL | |
|
|
332
|
-
| V3 | Audit-friendly records | Decisions are stored in a format suitable for compliance review with full context | PASS / FAIL / PARTIAL | |
|
|
333
|
-
| V4 | Appeal mechanism | Users or affected individuals have a way to appeal or request review of AI decisions | PASS / FAIL / PARTIAL | |
|
|
334
|
-
|
|
335
|
-
---
|
|
336
|
-
|
|
337
|
-
## PHASE 5: GAP REPORT
|
|
195
|
+
## PHASE 4: SCOPED CONTROL EVALUATION (handoff)
|
|
338
196
|
|
|
339
|
-
|
|
197
|
+
Do not evaluate controls inline with this prompt. The scoped checklist is produced by a separate command that uses the classify output from Phase 3.
|
|
340
198
|
|
|
341
|
-
|
|
199
|
+
Run:
|
|
342
200
|
|
|
343
201
|
```
|
|
344
|
-
|
|
345
|
-
Scan date: [date]
|
|
346
|
-
Risk tier: [from Phase 3]
|
|
347
|
-
Traits detected: [list]
|
|
348
|
-
|
|
349
|
-
Overall score: [X] / [total checks] PASS
|
|
350
|
-
Critical gaps: [count of FAIL on high-priority controls]
|
|
351
|
-
Partial implementations: [count of PARTIAL]
|
|
202
|
+
aigis audit --traits <detected-traits>
|
|
352
203
|
```
|
|
353
204
|
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
List every check that received FAIL, ordered by priority:
|
|
357
|
-
|
|
358
|
-
1. OWASP-mapped controls first (these are active security vulnerabilities)
|
|
359
|
-
2. NIST MEASURE controls second (these are evaluation and testing gaps)
|
|
360
|
-
3. NIST MANAGE controls third (these are operational monitoring gaps)
|
|
361
|
-
4. ISO documentation requirements last (these are compliance documentation gaps)
|
|
362
|
-
|
|
363
|
-
For each gap:
|
|
364
|
-
- Control ID and description
|
|
365
|
-
- What is missing
|
|
366
|
-
- Which implement file to reference: `aigis get <file-id>`
|
|
367
|
-
- Specific pattern(s) to implement
|
|
368
|
-
- Estimated effort (small: <1 hour, medium: 1-4 hours, large: 4+ hours)
|
|
369
|
-
|
|
370
|
-
### 5.3 Partial implementations (PARTIAL — needs improvement)
|
|
205
|
+
That command:
|
|
371
206
|
|
|
372
|
-
|
|
373
|
-
-
|
|
374
|
-
-
|
|
375
|
-
- Specific improvement needed
|
|
207
|
+
- Includes only the pattern areas that `classify` recommended for this trait set. Areas that are not recommended are not printed at all (no "N/A" placeholders, no agent-side skipping).
|
|
208
|
+
- Prints the deterministic total-check count for this scope at the top and repeats it at the bottom.
|
|
209
|
+
- Prints the exact `Score: <pass> / <total> total checks across <N> recommended areas (areas: ...)` line you should emit once you have filled in the checklists.
|
|
376
210
|
|
|
377
|
-
|
|
211
|
+
Use the output of `aigis audit --traits` as your Phase 4 worksheet. Fill every row with PASS / FAIL / PARTIAL and file:line evidence. Then emit the prescribed score line, followed by:
|
|
378
212
|
|
|
379
|
-
|
|
213
|
+
- A list of FAIL items in priority order (OWASP controls first, then NIST MEASURE, then NIST MANAGE, then ISO documentation).
|
|
214
|
+
- A list of PARTIAL items.
|
|
215
|
+
- The exact `aigis template ...` commands from your classification output for any required compliance documentation.
|
|
380
216
|
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
Based on the gaps identified, provide a prioritized implementation plan:
|
|
384
|
-
|
|
385
|
-
1. **Immediate (security vulnerabilities):** Input validation, output sanitization, PII handling gaps
|
|
386
|
-
2. **Short-term (operational risk):** Audit logging, fallback patterns, rate limiting gaps
|
|
387
|
-
3. **Medium-term (compliance):** Monitoring, bias monitoring, explainability gaps
|
|
388
|
-
4. **Documentation:** Templates to generate (list specific `aigis template` commands)
|
|
389
|
-
|
|
390
|
-
### 5.6 Commands to run
|
|
391
|
-
|
|
392
|
-
Provide the exact aigis commands for the developer:
|
|
393
|
-
|
|
394
|
-
```
|
|
395
|
-
# Fetch patterns for all identified gaps:
|
|
396
|
-
aigis get [list of files with FAIL or PARTIAL checks]
|
|
397
|
-
|
|
398
|
-
# After implementing fixes, verify:
|
|
399
|
-
aigis verify [same list]
|
|
400
|
-
|
|
401
|
-
# Generate required compliance documentation:
|
|
402
|
-
aigis template [list from classification]
|
|
403
|
-
```
|
|
217
|
+
(End of discovery prompt.)
|