@cdot65/prisma-airs-sdk 0.6.7 → 0.6.9

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 CHANGED
@@ -24,7 +24,7 @@ Requires Node.js 18+. Zero external HTTP dependencies (native `fetch` + `crypto`
24
24
  | Service | Client | Auth | Capabilities |
25
25
  | ----------------------- | --------------------- | ------- | ---------------------------------------------------------- |
26
26
  | **AI Runtime Security** | `Scanner` | API Key | Sync/async content scanning, prompt injection detection |
27
- | **Management** | `ManagementClient` | OAuth2 | Security profiles and custom topics CRUD |
27
+ | **Management** | `ManagementClient` | OAuth2 | Profiles, topics, API keys, apps, DLP, deployment, logs |
28
28
  | **Model Security** | `ModelSecurityClient` | OAuth2 | ML model scanning, security groups, rule management |
29
29
  | **AI Red Teaming** | `RedTeamClient` | OAuth2 | Automated red team scans, reports, targets, custom attacks |
30
30
 
@@ -53,28 +53,20 @@ console.log(result.action); // "allow" | "block"
53
53
 
54
54
  ### Management — Configuration CRUD (OAuth2)
55
55
 
56
- CRUD operations for all three Prisma AIRS services use OAuth2:
57
-
58
56
  ```ts
59
57
  import { ManagementClient } from '@cdot65/prisma-airs-sdk';
60
58
 
61
59
  const client = new ManagementClient(); // reads PANW_MGMT_* env vars
62
60
 
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
- },
71
- });
72
-
73
- // Custom Topics
74
- const topic = await client.topics.create({
75
- topic_name: 'pii-detector',
76
- examples: ['SSN: 123-45-6789'],
77
- });
61
+ // 8 sub-clients available:
62
+ client.profiles; // AI security profile CRUD
63
+ client.topics; // Custom detection topic CRUD
64
+ client.apiKeys; // API key lifecycle (create, list, regenerate, delete)
65
+ client.customerApps; // Customer application management
66
+ client.dlpProfiles; // DLP data profile listing
67
+ client.deploymentProfiles; // Deployment profile listing
68
+ client.scanLogs; // Scan activity log queries
69
+ client.oauth; // OAuth token management (get/invalidate)
78
70
  ```
79
71
 
80
72
  ### Model Security — ML Model Scanning (OAuth2)
@@ -84,6 +76,7 @@ import { ModelSecurityClient } from '@cdot65/prisma-airs-sdk';
84
76
 
85
77
  const client = new ModelSecurityClient(); // falls back to PANW_MGMT_* env vars
86
78
 
79
+ // 3 sub-clients: scans, securityGroups, securityRules
87
80
  const scans = await client.scans.list({ limit: 10 });
88
81
  const groups = await client.securityGroups.list();
89
82
  const rules = await client.securityRules.list();
@@ -96,6 +89,7 @@ import { RedTeamClient } from '@cdot65/prisma-airs-sdk';
96
89
 
97
90
  const client = new RedTeamClient(); // falls back to PANW_MGMT_* env vars
98
91
 
92
+ // 5 sub-clients: scans, reports, customAttackReports, targets, customAttacks
99
93
  const scans = await client.scans.list({ limit: 5 });
100
94
  const targets = await client.targets.list();
101
95
  const categories = await client.scans.getCategories();
@@ -118,15 +112,6 @@ export PANW_MGMT_CLIENT_SECRET=your-client-secret
118
112
  export PANW_MGMT_TSG_ID=1234567890
119
113
  ```
120
114
 
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
-
130
115
  ## Error Handling
131
116
 
132
117
  ```ts
@@ -153,7 +138,7 @@ Full documentation at **[cdot65.github.io/prisma-airs-sdk](https://cdot65.github
153
138
  ```bash
154
139
  npm install
155
140
  npm run build # tsup (CJS + ESM + .d.ts)
156
- npm run test # vitest (617 tests, 99%+ coverage)
141
+ npm run test # vitest (829 tests, 99%+ coverage)
157
142
  npm run lint # eslint
158
143
  npm run typecheck # tsc --noEmit
159
144
  ```
package/dist/index.cjs CHANGED
@@ -29,8 +29,10 @@ __export(index_exports, {
29
29
  Action: () => Action,
30
30
  AgentEntrySchema: () => AgentEntrySchema,
31
31
  AgentMetaSchema: () => AgentMetaSchema,
32
+ AgentProtectionItemSchema: () => AgentProtectionItemSchema,
32
33
  AgentReportSchema: () => AgentReportSchema,
33
34
  AiProfileSchema: () => AiProfileSchema,
35
+ AiSecurityProfileSchema: () => AiSecurityProfileSchema,
34
36
  ApiEndpointType: () => ApiEndpointType,
35
37
  ApiKeyCreateRequestSchema: () => ApiKeyCreateRequestSchema,
36
38
  ApiKeyDPInfoSchema: () => ApiKeyDPInfoSchema,
@@ -106,6 +108,9 @@ __export(index_exports, {
106
108
  DSDetailResultSchema: () => DSDetailResultSchema,
107
109
  DSResultMetadataSchema: () => DSResultMetadataSchema,
108
110
  DashboardOverviewResponseSchema: () => DashboardOverviewResponseSchema,
111
+ DataLeakDetectionMemberSchema: () => DataLeakDetectionMemberSchema,
112
+ DataProtectionSchema: () => DataProtectionSchema,
113
+ DatabaseSecurityItemSchema: () => DatabaseSecurityItemSchema,
109
114
  DatabricksConnectionParamsSchema: () => DatabricksConnectionParamsSchema,
110
115
  DateRangeFilter: () => DateRangeFilter,
111
116
  DbsEntrySchema: () => DbsEntrySchema,
@@ -119,11 +124,13 @@ __export(index_exports, {
119
124
  DeploymentProfilesResponseSchema: () => DeploymentProfilesResponseSchema,
120
125
  DetectionServiceName: () => DetectionServiceName,
121
126
  DetectionServiceResultSchema: () => DetectionServiceResultSchema,
122
- DlpDataProfileSchema: () => DlpDataProfileSchema2,
127
+ DlpDataProfilePolicySchema: () => DlpDataProfilePolicySchema,
128
+ DlpDataProfileSchema: () => DlpDataProfileSchema,
123
129
  DlpPatternDetectionSchema: () => DlpPatternDetectionSchema,
124
130
  DlpProfileListResponseSchema: () => DlpProfileListResponseSchema,
125
131
  DlpProfilesClient: () => DlpProfilesClient,
126
132
  DlpReportSchema: () => DlpReportSchema,
133
+ DlpRuleSchema: () => DlpRuleSchema,
127
134
  DynamicJobMetadataSchema: () => DynamicJobMetadataSchema,
128
135
  DynamicJobReportSchema: () => DynamicJobReportSchema,
129
136
  DynamicJobReportStatsSchema: () => DynamicJobReportStatsSchema,
@@ -215,12 +222,15 @@ __export(index_exports, {
215
222
  MODEL_SEC_TOKEN_ENDPOINT: () => MODEL_SEC_TOKEN_ENDPOINT,
216
223
  MODEL_SEC_TSG_ID: () => MODEL_SEC_TSG_ID,
217
224
  MODEL_SEC_VIOLATIONS_PATH: () => MODEL_SEC_VIOLATIONS_PATH,
225
+ MaliciousCodeProtectionSchema: () => MaliciousCodeProtectionSchema,
218
226
  MalwareReportSchema: () => MalwareReportSchema,
219
227
  ManagementClient: () => ManagementClient,
220
228
  MaskedDataSchema: () => MaskedDataSchema,
221
229
  McEntrySchema: () => McEntrySchema,
222
230
  McReportSchema: () => McReportSchema,
223
231
  MetadataSchema: () => MetadataSchema,
232
+ ModelConfigurationSchema: () => ModelConfigurationSchema,
233
+ ModelProtectionItemSchema: () => ModelProtectionItemSchema,
224
234
  ModelScanIssueSchema: () => ModelScanIssueSchema,
225
235
  ModelScanStatus: () => ModelScanStatus,
226
236
  ModelSecurityClient: () => ModelSecurityClient,
@@ -245,6 +255,8 @@ __export(index_exports, {
245
255
  PAYLOAD_HASH: () => PAYLOAD_HASH,
246
256
  PaginatedScanResultsSchema: () => PaginatedScanResultsSchema,
247
257
  PatternDetectionSchema: () => PatternDetectionSchema,
258
+ PolicyAppProtectionSchema: () => PolicyAppProtectionSchema,
259
+ PolicyLatencySchema: () => PolicyLatencySchema,
248
260
  PolicySchema: () => PolicySchema,
249
261
  PolicyType: () => PolicyType,
250
262
  PrerequisiteModelSchema: () => PrerequisiteModelSchema,
@@ -387,8 +399,11 @@ __export(index_exports, {
387
399
  ToolDetectedSchema: () => ToolDetectedSchema,
388
400
  ToolEventMetadataSchema: () => ToolEventMetadataSchema,
389
401
  ToolEventSchema: () => ToolEventSchema,
402
+ TopicArraySchema: () => TopicArraySchema,
403
+ TopicObjectSchema: () => TopicObjectSchema,
390
404
  TopicsClient: () => TopicsClient,
391
405
  USER_AGENT: () => USER_AGENT,
406
+ UrlCategorySchema: () => UrlCategorySchema,
392
407
  UrlfEntrySchema: () => UrlfEntrySchema,
393
408
  ValidationErrorSchema: () => ValidationErrorSchema,
394
409
  Verdict: () => Verdict,
@@ -430,7 +445,7 @@ var MAX_NUMBER_OF_BATCH_SCAN_OBJECTS = 5;
430
445
  var MAX_CONNECTION_POOL_SIZE = 100;
431
446
  var MAX_NUMBER_OF_RETRIES = 5;
432
447
  var HTTP_FORCE_RETRY_STATUS_CODES = [500, 502, 503, 504];
433
- var SDK_VERSION = "0.6.7";
448
+ var SDK_VERSION = "0.6.9";
434
449
  var USER_AGENT = `PAN-AIRS/${SDK_VERSION}-typescript-sdk`;
435
450
  var DEFAULT_MGMT_ENDPOINT = "https://api.sase.paloaltonetworks.com/aisec";
436
451
  var DEFAULT_TOKEN_ENDPOINT = "https://auth.apps.paloaltonetworks.com/oauth2/access_token";
@@ -1331,41 +1346,90 @@ var ErrorResponseSchema = import_zod15.z.object({
1331
1346
 
1332
1347
  // src/models/mgmt-security-profile.ts
1333
1348
  var import_zod16 = require("zod");
1334
- var DlpDataProfileSchema = import_zod16.z.object({
1335
- profile_name: import_zod16.z.string(),
1336
- active: import_zod16.z.boolean().optional()
1337
- }).passthrough();
1338
- var DlpSchema = import_zod16.z.object({
1339
- dlp_status: import_zod16.z.string().optional(),
1340
- data_profiles: import_zod16.z.array(DlpDataProfileSchema).optional()
1341
- }).passthrough();
1342
- var DataLeakDetectionSchema = import_zod16.z.object({
1343
- "data-leak-detection-status": import_zod16.z.string().optional(),
1344
- dlp: DlpSchema.optional()
1345
- }).passthrough();
1346
- var AppProtectionSchema = import_zod16.z.object({
1347
- "prompt-injection": import_zod16.z.string().optional(),
1348
- "jailbreak-detection": import_zod16.z.string().optional()
1349
- }).passthrough();
1350
- var ModelProtectionSchema = import_zod16.z.object({
1351
- "model-denial-of-service": import_zod16.z.string().optional()
1352
- }).passthrough();
1353
- var AgentProtectionSchema = import_zod16.z.object({
1354
- "malicious-agent-activity": import_zod16.z.string().optional()
1355
- }).passthrough();
1356
- var LatencySchema = import_zod16.z.object({
1357
- status: import_zod16.z.string().optional(),
1358
- max_latency_ms: import_zod16.z.number().optional()
1349
+ var PolicyLatencySchema = import_zod16.z.object({
1350
+ "inline-timeout-action": import_zod16.z.string().optional(),
1351
+ "max-inline-latency": import_zod16.z.number().optional()
1352
+ }).passthrough();
1353
+ var DataLeakDetectionMemberSchema = import_zod16.z.object({
1354
+ text: import_zod16.z.string(),
1355
+ id: import_zod16.z.string().optional(),
1356
+ version: import_zod16.z.string().optional()
1357
+ }).passthrough();
1358
+ var DatabaseSecurityItemSchema = import_zod16.z.object({
1359
+ name: import_zod16.z.string(),
1360
+ action: import_zod16.z.string()
1361
+ }).passthrough();
1362
+ var DataProtectionSchema = import_zod16.z.object({
1363
+ "data-leak-detection": import_zod16.z.object({
1364
+ member: import_zod16.z.array(DataLeakDetectionMemberSchema).nullable().optional(),
1365
+ action: import_zod16.z.string(),
1366
+ "mask-data-inline": import_zod16.z.boolean().optional()
1367
+ }).passthrough().optional(),
1368
+ "database-security": import_zod16.z.array(DatabaseSecurityItemSchema).nullable().optional()
1369
+ }).passthrough();
1370
+ var UrlCategorySchema = import_zod16.z.object({
1371
+ member: import_zod16.z.array(import_zod16.z.string()).nullable().optional()
1372
+ }).passthrough();
1373
+ var MaliciousCodeProtectionSchema = import_zod16.z.object({
1374
+ name: import_zod16.z.string(),
1375
+ action: import_zod16.z.string()
1376
+ }).passthrough();
1377
+ var PolicyAppProtectionSchema = import_zod16.z.object({
1378
+ "alert-url-category": UrlCategorySchema.optional(),
1379
+ "block-url-category": UrlCategorySchema.optional(),
1380
+ "allow-url-category": UrlCategorySchema.optional(),
1381
+ "default-url-category": UrlCategorySchema.optional(),
1382
+ "url-detected-action": import_zod16.z.string().optional(),
1383
+ "malicious-code-protection": MaliciousCodeProtectionSchema.optional()
1384
+ }).passthrough();
1385
+ var TopicObjectSchema = import_zod16.z.object({
1386
+ topic_name: import_zod16.z.string(),
1387
+ topic_id: import_zod16.z.string(),
1388
+ revision: import_zod16.z.number()
1389
+ }).passthrough();
1390
+ var TopicArraySchema = import_zod16.z.object({
1391
+ action: import_zod16.z.string(),
1392
+ topic: import_zod16.z.array(TopicObjectSchema)
1393
+ }).passthrough();
1394
+ var ModelProtectionItemSchema = import_zod16.z.object({
1395
+ name: import_zod16.z.string(),
1396
+ action: import_zod16.z.string(),
1397
+ "topic-list": import_zod16.z.array(TopicArraySchema).optional()
1398
+ }).passthrough();
1399
+ var AgentProtectionItemSchema = import_zod16.z.object({
1400
+ name: import_zod16.z.string(),
1401
+ action: import_zod16.z.string()
1402
+ }).passthrough();
1403
+ var DlpRuleSchema = import_zod16.z.object({
1404
+ action: import_zod16.z.string().optional()
1405
+ }).passthrough();
1406
+ var DlpDataProfilePolicySchema = import_zod16.z.object({
1407
+ name: import_zod16.z.string(),
1408
+ uuid: import_zod16.z.string(),
1409
+ id: import_zod16.z.string().optional(),
1410
+ version: import_zod16.z.string().optional(),
1411
+ rule1: DlpRuleSchema.optional(),
1412
+ rule2: DlpRuleSchema.optional(),
1413
+ "log-severity": import_zod16.z.string().optional(),
1414
+ "non-file-based": import_zod16.z.string().optional(),
1415
+ "file-based": import_zod16.z.string().optional()
1359
1416
  }).passthrough();
1360
1417
  var ModelConfigurationSchema = import_zod16.z.object({
1361
- latency: LatencySchema.optional()
1418
+ "mask-data-in-storage": import_zod16.z.boolean().optional(),
1419
+ latency: PolicyLatencySchema.optional(),
1420
+ "data-protection": DataProtectionSchema.optional(),
1421
+ "app-protection": PolicyAppProtectionSchema.optional(),
1422
+ "model-protection": import_zod16.z.array(ModelProtectionItemSchema).optional(),
1423
+ "agent-protection": import_zod16.z.array(AgentProtectionItemSchema).optional()
1424
+ }).passthrough();
1425
+ var AiSecurityProfileSchema = import_zod16.z.object({
1426
+ "model-type": import_zod16.z.string().optional(),
1427
+ "content-type": import_zod16.z.string().optional(),
1428
+ "model-configuration": ModelConfigurationSchema.optional()
1362
1429
  }).passthrough();
1363
1430
  var PolicySchema = import_zod16.z.object({
1364
- "data-leak-detection": DataLeakDetectionSchema.optional(),
1365
- "app-protection": AppProtectionSchema.optional(),
1366
- "model-protection": ModelProtectionSchema.optional(),
1367
- "agent-protection": AgentProtectionSchema.optional(),
1368
- "model-configuration": ModelConfigurationSchema.optional()
1431
+ "ai-security-profiles": import_zod16.z.array(AiSecurityProfileSchema).optional(),
1432
+ "dlp-data-profiles": import_zod16.z.array(DlpDataProfilePolicySchema).optional()
1369
1433
  }).passthrough();
1370
1434
  var SecurityProfileSchema = import_zod16.z.object({
1371
1435
  profile_id: import_zod16.z.string().optional(),
@@ -1555,7 +1619,7 @@ var DeploymentProfilesResponseSchema = import_zod20.z.object({
1555
1619
 
1556
1620
  // src/models/mgmt-dlp-profile.ts
1557
1621
  var import_zod21 = require("zod");
1558
- var DlpDataProfileSchema2 = import_zod21.z.object({
1622
+ var DlpDataProfileSchema = import_zod21.z.object({
1559
1623
  name: import_zod21.z.string(),
1560
1624
  uuid: import_zod21.z.string(),
1561
1625
  id: import_zod21.z.string().optional(),
@@ -1567,7 +1631,7 @@ var DlpDataProfileSchema2 = import_zod21.z.object({
1567
1631
  "file-based": import_zod21.z.string().optional()
1568
1632
  }).passthrough();
1569
1633
  var DlpProfileListResponseSchema = import_zod21.z.object({
1570
- dlp_profiles: import_zod21.z.array(DlpDataProfileSchema2).optional()
1634
+ dlp_profiles: import_zod21.z.array(DlpDataProfileSchema).optional()
1571
1635
  }).passthrough();
1572
1636
 
1573
1637
  // src/models/mgmt-scan-log.ts
@@ -3385,6 +3449,40 @@ var ProfilesClient = class {
3385
3449
  });
3386
3450
  return res.data;
3387
3451
  }
3452
+ /**
3453
+ * Get a security profile by UUID.
3454
+ * Fetches all profiles and filters — no dedicated API endpoint exists.
3455
+ * @param profileId - UUID of the profile to retrieve.
3456
+ * @returns The matching security profile.
3457
+ */
3458
+ async get(profileId) {
3459
+ const { ai_profiles } = await this.list();
3460
+ const profile = ai_profiles.find((p) => p.profile_id === profileId);
3461
+ if (!profile) {
3462
+ throw new AISecSDKException(
3463
+ `Profile not found: ${profileId}`,
3464
+ "AISEC_USER_REQUEST_PAYLOAD_ERROR" /* USER_REQUEST_PAYLOAD_ERROR */
3465
+ );
3466
+ }
3467
+ return profile;
3468
+ }
3469
+ /**
3470
+ * Get a security profile by name.
3471
+ * Returns the highest-revision match (latest version).
3472
+ * @param profileName - Name of the profile to retrieve.
3473
+ * @returns The matching security profile with the highest revision.
3474
+ */
3475
+ async getByName(profileName) {
3476
+ const { ai_profiles } = await this.list();
3477
+ const matches = ai_profiles.filter((p) => p.profile_name === profileName);
3478
+ if (matches.length === 0) {
3479
+ throw new AISecSDKException(
3480
+ `Profile not found: ${profileName}`,
3481
+ "AISEC_USER_REQUEST_PAYLOAD_ERROR" /* USER_REQUEST_PAYLOAD_ERROR */
3482
+ );
3483
+ }
3484
+ return matches.reduce((best, p) => (p.revision ?? 0) > (best.revision ?? 0) ? p : best);
3485
+ }
3388
3486
  /**
3389
3487
  * Update an existing security profile.
3390
3488
  * @param profileId - UUID of the profile to update.
@@ -5924,8 +6022,10 @@ var RedTeamClient = class {
5924
6022
  Action,
5925
6023
  AgentEntrySchema,
5926
6024
  AgentMetaSchema,
6025
+ AgentProtectionItemSchema,
5927
6026
  AgentReportSchema,
5928
6027
  AiProfileSchema,
6028
+ AiSecurityProfileSchema,
5929
6029
  ApiEndpointType,
5930
6030
  ApiKeyCreateRequestSchema,
5931
6031
  ApiKeyDPInfoSchema,
@@ -6001,6 +6101,9 @@ var RedTeamClient = class {
6001
6101
  DSDetailResultSchema,
6002
6102
  DSResultMetadataSchema,
6003
6103
  DashboardOverviewResponseSchema,
6104
+ DataLeakDetectionMemberSchema,
6105
+ DataProtectionSchema,
6106
+ DatabaseSecurityItemSchema,
6004
6107
  DatabricksConnectionParamsSchema,
6005
6108
  DateRangeFilter,
6006
6109
  DbsEntrySchema,
@@ -6014,11 +6117,13 @@ var RedTeamClient = class {
6014
6117
  DeploymentProfilesResponseSchema,
6015
6118
  DetectionServiceName,
6016
6119
  DetectionServiceResultSchema,
6120
+ DlpDataProfilePolicySchema,
6017
6121
  DlpDataProfileSchema,
6018
6122
  DlpPatternDetectionSchema,
6019
6123
  DlpProfileListResponseSchema,
6020
6124
  DlpProfilesClient,
6021
6125
  DlpReportSchema,
6126
+ DlpRuleSchema,
6022
6127
  DynamicJobMetadataSchema,
6023
6128
  DynamicJobReportSchema,
6024
6129
  DynamicJobReportStatsSchema,
@@ -6110,12 +6215,15 @@ var RedTeamClient = class {
6110
6215
  MODEL_SEC_TOKEN_ENDPOINT,
6111
6216
  MODEL_SEC_TSG_ID,
6112
6217
  MODEL_SEC_VIOLATIONS_PATH,
6218
+ MaliciousCodeProtectionSchema,
6113
6219
  MalwareReportSchema,
6114
6220
  ManagementClient,
6115
6221
  MaskedDataSchema,
6116
6222
  McEntrySchema,
6117
6223
  McReportSchema,
6118
6224
  MetadataSchema,
6225
+ ModelConfigurationSchema,
6226
+ ModelProtectionItemSchema,
6119
6227
  ModelScanIssueSchema,
6120
6228
  ModelScanStatus,
6121
6229
  ModelSecurityClient,
@@ -6140,6 +6248,8 @@ var RedTeamClient = class {
6140
6248
  PAYLOAD_HASH,
6141
6249
  PaginatedScanResultsSchema,
6142
6250
  PatternDetectionSchema,
6251
+ PolicyAppProtectionSchema,
6252
+ PolicyLatencySchema,
6143
6253
  PolicySchema,
6144
6254
  PolicyType,
6145
6255
  PrerequisiteModelSchema,
@@ -6282,8 +6392,11 @@ var RedTeamClient = class {
6282
6392
  ToolDetectedSchema,
6283
6393
  ToolEventMetadataSchema,
6284
6394
  ToolEventSchema,
6395
+ TopicArraySchema,
6396
+ TopicObjectSchema,
6285
6397
  TopicsClient,
6286
6398
  USER_AGENT,
6399
+ UrlCategorySchema,
6287
6400
  UrlfEntrySchema,
6288
6401
  ValidationErrorSchema,
6289
6402
  Verdict,