@cdot65/prisma-airs-sdk 0.5.0 → 0.5.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/README.md +86 -112
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/package.json +4 -3
package/README.md
CHANGED
|
@@ -1,6 +1,15 @@
|
|
|
1
1
|
# prisma-airs-sdk
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
[](https://github.com/cdot65/prisma-airs-sdk/actions/workflows/ci.yml)
|
|
4
|
+
[](https://github.com/cdot65/prisma-airs-sdk/actions/workflows/test.yml)
|
|
5
|
+
[](https://www.npmjs.com/package/@cdot65/prisma-airs-sdk)
|
|
6
|
+
[](https://www.npmjs.com/package/@cdot65/prisma-airs-sdk)
|
|
7
|
+
[](https://github.com/cdot65/prisma-airs-sdk)
|
|
8
|
+
[](https://www.typescriptlang.org/)
|
|
9
|
+
[](https://nodejs.org/)
|
|
10
|
+
[](https://opensource.org/licenses/MIT)
|
|
11
|
+
|
|
12
|
+
TypeScript SDK for Palo Alto Networks **Prisma AIRS** — covering the full lifecycle from configuration management to operational scanning across all three service domains: **AI Runtime Security**, **AI Red Teaming**, and **Model Security**.
|
|
4
13
|
|
|
5
14
|
## Installation
|
|
6
15
|
|
|
@@ -8,14 +17,26 @@ TypeScript SDK for Palo Alto Networks **AI Runtime Security (AIRS)**. API-compat
|
|
|
8
17
|
npm install @cdot65/prisma-airs-sdk
|
|
9
18
|
```
|
|
10
19
|
|
|
11
|
-
Requires Node.js 18+.
|
|
20
|
+
Requires Node.js 18+. Zero external HTTP dependencies (native `fetch` + `crypto`).
|
|
21
|
+
|
|
22
|
+
## What's Included
|
|
23
|
+
|
|
24
|
+
| Service | Client | Auth | Capabilities |
|
|
25
|
+
| ----------------------- | --------------------- | ------- | ---------------------------------------------------------- |
|
|
26
|
+
| **AI Runtime Security** | `Scanner` | API Key | Sync/async content scanning, prompt injection detection |
|
|
27
|
+
| **Management** | `ManagementClient` | OAuth2 | Security profiles and custom topics CRUD |
|
|
28
|
+
| **Model Security** | `ModelSecurityClient` | OAuth2 | ML model scanning, security groups, rule management |
|
|
29
|
+
| **AI Red Teaming** | `RedTeamClient` | OAuth2 | Automated red team scans, reports, targets, custom attacks |
|
|
30
|
+
|
|
31
|
+
All OAuth2 services share credentials and handle token lifecycle automatically (caching, proactive refresh, 401/403 auto-retry).
|
|
12
32
|
|
|
13
33
|
## Quick Start
|
|
14
34
|
|
|
35
|
+
### AI Runtime Security — Content Scanning (API Key)
|
|
36
|
+
|
|
15
37
|
```ts
|
|
16
38
|
import { init, Scanner, Content } from '@cdot65/prisma-airs-sdk';
|
|
17
39
|
|
|
18
|
-
// Initialize (mirrors Python's aisecurity.init())
|
|
19
40
|
init({ apiKey: 'YOUR_API_KEY' });
|
|
20
41
|
|
|
21
42
|
const scanner = new Scanner();
|
|
@@ -30,90 +51,82 @@ console.log(result.category); // "benign" | "malicious"
|
|
|
30
51
|
console.log(result.action); // "allow" | "block"
|
|
31
52
|
```
|
|
32
53
|
|
|
33
|
-
|
|
54
|
+
### Management — Configuration CRUD (OAuth2)
|
|
55
|
+
|
|
56
|
+
CRUD operations for all three Prisma AIRS services use OAuth2:
|
|
34
57
|
|
|
35
58
|
```ts
|
|
36
|
-
import {
|
|
59
|
+
import { ManagementClient } from '@cdot65/prisma-airs-sdk';
|
|
60
|
+
|
|
61
|
+
const client = new ManagementClient(); // reads PANW_MGMT_* env vars
|
|
37
62
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
63
|
+
// Security Profiles
|
|
64
|
+
const profiles = await client.profiles.list();
|
|
65
|
+
const created = await client.profiles.create({
|
|
66
|
+
profile_name: 'my-profile',
|
|
67
|
+
active: true,
|
|
68
|
+
policy: {
|
|
69
|
+
/* ... */
|
|
70
|
+
},
|
|
43
71
|
});
|
|
44
|
-
```
|
|
45
72
|
|
|
46
|
-
|
|
73
|
+
// Custom Topics
|
|
74
|
+
const topic = await client.topics.create({
|
|
75
|
+
topic_name: 'pii-detector',
|
|
76
|
+
examples: ['SSN: 123-45-6789'],
|
|
77
|
+
});
|
|
78
|
+
```
|
|
47
79
|
|
|
48
|
-
|
|
80
|
+
### Model Security — ML Model Scanning (OAuth2)
|
|
49
81
|
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
| `syncScan(aiProfile, content, opts?)` | Synchronous inline scan |
|
|
53
|
-
| `asyncScan(scanObjects)` | Batch async scan (up to 5) |
|
|
54
|
-
| `queryByScanIds(scanIds)` | Get results by scan IDs (up to 5) |
|
|
55
|
-
| `queryByReportIds(reportIds)` | Get threat reports by report IDs (up to 5) |
|
|
82
|
+
```ts
|
|
83
|
+
import { ModelSecurityClient } from '@cdot65/prisma-airs-sdk';
|
|
56
84
|
|
|
57
|
-
|
|
85
|
+
const client = new ModelSecurityClient(); // falls back to PANW_MGMT_* env vars
|
|
58
86
|
|
|
59
|
-
|
|
60
|
-
const
|
|
61
|
-
|
|
62
|
-
new Content({ prompt: 'user input', response: 'model output' }),
|
|
63
|
-
{
|
|
64
|
-
trId: 'transaction-123',
|
|
65
|
-
sessionId: 'session-456',
|
|
66
|
-
metadata: { app_name: 'my-app', ai_model: 'gpt-4' },
|
|
67
|
-
},
|
|
68
|
-
);
|
|
87
|
+
const scans = await client.scans.list({ limit: 10 });
|
|
88
|
+
const groups = await client.securityGroups.list();
|
|
89
|
+
const rules = await client.securityRules.list();
|
|
69
90
|
```
|
|
70
91
|
|
|
71
|
-
###
|
|
92
|
+
### AI Red Teaming — Automated Testing (OAuth2)
|
|
72
93
|
|
|
73
94
|
```ts
|
|
74
|
-
|
|
75
|
-
{
|
|
76
|
-
req_id: 1,
|
|
77
|
-
scan_req: {
|
|
78
|
-
ai_profile: { profile_name: 'my-profile' },
|
|
79
|
-
contents: [{ prompt: 'hello', response: 'world' }],
|
|
80
|
-
},
|
|
81
|
-
},
|
|
82
|
-
]);
|
|
83
|
-
```
|
|
95
|
+
import { RedTeamClient } from '@cdot65/prisma-airs-sdk';
|
|
84
96
|
|
|
85
|
-
|
|
97
|
+
const client = new RedTeamClient(); // falls back to PANW_MGMT_* env vars
|
|
86
98
|
|
|
87
|
-
|
|
88
|
-
const
|
|
89
|
-
const
|
|
99
|
+
const scans = await client.scans.list({ limit: 5 });
|
|
100
|
+
const targets = await client.targets.list();
|
|
101
|
+
const categories = await client.scans.getCategories();
|
|
90
102
|
```
|
|
91
103
|
|
|
92
|
-
##
|
|
104
|
+
## Authentication
|
|
93
105
|
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
prompt: 'user prompt',
|
|
99
|
-
response: 'model response',
|
|
100
|
-
context: 'grounding context',
|
|
101
|
-
codePrompt: 'code input',
|
|
102
|
-
codeResponse: 'code output',
|
|
103
|
-
toolEvent: {
|
|
104
|
-
metadata: { ecosystem: 'mcp', method: 'invoke', server_name: 'my-server' },
|
|
105
|
-
input: '{"query": "test"}',
|
|
106
|
-
},
|
|
107
|
-
});
|
|
106
|
+
| Auth Method | Used By |
|
|
107
|
+
| ------------------------------- | ----------------------------------------------------------- |
|
|
108
|
+
| **API Key** (HMAC-SHA256) | AI Runtime Security scans only |
|
|
109
|
+
| **OAuth2** (client_credentials) | Everything else — Management CRUD, Red Team, Model Security |
|
|
108
110
|
|
|
109
|
-
|
|
110
|
-
|
|
111
|
+
```bash
|
|
112
|
+
# AI Runtime Security scans
|
|
113
|
+
export PANW_AI_SEC_API_KEY=your-api-key
|
|
111
114
|
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
+
# OAuth2 (shared by Management, Red Team, Model Security)
|
|
116
|
+
export PANW_MGMT_CLIENT_ID=your-client-id
|
|
117
|
+
export PANW_MGMT_CLIENT_SECRET=your-client-secret
|
|
118
|
+
export PANW_MGMT_TSG_ID=1234567890
|
|
115
119
|
```
|
|
116
120
|
|
|
121
|
+
## Scanner Methods
|
|
122
|
+
|
|
123
|
+
| Method | Description |
|
|
124
|
+
| ------------------------------------- | ------------------------------------------ |
|
|
125
|
+
| `syncScan(aiProfile, content, opts?)` | Synchronous inline scan |
|
|
126
|
+
| `asyncScan(scanObjects)` | Batch async scan (up to 5) |
|
|
127
|
+
| `queryByScanIds(scanIds)` | Get results by scan IDs (up to 5) |
|
|
128
|
+
| `queryByReportIds(reportIds)` | Get threat reports by report IDs (up to 5) |
|
|
129
|
+
|
|
117
130
|
## Error Handling
|
|
118
131
|
|
|
119
132
|
```ts
|
|
@@ -123,65 +136,26 @@ try {
|
|
|
123
136
|
await scanner.syncScan(profile, content);
|
|
124
137
|
} catch (err) {
|
|
125
138
|
if (err instanceof AISecSDKException) {
|
|
126
|
-
console.error(err.message);
|
|
127
|
-
console.error(err.errorType);
|
|
139
|
+
console.error(err.message);
|
|
140
|
+
console.error(err.errorType);
|
|
128
141
|
}
|
|
129
142
|
}
|
|
130
143
|
```
|
|
131
144
|
|
|
132
145
|
Error types: `SERVER_SIDE_ERROR`, `CLIENT_SIDE_ERROR`, `USER_REQUEST_PAYLOAD_ERROR`, `MISSING_VARIABLE`, `AISEC_SDK_ERROR`, `OAUTH_ERROR`.
|
|
133
146
|
|
|
134
|
-
##
|
|
135
|
-
|
|
136
|
-
Separate client for CRUD operations on Security Profiles and Custom Topics via OAuth2 client credentials. See [docs/management-api.md](docs/management-api.md) for full details.
|
|
137
|
-
|
|
138
|
-
```bash
|
|
139
|
-
# Required env vars (or pass as constructor options)
|
|
140
|
-
export PANW_MGMT_CLIENT_ID=your-client-id
|
|
141
|
-
export PANW_MGMT_CLIENT_SECRET=your-client-secret
|
|
142
|
-
export PANW_MGMT_TSG_ID=1234567890
|
|
143
|
-
# Optional: override for EU/UK/FedRAMP
|
|
144
|
-
# export PANW_MGMT_ENDPOINT=https://api.eu.sase.paloaltonetworks.com/aisec
|
|
145
|
-
```
|
|
146
|
-
|
|
147
|
-
```ts
|
|
148
|
-
import { ManagementClient } from '@cdot65/prisma-airs-sdk';
|
|
149
|
-
|
|
150
|
-
const client = new ManagementClient();
|
|
151
|
-
|
|
152
|
-
// Security Profiles
|
|
153
|
-
const profiles = await client.profiles.list();
|
|
154
|
-
const created = await client.profiles.create({ profile_name: 'my-profile', active: true, policy: { ... } });
|
|
155
|
-
await client.profiles.update(created.profile_id, { ... });
|
|
156
|
-
await client.profiles.delete(created.profile_id);
|
|
157
|
-
|
|
158
|
-
// Custom Topics
|
|
159
|
-
const topics = await client.topics.list();
|
|
160
|
-
const topic = await client.topics.create({ topic_name: 'pii-detector', examples: ['SSN: 123-45-6789'] });
|
|
161
|
-
await client.topics.update(topic.topic_id, { ... });
|
|
162
|
-
await client.topics.delete(topic.topic_id);
|
|
163
|
-
await client.topics.forceDelete(topic.topic_id); // even if referenced by a profile
|
|
164
|
-
```
|
|
165
|
-
|
|
166
|
-
## Migration from v0.1
|
|
147
|
+
## Documentation
|
|
167
148
|
|
|
168
|
-
|
|
169
|
-
| --------------------------------------- | --------------------------------------------- |
|
|
170
|
-
| `new PrismaAirsSdkClient({ apiToken })` | `init({ apiKey }); new Scanner()` |
|
|
171
|
-
| `client.scanSyncRequest(body)` | `scanner.syncScan(aiProfile, content, opts?)` |
|
|
172
|
-
| `client.scanAsyncRequest(body)` | `scanner.asyncScan(scanObjects)` |
|
|
173
|
-
| `client.getScanResultsByScanIds(ids)` | `scanner.queryByScanIds(ids)` |
|
|
174
|
-
| `client.getThreatScanReports(ids)` | `scanner.queryByReportIds(ids)` |
|
|
175
|
-
| `PrismaAirsApiError` | `AISecSDKException` |
|
|
176
|
-
| `axios` dependency | Native `fetch` (zero HTTP deps) |
|
|
149
|
+
Full documentation at **[cdot65.github.io/prisma-airs-sdk](https://cdot65.github.io/prisma-airs-sdk/)** — includes API reference, service guides, OAuth lifecycle docs, and examples.
|
|
177
150
|
|
|
178
151
|
## Development
|
|
179
152
|
|
|
180
153
|
```bash
|
|
181
154
|
npm install
|
|
182
|
-
npm run build
|
|
183
|
-
npm run test
|
|
184
|
-
npm run lint
|
|
155
|
+
npm run build # tsup (CJS + ESM + .d.ts)
|
|
156
|
+
npm run test # vitest (617 tests, 99%+ coverage)
|
|
157
|
+
npm run lint # eslint
|
|
158
|
+
npm run typecheck # tsc --noEmit
|
|
185
159
|
```
|
|
186
160
|
|
|
187
161
|
## License
|
package/dist/index.cjs
CHANGED
|
@@ -362,7 +362,7 @@ var MAX_NUMBER_OF_BATCH_SCAN_OBJECTS = 5;
|
|
|
362
362
|
var MAX_CONNECTION_POOL_SIZE = 100;
|
|
363
363
|
var MAX_NUMBER_OF_RETRIES = 5;
|
|
364
364
|
var HTTP_FORCE_RETRY_STATUS_CODES = [500, 502, 503, 504];
|
|
365
|
-
var SDK_VERSION = "0.5.
|
|
365
|
+
var SDK_VERSION = "0.5.2";
|
|
366
366
|
var USER_AGENT = `PAN-AIRS/${SDK_VERSION}-typescript-sdk`;
|
|
367
367
|
var DEFAULT_MGMT_ENDPOINT = "https://api.sase.paloaltonetworks.com/aisec";
|
|
368
368
|
var DEFAULT_TOKEN_ENDPOINT = "https://auth.apps.paloaltonetworks.com/oauth2/access_token";
|