@panguard-ai/atr 0.2.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/LICENSE +21 -0
- package/README.md +299 -0
- package/dist/cli.d.ts +12 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +720 -0
- package/dist/cli.js.map +1 -0
- package/dist/coverage-analyzer.d.ts +43 -0
- package/dist/coverage-analyzer.d.ts.map +1 -0
- package/dist/coverage-analyzer.js +329 -0
- package/dist/coverage-analyzer.js.map +1 -0
- package/dist/engine.d.ts +127 -0
- package/dist/engine.d.ts.map +1 -0
- package/dist/engine.js +636 -0
- package/dist/engine.js.map +1 -0
- package/dist/index.d.ts +26 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +18 -0
- package/dist/index.js.map +1 -0
- package/dist/loader.d.ts +21 -0
- package/dist/loader.d.ts.map +1 -0
- package/dist/loader.js +124 -0
- package/dist/loader.js.map +1 -0
- package/dist/mcp-server.d.ts +13 -0
- package/dist/mcp-server.d.ts.map +1 -0
- package/dist/mcp-server.js +220 -0
- package/dist/mcp-server.js.map +1 -0
- package/dist/mcp-tools/coverage-gaps.d.ts +13 -0
- package/dist/mcp-tools/coverage-gaps.d.ts.map +1 -0
- package/dist/mcp-tools/coverage-gaps.js +55 -0
- package/dist/mcp-tools/coverage-gaps.js.map +1 -0
- package/dist/mcp-tools/list-rules.d.ts +17 -0
- package/dist/mcp-tools/list-rules.d.ts.map +1 -0
- package/dist/mcp-tools/list-rules.js +45 -0
- package/dist/mcp-tools/list-rules.js.map +1 -0
- package/dist/mcp-tools/scan.d.ts +18 -0
- package/dist/mcp-tools/scan.d.ts.map +1 -0
- package/dist/mcp-tools/scan.js +75 -0
- package/dist/mcp-tools/scan.js.map +1 -0
- package/dist/mcp-tools/submit-proposal.d.ts +12 -0
- package/dist/mcp-tools/submit-proposal.d.ts.map +1 -0
- package/dist/mcp-tools/submit-proposal.js +95 -0
- package/dist/mcp-tools/submit-proposal.js.map +1 -0
- package/dist/mcp-tools/threat-summary.d.ts +12 -0
- package/dist/mcp-tools/threat-summary.d.ts.map +1 -0
- package/dist/mcp-tools/threat-summary.js +74 -0
- package/dist/mcp-tools/threat-summary.js.map +1 -0
- package/dist/mcp-tools/validate.d.ts +15 -0
- package/dist/mcp-tools/validate.d.ts.map +1 -0
- package/dist/mcp-tools/validate.js +45 -0
- package/dist/mcp-tools/validate.js.map +1 -0
- package/dist/modules/index.d.ts +144 -0
- package/dist/modules/index.d.ts.map +1 -0
- package/dist/modules/index.js +82 -0
- package/dist/modules/index.js.map +1 -0
- package/dist/modules/semantic.d.ts +105 -0
- package/dist/modules/semantic.d.ts.map +1 -0
- package/dist/modules/semantic.js +283 -0
- package/dist/modules/semantic.js.map +1 -0
- package/dist/modules/session.d.ts +70 -0
- package/dist/modules/session.d.ts.map +1 -0
- package/dist/modules/session.js +128 -0
- package/dist/modules/session.js.map +1 -0
- package/dist/rule-scaffolder.d.ts +39 -0
- package/dist/rule-scaffolder.d.ts.map +1 -0
- package/dist/rule-scaffolder.js +173 -0
- package/dist/rule-scaffolder.js.map +1 -0
- package/dist/session-tracker.d.ts +56 -0
- package/dist/session-tracker.d.ts.map +1 -0
- package/dist/session-tracker.js +175 -0
- package/dist/session-tracker.js.map +1 -0
- package/dist/skill-fingerprint.d.ts +96 -0
- package/dist/skill-fingerprint.d.ts.map +1 -0
- package/dist/skill-fingerprint.js +337 -0
- package/dist/skill-fingerprint.js.map +1 -0
- package/dist/types.d.ts +129 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +6 -0
- package/dist/types.js.map +1 -0
- package/package.json +75 -0
- package/rules/agent-manipulation/ATR-2026-030-cross-agent-attack.yaml +175 -0
- package/rules/agent-manipulation/ATR-2026-032-goal-hijacking.yaml +135 -0
- package/rules/agent-manipulation/ATR-2026-074-cross-agent-privilege-escalation.yaml +115 -0
- package/rules/agent-manipulation/ATR-2026-076-inter-agent-message-spoofing.yaml +165 -0
- package/rules/agent-manipulation/ATR-2026-077-human-trust-exploitation.yaml +144 -0
- package/rules/context-exfiltration/ATR-2026-020-system-prompt-leak.yaml +175 -0
- package/rules/context-exfiltration/ATR-2026-021-api-key-exposure.yaml +176 -0
- package/rules/context-exfiltration/ATR-2026-075-agent-memory-manipulation.yaml +115 -0
- package/rules/data-poisoning/ATR-2026-070-data-poisoning.yaml +160 -0
- package/rules/excessive-autonomy/ATR-2026-050-runaway-agent-loop.yaml +134 -0
- package/rules/excessive-autonomy/ATR-2026-051-resource-exhaustion.yaml +137 -0
- package/rules/excessive-autonomy/ATR-2026-052-cascading-failure.yaml +153 -0
- package/rules/model-security/ATR-2026-072-model-behavior-extraction.yaml +115 -0
- package/rules/model-security/ATR-2026-073-malicious-finetuning-data.yaml +108 -0
- package/rules/privilege-escalation/ATR-2026-040-privilege-escalation.yaml +175 -0
- package/rules/privilege-escalation/ATR-2026-041-scope-creep.yaml +124 -0
- package/rules/prompt-injection/ATR-2026-001-direct-prompt-injection.yaml +265 -0
- package/rules/prompt-injection/ATR-2026-002-indirect-prompt-injection.yaml +214 -0
- package/rules/prompt-injection/ATR-2026-003-jailbreak-attempt.yaml +250 -0
- package/rules/prompt-injection/ATR-2026-004-system-prompt-override.yaml +204 -0
- package/rules/prompt-injection/ATR-2026-005-multi-turn-injection.yaml +181 -0
- package/rules/prompt-injection/ATR-PRED-2026-001.yaml +61 -0
- package/rules/prompt-injection/ATR-PRED-2026-002.yaml +58 -0
- package/rules/prompt-injection/ATR-PRED-2026-003.yaml +61 -0
- package/rules/prompt-injection/ATR-PRED-2026-005.yaml +55 -0
- package/rules/prompt-injection/ATR-PRED-2026-006.yaml +51 -0
- package/rules/prompt-injection/ATR-PRED-2026-007.yaml +57 -0
- package/rules/prompt-injection/ATR-PRED-2026-008.yaml +57 -0
- package/rules/prompt-injection/ATR-PRED-2026-009.yaml +51 -0
- package/rules/prompt-injection/ATR-PRED-2026-010.yaml +57 -0
- package/rules/prompt-injection/ATR-PRED-2026-011.yaml +53 -0
- package/rules/prompt-injection/ATR-PRED-2026-012.yaml +57 -0
- package/rules/prompt-injection/ATR-PRED-2026-023.yaml +56 -0
- package/rules/prompt-injection/ATR-PRED-2026-025.yaml +68 -0
- package/rules/prompt-injection/ATR-PRED-2026-026.yaml +66 -0
- package/rules/prompt-injection/ATR-PRED-2026-027.yaml +62 -0
- package/rules/skill-compromise/ATR-2026-060-skill-impersonation.yaml +153 -0
- package/rules/skill-compromise/ATR-2026-061-description-behavior-mismatch.yaml +98 -0
- package/rules/skill-compromise/ATR-2026-062-hidden-capability.yaml +96 -0
- package/rules/skill-compromise/ATR-2026-063-skill-chain-attack.yaml +96 -0
- package/rules/skill-compromise/ATR-2026-064-over-permissioned-skill.yaml +115 -0
- package/rules/skill-compromise/ATR-2026-065-skill-update-attack.yaml +93 -0
- package/rules/skill-compromise/ATR-2026-066-parameter-injection.yaml +106 -0
- package/rules/tool-poisoning/ATR-2026-010-mcp-malicious-response.yaml +237 -0
- package/rules/tool-poisoning/ATR-2026-011-tool-output-injection.yaml +185 -0
- package/rules/tool-poisoning/ATR-2026-012-unauthorized-tool-call.yaml +190 -0
- package/rules/tool-poisoning/ATR-2026-013-tool-ssrf.yaml +208 -0
- package/rules/tool-poisoning/ATR-PRED-2026-004.yaml +54 -0
- package/rules/tool-poisoning/ATR-PRED-2026-024.yaml +68 -0
- package/spec/atr-schema.yaml +375 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ATR (Agent Threat Rules) - Detection rules for AI Agent threats
|
|
3
|
+
*
|
|
4
|
+
* ATR is an open standard for writing detection rules specifically
|
|
5
|
+
* for AI agent threats. Think "Sigma for AI Agents."
|
|
6
|
+
*
|
|
7
|
+
* @module agent-threat-rules
|
|
8
|
+
*/
|
|
9
|
+
export { ATREngine } from './engine.js';
|
|
10
|
+
export type { ATREngineConfig } from './engine.js';
|
|
11
|
+
export { SessionTracker } from './session-tracker.js';
|
|
12
|
+
export type { SessionStateSnapshot } from './session-tracker.js';
|
|
13
|
+
export { loadRuleFile, loadRulesFromDirectory, validateRule } from './loader.js';
|
|
14
|
+
export { ModuleRegistry } from './modules/index.js';
|
|
15
|
+
export type { ATRModule, ModuleCondition, ModuleResult } from './modules/index.js';
|
|
16
|
+
export { SessionModule } from './modules/session.js';
|
|
17
|
+
export { SemanticModule } from './modules/semantic.js';
|
|
18
|
+
export type { SemanticModuleConfig } from './modules/semantic.js';
|
|
19
|
+
export { SkillFingerprintStore } from './skill-fingerprint.js';
|
|
20
|
+
export type { SkillFingerprint, BehaviorAnomaly, SkillFingerprintConfig, } from './skill-fingerprint.js';
|
|
21
|
+
export { RuleScaffolder } from './rule-scaffolder.js';
|
|
22
|
+
export type { ScaffoldInput, ScaffoldResult, ScaffoldOptions } from './rule-scaffolder.js';
|
|
23
|
+
export { CoverageAnalyzer } from './coverage-analyzer.js';
|
|
24
|
+
export type { CoverageGap, CoverageReport } from './coverage-analyzer.js';
|
|
25
|
+
export type { ATRRule, ATRMatch, AgentEvent, AgentEventType, ATRAction, ATRCategory, ATRSeverity, ATRStatus, ATRConfidence, ATRSourceType, ATRMatchType, ATROperator, ATRReferences, ATRTags, ATRAgentSource, ATRDetection, ATRResponse, ATRTestCases, ATRTestCase, ATRPatternCondition, ATRBehavioralCondition, ATRSequenceCondition, ATRSequenceStep, } from './types.js';
|
|
26
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,YAAY,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AACnD,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,YAAY,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AACjE,OAAO,EAAE,YAAY,EAAE,sBAAsB,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AACjF,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACpD,YAAY,EAAE,SAAS,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AACnF,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACvD,YAAY,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;AAClE,OAAO,EAAE,qBAAqB,EAAE,MAAM,wBAAwB,CAAC;AAC/D,YAAY,EACV,gBAAgB,EAChB,eAAe,EACf,sBAAsB,GACvB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,YAAY,EAAE,aAAa,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAC3F,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC1D,YAAY,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAC1E,YAAY,EACV,OAAO,EACP,QAAQ,EACR,UAAU,EACV,cAAc,EACd,SAAS,EACT,WAAW,EACX,WAAW,EACX,SAAS,EACT,aAAa,EACb,aAAa,EACb,YAAY,EACZ,WAAW,EACX,aAAa,EACb,OAAO,EACP,cAAc,EACd,YAAY,EACZ,WAAW,EACX,YAAY,EACZ,WAAW,EACX,mBAAmB,EACnB,sBAAsB,EACtB,oBAAoB,EACpB,eAAe,GAChB,MAAM,YAAY,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ATR (Agent Threat Rules) - Detection rules for AI Agent threats
|
|
3
|
+
*
|
|
4
|
+
* ATR is an open standard for writing detection rules specifically
|
|
5
|
+
* for AI agent threats. Think "Sigma for AI Agents."
|
|
6
|
+
*
|
|
7
|
+
* @module agent-threat-rules
|
|
8
|
+
*/
|
|
9
|
+
export { ATREngine } from './engine.js';
|
|
10
|
+
export { SessionTracker } from './session-tracker.js';
|
|
11
|
+
export { loadRuleFile, loadRulesFromDirectory, validateRule } from './loader.js';
|
|
12
|
+
export { ModuleRegistry } from './modules/index.js';
|
|
13
|
+
export { SessionModule } from './modules/session.js';
|
|
14
|
+
export { SemanticModule } from './modules/semantic.js';
|
|
15
|
+
export { SkillFingerprintStore } from './skill-fingerprint.js';
|
|
16
|
+
export { RuleScaffolder } from './rule-scaffolder.js';
|
|
17
|
+
export { CoverageAnalyzer } from './coverage-analyzer.js';
|
|
18
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAExC,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAEtD,OAAO,EAAE,YAAY,EAAE,sBAAsB,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AACjF,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAEpD,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAEvD,OAAO,EAAE,qBAAqB,EAAE,MAAM,wBAAwB,CAAC;AAM/D,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAEtD,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC"}
|
package/dist/loader.d.ts
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ATR Rule Loader - Reads and parses ATR YAML rule files
|
|
3
|
+
* @module agent-threat-rules/loader
|
|
4
|
+
*/
|
|
5
|
+
import type { ATRRule } from './types.js';
|
|
6
|
+
/**
|
|
7
|
+
* Load a single ATR rule from a YAML file.
|
|
8
|
+
*/
|
|
9
|
+
export declare function loadRuleFile(filePath: string): ATRRule;
|
|
10
|
+
/**
|
|
11
|
+
* Recursively load all ATR YAML rules from a directory.
|
|
12
|
+
*/
|
|
13
|
+
export declare function loadRulesFromDirectory(dirPath: string): ATRRule[];
|
|
14
|
+
/**
|
|
15
|
+
* Validate that a parsed object conforms to the ATR rule schema (basic checks).
|
|
16
|
+
*/
|
|
17
|
+
export declare function validateRule(rule: unknown): {
|
|
18
|
+
valid: boolean;
|
|
19
|
+
errors: string[];
|
|
20
|
+
};
|
|
21
|
+
//# sourceMappingURL=loader.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"loader.d.ts","sourceRoot":"","sources":["../src/loader.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAKH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAE1C;;GAEG;AACH,wBAAgB,YAAY,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAStD;AAED;;GAEG;AACH,wBAAgB,sBAAsB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,EAAE,CAoBjE;AAED;;GAEG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,OAAO,GAAG;IAAE,KAAK,EAAE,OAAO,CAAC;IAAC,MAAM,EAAE,MAAM,EAAE,CAAA;CAAE,CAwFhF"}
|
package/dist/loader.js
ADDED
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ATR Rule Loader - Reads and parses ATR YAML rule files
|
|
3
|
+
* @module agent-threat-rules/loader
|
|
4
|
+
*/
|
|
5
|
+
import { readFileSync, readdirSync, statSync } from 'node:fs';
|
|
6
|
+
import { join, extname } from 'node:path';
|
|
7
|
+
import yaml from 'js-yaml';
|
|
8
|
+
/**
|
|
9
|
+
* Load a single ATR rule from a YAML file.
|
|
10
|
+
*/
|
|
11
|
+
export function loadRuleFile(filePath) {
|
|
12
|
+
const content = readFileSync(filePath, 'utf-8');
|
|
13
|
+
const parsed = yaml.load(content);
|
|
14
|
+
if (!parsed.id || !parsed.title || !parsed.detection) {
|
|
15
|
+
throw new Error(`Invalid ATR rule in ${filePath}: missing required fields (id, title, detection)`);
|
|
16
|
+
}
|
|
17
|
+
return parsed;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Recursively load all ATR YAML rules from a directory.
|
|
21
|
+
*/
|
|
22
|
+
export function loadRulesFromDirectory(dirPath) {
|
|
23
|
+
const rules = [];
|
|
24
|
+
const entries = readdirSync(dirPath);
|
|
25
|
+
for (const entry of entries) {
|
|
26
|
+
const fullPath = join(dirPath, entry);
|
|
27
|
+
const stat = statSync(fullPath);
|
|
28
|
+
if (stat.isDirectory()) {
|
|
29
|
+
rules.push(...loadRulesFromDirectory(fullPath));
|
|
30
|
+
}
|
|
31
|
+
else if (stat.isFile() && (extname(entry) === '.yaml' || extname(entry) === '.yml')) {
|
|
32
|
+
try {
|
|
33
|
+
rules.push(loadRuleFile(fullPath));
|
|
34
|
+
}
|
|
35
|
+
catch {
|
|
36
|
+
// Skip invalid rule files — logged at caller level
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
return rules;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Validate that a parsed object conforms to the ATR rule schema (basic checks).
|
|
44
|
+
*/
|
|
45
|
+
export function validateRule(rule) {
|
|
46
|
+
const errors = [];
|
|
47
|
+
const r = rule;
|
|
48
|
+
// Required fields
|
|
49
|
+
const required = ['title', 'id', 'status', 'description', 'author', 'date', 'severity', 'tags', 'agent_source', 'detection', 'response'];
|
|
50
|
+
for (const field of required) {
|
|
51
|
+
if (!r[field]) {
|
|
52
|
+
errors.push(`Missing required field: ${field}`);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
// ID format
|
|
56
|
+
if (typeof r['id'] === 'string' && !/^ATR-\d{4}-\d{3}$/.test(r['id'])) {
|
|
57
|
+
errors.push(`Invalid id format: ${r['id']} (expected ATR-YYYY-NNN)`);
|
|
58
|
+
}
|
|
59
|
+
// Status enum
|
|
60
|
+
const validStatuses = ['draft', 'experimental', 'stable', 'deprecated'];
|
|
61
|
+
if (typeof r['status'] === 'string' && !validStatuses.includes(r['status'])) {
|
|
62
|
+
errors.push(`Invalid status: ${r['status']}`);
|
|
63
|
+
}
|
|
64
|
+
// Severity enum
|
|
65
|
+
const validSeverities = ['critical', 'high', 'medium', 'low', 'informational'];
|
|
66
|
+
if (typeof r['severity'] === 'string' && !validSeverities.includes(r['severity'])) {
|
|
67
|
+
errors.push(`Invalid severity: ${r['severity']}`);
|
|
68
|
+
}
|
|
69
|
+
// Tags category
|
|
70
|
+
const tags = r['tags'];
|
|
71
|
+
if (tags) {
|
|
72
|
+
const validCategories = [
|
|
73
|
+
'prompt-injection', 'tool-poisoning', 'context-exfiltration',
|
|
74
|
+
'agent-manipulation', 'privilege-escalation', 'excessive-autonomy',
|
|
75
|
+
'data-poisoning', 'model-abuse', 'skill-compromise',
|
|
76
|
+
];
|
|
77
|
+
if (typeof tags['category'] === 'string' && !validCategories.includes(tags['category'])) {
|
|
78
|
+
errors.push(`Invalid tags.category: ${tags['category']}`);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
// Agent source type
|
|
82
|
+
const agentSource = r['agent_source'];
|
|
83
|
+
if (agentSource) {
|
|
84
|
+
const validTypes = [
|
|
85
|
+
'llm_io', 'tool_call', 'mcp_exchange', 'agent_behavior',
|
|
86
|
+
'multi_agent_comm', 'context_window', 'memory_access',
|
|
87
|
+
'skill_lifecycle', 'skill_permission', 'skill_chain',
|
|
88
|
+
];
|
|
89
|
+
if (typeof agentSource['type'] === 'string' && !validTypes.includes(agentSource['type'])) {
|
|
90
|
+
errors.push(`Invalid agent_source.type: ${agentSource['type']}`);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
// Detection must have conditions and condition
|
|
94
|
+
const detection = r['detection'];
|
|
95
|
+
if (detection) {
|
|
96
|
+
if (!detection['conditions']) {
|
|
97
|
+
errors.push('Missing detection.conditions');
|
|
98
|
+
}
|
|
99
|
+
if (!detection['condition']) {
|
|
100
|
+
errors.push('Missing detection.condition');
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
// Response must have actions
|
|
104
|
+
const response = r['response'];
|
|
105
|
+
if (response) {
|
|
106
|
+
if (!Array.isArray(response['actions']) || response['actions'].length === 0) {
|
|
107
|
+
errors.push('Missing or empty response.actions');
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
// Test cases validation
|
|
111
|
+
const testCases = r['test_cases'];
|
|
112
|
+
if (testCases) {
|
|
113
|
+
const tp = testCases['true_positives'];
|
|
114
|
+
const tn = testCases['true_negatives'];
|
|
115
|
+
if (!Array.isArray(tp) || tp.length === 0) {
|
|
116
|
+
errors.push('test_cases.true_positives must have at least one entry');
|
|
117
|
+
}
|
|
118
|
+
if (!Array.isArray(tn) || tn.length === 0) {
|
|
119
|
+
errors.push('test_cases.true_negatives must have at least one entry');
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
return { valid: errors.length === 0, errors };
|
|
123
|
+
}
|
|
124
|
+
//# sourceMappingURL=loader.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"loader.js","sourceRoot":"","sources":["../src/loader.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAC9D,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,IAAI,MAAM,SAAS,CAAC;AAG3B;;GAEG;AACH,MAAM,UAAU,YAAY,CAAC,QAAgB;IAC3C,MAAM,OAAO,GAAG,YAAY,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;IAChD,MAAM,MAAM,GAAG,IAAI,CAAC,IAAI,CAAC,O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ents and IDEs.
|
|
6
|
+
* Start with: atr mcp (stdio transport)
|
|
7
|
+
*
|
|
8
|
+
* @module agent-threat-rules/mcp-server
|
|
9
|
+
*/
|
|
10
|
+
import { Server } from '@modelcontextprotocol/sdk/server/index.js';
|
|
11
|
+
export declare function createMCPServer(): Promise<Server>;
|
|
12
|
+
export declare function startMCPServer(): Promise<void>;
|
|
13
|
+
//# sourceMappingURL=mcp-server.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mcp-server.d.ts","sourceRoot":"","sources":["../src/mcp-server.ts"],"names":[],"mappings":";AACA;;;;;;;GAOG;AAIH,OAAO,EAAE,MAAM,EAAE,MAAM,2CAA2C,CAAC;AAsKnE,wBAAsB,eAAe,IAAI,OAAO,CAAC,MAAM,CAAC,CAoDvD;AAED,wBAAsB,cAAc,IAAI,OAAO,CAAC,IAAI,CAAC,CAIpD"}
|
|
@@ -0,0 +1,220 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* ATR MCP Server - Model Context Protocol server for Agent Threat Rules
|
|
4
|
+
*
|
|
5
|
+
* Exposes ATR functionality as MCP tools for AI agents and IDEs.
|
|
6
|
+
* Start with: atr mcp (stdio transport)
|
|
7
|
+
*
|
|
8
|
+
* @module agent-threat-rules/mcp-server
|
|
9
|
+
*/
|
|
10
|
+
import { resolve, dirname } from 'node:path';
|
|
11
|
+
import { fileURLToPath } from 'node:url';
|
|
12
|
+
import { Server } from '@modelcontextprotocol/sdk/server/index.js';
|
|
13
|
+
import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
|
|
14
|
+
import { ListToolsRequestSchema, CallToolRequestSchema, } from '@modelcontextprotocol/sdk/types.js';
|
|
15
|
+
import { ATREngine } from './engine.js';
|
|
16
|
+
import { handleScan } from './mcp-tools/scan.js';
|
|
17
|
+
import { handleListRules } from './mcp-tools/list-rules.js';
|
|
18
|
+
import { handleValidate } from './mcp-tools/validate.js';
|
|
19
|
+
import { handleSubmitProposal } from './mcp-tools/submit-proposal.js';
|
|
20
|
+
import { handleCoverageGaps } from './mcp-tools/coverage-gaps.js';
|
|
21
|
+
import { handleThreatSummary } from './mcp-tools/threat-summary.js';
|
|
22
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
23
|
+
const __dirname = dirname(__filename);
|
|
24
|
+
const RULES_DIR = resolve(__dirname, '..', 'rules');
|
|
25
|
+
const TOOLS = [
|
|
26
|
+
{
|
|
27
|
+
name: 'atr_scan',
|
|
28
|
+
description: 'Scan text content for AI agent security threats using ATR detection rules. Returns matched rules with severity, confidence, and recommended actions.',
|
|
29
|
+
inputSchema: {
|
|
30
|
+
type: 'object',
|
|
31
|
+
properties: {
|
|
32
|
+
content: {
|
|
33
|
+
type: 'string',
|
|
34
|
+
description: 'The text content to scan for threats (prompt, tool response, agent output, etc.)',
|
|
35
|
+
},
|
|
36
|
+
event_type: {
|
|
37
|
+
type: 'string',
|
|
38
|
+
enum: ['llm_input', 'llm_output', 'tool_call', 'tool_response', 'agent_behavior', 'multi_agent_message'],
|
|
39
|
+
description: 'Type of agent event being scanned. Defaults to "llm_input".',
|
|
40
|
+
},
|
|
41
|
+
min_severity: {
|
|
42
|
+
type: 'string',
|
|
43
|
+
enum: ['informational', 'low', 'medium', 'high', 'critical'],
|
|
44
|
+
description: 'Minimum severity level to include in results. Defaults to "informational".',
|
|
45
|
+
},
|
|
46
|
+
},
|
|
47
|
+
required: ['content'],
|
|
48
|
+
},
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
name: 'atr_list_rules',
|
|
52
|
+
description: 'List and filter available ATR detection rules. Search by category, severity, or keyword.',
|
|
53
|
+
inputSchema: {
|
|
54
|
+
type: 'object',
|
|
55
|
+
properties: {
|
|
56
|
+
category: {
|
|
57
|
+
type: 'string',
|
|
58
|
+
enum: [
|
|
59
|
+
'prompt-injection', 'tool-poisoning', 'context-exfiltration',
|
|
60
|
+
'agent-manipulation', 'privilege-escalation', 'excessive-autonomy',
|
|
61
|
+
'data-poisoning', 'model-abuse', 'skill-compromise',
|
|
62
|
+
],
|
|
63
|
+
description: 'Filter rules by threat category.',
|
|
64
|
+
},
|
|
65
|
+
severity: {
|
|
66
|
+
type: 'string',
|
|
67
|
+
enum: ['informational', 'low', 'medium', 'high', 'critical'],
|
|
68
|
+
description: 'Filter rules by severity level.',
|
|
69
|
+
},
|
|
70
|
+
search: {
|
|
71
|
+
type: 'string',
|
|
72
|
+
description: 'Search rules by keyword in title, description, or ID.',
|
|
73
|
+
},
|
|
74
|
+
},
|
|
75
|
+
},
|
|
76
|
+
},
|
|
77
|
+
{
|
|
78
|
+
name: 'atr_validate_rule',
|
|
79
|
+
description: 'Validate an ATR rule written in YAML format. Checks required fields, enum values, and structural correctness.',
|
|
80
|
+
inputSchema: {
|
|
81
|
+
type: 'object',
|
|
82
|
+
properties: {
|
|
83
|
+
yaml_content: {
|
|
84
|
+
type: 'string',
|
|
85
|
+
description: 'The ATR rule YAML content to validate.',
|
|
86
|
+
},
|
|
87
|
+
},
|
|
88
|
+
required: ['yaml_content'],
|
|
89
|
+
},
|
|
90
|
+
},
|
|
91
|
+
{
|
|
92
|
+
name: 'atr_submit_proposal',
|
|
93
|
+
description: 'Generate a draft ATR rule from a threat description. Produces YAML with detection patterns derived from example payloads.',
|
|
94
|
+
inputSchema: {
|
|
95
|
+
type: 'object',
|
|
96
|
+
properties: {
|
|
97
|
+
title: {
|
|
98
|
+
type: 'string',
|
|
99
|
+
description: 'Title for the new rule (e.g., "Multi-turn Context Hijacking").',
|
|
100
|
+
},
|
|
101
|
+
category: {
|
|
102
|
+
type: 'string',
|
|
103
|
+
enum: [
|
|
104
|
+
'prompt-injection', 'tool-poisoning', 'context-exfiltration',
|
|
105
|
+
'agent-manipulation', 'privilege-escalation', 'excessive-autonomy',
|
|
106
|
+
'data-poisoning', 'model-abuse', 'skill-compromise',
|
|
107
|
+
],
|
|
108
|
+
description: 'Threat category for the rule.',
|
|
109
|
+
},
|
|
110
|
+
attack_description: {
|
|
111
|
+
type: 'string',
|
|
112
|
+
description: 'Detailed description of the attack this rule detects.',
|
|
113
|
+
},
|
|
114
|
+
example_payloads: {
|
|
115
|
+
type: 'array',
|
|
116
|
+
items: { type: 'string' },
|
|
117
|
+
description: 'Example attack payloads to generate detection patterns from.',
|
|
118
|
+
},
|
|
119
|
+
severity: {
|
|
120
|
+
type: 'string',
|
|
121
|
+
enum: ['informational', 'low', 'medium', 'high', 'critical'],
|
|
122
|
+
description: 'Severity level. Defaults to "medium".',
|
|
123
|
+
},
|
|
124
|
+
mitre_refs: {
|
|
125
|
+
type: 'array',
|
|
126
|
+
items: { type: 'string' },
|
|
127
|
+
description: 'Optional MITRE ATLAS reference IDs (e.g., "AML.T0051").',
|
|
128
|
+
},
|
|
129
|
+
},
|
|
130
|
+
required: ['title', 'category', 'attack_description', 'example_payloads'],
|
|
131
|
+
},
|
|
132
|
+
},
|
|
133
|
+
{
|
|
134
|
+
name: 'atr_coverage_gaps',
|
|
135
|
+
description: 'Analyze ATR rule coverage against security frameworks (OWASP Agentic AI, MITRE ATLAS). Identifies uncovered threat categories.',
|
|
136
|
+
inputSchema: {
|
|
137
|
+
type: 'object',
|
|
138
|
+
properties: {
|
|
139
|
+
framework: {
|
|
140
|
+
type: 'string',
|
|
141
|
+
enum: ['owasp_agentic', 'mitre_atlas', 'all'],
|
|
142
|
+
description: 'Security framework to analyze against. Defaults to "all".',
|
|
143
|
+
},
|
|
144
|
+
},
|
|
145
|
+
},
|
|
146
|
+
},
|
|
147
|
+
{
|
|
148
|
+
name: 'atr_threat_summary',
|
|
149
|
+
description: 'Get aggregated statistics about loaded ATR rules. Shows distribution by category, severity, status, and test coverage.',
|
|
150
|
+
inputSchema: {
|
|
151
|
+
type: 'object',
|
|
152
|
+
properties: {
|
|
153
|
+
category: {
|
|
154
|
+
type: 'string',
|
|
155
|
+
enum: [
|
|
156
|
+
'prompt-injection', 'tool-poisoning', 'context-exfiltration',
|
|
157
|
+
'agent-manipulation', 'privilege-escalation', 'excessive-autonomy',
|
|
158
|
+
'data-poisoning', 'model-abuse', 'skill-compromise',
|
|
159
|
+
],
|
|
160
|
+
description: 'Optional: filter statistics to a single threat category.',
|
|
161
|
+
},
|
|
162
|
+
},
|
|
163
|
+
},
|
|
164
|
+
},
|
|
165
|
+
];
|
|
166
|
+
export async function createMCPServer() {
|
|
167
|
+
const engine = new ATREngine({ rulesDir: RULES_DIR });
|
|
168
|
+
const ruleCount = await engine.loadRules();
|
|
169
|
+
const server = new Server({
|
|
170
|
+
name: 'atr-mcp-server',
|
|
171
|
+
version: '0.1.0',
|
|
172
|
+
}, {
|
|
173
|
+
capabilities: {
|
|
174
|
+
tools: {},
|
|
175
|
+
},
|
|
176
|
+
});
|
|
177
|
+
server.setRequestHandler(ListToolsRequestSchema, async () => ({
|
|
178
|
+
tools: TOOLS,
|
|
179
|
+
}));
|
|
180
|
+
server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
181
|
+
const { name, arguments: args } = request.params;
|
|
182
|
+
const toolArgs = (args ?? {});
|
|
183
|
+
switch (name) {
|
|
184
|
+
case 'atr_scan':
|
|
185
|
+
return handleScan(engine, toolArgs);
|
|
186
|
+
case 'atr_list_rules':
|
|
187
|
+
return handleListRules(engine, toolArgs);
|
|
188
|
+
case 'atr_validate_rule':
|
|
189
|
+
return handleValidate(toolArgs);
|
|
190
|
+
case 'atr_submit_proposal':
|
|
191
|
+
return handleSubmitProposal(toolArgs);
|
|
192
|
+
case 'atr_coverage_gaps':
|
|
193
|
+
return handleCoverageGaps(engine, toolArgs);
|
|
194
|
+
case 'atr_threat_summary':
|
|
195
|
+
return handleThreatSummary(engine, toolArgs);
|
|
196
|
+
default:
|
|
197
|
+
return {
|
|
198
|
+
content: [{ type: 'text', text: `Error: Unknown tool "${name}".` }],
|
|
199
|
+
isError: true,
|
|
200
|
+
};
|
|
201
|
+
}
|
|
202
|
+
});
|
|
203
|
+
return server;
|
|
204
|
+
}
|
|
205
|
+
export async function startMCPServer() {
|
|
206
|
+
const server = await createMCPServer();
|
|
207
|
+
const transport = new StdioServerTransport();
|
|
208
|
+
await server.connect(transport);
|
|
209
|
+
}
|
|
210
|
+
// Auto-start when run directly
|
|
211
|
+
const isDirectExecution = process.argv[1] &&
|
|
212
|
+
(process.argv[1].endsWith('mcp-server.js') ||
|
|
213
|
+
process.argv[1].endsWith('mcp-server.ts'));
|
|
214
|
+
if (isDirectExecution) {
|
|
215
|
+
startMCPServer().catch((err) => {
|
|
216
|
+
process.stderr.write(`ATR MCP Server error: ${err instanceof Error ? err.message : String(err)}\n`);
|
|
217
|
+
process.exit(1);
|
|
218
|
+
});
|
|
219
|
+
}
|
|
220
|
+
//# sourceMappingURL=mcp-server.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mcp-server.js","sourceRoot":"","sources":["../src/mcp-server.ts"],"names":[],"mappings":";AACA;;;;;;;GAOG;AAEH,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAC7C,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,MAAM,EAAE,MAAM,2CAA2C,CAAC;AACnE,OAAO,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAC;AACjF,OAAO,EACL,sBAAsB,EACtB,qBAAqB,GACtB,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACjD,OAAO,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAC5D,OAAO,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AACzD,OAAO,EAAE,oBAAoB,EAAE,MAAM,gCAAgC,CAAC;AACtE,OAAO,EAAE,kBAAkB,EAAE,MAAM,8BAA8B,CAAC;AAClE,OAAO,EAAE,mBAAmB,EAAE,MAAM,+BAA+B,CAAC;AAEpE,MA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AAS,CAAC,CAAC;AAClC,CAAC;AAED,+BAA+B;AAC/B,MAAM,iBAAiB,GACrB,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC;IACf,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,eAAe,CAAC;QACzC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,eAAe,CAAC,CAAC,CAAC;AAE9C,IAAI,iBAAiB,EAAE,CAAC;IACtB,cAAc,EAAE,CAAC,KAAK,CAAC,CAAC,GAAG,EAAE,EAAE;QAC7B,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,yBAAyB,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;QACpG,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* atr_coverage_gaps MCP tool - Analyze coverage gaps against security frameworks
|
|
3
|
+
* @module agent-threat-rules/mcp-tools/coverage-gaps
|
|
4
|
+
*/
|
|
5
|
+
import type { ATREngine } from '../engine.js';
|
|
6
|
+
export declare function handleCoverageGaps(engine: ATREngine, args: Record<string, unknown>): {
|
|
7
|
+
content: Array<{
|
|
8
|
+
type: string;
|
|
9
|
+
text: string;
|
|
10
|
+
}>;
|
|
11
|
+
isError?: boolean;
|
|
12
|
+
};
|
|
13
|
+
//# sourceMappingURL=coverage-gaps.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"coverage-gaps.d.ts","sourceRoot":"","sources":["../../src/mcp-tools/coverage-gaps.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAE9C,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,SAAS,EAAE,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG;IACpF,OAAO,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAC/C,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB,CAkDA"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* atr_coverage_gaps MCP tool - Analyze coverage gaps against security frameworks
|
|
3
|
+
* @module agent-threat-rules/mcp-tools/coverage-gaps
|
|
4
|
+
*/
|
|
5
|
+
import { CoverageAnalyzer } from '../coverage-analyzer.js';
|
|
6
|
+
export function handleCoverageGaps(engine, args) {
|
|
7
|
+
const framework = (args['framework'] ?? 'all').toLowerCase();
|
|
8
|
+
const validFrameworks = ['owasp_agentic', 'mitre_atlas', 'all'];
|
|
9
|
+
if (!validFrameworks.includes(framework)) {
|
|
10
|
+
return {
|
|
11
|
+
content: [{ type: 'text', text: `Error: "framework" must be one of: ${validFrameworks.join(', ')}` }],
|
|
12
|
+
isError: true,
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
const analyzer = new CoverageAnalyzer(engine.getRules());
|
|
16
|
+
const report = analyzer.analyze();
|
|
17
|
+
// Filter gaps by requested framework
|
|
18
|
+
const filteredGaps = framework === 'all'
|
|
19
|
+
? report.gaps
|
|
20
|
+
: report.gaps.filter((g) => {
|
|
21
|
+
if (framework === 'owasp_agentic')
|
|
22
|
+
return g.framework === 'OWASP Agentic Top 10';
|
|
23
|
+
if (framework === 'mitre_atlas')
|
|
24
|
+
return g.framework === 'MITRE ATLAS';
|
|
25
|
+
return true;
|
|
26
|
+
});
|
|
27
|
+
const filteredSuggestions = framework === 'all'
|
|
28
|
+
? report.suggestions
|
|
29
|
+
: report.suggestions.filter((s) => {
|
|
30
|
+
if (framework === 'owasp_agentic')
|
|
31
|
+
return s.includes('OWASP') || s.includes('ASI');
|
|
32
|
+
if (framework === 'mitre_atlas')
|
|
33
|
+
return s.includes('MITRE') || s.includes('AML');
|
|
34
|
+
return true;
|
|
35
|
+
});
|
|
36
|
+
const result = {
|
|
37
|
+
analysis_timestamp: new Date().toISOString(),
|
|
38
|
+
total_rules_loaded: engine.getRuleCount(),
|
|
39
|
+
total_active_rules: report.totalRules,
|
|
40
|
+
framework_filter: framework,
|
|
41
|
+
gaps: filteredGaps.map((g) => ({
|
|
42
|
+
framework: g.framework,
|
|
43
|
+
risk_id: g.riskId,
|
|
44
|
+
risk_name: g.riskName,
|
|
45
|
+
current_rule_count: g.currentRuleCount,
|
|
46
|
+
recommended_min: g.recommendedMin,
|
|
47
|
+
})),
|
|
48
|
+
category_distribution: report.categoryDistribution,
|
|
49
|
+
suggestions: filteredSuggestions,
|
|
50
|
+
};
|
|
51
|
+
return {
|
|
52
|
+
content: [{ type: 'text', text: JSON.stringify(result, null, 2) }],
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
//# sourceMappingURL=coverage-gaps.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"coverage-gaps.js","sourceRoot":"","sources":["../../src/mcp-tools/coverage-gaps.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAI3D,MAAM,UAAU,kBAAkB,CAAC,MAAiB,EAAE,IAA6B;IAIjF,MAAM,SAAS,GAAG,CAAE,IAAI,CAAC,WAAW,CAAY,IAAI,KAAK,CAAC,CAAC,WAAW,EAAE,CAAC;IAEzE,MAAM,eAAe,GAAG,CAAC,eAAe,EAAE,aAAa,EAAE,KAAK,CAAC,CAAC;IAChE,IAAI,CAAC,eAAe,CAAC,QAAQ,CAAC,SAAS,CAAC,EAAE,CAAC;QACzC,OAAO;YACL,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,sCAAsC,eAAe,CAAC,I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AU;QACrC,gBAAgB,EAAE,SAAS;QAC3B,IAAI,EAAE,YAAY,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;YAC7B,SAAS,EAAE,CAAC,CAAC,SAAS;YACtB,OAAO,EAAE,CAAC,CAAC,MAAM;YACjB,SAAS,EAAE,CAAC,CAAC,QAAQ;YACrB,kBAAkB,EAAE,CAAC,CAAC,gBAAgB;YACtC,eAAe,EAAE,CAAC,CAAC,cAAc;SAClC,CAAC,CAAC;QACH,qBAAqB,EAAE,MAAM,CAAC,oBAAoB;QAClD,WAAW,EAAE,mBAAmB;KACjC,CAAC;IAEF,OAAO;QACL,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC,EAAE,CAAC;KACnE,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* atr_list_rules MCP tool - List and filter ATR rules
|
|
3
|
+
* @module agent-threat-rules/mcp-tools/list-rules
|
|
4
|
+
*/
|
|
5
|
+
import type { ATREngine } from '../engine.js';
|
|
6
|
+
export interface ListRulesInput {
|
|
7
|
+
category?: string;
|
|
8
|
+
severity?: string;
|
|
9
|
+
search?: string;
|
|
10
|
+
}
|
|
11
|
+
export declare function handleListRules(engine: ATREngine, args: Record<string, unknown>): {
|
|
12
|
+
content: Array<{
|
|
13
|
+
type: string;
|
|
14
|
+
text: string;
|
|
15
|
+
}>;
|
|
16
|
+
};
|
|
17
|
+
//# sourceMappingURL=list-rules.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"list-rules.d.ts","sourceRoot":"","sources":["../../src/mcp-tools/list-rules.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAE9C,MAAM,WAAW,cAAc;IAC7B,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,wBAAgB,eAAe,CAAC,MAAM,EAAE,SAAS,EAAE,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG;IACjF,OAAO,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;CAChD,CAgDA"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* atr_list_rules MCP tool - List and filter ATR rules
|
|
3
|
+
* @module agent-threat-rules/mcp-tools/list-rules
|
|
4
|
+
*/
|
|
5
|
+
export function handleListRules(engine, args) {
|
|
6
|
+
const category = args['category'];
|
|
7
|
+
const severity = args['severity'];
|
|
8
|
+
const search = args['search'];
|
|
9
|
+
let rules = [...engine.getRules()];
|
|
10
|
+
if (category) {
|
|
11
|
+
rules = rules.filter((r) => r.tags.category === category);
|
|
12
|
+
}
|
|
13
|
+
if (severity) {
|
|
14
|
+
rules = rules.filter((r) => r.severity === severity.toLowerCase());
|
|
15
|
+
}
|
|
16
|
+
if (search) {
|
|
17
|
+
const term = search.toLowerCase();
|
|
18
|
+
rules = rules.filter((r) => r.title.toLowerCase().includes(term) ||
|
|
19
|
+
r.description.toLowerCase().includes(term) ||
|
|
20
|
+
r.id.toLowerCase().includes(term) ||
|
|
21
|
+
r.tags.category.toLowerCase().includes(term));
|
|
22
|
+
}
|
|
23
|
+
const result = {
|
|
24
|
+
total: rules.length,
|
|
25
|
+
filters_applied: {
|
|
26
|
+
...(category ? { category } : {}),
|
|
27
|
+
...(severity ? { severity } : {}),
|
|
28
|
+
...(search ? { search } : {}),
|
|
29
|
+
},
|
|
30
|
+
rules: rules.map((r) => ({
|
|
31
|
+
id: r.id,
|
|
32
|
+
title: r.title,
|
|
33
|
+
severity: r.severity,
|
|
34
|
+
status: r.status,
|
|
35
|
+
category: r.tags.category,
|
|
36
|
+
source_type: r.agent_source.type,
|
|
37
|
+
description: r.description,
|
|
38
|
+
actions: r.response.actions,
|
|
39
|
+
})),
|
|
40
|
+
};
|
|
41
|
+
return {
|
|
42
|
+
content: [{ type: 'text', text: JSON.stringify(result, null, 2) }],
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
//# sourceMappingURL=list-rules.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"list-rules.js","sourceRoot":"","sources":["../../src/mcp-tools/list-rules.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAUH,MAAM,UAAU,eAAe,CAAC,MAAiB,EAAE,IAA6B;IAG9E,MAAM,QAAQ,GAAG,IAAI,CAAC,UAAU,CAAuB,CAAC;IACxD,MAAM,QAAQ,GAAG,IAAI,CAAC,UAAU,CAAuB,CAAC;IACxD,MAAM,MAAM,GAAG,IAAI,CAAC,QAAQ,CAAuB,CAAC;IAEpD,IAAI,KAAK,GAAG,CAAC,GAAG,MAAM,CAAC,QAAQ,EAAE,CAAC,CAAC;IAEnC,IAAI,QAAQ,EAAE,CAAC;QACb,KAAK,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,QAAQ,KAAK,QAAQ,CAAC,CAAC;IAC5D,CAAC;IAED,IAAI,QAAQ,EAAE,CAAC;QACb,KAAK,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,QAAQ,KAAK,QAAQ,CAAC,WAAW,EAAE,CAAC,CAAC;IACrE,CAAC;IAED,IAAI,MAAM,EAAE,CAAC;QACX,MAAM,IAAI,GAAG,MAAM,CAAC,WAAW,EAAE,CAAC;QAClC,KAAK,GAAG,KAAK,CAAC,MAAM,CAClB,CAAC,CAAC,EAAE,EAAE,CACJ,CAAC,CAAC,KAAK,CAAC,WA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,EAAE,CAAC;KACnE,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* atr_scan MCP tool - Scan content for agent threats
|
|
3
|
+
* @module agent-threat-rules/mcp-tools/scan
|
|
4
|
+
*/
|
|
5
|
+
import type { ATREngine } from '../engine.js';
|
|
6
|
+
export interface ScanInput {
|
|
7
|
+
content: string;
|
|
8
|
+
event_type?: string;
|
|
9
|
+
min_severity?: string;
|
|
10
|
+
}
|
|
11
|
+
export declare function handleScan(engine: ATREngine, args: Record<string, unknown>): {
|
|
12
|
+
content: Array<{
|
|
13
|
+
type: string;
|
|
14
|
+
text: string;
|
|
15
|
+
}>;
|
|
16
|
+
isError?: boolean;
|
|
17
|
+
};
|
|
18
|
+
//# sourceMappingURL=scan.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scan.d.ts","sourceRoot":"","sources":["../../src/mcp-tools/scan.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAG9C,MAAM,WAAW,SAAS;IACxB,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAmBD,wBAAgB,UAAU,CAAC,MAAM,EAAE,SAAS,EAAE,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG;IAC5E,OAAO,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAC/C,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB,CA+DA"}
|