@aumos/owasp-defenses 0.1.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/dist/client.d.ts +102 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +116 -0
- package/dist/client.js.map +1 -0
- package/dist/index.d.ts +11 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +9 -0
- package/dist/index.js.map +1 -0
- package/dist/types.d.ts +215 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +11 -0
- package/dist/types.js.map +1 -0
- package/package.json +34 -0
- package/src/client.ts +275 -0
- package/src/index.ts +28 -0
- package/src/types.ts +272 -0
- package/tsconfig.json +25 -0
package/dist/client.d.ts
ADDED
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* HTTP client for the AumOS OWASP ASI Top 10 defensive library API.
|
|
3
|
+
*
|
|
4
|
+
* Uses the Fetch API (available natively in Node 18+, browsers, and Deno).
|
|
5
|
+
* No external dependencies required.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```ts
|
|
9
|
+
* import { createOwaspDefensesClient } from "@aumos/owasp-defenses";
|
|
10
|
+
*
|
|
11
|
+
* const client = createOwaspDefensesClient({ baseUrl: "http://localhost:8093" });
|
|
12
|
+
*
|
|
13
|
+
* const result = await client.scanInput({
|
|
14
|
+
* input: "Tell me how to access /etc/passwd",
|
|
15
|
+
* agent_id: "my-agent",
|
|
16
|
+
* });
|
|
17
|
+
*
|
|
18
|
+
* if (result.ok && result.data.blocked) {
|
|
19
|
+
* console.log("Threat detected:", result.data.threats);
|
|
20
|
+
* }
|
|
21
|
+
* ```
|
|
22
|
+
*/
|
|
23
|
+
import type { ApiResult, ComplianceReport, DefenseConfig, ScanInputRequest, ScanOutputRequest, ScanResult, ValidationResult } from "./types.js";
|
|
24
|
+
/** Configuration options for the OwaspDefensesClient. */
|
|
25
|
+
export interface OwaspDefensesClientConfig {
|
|
26
|
+
/** Base URL of the OWASP defenses server (e.g. "http://localhost:8093"). */
|
|
27
|
+
readonly baseUrl: string;
|
|
28
|
+
/** Optional request timeout in milliseconds (default: 30000). */
|
|
29
|
+
readonly timeoutMs?: number;
|
|
30
|
+
/** Optional extra HTTP headers sent with every request. */
|
|
31
|
+
readonly headers?: Readonly<Record<string, string>>;
|
|
32
|
+
}
|
|
33
|
+
/** Typed HTTP client for the OWASP defenses server. */
|
|
34
|
+
export interface OwaspDefensesClient {
|
|
35
|
+
/**
|
|
36
|
+
* Scan an agent's input payload for security threats.
|
|
37
|
+
*
|
|
38
|
+
* Evaluates the input against all relevant ASI defense categories
|
|
39
|
+
* and returns detected threats along with a blocking decision.
|
|
40
|
+
*
|
|
41
|
+
* @param request - The input payload and agent context.
|
|
42
|
+
* @returns A ValidationResult with threat detections and blocking decision.
|
|
43
|
+
*/
|
|
44
|
+
scanInput(request: ScanInputRequest): Promise<ApiResult<ValidationResult>>;
|
|
45
|
+
/**
|
|
46
|
+
* Scan an agent's output payload for security issues.
|
|
47
|
+
*
|
|
48
|
+
* Evaluates the output for data exfiltration, PII leakage, and
|
|
49
|
+
* other output-side ASI violations.
|
|
50
|
+
*
|
|
51
|
+
* @param request - The output payload and agent context.
|
|
52
|
+
* @returns A ValidationResult with threat detections and blocking decision.
|
|
53
|
+
*/
|
|
54
|
+
scanOutput(request: ScanOutputRequest): Promise<ApiResult<ValidationResult>>;
|
|
55
|
+
/**
|
|
56
|
+
* Retrieve the current defense status for a configured agent.
|
|
57
|
+
*
|
|
58
|
+
* Returns a full ScanResult representing the agent's current
|
|
59
|
+
* defense posture based on its declared configuration.
|
|
60
|
+
*
|
|
61
|
+
* @param agentId - The agent identifier to inspect.
|
|
62
|
+
* @returns A ScanResult with per-category scores and grades.
|
|
63
|
+
*/
|
|
64
|
+
getDefenseStatus(agentId: string): Promise<ApiResult<ScanResult>>;
|
|
65
|
+
/**
|
|
66
|
+
* Validate an agent tool declaration against security rules.
|
|
67
|
+
*
|
|
68
|
+
* Checks whether the tool's schema, name, and configuration
|
|
69
|
+
* conform to ASI-02 (Tool and Resource Misuse) requirements.
|
|
70
|
+
*
|
|
71
|
+
* @param agentId - The agent that owns the tool.
|
|
72
|
+
* @param toolName - The name of the tool to validate.
|
|
73
|
+
* @param toolSchema - The tool's argument schema (JSON Schema object).
|
|
74
|
+
* @returns A ValidationResult for the tool declaration.
|
|
75
|
+
*/
|
|
76
|
+
validateTool(agentId: string, toolName: string, toolSchema: Readonly<Record<string, unknown>>): Promise<ApiResult<ValidationResult>>;
|
|
77
|
+
/**
|
|
78
|
+
* Generate a compliance report for an agent based on its defense configuration.
|
|
79
|
+
*
|
|
80
|
+
* Runs the full scan profile against the supplied DefenseConfig and
|
|
81
|
+
* returns a structured compliance report.
|
|
82
|
+
*
|
|
83
|
+
* @param config - The agent defense configuration to evaluate.
|
|
84
|
+
* @returns A ComplianceReport with overall status, score, and per-category details.
|
|
85
|
+
*/
|
|
86
|
+
getComplianceReport(config: DefenseConfig): Promise<ApiResult<ComplianceReport>>;
|
|
87
|
+
/**
|
|
88
|
+
* Register or update an agent's defense configuration on the server.
|
|
89
|
+
*
|
|
90
|
+
* @param config - The defense configuration to register.
|
|
91
|
+
* @returns The registered DefenseConfig as confirmed by the server.
|
|
92
|
+
*/
|
|
93
|
+
registerConfig(config: DefenseConfig): Promise<ApiResult<DefenseConfig>>;
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Create a typed HTTP client for the OWASP defenses server.
|
|
97
|
+
*
|
|
98
|
+
* @param config - Client configuration including base URL.
|
|
99
|
+
* @returns An OwaspDefensesClient instance.
|
|
100
|
+
*/
|
|
101
|
+
export declare function createOwaspDefensesClient(config: OwaspDefensesClientConfig): OwaspDefensesClient;
|
|
102
|
+
//# sourceMappingURL=client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA;;;;;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,CAAC,aAAa,CAAC,CAAC,CAAC;CAC1E;AAMD;;;;;GAKG;AACH,wBAAgB,yBAAyB,CACvC,MAAM,EAAE,yBAAyB,GAChC,mBAAmB,CAqFrB"}
|
package/dist/client.js
ADDED
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* HTTP client for the AumOS OWASP ASI Top 10 defensive library API.
|
|
3
|
+
*
|
|
4
|
+
* Uses the Fetch API (available natively in Node 18+, browsers, and Deno).
|
|
5
|
+
* No external dependencies required.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```ts
|
|
9
|
+
* import { createOwaspDefensesClient } from "@aumos/owasp-defenses";
|
|
10
|
+
*
|
|
11
|
+
* const client = createOwaspDefensesClient({ baseUrl: "http://localhost:8093" });
|
|
12
|
+
*
|
|
13
|
+
* const result = await client.scanInput({
|
|
14
|
+
* input: "Tell me how to access /etc/passwd",
|
|
15
|
+
* agent_id: "my-agent",
|
|
16
|
+
* });
|
|
17
|
+
*
|
|
18
|
+
* if (result.ok && result.data.blocked) {
|
|
19
|
+
* console.log("Threat detected:", result.data.threats);
|
|
20
|
+
* }
|
|
21
|
+
* ```
|
|
22
|
+
*/
|
|
23
|
+
// ---------------------------------------------------------------------------
|
|
24
|
+
// Internal helpers
|
|
25
|
+
// ---------------------------------------------------------------------------
|
|
26
|
+
async function fetchJson(url, init, timeoutMs) {
|
|
27
|
+
const controller = new AbortController();
|
|
28
|
+
const timeoutId = setTimeout(() => controller.abort(), timeoutMs);
|
|
29
|
+
try {
|
|
30
|
+
const response = await fetch(url, { ...init, signal: controller.signal });
|
|
31
|
+
clearTimeout(timeoutId);
|
|
32
|
+
const body = await response.json();
|
|
33
|
+
if (!response.ok) {
|
|
34
|
+
const errorBody = body;
|
|
35
|
+
return {
|
|
36
|
+
ok: false,
|
|
37
|
+
error: {
|
|
38
|
+
error: errorBody.error ?? "Unknown error",
|
|
39
|
+
detail: errorBody.detail ?? "",
|
|
40
|
+
},
|
|
41
|
+
status: response.status,
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
return { ok: true, data: body };
|
|
45
|
+
}
|
|
46
|
+
catch (err) {
|
|
47
|
+
clearTimeout(timeoutId);
|
|
48
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
49
|
+
return {
|
|
50
|
+
ok: false,
|
|
51
|
+
error: { error: "Network error", detail: message },
|
|
52
|
+
status: 0,
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
function buildHeaders(extraHeaders) {
|
|
57
|
+
return {
|
|
58
|
+
"Content-Type": "application/json",
|
|
59
|
+
Accept: "application/json",
|
|
60
|
+
...extraHeaders,
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
// ---------------------------------------------------------------------------
|
|
64
|
+
// Client factory
|
|
65
|
+
// ---------------------------------------------------------------------------
|
|
66
|
+
/**
|
|
67
|
+
* Create a typed HTTP client for the OWASP defenses server.
|
|
68
|
+
*
|
|
69
|
+
* @param config - Client configuration including base URL.
|
|
70
|
+
* @returns An OwaspDefensesClient instance.
|
|
71
|
+
*/
|
|
72
|
+
export function createOwaspDefensesClient(config) {
|
|
73
|
+
const { baseUrl, timeoutMs = 30000, headers: extraHeaders } = config;
|
|
74
|
+
const baseHeaders = buildHeaders(extraHeaders);
|
|
75
|
+
return {
|
|
76
|
+
async scanInput(request) {
|
|
77
|
+
return fetchJson(`${baseUrl}/scan/input`, {
|
|
78
|
+
method: "POST",
|
|
79
|
+
headers: baseHeaders,
|
|
80
|
+
body: JSON.stringify(request),
|
|
81
|
+
}, timeoutMs);
|
|
82
|
+
},
|
|
83
|
+
async scanOutput(request) {
|
|
84
|
+
return fetchJson(`${baseUrl}/scan/output`, {
|
|
85
|
+
method: "POST",
|
|
86
|
+
headers: baseHeaders,
|
|
87
|
+
body: JSON.stringify(request),
|
|
88
|
+
}, timeoutMs);
|
|
89
|
+
},
|
|
90
|
+
async getDefenseStatus(agentId) {
|
|
91
|
+
return fetchJson(`${baseUrl}/agents/${encodeURIComponent(agentId)}/status`, { method: "GET", headers: baseHeaders }, timeoutMs);
|
|
92
|
+
},
|
|
93
|
+
async validateTool(agentId, toolName, toolSchema) {
|
|
94
|
+
return fetchJson(`${baseUrl}/tools/validate`, {
|
|
95
|
+
method: "POST",
|
|
96
|
+
headers: baseHeaders,
|
|
97
|
+
body: JSON.stringify({ agent_id: agentId, tool_name: toolName, schema: toolSchema }),
|
|
98
|
+
}, timeoutMs);
|
|
99
|
+
},
|
|
100
|
+
async getComplianceReport(config) {
|
|
101
|
+
return fetchJson(`${baseUrl}/compliance/report`, {
|
|
102
|
+
method: "POST",
|
|
103
|
+
headers: baseHeaders,
|
|
104
|
+
body: JSON.stringify(config),
|
|
105
|
+
}, timeoutMs);
|
|
106
|
+
},
|
|
107
|
+
async registerConfig(config) {
|
|
108
|
+
return fetchJson(`${baseUrl}/agents/${encodeURIComponent(config.agent_id)}/config`, {
|
|
109
|
+
method: "PUT",
|
|
110
|
+
headers: baseHeaders,
|
|
111
|
+
body: JSON.stringify(config),
|
|
112
|
+
}, timeoutMs);
|
|
113
|
+
},
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
//# sourceMappingURL=client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AA2BH,8EAA8E;AAC9E,mBAAmB;AACnB,8EAA8E;AAE9E,KAAK,UAAU,SAAS,CACtB,GAAW,EACX,IAAiB,EACjB,SAAiB;IAEjB,MAAM,UAAU,GAAG,IAAI,eAAe,EAAE,CAAC;IACzC,MAAM,SAAS,GAAG,UAAU,CAAC,GAAG,EAAE,CAAC,UAAU,CAAC,KAAK,EAAE,EAAE,SAAS,CAAC,CAAC;IAElE,IAAI,CAAC;QACH,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,GAAG,EAAE,EAAE,GAAG,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I,CAAC,SAAS,CAAC,MAAM,CAAC;aAC7B,EACD,SAAS,CACV,CAAC;QACJ,CAAC;QAED,KAAK,CAAC,cAAc,CAClB,MAAqB;YAErB,OAAO,SAAS,CACd,GAAG,OAAO,WAAW,kBAAkB,CAAC,MAAM,CAAC,QAAQ,CAAC,SAAS,EACjE;gBACE,MAAM,EAAE,KAAK;gBACb,OAAO,EAAE,WAAW;gBACpB,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC;aAC7B,EACD,SAAS,CACV,CAAC;QACJ,CAAC;KACF,CAAC;AACJ,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @aumos/owasp-defenses
|
|
3
|
+
*
|
|
4
|
+
* TypeScript client for the AumOS OWASP ASI Top 10 defensive library.
|
|
5
|
+
* Provides HTTP client and security type definitions for agent input/output
|
|
6
|
+
* scanning, threat detection, tool validation, and compliance reporting.
|
|
7
|
+
*/
|
|
8
|
+
export type { OwaspDefensesClient, OwaspDefensesClientConfig } from "./client.js";
|
|
9
|
+
export { createOwaspDefensesClient } from "./client.js";
|
|
10
|
+
export type { DefenseCategory, ScanProfile, CategoryResult, ScanResult, ThreatDetection, DefenseConfig, AgentToolDeclaration, ValidationResult, ComplianceReport, ScanInputRequest, ScanOutputRequest, ApiError, ApiResult, } from "./types.js";
|
|
11
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,YAAY,EAAE,mBAAmB,EAAE,yBAAyB,EAAE,MAAM,aAAa,CAAC;AAClF,OAAO,EAAE,yBAAyB,EAAE,MAAM,aAAa,CAAC;AAGxD,YAAY,EACV,eAAe,EACf,WAAW,EACX,cAAc,EACd,UAAU,EACV,eAAe,EACf,aAAa,EACb,oBAAoB,EACpB,gBAAgB,EAChB,gBAAgB,EAChB,gBAAgB,EAChB,iBAAiB,EACjB,QAAQ,EACR,SAAS,GACV,MAAM,YAAY,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @aumos/owasp-defenses
|
|
3
|
+
*
|
|
4
|
+
* TypeScript client for the AumOS OWASP ASI Top 10 defensive library.
|
|
5
|
+
* Provides HTTP client and security type definitions for agent input/output
|
|
6
|
+
* scanning, threat detection, tool validation, and compliance reporting.
|
|
7
|
+
*/
|
|
8
|
+
export { createOwaspDefensesClient } from "./client.js";
|
|
9
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAIH,OAAO,EAAE,yBAAyB,EAAE,MAAM,aAAa,CAAC"}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,215 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* TypeScript interfaces for the AumOS OWASP ASI Top 10 defensive library.
|
|
3
|
+
*
|
|
4
|
+
* Mirrors the Python types defined in:
|
|
5
|
+
* aumos_owasp_defenses.scanner.agent_scanner
|
|
6
|
+
* aumos_owasp_defenses.scanner.report_generator
|
|
7
|
+
*
|
|
8
|
+
* All interfaces use readonly fields to match Python's frozen dataclasses.
|
|
9
|
+
*/
|
|
10
|
+
/**
|
|
11
|
+
* The ten OWASP ASI (Agentic Security Initiative) Top 10 category identifiers.
|
|
12
|
+
* Maps to the ASI category system in the Python scanner.
|
|
13
|
+
*/
|
|
14
|
+
export type DefenseCategory = "ASI-01" | "ASI-02" | "ASI-03" | "ASI-04" | "ASI-05" | "ASI-06" | "ASI-07" | "ASI-08" | "ASI-09" | "ASI-10";
|
|
15
|
+
/**
|
|
16
|
+
* Pre-defined scan profiles controlling which ASI categories are evaluated.
|
|
17
|
+
* Maps to ScanProfile enum in Python.
|
|
18
|
+
*/
|
|
19
|
+
export type ScanProfile = "standard" | "quick" | "mcp_focused" | "compliance";
|
|
20
|
+
/**
|
|
21
|
+
* Result for a single ASI category evaluation.
|
|
22
|
+
* Maps to CategoryResult dataclass in Python.
|
|
23
|
+
*/
|
|
24
|
+
export interface CategoryResult {
|
|
25
|
+
/** Category identifier (e.g. "ASI-01"). */
|
|
26
|
+
readonly asi_id: DefenseCategory;
|
|
27
|
+
/** Human-readable category name. */
|
|
28
|
+
readonly name: string;
|
|
29
|
+
/** Evaluation status: "PASS", "WARN", or "FAIL". */
|
|
30
|
+
readonly status: "PASS" | "WARN" | "FAIL";
|
|
31
|
+
/** Numeric score for this category (0–100). */
|
|
32
|
+
readonly score: number;
|
|
33
|
+
/** One-sentence description of the finding. */
|
|
34
|
+
readonly summary: string;
|
|
35
|
+
/** List of detailed finding strings. */
|
|
36
|
+
readonly findings: readonly string[];
|
|
37
|
+
/** Actionable remediation steps. */
|
|
38
|
+
readonly recommendations: readonly string[];
|
|
39
|
+
/** Whether the issue can be resolved automatically. */
|
|
40
|
+
readonly auto_fixable: boolean;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Aggregate result of a full agent security scan.
|
|
44
|
+
* Maps to ScanResult dataclass in Python.
|
|
45
|
+
*/
|
|
46
|
+
export interface ScanResult {
|
|
47
|
+
/** Identifier of the scanned agent. */
|
|
48
|
+
readonly agent_id: string;
|
|
49
|
+
/** The scan profile used. */
|
|
50
|
+
readonly profile: ScanProfile;
|
|
51
|
+
/** Overall security score (0–100), average of category scores. */
|
|
52
|
+
readonly score: number;
|
|
53
|
+
/** Letter grade derived from score (A–F). */
|
|
54
|
+
readonly grade: "A" | "B" | "C" | "D" | "F";
|
|
55
|
+
/** Per-ASI-category results. */
|
|
56
|
+
readonly category_results: readonly CategoryResult[];
|
|
57
|
+
/** ISO-8601 UTC timestamp of when the scan was performed. */
|
|
58
|
+
readonly scanned_at: string;
|
|
59
|
+
/** Wall-clock time for the scan in milliseconds. */
|
|
60
|
+
readonly scan_duration_ms: number;
|
|
61
|
+
/** Count of PASS categories. */
|
|
62
|
+
readonly passed: number;
|
|
63
|
+
/** Count of WARN categories. */
|
|
64
|
+
readonly warned: number;
|
|
65
|
+
/** Count of FAIL categories. */
|
|
66
|
+
readonly failed: number;
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* A detected threat or security concern found during input/output scanning.
|
|
70
|
+
*/
|
|
71
|
+
export interface ThreatDetection {
|
|
72
|
+
/** The ASI category this threat maps to. */
|
|
73
|
+
readonly category: DefenseCategory;
|
|
74
|
+
/** Severity level of the detected threat. */
|
|
75
|
+
readonly severity: "low" | "medium" | "high" | "critical";
|
|
76
|
+
/** Human-readable description of what was detected. */
|
|
77
|
+
readonly description: string;
|
|
78
|
+
/** Whether this threat blocks the action from proceeding. */
|
|
79
|
+
readonly blocking: boolean;
|
|
80
|
+
/** Optional remediation suggestion. */
|
|
81
|
+
readonly remediation?: string;
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Configuration for the defense scanning client.
|
|
85
|
+
* Mirrors the agent config format accepted by AgentScanner in Python.
|
|
86
|
+
*/
|
|
87
|
+
export interface DefenseConfig {
|
|
88
|
+
/** Identifier for the agent being configured. */
|
|
89
|
+
readonly agent_id: string;
|
|
90
|
+
/** The scan profile to apply during scanning. */
|
|
91
|
+
readonly profile?: ScanProfile;
|
|
92
|
+
/** System prompt of the agent (used for ASI-01 checks). */
|
|
93
|
+
readonly system_prompt?: string;
|
|
94
|
+
/** Tool declarations with their schemas. */
|
|
95
|
+
readonly tools?: readonly AgentToolDeclaration[];
|
|
96
|
+
/** Declared capability names for privilege checking. */
|
|
97
|
+
readonly capabilities?: readonly string[];
|
|
98
|
+
/** Rate limiting configuration. */
|
|
99
|
+
readonly rate_limits?: {
|
|
100
|
+
readonly enabled: boolean;
|
|
101
|
+
};
|
|
102
|
+
/** Circuit breaker configuration. */
|
|
103
|
+
readonly circuit_breakers?: {
|
|
104
|
+
readonly enabled: boolean;
|
|
105
|
+
};
|
|
106
|
+
/** Memory configuration for ASI-06 checks. */
|
|
107
|
+
readonly memory?: {
|
|
108
|
+
readonly enabled: boolean;
|
|
109
|
+
readonly provenance_tracking?: boolean;
|
|
110
|
+
readonly trust_level_enforcement?: boolean;
|
|
111
|
+
};
|
|
112
|
+
/** Code execution configuration for ASI-05 checks. */
|
|
113
|
+
readonly code_execution?: {
|
|
114
|
+
readonly enabled: boolean;
|
|
115
|
+
readonly sandbox?: boolean;
|
|
116
|
+
readonly allowed_paths?: readonly string[];
|
|
117
|
+
readonly command_allowlist?: readonly string[];
|
|
118
|
+
};
|
|
119
|
+
/** Trust configuration for ASI-09 checks. */
|
|
120
|
+
readonly trust_config?: {
|
|
121
|
+
readonly ceiling?: string;
|
|
122
|
+
readonly allow_self_escalation?: boolean;
|
|
123
|
+
};
|
|
124
|
+
/** Supply chain configuration for ASI-04 checks. */
|
|
125
|
+
readonly supply_chain?: {
|
|
126
|
+
readonly hash_verification?: boolean;
|
|
127
|
+
readonly vendor_allowlist?: readonly string[];
|
|
128
|
+
};
|
|
129
|
+
/** Inter-agent communication configuration for ASI-07 checks. */
|
|
130
|
+
readonly inter_agent?: {
|
|
131
|
+
readonly message_validation?: boolean;
|
|
132
|
+
readonly replay_protection?: boolean;
|
|
133
|
+
readonly sender_allowlist?: readonly string[];
|
|
134
|
+
};
|
|
135
|
+
/** Behavioral monitoring configuration for ASI-10 checks. */
|
|
136
|
+
readonly behavioral_monitoring?: {
|
|
137
|
+
readonly enabled: boolean;
|
|
138
|
+
readonly baseline_established?: boolean;
|
|
139
|
+
readonly drift_alerts?: boolean;
|
|
140
|
+
};
|
|
141
|
+
}
|
|
142
|
+
/** Declaration of a single tool with its argument schema. */
|
|
143
|
+
export interface AgentToolDeclaration {
|
|
144
|
+
/** Name of the tool. */
|
|
145
|
+
readonly name: string;
|
|
146
|
+
/** JSON Schema object describing the tool's arguments. */
|
|
147
|
+
readonly schema?: Readonly<Record<string, unknown>>;
|
|
148
|
+
}
|
|
149
|
+
/**
|
|
150
|
+
* Result of validating a tool or input against defense rules.
|
|
151
|
+
*/
|
|
152
|
+
export interface ValidationResult {
|
|
153
|
+
/** Whether the validated item passes all checks. */
|
|
154
|
+
readonly valid: boolean;
|
|
155
|
+
/** Whether the item should be blocked from execution. */
|
|
156
|
+
readonly blocked: boolean;
|
|
157
|
+
/** List of detected threats, if any. */
|
|
158
|
+
readonly threats: readonly ThreatDetection[];
|
|
159
|
+
/** Human-readable summary of the validation outcome. */
|
|
160
|
+
readonly summary: string;
|
|
161
|
+
}
|
|
162
|
+
/**
|
|
163
|
+
* A compliance report summarising the defense posture of an agent.
|
|
164
|
+
*/
|
|
165
|
+
export interface ComplianceReport {
|
|
166
|
+
/** Identifier of the agent that was assessed. */
|
|
167
|
+
readonly agent_id: string;
|
|
168
|
+
/** ISO-8601 UTC timestamp of report generation. */
|
|
169
|
+
readonly generated_at: string;
|
|
170
|
+
/** Overall compliance status across all categories. */
|
|
171
|
+
readonly overall_status: "compliant" | "partial" | "non_compliant";
|
|
172
|
+
/** Overall security score (0–100). */
|
|
173
|
+
readonly score: number;
|
|
174
|
+
/** Letter grade (A–F). */
|
|
175
|
+
readonly grade: "A" | "B" | "C" | "D" | "F";
|
|
176
|
+
/** Per-category compliance breakdown. */
|
|
177
|
+
readonly categories: readonly CategoryResult[];
|
|
178
|
+
/** Total number of findings across all categories. */
|
|
179
|
+
readonly total_findings: number;
|
|
180
|
+
/** Total number of recommendations across all categories. */
|
|
181
|
+
readonly total_recommendations: number;
|
|
182
|
+
}
|
|
183
|
+
/** Request to scan an agent's input payload. */
|
|
184
|
+
export interface ScanInputRequest {
|
|
185
|
+
/** The input text or payload to scan. */
|
|
186
|
+
readonly input: string;
|
|
187
|
+
/** Agent identifier for context. */
|
|
188
|
+
readonly agent_id: string;
|
|
189
|
+
/** Optional tool name if the input is a tool argument. */
|
|
190
|
+
readonly tool_name?: string;
|
|
191
|
+
}
|
|
192
|
+
/** Request to scan an agent's output payload. */
|
|
193
|
+
export interface ScanOutputRequest {
|
|
194
|
+
/** The output text or payload to scan. */
|
|
195
|
+
readonly output: string;
|
|
196
|
+
/** Agent identifier for context. */
|
|
197
|
+
readonly agent_id: string;
|
|
198
|
+
/** Optional tool name if the output is a tool result. */
|
|
199
|
+
readonly tool_name?: string;
|
|
200
|
+
}
|
|
201
|
+
/** Standard error payload returned by the OWASP defenses API. */
|
|
202
|
+
export interface ApiError {
|
|
203
|
+
readonly error: string;
|
|
204
|
+
readonly detail: string;
|
|
205
|
+
}
|
|
206
|
+
/** Result type for all client operations. */
|
|
207
|
+
export type ApiResult<T> = {
|
|
208
|
+
readonly ok: true;
|
|
209
|
+
readonly data: T;
|
|
210
|
+
} | {
|
|
211
|
+
readonly ok: false;
|
|
212
|
+
readonly error: ApiError;
|
|
213
|
+
readonly status: number;
|
|
214
|
+
};
|
|
215
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAMH;;;GAGG;AACH,MAAM,MAAM,eAAe,GACvB,QAAQ,GACR,QAAQ,GACR,QAAQ,GACR,QAAQ,GACR,QAAQ,GACR,QAAQ,GACR,QAAQ,GACR,QAAQ,GACR,QAAQ,GACR,QAAQ,CAAC;AAMb;;;GAGG;AACH,MAAM,MAAM,WAAW,GACnB,UAAU,GACV,OAAO,GACP,aAAa,GACb,YAAY,CAAC;AAMjB;;;GAGG;AACH,MAAM,WAAW,cAAc;IAC7B,2CAA2C;IAC3C,QAAQ,CAAC,MAAM,EAAE,eAAe,CAAC;IACjC,oCAAoC;IACpC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,oDAAoD;IACpD,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,CAAC;IAC1C,+CAA+C;IAC/C,QAAQ,CAAC,KAA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,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;CACzB;AAED,6CAA6C;AAC7C,MAAM,MAAM,SAAS,CAAC,CAAC,IACnB;IAAE,QAAQ,CAAC,EAAE,EAAE,IAAI,CAAC;IAAC,QAAQ,CAAC,IAAI,EAAE,CAAC,CAAA;CAAE,GACvC;IAAE,QAAQ,CAAC,EAAE,EAAE,KAAK,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,QAAQ,CAAC;IAAC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAAC"}
|
package/dist/types.js
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* TypeScript interfaces for the AumOS OWASP ASI Top 10 defensive library.
|
|
3
|
+
*
|
|
4
|
+
* Mirrors the Python types defined in:
|
|
5
|
+
* aumos_owasp_defenses.scanner.agent_scanner
|
|
6
|
+
* aumos_owasp_defenses.scanner.report_generator
|
|
7
|
+
*
|
|
8
|
+
* All interfaces use readonly fields to match Python's frozen dataclasses.
|
|
9
|
+
*/
|
|
10
|
+
export {};
|
|
11
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG"}
|
package/package.json
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@aumos/owasp-defenses",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "TypeScript client for the AumOS OWASP ASI Top 10 defensive library — agent security scanning, threat detection, and compliance reporting",
|
|
5
|
+
"license": "Apache-2.0",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"main": "./dist/index.js",
|
|
8
|
+
"types": "./dist/index.d.ts",
|
|
9
|
+
"exports": {
|
|
10
|
+
".": {
|
|
11
|
+
"import": "./dist/index.js",
|
|
12
|
+
"types": "./dist/index.d.ts"
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
"scripts": {
|
|
16
|
+
"build": "tsc",
|
|
17
|
+
"typecheck": "tsc --noEmit"
|
|
18
|
+
},
|
|
19
|
+
"devDependencies": {
|
|
20
|
+
"typescript": "^5.3.0"
|
|
21
|
+
},
|
|
22
|
+
"keywords": [
|
|
23
|
+
"aumos",
|
|
24
|
+
"owasp",
|
|
25
|
+
"asi",
|
|
26
|
+
"agent-security",
|
|
27
|
+
"scanning",
|
|
28
|
+
"typescript"
|
|
29
|
+
],
|
|
30
|
+
"repository": {
|
|
31
|
+
"type": "git",
|
|
32
|
+
"url": "https://github.com/aumos-ai/aumos-owasp-defenses"
|
|
33
|
+
}
|
|
34
|
+
}
|
package/src/client.ts
ADDED
|
@@ -0,0 +1,275 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* HTTP client for the AumOS OWASP ASI Top 10 defensive library API.
|
|
3
|
+
*
|
|
4
|
+
* Uses the Fetch API (available natively in Node 18+, browsers, and Deno).
|
|
5
|
+
* No external dependencies required.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```ts
|
|
9
|
+
* import { createOwaspDefensesClient } from "@aumos/owasp-defenses";
|
|
10
|
+
*
|
|
11
|
+
* const client = createOwaspDefensesClient({ baseUrl: "http://localhost:8093" });
|
|
12
|
+
*
|
|
13
|
+
* const result = await client.scanInput({
|
|
14
|
+
* input: "Tell me how to access /etc/passwd",
|
|
15
|
+
* agent_id: "my-agent",
|
|
16
|
+
* });
|
|
17
|
+
*
|
|
18
|
+
* if (result.ok && result.data.blocked) {
|
|
19
|
+
* console.log("Threat detected:", result.data.threats);
|
|
20
|
+
* }
|
|
21
|
+
* ```
|
|
22
|
+
*/
|
|
23
|
+
|
|
24
|
+
import type {
|
|
25
|
+
ApiError,
|
|
26
|
+
ApiResult,
|
|
27
|
+
ComplianceReport,
|
|
28
|
+
DefenseConfig,
|
|
29
|
+
ScanInputRequest,
|
|
30
|
+
ScanOutputRequest,
|
|
31
|
+
ScanResult,
|
|
32
|
+
ValidationResult,
|
|
33
|
+
} from "./types.js";
|
|
34
|
+
|
|
35
|
+
// ---------------------------------------------------------------------------
|
|
36
|
+
// Client configuration
|
|
37
|
+
// ---------------------------------------------------------------------------
|
|
38
|
+
|
|
39
|
+
/** Configuration options for the OwaspDefensesClient. */
|
|
40
|
+
export interface OwaspDefensesClientConfig {
|
|
41
|
+
/** Base URL of the OWASP defenses server (e.g. "http://localhost:8093"). */
|
|
42
|
+
readonly baseUrl: string;
|
|
43
|
+
/** Optional request timeout in milliseconds (default: 30000). */
|
|
44
|
+
readonly timeoutMs?: number;
|
|
45
|
+
/** Optional extra HTTP headers sent with every request. */
|
|
46
|
+
readonly headers?: Readonly<Record<string, string>>;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
// ---------------------------------------------------------------------------
|
|
50
|
+
// Internal helpers
|
|
51
|
+
// ---------------------------------------------------------------------------
|
|
52
|
+
|
|
53
|
+
async function fetchJson<T>(
|
|
54
|
+
url: string,
|
|
55
|
+
init: RequestInit,
|
|
56
|
+
timeoutMs: number,
|
|
57
|
+
): Promise<ApiResult<T>> {
|
|
58
|
+
const controller = new AbortController();
|
|
59
|
+
const timeoutId = setTimeout(() => controller.abort(), timeoutMs);
|
|
60
|
+
|
|
61
|
+
try {
|
|
62
|
+
const response = await fetch(url, { ...init, signal: controller.signal });
|
|
63
|
+
clearTimeout(timeoutId);
|
|
64
|
+
|
|
65
|
+
const body = await response.json() as unknown;
|
|
66
|
+
|
|
67
|
+
if (!response.ok) {
|
|
68
|
+
const errorBody = body as Partial<ApiError>;
|
|
69
|
+
return {
|
|
70
|
+
ok: false,
|
|
71
|
+
error: {
|
|
72
|
+
error: errorBody.error ?? "Unknown error",
|
|
73
|
+
detail: errorBody.detail ?? "",
|
|
74
|
+
},
|
|
75
|
+
status: response.status,
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
return { ok: true, data: body as T };
|
|
80
|
+
} catch (err: unknown) {
|
|
81
|
+
clearTimeout(timeoutId);
|
|
82
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
83
|
+
return {
|
|
84
|
+
ok: false,
|
|
85
|
+
error: { error: "Network error", detail: message },
|
|
86
|
+
status: 0,
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
function buildHeaders(
|
|
92
|
+
extraHeaders: Readonly<Record<string, string>> | undefined,
|
|
93
|
+
): Record<string, string> {
|
|
94
|
+
return {
|
|
95
|
+
"Content-Type": "application/json",
|
|
96
|
+
Accept: "application/json",
|
|
97
|
+
...extraHeaders,
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
// ---------------------------------------------------------------------------
|
|
102
|
+
// Client interface
|
|
103
|
+
// ---------------------------------------------------------------------------
|
|
104
|
+
|
|
105
|
+
/** Typed HTTP client for the OWASP defenses server. */
|
|
106
|
+
export interface OwaspDefensesClient {
|
|
107
|
+
/**
|
|
108
|
+
* Scan an agent's input payload for security threats.
|
|
109
|
+
*
|
|
110
|
+
* Evaluates the input against all relevant ASI defense categories
|
|
111
|
+
* and returns detected threats along with a blocking decision.
|
|
112
|
+
*
|
|
113
|
+
* @param request - The input payload and agent context.
|
|
114
|
+
* @returns A ValidationResult with threat detections and blocking decision.
|
|
115
|
+
*/
|
|
116
|
+
scanInput(request: ScanInputRequest): Promise<ApiResult<ValidationResult>>;
|
|
117
|
+
|
|
118
|
+
/**
|
|
119
|
+
* Scan an agent's output payload for security issues.
|
|
120
|
+
*
|
|
121
|
+
* Evaluates the output for data exfiltration, PII leakage, and
|
|
122
|
+
* other output-side ASI violations.
|
|
123
|
+
*
|
|
124
|
+
* @param request - The output payload and agent context.
|
|
125
|
+
* @returns A ValidationResult with threat detections and blocking decision.
|
|
126
|
+
*/
|
|
127
|
+
scanOutput(request: ScanOutputRequest): Promise<ApiResult<ValidationResult>>;
|
|
128
|
+
|
|
129
|
+
/**
|
|
130
|
+
* Retrieve the current defense status for a configured agent.
|
|
131
|
+
*
|
|
132
|
+
* Returns a full ScanResult representing the agent's current
|
|
133
|
+
* defense posture based on its declared configuration.
|
|
134
|
+
*
|
|
135
|
+
* @param agentId - The agent identifier to inspect.
|
|
136
|
+
* @returns A ScanResult with per-category scores and grades.
|
|
137
|
+
*/
|
|
138
|
+
getDefenseStatus(agentId: string): Promise<ApiResult<ScanResult>>;
|
|
139
|
+
|
|
140
|
+
/**
|
|
141
|
+
* Validate an agent tool declaration against security rules.
|
|
142
|
+
*
|
|
143
|
+
* Checks whether the tool's schema, name, and configuration
|
|
144
|
+
* conform to ASI-02 (Tool and Resource Misuse) requirements.
|
|
145
|
+
*
|
|
146
|
+
* @param agentId - The agent that owns the tool.
|
|
147
|
+
* @param toolName - The name of the tool to validate.
|
|
148
|
+
* @param toolSchema - The tool's argument schema (JSON Schema object).
|
|
149
|
+
* @returns A ValidationResult for the tool declaration.
|
|
150
|
+
*/
|
|
151
|
+
validateTool(
|
|
152
|
+
agentId: string,
|
|
153
|
+
toolName: string,
|
|
154
|
+
toolSchema: Readonly<Record<string, unknown>>,
|
|
155
|
+
): Promise<ApiResult<ValidationResult>>;
|
|
156
|
+
|
|
157
|
+
/**
|
|
158
|
+
* Generate a compliance report for an agent based on its defense configuration.
|
|
159
|
+
*
|
|
160
|
+
* Runs the full scan profile against the supplied DefenseConfig and
|
|
161
|
+
* returns a structured compliance report.
|
|
162
|
+
*
|
|
163
|
+
* @param config - The agent defense configuration to evaluate.
|
|
164
|
+
* @returns A ComplianceReport with overall status, score, and per-category details.
|
|
165
|
+
*/
|
|
166
|
+
getComplianceReport(config: DefenseConfig): Promise<ApiResult<ComplianceReport>>;
|
|
167
|
+
|
|
168
|
+
/**
|
|
169
|
+
* Register or update an agent's defense configuration on the server.
|
|
170
|
+
*
|
|
171
|
+
* @param config - The defense configuration to register.
|
|
172
|
+
* @returns The registered DefenseConfig as confirmed by the server.
|
|
173
|
+
*/
|
|
174
|
+
registerConfig(config: DefenseConfig): Promise<ApiResult<DefenseConfig>>;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
// ---------------------------------------------------------------------------
|
|
178
|
+
// Client factory
|
|
179
|
+
// ---------------------------------------------------------------------------
|
|
180
|
+
|
|
181
|
+
/**
|
|
182
|
+
* Create a typed HTTP client for the OWASP defenses server.
|
|
183
|
+
*
|
|
184
|
+
* @param config - Client configuration including base URL.
|
|
185
|
+
* @returns An OwaspDefensesClient instance.
|
|
186
|
+
*/
|
|
187
|
+
export function createOwaspDefensesClient(
|
|
188
|
+
config: OwaspDefensesClientConfig,
|
|
189
|
+
): OwaspDefensesClient {
|
|
190
|
+
const { baseUrl, timeoutMs = 30_000, headers: extraHeaders } = config;
|
|
191
|
+
const baseHeaders = buildHeaders(extraHeaders);
|
|
192
|
+
|
|
193
|
+
return {
|
|
194
|
+
async scanInput(
|
|
195
|
+
request: ScanInputRequest,
|
|
196
|
+
): Promise<ApiResult<ValidationResult>> {
|
|
197
|
+
return fetchJson<ValidationResult>(
|
|
198
|
+
`${baseUrl}/scan/input`,
|
|
199
|
+
{
|
|
200
|
+
method: "POST",
|
|
201
|
+
headers: baseHeaders,
|
|
202
|
+
body: JSON.stringify(request),
|
|
203
|
+
},
|
|
204
|
+
timeoutMs,
|
|
205
|
+
);
|
|
206
|
+
},
|
|
207
|
+
|
|
208
|
+
async scanOutput(
|
|
209
|
+
request: ScanOutputRequest,
|
|
210
|
+
): Promise<ApiResult<ValidationResult>> {
|
|
211
|
+
return fetchJson<ValidationResult>(
|
|
212
|
+
`${baseUrl}/scan/output`,
|
|
213
|
+
{
|
|
214
|
+
method: "POST",
|
|
215
|
+
headers: baseHeaders,
|
|
216
|
+
body: JSON.stringify(request),
|
|
217
|
+
},
|
|
218
|
+
timeoutMs,
|
|
219
|
+
);
|
|
220
|
+
},
|
|
221
|
+
|
|
222
|
+
async getDefenseStatus(agentId: string): Promise<ApiResult<ScanResult>> {
|
|
223
|
+
return fetchJson<ScanResult>(
|
|
224
|
+
`${baseUrl}/agents/${encodeURIComponent(agentId)}/status`,
|
|
225
|
+
{ method: "GET", headers: baseHeaders },
|
|
226
|
+
timeoutMs,
|
|
227
|
+
);
|
|
228
|
+
},
|
|
229
|
+
|
|
230
|
+
async validateTool(
|
|
231
|
+
agentId: string,
|
|
232
|
+
toolName: string,
|
|
233
|
+
toolSchema: Readonly<Record<string, unknown>>,
|
|
234
|
+
): Promise<ApiResult<ValidationResult>> {
|
|
235
|
+
return fetchJson<ValidationResult>(
|
|
236
|
+
`${baseUrl}/tools/validate`,
|
|
237
|
+
{
|
|
238
|
+
method: "POST",
|
|
239
|
+
headers: baseHeaders,
|
|
240
|
+
body: JSON.stringify({ agent_id: agentId, tool_name: toolName, schema: toolSchema }),
|
|
241
|
+
},
|
|
242
|
+
timeoutMs,
|
|
243
|
+
);
|
|
244
|
+
},
|
|
245
|
+
|
|
246
|
+
async getComplianceReport(
|
|
247
|
+
config: DefenseConfig,
|
|
248
|
+
): Promise<ApiResult<ComplianceReport>> {
|
|
249
|
+
return fetchJson<ComplianceReport>(
|
|
250
|
+
`${baseUrl}/compliance/report`,
|
|
251
|
+
{
|
|
252
|
+
method: "POST",
|
|
253
|
+
headers: baseHeaders,
|
|
254
|
+
body: JSON.stringify(config),
|
|
255
|
+
},
|
|
256
|
+
timeoutMs,
|
|
257
|
+
);
|
|
258
|
+
},
|
|
259
|
+
|
|
260
|
+
async registerConfig(
|
|
261
|
+
config: DefenseConfig,
|
|
262
|
+
): Promise<ApiResult<DefenseConfig>> {
|
|
263
|
+
return fetchJson<DefenseConfig>(
|
|
264
|
+
`${baseUrl}/agents/${encodeURIComponent(config.agent_id)}/config`,
|
|
265
|
+
{
|
|
266
|
+
method: "PUT",
|
|
267
|
+
headers: baseHeaders,
|
|
268
|
+
body: JSON.stringify(config),
|
|
269
|
+
},
|
|
270
|
+
timeoutMs,
|
|
271
|
+
);
|
|
272
|
+
},
|
|
273
|
+
};
|
|
274
|
+
}
|
|
275
|
+
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @aumos/owasp-defenses
|
|
3
|
+
*
|
|
4
|
+
* TypeScript client for the AumOS OWASP ASI Top 10 defensive library.
|
|
5
|
+
* Provides HTTP client and security type definitions for agent input/output
|
|
6
|
+
* scanning, threat detection, tool validation, and compliance reporting.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
// Client and configuration
|
|
10
|
+
export type { OwaspDefensesClient, OwaspDefensesClientConfig } from "./client.js";
|
|
11
|
+
export { createOwaspDefensesClient } from "./client.js";
|
|
12
|
+
|
|
13
|
+
// Core types
|
|
14
|
+
export type {
|
|
15
|
+
DefenseCategory,
|
|
16
|
+
ScanProfile,
|
|
17
|
+
CategoryResult,
|
|
18
|
+
ScanResult,
|
|
19
|
+
ThreatDetection,
|
|
20
|
+
DefenseConfig,
|
|
21
|
+
AgentToolDeclaration,
|
|
22
|
+
ValidationResult,
|
|
23
|
+
ComplianceReport,
|
|
24
|
+
ScanInputRequest,
|
|
25
|
+
ScanOutputRequest,
|
|
26
|
+
ApiError,
|
|
27
|
+
ApiResult,
|
|
28
|
+
} from "./types.js";
|
package/src/types.ts
ADDED
|
@@ -0,0 +1,272 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* TypeScript interfaces for the AumOS OWASP ASI Top 10 defensive library.
|
|
3
|
+
*
|
|
4
|
+
* Mirrors the Python types defined in:
|
|
5
|
+
* aumos_owasp_defenses.scanner.agent_scanner
|
|
6
|
+
* aumos_owasp_defenses.scanner.report_generator
|
|
7
|
+
*
|
|
8
|
+
* All interfaces use readonly fields to match Python's frozen dataclasses.
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
// ---------------------------------------------------------------------------
|
|
12
|
+
// OWASP ASI category identifiers
|
|
13
|
+
// ---------------------------------------------------------------------------
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* The ten OWASP ASI (Agentic Security Initiative) Top 10 category identifiers.
|
|
17
|
+
* Maps to the ASI category system in the Python scanner.
|
|
18
|
+
*/
|
|
19
|
+
export type DefenseCategory =
|
|
20
|
+
| "ASI-01" // Goal and Task Hijacking
|
|
21
|
+
| "ASI-02" // Tool and Resource Misuse
|
|
22
|
+
| "ASI-03" // Identity and Privilege Compromise
|
|
23
|
+
| "ASI-04" // Supply Chain and Dependency Risks
|
|
24
|
+
| "ASI-05" // Insecure Code Execution
|
|
25
|
+
| "ASI-06" // Memory and Context Manipulation
|
|
26
|
+
| "ASI-07" // Inter-Agent Trust Exploitation
|
|
27
|
+
| "ASI-08" // Cascading and Recursive Failures
|
|
28
|
+
| "ASI-09" // Context Trust Exploitation
|
|
29
|
+
| "ASI-10"; // Rogue and Emergent Agent Behaviors
|
|
30
|
+
|
|
31
|
+
// ---------------------------------------------------------------------------
|
|
32
|
+
// Scan profile
|
|
33
|
+
// ---------------------------------------------------------------------------
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Pre-defined scan profiles controlling which ASI categories are evaluated.
|
|
37
|
+
* Maps to ScanProfile enum in Python.
|
|
38
|
+
*/
|
|
39
|
+
export type ScanProfile =
|
|
40
|
+
| "standard" // All ten ASI categories
|
|
41
|
+
| "quick" // ASI-01, ASI-02, ASI-03 only
|
|
42
|
+
| "mcp_focused" // ASI-01, ASI-02, ASI-04, ASI-07
|
|
43
|
+
| "compliance"; // All ten categories with stricter thresholds
|
|
44
|
+
|
|
45
|
+
// ---------------------------------------------------------------------------
|
|
46
|
+
// Category result
|
|
47
|
+
// ---------------------------------------------------------------------------
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Result for a single ASI category evaluation.
|
|
51
|
+
* Maps to CategoryResult dataclass in Python.
|
|
52
|
+
*/
|
|
53
|
+
export interface CategoryResult {
|
|
54
|
+
/** Category identifier (e.g. "ASI-01"). */
|
|
55
|
+
readonly asi_id: DefenseCategory;
|
|
56
|
+
/** Human-readable category name. */
|
|
57
|
+
readonly name: string;
|
|
58
|
+
/** Evaluation status: "PASS", "WARN", or "FAIL". */
|
|
59
|
+
readonly status: "PASS" | "WARN" | "FAIL";
|
|
60
|
+
/** Numeric score for this category (0–100). */
|
|
61
|
+
readonly score: number;
|
|
62
|
+
/** One-sentence description of the finding. */
|
|
63
|
+
readonly summary: string;
|
|
64
|
+
/** List of detailed finding strings. */
|
|
65
|
+
readonly findings: readonly string[];
|
|
66
|
+
/** Actionable remediation steps. */
|
|
67
|
+
readonly recommendations: readonly string[];
|
|
68
|
+
/** Whether the issue can be resolved automatically. */
|
|
69
|
+
readonly auto_fixable: boolean;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
// ---------------------------------------------------------------------------
|
|
73
|
+
// Scan result
|
|
74
|
+
// ---------------------------------------------------------------------------
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* Aggregate result of a full agent security scan.
|
|
78
|
+
* Maps to ScanResult dataclass in Python.
|
|
79
|
+
*/
|
|
80
|
+
export interface ScanResult {
|
|
81
|
+
/** Identifier of the scanned agent. */
|
|
82
|
+
readonly agent_id: string;
|
|
83
|
+
/** The scan profile used. */
|
|
84
|
+
readonly profile: ScanProfile;
|
|
85
|
+
/** Overall security score (0–100), average of category scores. */
|
|
86
|
+
readonly score: number;
|
|
87
|
+
/** Letter grade derived from score (A–F). */
|
|
88
|
+
readonly grade: "A" | "B" | "C" | "D" | "F";
|
|
89
|
+
/** Per-ASI-category results. */
|
|
90
|
+
readonly category_results: readonly CategoryResult[];
|
|
91
|
+
/** ISO-8601 UTC timestamp of when the scan was performed. */
|
|
92
|
+
readonly scanned_at: string;
|
|
93
|
+
/** Wall-clock time for the scan in milliseconds. */
|
|
94
|
+
readonly scan_duration_ms: number;
|
|
95
|
+
/** Count of PASS categories. */
|
|
96
|
+
readonly passed: number;
|
|
97
|
+
/** Count of WARN categories. */
|
|
98
|
+
readonly warned: number;
|
|
99
|
+
/** Count of FAIL categories. */
|
|
100
|
+
readonly failed: number;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
// ---------------------------------------------------------------------------
|
|
104
|
+
// Threat detection
|
|
105
|
+
// ---------------------------------------------------------------------------
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* A detected threat or security concern found during input/output scanning.
|
|
109
|
+
*/
|
|
110
|
+
export interface ThreatDetection {
|
|
111
|
+
/** The ASI category this threat maps to. */
|
|
112
|
+
readonly category: DefenseCategory;
|
|
113
|
+
/** Severity level of the detected threat. */
|
|
114
|
+
readonly severity: "low" | "medium" | "high" | "critical";
|
|
115
|
+
/** Human-readable description of what was detected. */
|
|
116
|
+
readonly description: string;
|
|
117
|
+
/** Whether this threat blocks the action from proceeding. */
|
|
118
|
+
readonly blocking: boolean;
|
|
119
|
+
/** Optional remediation suggestion. */
|
|
120
|
+
readonly remediation?: string;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
// ---------------------------------------------------------------------------
|
|
124
|
+
// Defense configuration
|
|
125
|
+
// ---------------------------------------------------------------------------
|
|
126
|
+
|
|
127
|
+
/**
|
|
128
|
+
* Configuration for the defense scanning client.
|
|
129
|
+
* Mirrors the agent config format accepted by AgentScanner in Python.
|
|
130
|
+
*/
|
|
131
|
+
export interface DefenseConfig {
|
|
132
|
+
/** Identifier for the agent being configured. */
|
|
133
|
+
readonly agent_id: string;
|
|
134
|
+
/** The scan profile to apply during scanning. */
|
|
135
|
+
readonly profile?: ScanProfile;
|
|
136
|
+
/** System prompt of the agent (used for ASI-01 checks). */
|
|
137
|
+
readonly system_prompt?: string;
|
|
138
|
+
/** Tool declarations with their schemas. */
|
|
139
|
+
readonly tools?: readonly AgentToolDeclaration[];
|
|
140
|
+
/** Declared capability names for privilege checking. */
|
|
141
|
+
readonly capabilities?: readonly string[];
|
|
142
|
+
/** Rate limiting configuration. */
|
|
143
|
+
readonly rate_limits?: { readonly enabled: boolean };
|
|
144
|
+
/** Circuit breaker configuration. */
|
|
145
|
+
readonly circuit_breakers?: { readonly enabled: boolean };
|
|
146
|
+
/** Memory configuration for ASI-06 checks. */
|
|
147
|
+
readonly memory?: {
|
|
148
|
+
readonly enabled: boolean;
|
|
149
|
+
readonly provenance_tracking?: boolean;
|
|
150
|
+
readonly trust_level_enforcement?: boolean;
|
|
151
|
+
};
|
|
152
|
+
/** Code execution configuration for ASI-05 checks. */
|
|
153
|
+
readonly code_execution?: {
|
|
154
|
+
readonly enabled: boolean;
|
|
155
|
+
readonly sandbox?: boolean;
|
|
156
|
+
readonly allowed_paths?: readonly string[];
|
|
157
|
+
readonly command_allowlist?: readonly string[];
|
|
158
|
+
};
|
|
159
|
+
/** Trust configuration for ASI-09 checks. */
|
|
160
|
+
readonly trust_config?: {
|
|
161
|
+
readonly ceiling?: string;
|
|
162
|
+
readonly allow_self_escalation?: boolean;
|
|
163
|
+
};
|
|
164
|
+
/** Supply chain configuration for ASI-04 checks. */
|
|
165
|
+
readonly supply_chain?: {
|
|
166
|
+
readonly hash_verification?: boolean;
|
|
167
|
+
readonly vendor_allowlist?: readonly string[];
|
|
168
|
+
};
|
|
169
|
+
/** Inter-agent communication configuration for ASI-07 checks. */
|
|
170
|
+
readonly inter_agent?: {
|
|
171
|
+
readonly message_validation?: boolean;
|
|
172
|
+
readonly replay_protection?: boolean;
|
|
173
|
+
readonly sender_allowlist?: readonly string[];
|
|
174
|
+
};
|
|
175
|
+
/** Behavioral monitoring configuration for ASI-10 checks. */
|
|
176
|
+
readonly behavioral_monitoring?: {
|
|
177
|
+
readonly enabled: boolean;
|
|
178
|
+
readonly baseline_established?: boolean;
|
|
179
|
+
readonly drift_alerts?: boolean;
|
|
180
|
+
};
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
/** Declaration of a single tool with its argument schema. */
|
|
184
|
+
export interface AgentToolDeclaration {
|
|
185
|
+
/** Name of the tool. */
|
|
186
|
+
readonly name: string;
|
|
187
|
+
/** JSON Schema object describing the tool's arguments. */
|
|
188
|
+
readonly schema?: Readonly<Record<string, unknown>>;
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
// ---------------------------------------------------------------------------
|
|
192
|
+
// Validation result
|
|
193
|
+
// ---------------------------------------------------------------------------
|
|
194
|
+
|
|
195
|
+
/**
|
|
196
|
+
* Result of validating a tool or input against defense rules.
|
|
197
|
+
*/
|
|
198
|
+
export interface ValidationResult {
|
|
199
|
+
/** Whether the validated item passes all checks. */
|
|
200
|
+
readonly valid: boolean;
|
|
201
|
+
/** Whether the item should be blocked from execution. */
|
|
202
|
+
readonly blocked: boolean;
|
|
203
|
+
/** List of detected threats, if any. */
|
|
204
|
+
readonly threats: readonly ThreatDetection[];
|
|
205
|
+
/** Human-readable summary of the validation outcome. */
|
|
206
|
+
readonly summary: string;
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
// ---------------------------------------------------------------------------
|
|
210
|
+
// Compliance report
|
|
211
|
+
// ---------------------------------------------------------------------------
|
|
212
|
+
|
|
213
|
+
/**
|
|
214
|
+
* A compliance report summarising the defense posture of an agent.
|
|
215
|
+
*/
|
|
216
|
+
export interface ComplianceReport {
|
|
217
|
+
/** Identifier of the agent that was assessed. */
|
|
218
|
+
readonly agent_id: string;
|
|
219
|
+
/** ISO-8601 UTC timestamp of report generation. */
|
|
220
|
+
readonly generated_at: string;
|
|
221
|
+
/** Overall compliance status across all categories. */
|
|
222
|
+
readonly overall_status: "compliant" | "partial" | "non_compliant";
|
|
223
|
+
/** Overall security score (0–100). */
|
|
224
|
+
readonly score: number;
|
|
225
|
+
/** Letter grade (A–F). */
|
|
226
|
+
readonly grade: "A" | "B" | "C" | "D" | "F";
|
|
227
|
+
/** Per-category compliance breakdown. */
|
|
228
|
+
readonly categories: readonly CategoryResult[];
|
|
229
|
+
/** Total number of findings across all categories. */
|
|
230
|
+
readonly total_findings: number;
|
|
231
|
+
/** Total number of recommendations across all categories. */
|
|
232
|
+
readonly total_recommendations: number;
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
// ---------------------------------------------------------------------------
|
|
236
|
+
// API request types
|
|
237
|
+
// ---------------------------------------------------------------------------
|
|
238
|
+
|
|
239
|
+
/** Request to scan an agent's input payload. */
|
|
240
|
+
export interface ScanInputRequest {
|
|
241
|
+
/** The input text or payload to scan. */
|
|
242
|
+
readonly input: string;
|
|
243
|
+
/** Agent identifier for context. */
|
|
244
|
+
readonly agent_id: string;
|
|
245
|
+
/** Optional tool name if the input is a tool argument. */
|
|
246
|
+
readonly tool_name?: string;
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
/** Request to scan an agent's output payload. */
|
|
250
|
+
export interface ScanOutputRequest {
|
|
251
|
+
/** The output text or payload to scan. */
|
|
252
|
+
readonly output: string;
|
|
253
|
+
/** Agent identifier for context. */
|
|
254
|
+
readonly agent_id: string;
|
|
255
|
+
/** Optional tool name if the output is a tool result. */
|
|
256
|
+
readonly tool_name?: string;
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
// ---------------------------------------------------------------------------
|
|
260
|
+
// API result wrapper
|
|
261
|
+
// ---------------------------------------------------------------------------
|
|
262
|
+
|
|
263
|
+
/** Standard error payload returned by the OWASP defenses API. */
|
|
264
|
+
export interface ApiError {
|
|
265
|
+
readonly error: string;
|
|
266
|
+
readonly detail: string;
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
/** Result type for all client operations. */
|
|
270
|
+
export type ApiResult<T> =
|
|
271
|
+
| { readonly ok: true; readonly data: T }
|
|
272
|
+
| { readonly ok: false; readonly error: ApiError; readonly status: number };
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "ES2020",
|
|
4
|
+
"module": "NodeNext",
|
|
5
|
+
"moduleResolution": "NodeNext",
|
|
6
|
+
"lib": ["ES2020", "DOM"],
|
|
7
|
+
"outDir": "./dist",
|
|
8
|
+
"rootDir": "./src",
|
|
9
|
+
"declaration": true,
|
|
10
|
+
"declarationMap": true,
|
|
11
|
+
"sourceMap": true,
|
|
12
|
+
"strict": true,
|
|
13
|
+
"noImplicitAny": true,
|
|
14
|
+
"strictNullChecks": true,
|
|
15
|
+
"noUnusedLocals": true,
|
|
16
|
+
"noUnusedParameters": true,
|
|
17
|
+
"noImplicitReturns": true,
|
|
18
|
+
"exactOptionalPropertyTypes": true,
|
|
19
|
+
"forceConsistentCasingInFileNames": true,
|
|
20
|
+
"esModuleInterop": true,
|
|
21
|
+
"skipLibCheck": true
|
|
22
|
+
},
|
|
23
|
+
"include": ["src/**/*"],
|
|
24
|
+
"exclude": ["node_modules", "dist"]
|
|
25
|
+
}
|