@cdot65/prisma-airs-sdk 0.6.5 → 0.6.7
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/index.cjs +106 -128
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +7 -7
- package/dist/index.d.ts +7 -7
- package/dist/index.js +106 -128
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -16503,6 +16503,7 @@ declare class Content {
|
|
|
16503
16503
|
/**
|
|
16504
16504
|
* Load content from a JSON file.
|
|
16505
16505
|
* @param filePath - Path to JSON file containing scan request contents.
|
|
16506
|
+
* @returns A new Content instance populated from the JSON file.
|
|
16506
16507
|
*/
|
|
16507
16508
|
static fromJSONFile(filePath: string): Content;
|
|
16508
16509
|
}
|
|
@@ -56696,8 +56697,8 @@ declare const MAX_NUMBER_OF_BATCH_SCAN_OBJECTS = 5;
|
|
|
56696
56697
|
declare const MAX_CONNECTION_POOL_SIZE = 100;
|
|
56697
56698
|
declare const MAX_NUMBER_OF_RETRIES = 5;
|
|
56698
56699
|
declare const HTTP_FORCE_RETRY_STATUS_CODES: number[];
|
|
56699
|
-
declare const SDK_VERSION = "0.6.
|
|
56700
|
-
declare const USER_AGENT = "PAN-AIRS/0.6.
|
|
56700
|
+
declare const SDK_VERSION = "0.6.7";
|
|
56701
|
+
declare const USER_AGENT = "PAN-AIRS/0.6.7-typescript-sdk";
|
|
56701
56702
|
declare const DEFAULT_MGMT_ENDPOINT = "https://api.sase.paloaltonetworks.com/aisec";
|
|
56702
56703
|
declare const DEFAULT_TOKEN_ENDPOINT = "https://auth.apps.paloaltonetworks.com/oauth2/access_token";
|
|
56703
56704
|
declare const MGMT_CLIENT_ID = "PANW_MGMT_CLIENT_ID";
|
|
@@ -56811,7 +56812,6 @@ declare class OAuthClient {
|
|
|
56811
56812
|
getToken(): Promise<string>;
|
|
56812
56813
|
/**
|
|
56813
56814
|
* Clear the cached token, forcing a fresh fetch on next call.
|
|
56814
|
-
* @returns Nothing.
|
|
56815
56815
|
*/
|
|
56816
56816
|
clearToken(): void;
|
|
56817
56817
|
/**
|
|
@@ -56931,7 +56931,7 @@ declare class TopicsClient {
|
|
|
56931
56931
|
/**
|
|
56932
56932
|
* Force-delete a custom topic, removing it from any referencing profiles.
|
|
56933
56933
|
* @param topicId - UUID of the topic to force-delete.
|
|
56934
|
-
* @param updatedBy - Email of the user performing the deletion.
|
|
56934
|
+
* @param updatedBy - Optional. Email of the user performing the deletion.
|
|
56935
56935
|
* @returns Deletion confirmation message.
|
|
56936
56936
|
*/
|
|
56937
56937
|
forceDelete(topicId: string, updatedBy?: string): Promise<DeleteTopicResponse>;
|
|
@@ -57675,13 +57675,13 @@ declare class RedTeamReportsClient {
|
|
|
57675
57675
|
* Download a report in the specified format.
|
|
57676
57676
|
* @param jobId - The job UUID.
|
|
57677
57677
|
* @param format - The file format (e.g. "pdf", "csv").
|
|
57678
|
-
* @returns The
|
|
57678
|
+
* @returns The report data in the requested format (untyped — shape depends on `format`).
|
|
57679
57679
|
*/
|
|
57680
57680
|
downloadReport(jobId: string, format: string): Promise<unknown>;
|
|
57681
57681
|
/**
|
|
57682
57682
|
* Generate a partial report for a running scan.
|
|
57683
57683
|
* @param jobId - The job UUID.
|
|
57684
|
-
* @returns The partial report
|
|
57684
|
+
* @returns The partial report payload (untyped — schema not yet defined by the API).
|
|
57685
57685
|
*/
|
|
57686
57686
|
generatePartialReport(jobId: string): Promise<unknown>;
|
|
57687
57687
|
}
|
|
@@ -57907,7 +57907,7 @@ declare class RedTeamCustomAttacksClient {
|
|
|
57907
57907
|
/**
|
|
57908
57908
|
* Download CSV template for a prompt set.
|
|
57909
57909
|
* @param uuid - The prompt set UUID.
|
|
57910
|
-
* @returns The CSV template
|
|
57910
|
+
* @returns The CSV template content (untyped — raw response from the API).
|
|
57911
57911
|
*/
|
|
57912
57912
|
downloadTemplate(uuid: string): Promise<unknown>;
|
|
57913
57913
|
/**
|
package/dist/index.d.ts
CHANGED
|
@@ -16503,6 +16503,7 @@ declare class Content {
|
|
|
16503
16503
|
/**
|
|
16504
16504
|
* Load content from a JSON file.
|
|
16505
16505
|
* @param filePath - Path to JSON file containing scan request contents.
|
|
16506
|
+
* @returns A new Content instance populated from the JSON file.
|
|
16506
16507
|
*/
|
|
16507
16508
|
static fromJSONFile(filePath: string): Content;
|
|
16508
16509
|
}
|
|
@@ -56696,8 +56697,8 @@ declare const MAX_NUMBER_OF_BATCH_SCAN_OBJECTS = 5;
|
|
|
56696
56697
|
declare const MAX_CONNECTION_POOL_SIZE = 100;
|
|
56697
56698
|
declare const MAX_NUMBER_OF_RETRIES = 5;
|
|
56698
56699
|
declare const HTTP_FORCE_RETRY_STATUS_CODES: number[];
|
|
56699
|
-
declare const SDK_VERSION = "0.6.
|
|
56700
|
-
declare const USER_AGENT = "PAN-AIRS/0.6.
|
|
56700
|
+
declare const SDK_VERSION = "0.6.7";
|
|
56701
|
+
declare const USER_AGENT = "PAN-AIRS/0.6.7-typescript-sdk";
|
|
56701
56702
|
declare const DEFAULT_MGMT_ENDPOINT = "https://api.sase.paloaltonetworks.com/aisec";
|
|
56702
56703
|
declare const DEFAULT_TOKEN_ENDPOINT = "https://auth.apps.paloaltonetworks.com/oauth2/access_token";
|
|
56703
56704
|
declare const MGMT_CLIENT_ID = "PANW_MGMT_CLIENT_ID";
|
|
@@ -56811,7 +56812,6 @@ declare class OAuthClient {
|
|
|
56811
56812
|
getToken(): Promise<string>;
|
|
56812
56813
|
/**
|
|
56813
56814
|
* Clear the cached token, forcing a fresh fetch on next call.
|
|
56814
|
-
* @returns Nothing.
|
|
56815
56815
|
*/
|
|
56816
56816
|
clearToken(): void;
|
|
56817
56817
|
/**
|
|
@@ -56931,7 +56931,7 @@ declare class TopicsClient {
|
|
|
56931
56931
|
/**
|
|
56932
56932
|
* Force-delete a custom topic, removing it from any referencing profiles.
|
|
56933
56933
|
* @param topicId - UUID of the topic to force-delete.
|
|
56934
|
-
* @param updatedBy - Email of the user performing the deletion.
|
|
56934
|
+
* @param updatedBy - Optional. Email of the user performing the deletion.
|
|
56935
56935
|
* @returns Deletion confirmation message.
|
|
56936
56936
|
*/
|
|
56937
56937
|
forceDelete(topicId: string, updatedBy?: string): Promise<DeleteTopicResponse>;
|
|
@@ -57675,13 +57675,13 @@ declare class RedTeamReportsClient {
|
|
|
57675
57675
|
* Download a report in the specified format.
|
|
57676
57676
|
* @param jobId - The job UUID.
|
|
57677
57677
|
* @param format - The file format (e.g. "pdf", "csv").
|
|
57678
|
-
* @returns The
|
|
57678
|
+
* @returns The report data in the requested format (untyped — shape depends on `format`).
|
|
57679
57679
|
*/
|
|
57680
57680
|
downloadReport(jobId: string, format: string): Promise<unknown>;
|
|
57681
57681
|
/**
|
|
57682
57682
|
* Generate a partial report for a running scan.
|
|
57683
57683
|
* @param jobId - The job UUID.
|
|
57684
|
-
* @returns The partial report
|
|
57684
|
+
* @returns The partial report payload (untyped — schema not yet defined by the API).
|
|
57685
57685
|
*/
|
|
57686
57686
|
generatePartialReport(jobId: string): Promise<unknown>;
|
|
57687
57687
|
}
|
|
@@ -57907,7 +57907,7 @@ declare class RedTeamCustomAttacksClient {
|
|
|
57907
57907
|
/**
|
|
57908
57908
|
* Download CSV template for a prompt set.
|
|
57909
57909
|
* @param uuid - The prompt set UUID.
|
|
57910
|
-
* @returns The CSV template
|
|
57910
|
+
* @returns The CSV template content (untyped — raw response from the API).
|
|
57911
57911
|
*/
|
|
57912
57912
|
downloadTemplate(uuid: string): Promise<unknown>;
|
|
57913
57913
|
/**
|
package/dist/index.js
CHANGED
|
@@ -29,7 +29,7 @@ var MAX_NUMBER_OF_BATCH_SCAN_OBJECTS = 5;
|
|
|
29
29
|
var MAX_CONNECTION_POOL_SIZE = 100;
|
|
30
30
|
var MAX_NUMBER_OF_RETRIES = 5;
|
|
31
31
|
var HTTP_FORCE_RETRY_STATUS_CODES = [500, 502, 503, 504];
|
|
32
|
-
var SDK_VERSION = "0.6.
|
|
32
|
+
var SDK_VERSION = "0.6.7";
|
|
33
33
|
var USER_AGENT = `PAN-AIRS/${SDK_VERSION}-typescript-sdk`;
|
|
34
34
|
var DEFAULT_MGMT_ENDPOINT = "https://api.sase.paloaltonetworks.com/aisec";
|
|
35
35
|
var DEFAULT_TOKEN_ENDPOINT = "https://auth.apps.paloaltonetworks.com/oauth2/access_token";
|
|
@@ -258,6 +258,11 @@ var UUID_RE = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
|
|
258
258
|
function isValidUuid(value) {
|
|
259
259
|
return UUID_RE.test(value);
|
|
260
260
|
}
|
|
261
|
+
function validateJobId(jobId) {
|
|
262
|
+
if (!isValidUuid(jobId)) {
|
|
263
|
+
throw new AISecSDKException(`Invalid job id: ${jobId}`, "AISEC_USER_REQUEST_PAYLOAD_ERROR" /* USER_REQUEST_PAYLOAD_ERROR */);
|
|
264
|
+
}
|
|
265
|
+
}
|
|
261
266
|
function generatePayloadHash(payload, secret) {
|
|
262
267
|
return createHmac("sha256", secret).update(payload).digest("hex");
|
|
263
268
|
}
|
|
@@ -567,6 +572,7 @@ var Content = class _Content {
|
|
|
567
572
|
/**
|
|
568
573
|
* Load content from a JSON file.
|
|
569
574
|
* @param filePath - Path to JSON file containing scan request contents.
|
|
575
|
+
* @returns A new Content instance populated from the JSON file.
|
|
570
576
|
*/
|
|
571
577
|
static fromJSONFile(filePath) {
|
|
572
578
|
const raw = readFileSync(filePath, "utf-8");
|
|
@@ -2753,7 +2759,6 @@ var OAuthClient = class {
|
|
|
2753
2759
|
}
|
|
2754
2760
|
/**
|
|
2755
2761
|
* Clear the cached token, forcing a fresh fetch on next call.
|
|
2756
|
-
* @returns Nothing.
|
|
2757
2762
|
*/
|
|
2758
2763
|
clearToken() {
|
|
2759
2764
|
this.accessToken = null;
|
|
@@ -2842,6 +2847,49 @@ var OAuthClient = class {
|
|
|
2842
2847
|
}
|
|
2843
2848
|
};
|
|
2844
2849
|
|
|
2850
|
+
// src/oauth-config.ts
|
|
2851
|
+
function resolveOAuthConfig(opts) {
|
|
2852
|
+
const { primaryEnvPrefix, fallbackEnvPrefix } = opts;
|
|
2853
|
+
const clientId = opts.clientId ?? process.env[`${primaryEnvPrefix}_CLIENT_ID`] ?? (fallbackEnvPrefix ? process.env[`${fallbackEnvPrefix}_CLIENT_ID`] : void 0);
|
|
2854
|
+
const clientSecret = opts.clientSecret ?? process.env[`${primaryEnvPrefix}_CLIENT_SECRET`] ?? (fallbackEnvPrefix ? process.env[`${fallbackEnvPrefix}_CLIENT_SECRET`] : void 0);
|
|
2855
|
+
const tsgId = opts.tsgId ?? process.env[`${primaryEnvPrefix}_TSG_ID`] ?? (fallbackEnvPrefix ? process.env[`${fallbackEnvPrefix}_TSG_ID`] : void 0);
|
|
2856
|
+
const tokenEndpoint = opts.tokenEndpoint ?? process.env[`${primaryEnvPrefix}_TOKEN_ENDPOINT`] ?? (fallbackEnvPrefix ? process.env[`${fallbackEnvPrefix}_TOKEN_ENDPOINT`] : void 0);
|
|
2857
|
+
const numRetries = Math.min(
|
|
2858
|
+
Math.max(opts.numRetries ?? MAX_NUMBER_OF_RETRIES, 0),
|
|
2859
|
+
MAX_NUMBER_OF_RETRIES
|
|
2860
|
+
);
|
|
2861
|
+
const envHint = fallbackEnvPrefix ? `${primaryEnvPrefix}_CLIENT_ID / ${fallbackEnvPrefix}_CLIENT_ID` : `${primaryEnvPrefix}_CLIENT_ID`;
|
|
2862
|
+
if (!clientId) {
|
|
2863
|
+
throw new AISecSDKException(
|
|
2864
|
+
`clientId is required (option or ${envHint} env var)`,
|
|
2865
|
+
"AISEC_MISSING_VARIABLE" /* MISSING_VARIABLE */
|
|
2866
|
+
);
|
|
2867
|
+
}
|
|
2868
|
+
const secretHint = fallbackEnvPrefix ? `${primaryEnvPrefix}_CLIENT_SECRET / ${fallbackEnvPrefix}_CLIENT_SECRET` : `${primaryEnvPrefix}_CLIENT_SECRET`;
|
|
2869
|
+
if (!clientSecret) {
|
|
2870
|
+
throw new AISecSDKException(
|
|
2871
|
+
`clientSecret is required (option or ${secretHint} env var)`,
|
|
2872
|
+
"AISEC_MISSING_VARIABLE" /* MISSING_VARIABLE */
|
|
2873
|
+
);
|
|
2874
|
+
}
|
|
2875
|
+
const tsgHint = fallbackEnvPrefix ? `${primaryEnvPrefix}_TSG_ID / ${fallbackEnvPrefix}_TSG_ID` : `${primaryEnvPrefix}_TSG_ID`;
|
|
2876
|
+
if (!tsgId) {
|
|
2877
|
+
throw new AISecSDKException(
|
|
2878
|
+
`tsgId is required (option or ${tsgHint} env var)`,
|
|
2879
|
+
"AISEC_MISSING_VARIABLE" /* MISSING_VARIABLE */
|
|
2880
|
+
);
|
|
2881
|
+
}
|
|
2882
|
+
const oauthClient = new OAuthClient({
|
|
2883
|
+
clientId,
|
|
2884
|
+
clientSecret,
|
|
2885
|
+
tsgId,
|
|
2886
|
+
tokenEndpoint,
|
|
2887
|
+
tokenBufferMs: opts.tokenBufferMs,
|
|
2888
|
+
onTokenRefresh: opts.onTokenRefresh
|
|
2889
|
+
});
|
|
2890
|
+
return { baseUrl: opts.baseUrl, oauthClient, numRetries, tsgId };
|
|
2891
|
+
}
|
|
2892
|
+
|
|
2845
2893
|
// src/management/management-http-client.ts
|
|
2846
2894
|
async function managementHttpRequest(opts) {
|
|
2847
2895
|
const { method, baseUrl, path, body, params, oauthClient, numRetries } = opts;
|
|
@@ -3100,7 +3148,7 @@ var TopicsClient = class {
|
|
|
3100
3148
|
/**
|
|
3101
3149
|
* Force-delete a custom topic, removing it from any referencing profiles.
|
|
3102
3150
|
* @param topicId - UUID of the topic to force-delete.
|
|
3103
|
-
* @param updatedBy - Email of the user performing the deletion.
|
|
3151
|
+
* @param updatedBy - Optional. Email of the user performing the deletion.
|
|
3104
3152
|
* @returns Deletion confirmation message.
|
|
3105
3153
|
*/
|
|
3106
3154
|
async forceDelete(topicId, updatedBy) {
|
|
@@ -3447,80 +3495,57 @@ var ManagementClient = class {
|
|
|
3447
3495
|
scanLogs;
|
|
3448
3496
|
oauth;
|
|
3449
3497
|
constructor(opts = {}) {
|
|
3450
|
-
const clientId = opts.clientId ?? process.env[MGMT_CLIENT_ID];
|
|
3451
|
-
const clientSecret = opts.clientSecret ?? process.env[MGMT_CLIENT_SECRET];
|
|
3452
|
-
const tsgId = opts.tsgId ?? process.env[MGMT_TSG_ID];
|
|
3453
3498
|
const apiEndpoint = opts.apiEndpoint ?? process.env[MGMT_ENDPOINT] ?? DEFAULT_MGMT_ENDPOINT;
|
|
3454
|
-
const
|
|
3455
|
-
|
|
3456
|
-
|
|
3457
|
-
|
|
3458
|
-
|
|
3459
|
-
|
|
3460
|
-
|
|
3461
|
-
|
|
3462
|
-
"AISEC_MISSING_VARIABLE" /* MISSING_VARIABLE */
|
|
3463
|
-
);
|
|
3464
|
-
}
|
|
3465
|
-
if (!clientSecret) {
|
|
3466
|
-
throw new AISecSDKException(
|
|
3467
|
-
"clientSecret is required (option or PANW_MGMT_CLIENT_SECRET env var)",
|
|
3468
|
-
"AISEC_MISSING_VARIABLE" /* MISSING_VARIABLE */
|
|
3469
|
-
);
|
|
3470
|
-
}
|
|
3471
|
-
if (!tsgId) {
|
|
3472
|
-
throw new AISecSDKException(
|
|
3473
|
-
"tsgId is required (option or PANW_MGMT_TSG_ID env var)",
|
|
3474
|
-
"AISEC_MISSING_VARIABLE" /* MISSING_VARIABLE */
|
|
3475
|
-
);
|
|
3476
|
-
}
|
|
3477
|
-
const oauthClient = new OAuthClient({
|
|
3478
|
-
clientId,
|
|
3479
|
-
clientSecret,
|
|
3480
|
-
tsgId,
|
|
3481
|
-
tokenEndpoint
|
|
3499
|
+
const { baseUrl, oauthClient, numRetries, tsgId } = resolveOAuthConfig({
|
|
3500
|
+
clientId: opts.clientId,
|
|
3501
|
+
clientSecret: opts.clientSecret,
|
|
3502
|
+
tsgId: opts.tsgId,
|
|
3503
|
+
baseUrl: apiEndpoint,
|
|
3504
|
+
numRetries: opts.numRetries,
|
|
3505
|
+
tokenEndpoint: opts.tokenEndpoint,
|
|
3506
|
+
primaryEnvPrefix: "PANW_MGMT"
|
|
3482
3507
|
});
|
|
3483
3508
|
this.profiles = new ProfilesClient({
|
|
3484
|
-
baseUrl
|
|
3509
|
+
baseUrl,
|
|
3485
3510
|
oauthClient,
|
|
3486
3511
|
tsgId,
|
|
3487
3512
|
numRetries
|
|
3488
3513
|
});
|
|
3489
3514
|
this.topics = new TopicsClient({
|
|
3490
|
-
baseUrl
|
|
3515
|
+
baseUrl,
|
|
3491
3516
|
oauthClient,
|
|
3492
3517
|
tsgId,
|
|
3493
3518
|
numRetries
|
|
3494
3519
|
});
|
|
3495
3520
|
this.apiKeys = new ApiKeysClient({
|
|
3496
|
-
baseUrl
|
|
3521
|
+
baseUrl,
|
|
3497
3522
|
oauthClient,
|
|
3498
3523
|
tsgId,
|
|
3499
3524
|
numRetries
|
|
3500
3525
|
});
|
|
3501
3526
|
this.customerApps = new CustomerAppsClient({
|
|
3502
|
-
baseUrl
|
|
3527
|
+
baseUrl,
|
|
3503
3528
|
oauthClient,
|
|
3504
3529
|
tsgId,
|
|
3505
3530
|
numRetries
|
|
3506
3531
|
});
|
|
3507
3532
|
this.dlpProfiles = new DlpProfilesClient({
|
|
3508
|
-
baseUrl
|
|
3533
|
+
baseUrl,
|
|
3509
3534
|
oauthClient,
|
|
3510
3535
|
numRetries
|
|
3511
3536
|
});
|
|
3512
3537
|
this.deploymentProfiles = new DeploymentProfilesClient({
|
|
3513
|
-
baseUrl
|
|
3538
|
+
baseUrl,
|
|
3514
3539
|
oauthClient,
|
|
3515
3540
|
numRetries
|
|
3516
3541
|
});
|
|
3517
3542
|
this.scanLogs = new ScanLogsClient({
|
|
3518
|
-
baseUrl
|
|
3543
|
+
baseUrl,
|
|
3519
3544
|
oauthClient,
|
|
3520
3545
|
numRetries
|
|
3521
3546
|
});
|
|
3522
3547
|
this.oauth = new OAuthManagementClient({
|
|
3523
|
-
baseUrl
|
|
3548
|
+
baseUrl,
|
|
3524
3549
|
oauthClient,
|
|
3525
3550
|
numRetries
|
|
3526
3551
|
});
|
|
@@ -4136,55 +4161,34 @@ var ModelSecurityClient = class {
|
|
|
4136
4161
|
oauthClient;
|
|
4137
4162
|
numRetries;
|
|
4138
4163
|
constructor(opts = {}) {
|
|
4139
|
-
const clientId = opts.clientId ?? process.env[MODEL_SEC_CLIENT_ID] ?? process.env[MGMT_CLIENT_ID];
|
|
4140
|
-
const clientSecret = opts.clientSecret ?? process.env[MODEL_SEC_CLIENT_SECRET] ?? process.env[MGMT_CLIENT_SECRET];
|
|
4141
|
-
const tsgId = opts.tsgId ?? process.env[MODEL_SEC_TSG_ID] ?? process.env[MGMT_TSG_ID];
|
|
4142
4164
|
const dataEndpoint = opts.dataEndpoint ?? process.env[MODEL_SEC_DATA_ENDPOINT] ?? DEFAULT_MODEL_SEC_DATA_ENDPOINT;
|
|
4143
4165
|
const mgmtEndpoint = opts.mgmtEndpoint ?? process.env[MODEL_SEC_MGMT_ENDPOINT] ?? DEFAULT_MODEL_SEC_MGMT_ENDPOINT;
|
|
4144
|
-
const
|
|
4145
|
-
|
|
4146
|
-
|
|
4147
|
-
|
|
4148
|
-
|
|
4149
|
-
|
|
4150
|
-
|
|
4151
|
-
|
|
4152
|
-
|
|
4153
|
-
);
|
|
4154
|
-
}
|
|
4155
|
-
if (!clientSecret) {
|
|
4156
|
-
throw new AISecSDKException(
|
|
4157
|
-
"clientSecret is required (option or PANW_MODEL_SEC_CLIENT_SECRET / PANW_MGMT_CLIENT_SECRET env var)",
|
|
4158
|
-
"AISEC_MISSING_VARIABLE" /* MISSING_VARIABLE */
|
|
4159
|
-
);
|
|
4160
|
-
}
|
|
4161
|
-
if (!tsgId) {
|
|
4162
|
-
throw new AISecSDKException(
|
|
4163
|
-
"tsgId is required (option or PANW_MODEL_SEC_TSG_ID / PANW_MGMT_TSG_ID env var)",
|
|
4164
|
-
"AISEC_MISSING_VARIABLE" /* MISSING_VARIABLE */
|
|
4165
|
-
);
|
|
4166
|
-
}
|
|
4167
|
-
this.oauthClient = new OAuthClient({
|
|
4168
|
-
clientId,
|
|
4169
|
-
clientSecret,
|
|
4170
|
-
tsgId,
|
|
4171
|
-
tokenEndpoint
|
|
4166
|
+
const { oauthClient, numRetries } = resolveOAuthConfig({
|
|
4167
|
+
clientId: opts.clientId,
|
|
4168
|
+
clientSecret: opts.clientSecret,
|
|
4169
|
+
tsgId: opts.tsgId,
|
|
4170
|
+
baseUrl: mgmtEndpoint,
|
|
4171
|
+
numRetries: opts.numRetries,
|
|
4172
|
+
tokenEndpoint: opts.tokenEndpoint,
|
|
4173
|
+
primaryEnvPrefix: "PANW_MODEL_SEC",
|
|
4174
|
+
fallbackEnvPrefix: "PANW_MGMT"
|
|
4172
4175
|
});
|
|
4176
|
+
this.oauthClient = oauthClient;
|
|
4173
4177
|
this.mgmtEndpoint = mgmtEndpoint;
|
|
4174
4178
|
this.numRetries = numRetries;
|
|
4175
4179
|
this.scans = new ModelSecurityScansClient({
|
|
4176
4180
|
baseUrl: dataEndpoint,
|
|
4177
|
-
oauthClient
|
|
4181
|
+
oauthClient,
|
|
4178
4182
|
numRetries
|
|
4179
4183
|
});
|
|
4180
4184
|
this.securityGroups = new ModelSecurityGroupsClient({
|
|
4181
4185
|
baseUrl: mgmtEndpoint,
|
|
4182
|
-
oauthClient
|
|
4186
|
+
oauthClient,
|
|
4183
4187
|
numRetries
|
|
4184
4188
|
});
|
|
4185
4189
|
this.securityRules = new ModelSecurityRulesClient({
|
|
4186
4190
|
baseUrl: mgmtEndpoint,
|
|
4187
|
-
oauthClient
|
|
4191
|
+
oauthClient,
|
|
4188
4192
|
numRetries
|
|
4189
4193
|
});
|
|
4190
4194
|
}
|
|
@@ -4312,11 +4316,6 @@ var RedTeamScansClient = class {
|
|
|
4312
4316
|
};
|
|
4313
4317
|
|
|
4314
4318
|
// src/red-team/reports-client.ts
|
|
4315
|
-
function validateJobId(jobId) {
|
|
4316
|
-
if (!isValidUuid(jobId)) {
|
|
4317
|
-
throw new AISecSDKException(`Invalid job id: ${jobId}`, "AISEC_USER_REQUEST_PAYLOAD_ERROR" /* USER_REQUEST_PAYLOAD_ERROR */);
|
|
4318
|
-
}
|
|
4319
|
-
}
|
|
4320
4319
|
var RedTeamReportsClient = class {
|
|
4321
4320
|
baseUrl;
|
|
4322
4321
|
oauthClient;
|
|
@@ -4574,7 +4573,7 @@ var RedTeamReportsClient = class {
|
|
|
4574
4573
|
* Download a report in the specified format.
|
|
4575
4574
|
* @param jobId - The job UUID.
|
|
4576
4575
|
* @param format - The file format (e.g. "pdf", "csv").
|
|
4577
|
-
* @returns The
|
|
4576
|
+
* @returns The report data in the requested format (untyped — shape depends on `format`).
|
|
4578
4577
|
*/
|
|
4579
4578
|
async downloadReport(jobId, format) {
|
|
4580
4579
|
validateJobId(jobId);
|
|
@@ -4592,7 +4591,7 @@ var RedTeamReportsClient = class {
|
|
|
4592
4591
|
/**
|
|
4593
4592
|
* Generate a partial report for a running scan.
|
|
4594
4593
|
* @param jobId - The job UUID.
|
|
4595
|
-
* @returns The partial report
|
|
4594
|
+
* @returns The partial report payload (untyped — schema not yet defined by the API).
|
|
4596
4595
|
*/
|
|
4597
4596
|
async generatePartialReport(jobId) {
|
|
4598
4597
|
validateJobId(jobId);
|
|
@@ -4608,11 +4607,6 @@ var RedTeamReportsClient = class {
|
|
|
4608
4607
|
};
|
|
4609
4608
|
|
|
4610
4609
|
// src/red-team/custom-attack-reports-client.ts
|
|
4611
|
-
function validateJobId2(jobId) {
|
|
4612
|
-
if (!isValidUuid(jobId)) {
|
|
4613
|
-
throw new AISecSDKException(`Invalid job id: ${jobId}`, "AISEC_USER_REQUEST_PAYLOAD_ERROR" /* USER_REQUEST_PAYLOAD_ERROR */);
|
|
4614
|
-
}
|
|
4615
|
-
}
|
|
4616
4610
|
var RedTeamCustomAttackReportsClient = class {
|
|
4617
4611
|
baseUrl;
|
|
4618
4612
|
oauthClient;
|
|
@@ -4628,7 +4622,7 @@ var RedTeamCustomAttackReportsClient = class {
|
|
|
4628
4622
|
* @returns The custom attack report response.
|
|
4629
4623
|
*/
|
|
4630
4624
|
async getReport(jobId) {
|
|
4631
|
-
|
|
4625
|
+
validateJobId(jobId);
|
|
4632
4626
|
const res = await managementHttpRequest({
|
|
4633
4627
|
method: "GET",
|
|
4634
4628
|
baseUrl: this.baseUrl,
|
|
@@ -4644,7 +4638,7 @@ var RedTeamCustomAttackReportsClient = class {
|
|
|
4644
4638
|
* @returns The prompt sets report response.
|
|
4645
4639
|
*/
|
|
4646
4640
|
async getPromptSets(jobId) {
|
|
4647
|
-
|
|
4641
|
+
validateJobId(jobId);
|
|
4648
4642
|
const res = await managementHttpRequest({
|
|
4649
4643
|
method: "GET",
|
|
4650
4644
|
baseUrl: this.baseUrl,
|
|
@@ -4662,7 +4656,7 @@ var RedTeamCustomAttackReportsClient = class {
|
|
|
4662
4656
|
* @returns The list of prompt detail responses.
|
|
4663
4657
|
*/
|
|
4664
4658
|
async getPromptsBySet(jobId, promptSetId, opts) {
|
|
4665
|
-
|
|
4659
|
+
validateJobId(jobId);
|
|
4666
4660
|
if (!isValidUuid(promptSetId)) {
|
|
4667
4661
|
throw new AISecSDKException(
|
|
4668
4662
|
`Invalid prompt set id: ${promptSetId}`,
|
|
@@ -4688,7 +4682,7 @@ var RedTeamCustomAttackReportsClient = class {
|
|
|
4688
4682
|
* @returns The prompt detail response.
|
|
4689
4683
|
*/
|
|
4690
4684
|
async getPromptDetail(jobId, promptId) {
|
|
4691
|
-
|
|
4685
|
+
validateJobId(jobId);
|
|
4692
4686
|
if (!isValidUuid(promptId)) {
|
|
4693
4687
|
throw new AISecSDKException(
|
|
4694
4688
|
`Invalid prompt id: ${promptId}`,
|
|
@@ -4711,7 +4705,7 @@ var RedTeamCustomAttackReportsClient = class {
|
|
|
4711
4705
|
* @returns The paginated list of custom attacks.
|
|
4712
4706
|
*/
|
|
4713
4707
|
async listCustomAttacks(jobId, opts) {
|
|
4714
|
-
|
|
4708
|
+
validateJobId(jobId);
|
|
4715
4709
|
const params = buildRedTeamListParams(opts);
|
|
4716
4710
|
if (opts?.threat !== void 0) params.threat = String(opts.threat);
|
|
4717
4711
|
if (opts?.prompt_set_id !== void 0) params.prompt_set_id = opts.prompt_set_id;
|
|
@@ -4733,7 +4727,7 @@ var RedTeamCustomAttackReportsClient = class {
|
|
|
4733
4727
|
* @returns The list of attack outputs.
|
|
4734
4728
|
*/
|
|
4735
4729
|
async getAttackOutputs(jobId, attackId) {
|
|
4736
|
-
|
|
4730
|
+
validateJobId(jobId);
|
|
4737
4731
|
if (!isValidUuid(attackId)) {
|
|
4738
4732
|
throw new AISecSDKException(
|
|
4739
4733
|
`Invalid attack id: ${attackId}`,
|
|
@@ -4755,7 +4749,7 @@ var RedTeamCustomAttackReportsClient = class {
|
|
|
4755
4749
|
* @returns The list of property statistics.
|
|
4756
4750
|
*/
|
|
4757
4751
|
async getPropertyStats(jobId) {
|
|
4758
|
-
|
|
4752
|
+
validateJobId(jobId);
|
|
4759
4753
|
const res = await managementHttpRequest({
|
|
4760
4754
|
method: "GET",
|
|
4761
4755
|
baseUrl: this.baseUrl,
|
|
@@ -5102,7 +5096,7 @@ var RedTeamCustomAttacksClient = class {
|
|
|
5102
5096
|
/**
|
|
5103
5097
|
* Download CSV template for a prompt set.
|
|
5104
5098
|
* @param uuid - The prompt set UUID.
|
|
5105
|
-
* @returns The CSV template
|
|
5099
|
+
* @returns The CSV template content (untyped — raw response from the API).
|
|
5106
5100
|
*/
|
|
5107
5101
|
async downloadTemplate(uuid) {
|
|
5108
5102
|
validateUuid(uuid, "prompt set uuid");
|
|
@@ -5346,61 +5340,45 @@ var RedTeamClient = class {
|
|
|
5346
5340
|
oauthClient;
|
|
5347
5341
|
numRetries;
|
|
5348
5342
|
constructor(opts = {}) {
|
|
5349
|
-
const clientId = opts.clientId ?? process.env[RED_TEAM_CLIENT_ID] ?? process.env[MGMT_CLIENT_ID];
|
|
5350
|
-
const clientSecret = opts.clientSecret ?? process.env[RED_TEAM_CLIENT_SECRET] ?? process.env[MGMT_CLIENT_SECRET];
|
|
5351
|
-
const tsgId = opts.tsgId ?? process.env[RED_TEAM_TSG_ID] ?? process.env[MGMT_TSG_ID];
|
|
5352
5343
|
const dataEndpoint = opts.dataEndpoint ?? process.env[RED_TEAM_DATA_ENDPOINT] ?? DEFAULT_RED_TEAM_DATA_ENDPOINT;
|
|
5353
5344
|
const mgmtEndpoint = opts.mgmtEndpoint ?? process.env[RED_TEAM_MGMT_ENDPOINT] ?? DEFAULT_RED_TEAM_MGMT_ENDPOINT;
|
|
5354
|
-
const
|
|
5355
|
-
|
|
5356
|
-
|
|
5357
|
-
|
|
5358
|
-
|
|
5359
|
-
|
|
5360
|
-
|
|
5361
|
-
|
|
5362
|
-
|
|
5363
|
-
|
|
5364
|
-
|
|
5365
|
-
if (!clientSecret) {
|
|
5366
|
-
throw new AISecSDKException(
|
|
5367
|
-
"clientSecret is required (option or PANW_RED_TEAM_CLIENT_SECRET / PANW_MGMT_CLIENT_SECRET env var)",
|
|
5368
|
-
"AISEC_MISSING_VARIABLE" /* MISSING_VARIABLE */
|
|
5369
|
-
);
|
|
5370
|
-
}
|
|
5371
|
-
if (!tsgId) {
|
|
5372
|
-
throw new AISecSDKException(
|
|
5373
|
-
"tsgId is required (option or PANW_RED_TEAM_TSG_ID / PANW_MGMT_TSG_ID env var)",
|
|
5374
|
-
"AISEC_MISSING_VARIABLE" /* MISSING_VARIABLE */
|
|
5375
|
-
);
|
|
5376
|
-
}
|
|
5377
|
-
this.oauthClient = new OAuthClient({ clientId, clientSecret, tsgId, tokenEndpoint });
|
|
5345
|
+
const { oauthClient, numRetries } = resolveOAuthConfig({
|
|
5346
|
+
clientId: opts.clientId,
|
|
5347
|
+
clientSecret: opts.clientSecret,
|
|
5348
|
+
tsgId: opts.tsgId,
|
|
5349
|
+
baseUrl: dataEndpoint,
|
|
5350
|
+
numRetries: opts.numRetries,
|
|
5351
|
+
tokenEndpoint: opts.tokenEndpoint,
|
|
5352
|
+
primaryEnvPrefix: "PANW_RED_TEAM",
|
|
5353
|
+
fallbackEnvPrefix: "PANW_MGMT"
|
|
5354
|
+
});
|
|
5355
|
+
this.oauthClient = oauthClient;
|
|
5378
5356
|
this.dataEndpoint = dataEndpoint;
|
|
5379
5357
|
this.mgmtEndpoint = mgmtEndpoint;
|
|
5380
5358
|
this.numRetries = numRetries;
|
|
5381
5359
|
this.scans = new RedTeamScansClient({
|
|
5382
5360
|
baseUrl: dataEndpoint,
|
|
5383
|
-
oauthClient
|
|
5361
|
+
oauthClient,
|
|
5384
5362
|
numRetries
|
|
5385
5363
|
});
|
|
5386
5364
|
this.reports = new RedTeamReportsClient({
|
|
5387
5365
|
baseUrl: dataEndpoint,
|
|
5388
|
-
oauthClient
|
|
5366
|
+
oauthClient,
|
|
5389
5367
|
numRetries
|
|
5390
5368
|
});
|
|
5391
5369
|
this.customAttackReports = new RedTeamCustomAttackReportsClient({
|
|
5392
5370
|
baseUrl: dataEndpoint,
|
|
5393
|
-
oauthClient
|
|
5371
|
+
oauthClient,
|
|
5394
5372
|
numRetries
|
|
5395
5373
|
});
|
|
5396
5374
|
this.targets = new RedTeamTargetsClient({
|
|
5397
5375
|
baseUrl: mgmtEndpoint,
|
|
5398
|
-
oauthClient
|
|
5376
|
+
oauthClient,
|
|
5399
5377
|
numRetries
|
|
5400
5378
|
});
|
|
5401
5379
|
this.customAttacks = new RedTeamCustomAttacksClient({
|
|
5402
5380
|
baseUrl: mgmtEndpoint,
|
|
5403
|
-
oauthClient
|
|
5381
|
+
oauthClient,
|
|
5404
5382
|
numRetries
|
|
5405
5383
|
});
|
|
5406
5384
|
}
|