@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.cjs
CHANGED
|
@@ -430,7 +430,7 @@ var MAX_NUMBER_OF_BATCH_SCAN_OBJECTS = 5;
|
|
|
430
430
|
var MAX_CONNECTION_POOL_SIZE = 100;
|
|
431
431
|
var MAX_NUMBER_OF_RETRIES = 5;
|
|
432
432
|
var HTTP_FORCE_RETRY_STATUS_CODES = [500, 502, 503, 504];
|
|
433
|
-
var SDK_VERSION = "0.6.
|
|
433
|
+
var SDK_VERSION = "0.6.7";
|
|
434
434
|
var USER_AGENT = `PAN-AIRS/${SDK_VERSION}-typescript-sdk`;
|
|
435
435
|
var DEFAULT_MGMT_ENDPOINT = "https://api.sase.paloaltonetworks.com/aisec";
|
|
436
436
|
var DEFAULT_TOKEN_ENDPOINT = "https://auth.apps.paloaltonetworks.com/oauth2/access_token";
|
|
@@ -659,6 +659,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;
|
|
|
659
659
|
function isValidUuid(value) {
|
|
660
660
|
return UUID_RE.test(value);
|
|
661
661
|
}
|
|
662
|
+
function validateJobId(jobId) {
|
|
663
|
+
if (!isValidUuid(jobId)) {
|
|
664
|
+
throw new AISecSDKException(`Invalid job id: ${jobId}`, "AISEC_USER_REQUEST_PAYLOAD_ERROR" /* USER_REQUEST_PAYLOAD_ERROR */);
|
|
665
|
+
}
|
|
666
|
+
}
|
|
662
667
|
function generatePayloadHash(payload, secret) {
|
|
663
668
|
return (0, import_node_crypto.createHmac)("sha256", secret).update(payload).digest("hex");
|
|
664
669
|
}
|
|
@@ -968,6 +973,7 @@ var Content = class _Content {
|
|
|
968
973
|
/**
|
|
969
974
|
* Load content from a JSON file.
|
|
970
975
|
* @param filePath - Path to JSON file containing scan request contents.
|
|
976
|
+
* @returns A new Content instance populated from the JSON file.
|
|
971
977
|
*/
|
|
972
978
|
static fromJSONFile(filePath) {
|
|
973
979
|
const raw = (0, import_node_fs.readFileSync)(filePath, "utf-8");
|
|
@@ -3154,7 +3160,6 @@ var OAuthClient = class {
|
|
|
3154
3160
|
}
|
|
3155
3161
|
/**
|
|
3156
3162
|
* Clear the cached token, forcing a fresh fetch on next call.
|
|
3157
|
-
* @returns Nothing.
|
|
3158
3163
|
*/
|
|
3159
3164
|
clearToken() {
|
|
3160
3165
|
this.accessToken = null;
|
|
@@ -3243,6 +3248,49 @@ var OAuthClient = class {
|
|
|
3243
3248
|
}
|
|
3244
3249
|
};
|
|
3245
3250
|
|
|
3251
|
+
// src/oauth-config.ts
|
|
3252
|
+
function resolveOAuthConfig(opts) {
|
|
3253
|
+
const { primaryEnvPrefix, fallbackEnvPrefix } = opts;
|
|
3254
|
+
const clientId = opts.clientId ?? process.env[`${primaryEnvPrefix}_CLIENT_ID`] ?? (fallbackEnvPrefix ? process.env[`${fallbackEnvPrefix}_CLIENT_ID`] : void 0);
|
|
3255
|
+
const clientSecret = opts.clientSecret ?? process.env[`${primaryEnvPrefix}_CLIENT_SECRET`] ?? (fallbackEnvPrefix ? process.env[`${fallbackEnvPrefix}_CLIENT_SECRET`] : void 0);
|
|
3256
|
+
const tsgId = opts.tsgId ?? process.env[`${primaryEnvPrefix}_TSG_ID`] ?? (fallbackEnvPrefix ? process.env[`${fallbackEnvPrefix}_TSG_ID`] : void 0);
|
|
3257
|
+
const tokenEndpoint = opts.tokenEndpoint ?? process.env[`${primaryEnvPrefix}_TOKEN_ENDPOINT`] ?? (fallbackEnvPrefix ? process.env[`${fallbackEnvPrefix}_TOKEN_ENDPOINT`] : void 0);
|
|
3258
|
+
const numRetries = Math.min(
|
|
3259
|
+
Math.max(opts.numRetries ?? MAX_NUMBER_OF_RETRIES, 0),
|
|
3260
|
+
MAX_NUMBER_OF_RETRIES
|
|
3261
|
+
);
|
|
3262
|
+
const envHint = fallbackEnvPrefix ? `${primaryEnvPrefix}_CLIENT_ID / ${fallbackEnvPrefix}_CLIENT_ID` : `${primaryEnvPrefix}_CLIENT_ID`;
|
|
3263
|
+
if (!clientId) {
|
|
3264
|
+
throw new AISecSDKException(
|
|
3265
|
+
`clientId is required (option or ${envHint} env var)`,
|
|
3266
|
+
"AISEC_MISSING_VARIABLE" /* MISSING_VARIABLE */
|
|
3267
|
+
);
|
|
3268
|
+
}
|
|
3269
|
+
const secretHint = fallbackEnvPrefix ? `${primaryEnvPrefix}_CLIENT_SECRET / ${fallbackEnvPrefix}_CLIENT_SECRET` : `${primaryEnvPrefix}_CLIENT_SECRET`;
|
|
3270
|
+
if (!clientSecret) {
|
|
3271
|
+
throw new AISecSDKException(
|
|
3272
|
+
`clientSecret is required (option or ${secretHint} env var)`,
|
|
3273
|
+
"AISEC_MISSING_VARIABLE" /* MISSING_VARIABLE */
|
|
3274
|
+
);
|
|
3275
|
+
}
|
|
3276
|
+
const tsgHint = fallbackEnvPrefix ? `${primaryEnvPrefix}_TSG_ID / ${fallbackEnvPrefix}_TSG_ID` : `${primaryEnvPrefix}_TSG_ID`;
|
|
3277
|
+
if (!tsgId) {
|
|
3278
|
+
throw new AISecSDKException(
|
|
3279
|
+
`tsgId is required (option or ${tsgHint} env var)`,
|
|
3280
|
+
"AISEC_MISSING_VARIABLE" /* MISSING_VARIABLE */
|
|
3281
|
+
);
|
|
3282
|
+
}
|
|
3283
|
+
const oauthClient = new OAuthClient({
|
|
3284
|
+
clientId,
|
|
3285
|
+
clientSecret,
|
|
3286
|
+
tsgId,
|
|
3287
|
+
tokenEndpoint,
|
|
3288
|
+
tokenBufferMs: opts.tokenBufferMs,
|
|
3289
|
+
onTokenRefresh: opts.onTokenRefresh
|
|
3290
|
+
});
|
|
3291
|
+
return { baseUrl: opts.baseUrl, oauthClient, numRetries, tsgId };
|
|
3292
|
+
}
|
|
3293
|
+
|
|
3246
3294
|
// src/management/management-http-client.ts
|
|
3247
3295
|
async function managementHttpRequest(opts) {
|
|
3248
3296
|
const { method, baseUrl, path, body, params, oauthClient, numRetries } = opts;
|
|
@@ -3501,7 +3549,7 @@ var TopicsClient = class {
|
|
|
3501
3549
|
/**
|
|
3502
3550
|
* Force-delete a custom topic, removing it from any referencing profiles.
|
|
3503
3551
|
* @param topicId - UUID of the topic to force-delete.
|
|
3504
|
-
* @param updatedBy - Email of the user performing the deletion.
|
|
3552
|
+
* @param updatedBy - Optional. Email of the user performing the deletion.
|
|
3505
3553
|
* @returns Deletion confirmation message.
|
|
3506
3554
|
*/
|
|
3507
3555
|
async forceDelete(topicId, updatedBy) {
|
|
@@ -3848,80 +3896,57 @@ var ManagementClient = class {
|
|
|
3848
3896
|
scanLogs;
|
|
3849
3897
|
oauth;
|
|
3850
3898
|
constructor(opts = {}) {
|
|
3851
|
-
const clientId = opts.clientId ?? process.env[MGMT_CLIENT_ID];
|
|
3852
|
-
const clientSecret = opts.clientSecret ?? process.env[MGMT_CLIENT_SECRET];
|
|
3853
|
-
const tsgId = opts.tsgId ?? process.env[MGMT_TSG_ID];
|
|
3854
3899
|
const apiEndpoint = opts.apiEndpoint ?? process.env[MGMT_ENDPOINT] ?? DEFAULT_MGMT_ENDPOINT;
|
|
3855
|
-
const
|
|
3856
|
-
|
|
3857
|
-
|
|
3858
|
-
|
|
3859
|
-
|
|
3860
|
-
|
|
3861
|
-
|
|
3862
|
-
|
|
3863
|
-
"AISEC_MISSING_VARIABLE" /* MISSING_VARIABLE */
|
|
3864
|
-
);
|
|
3865
|
-
}
|
|
3866
|
-
if (!clientSecret) {
|
|
3867
|
-
throw new AISecSDKException(
|
|
3868
|
-
"clientSecret is required (option or PANW_MGMT_CLIENT_SECRET env var)",
|
|
3869
|
-
"AISEC_MISSING_VARIABLE" /* MISSING_VARIABLE */
|
|
3870
|
-
);
|
|
3871
|
-
}
|
|
3872
|
-
if (!tsgId) {
|
|
3873
|
-
throw new AISecSDKException(
|
|
3874
|
-
"tsgId is required (option or PANW_MGMT_TSG_ID env var)",
|
|
3875
|
-
"AISEC_MISSING_VARIABLE" /* MISSING_VARIABLE */
|
|
3876
|
-
);
|
|
3877
|
-
}
|
|
3878
|
-
const oauthClient = new OAuthClient({
|
|
3879
|
-
clientId,
|
|
3880
|
-
clientSecret,
|
|
3881
|
-
tsgId,
|
|
3882
|
-
tokenEndpoint
|
|
3900
|
+
const { baseUrl, oauthClient, numRetries, tsgId } = resolveOAuthConfig({
|
|
3901
|
+
clientId: opts.clientId,
|
|
3902
|
+
clientSecret: opts.clientSecret,
|
|
3903
|
+
tsgId: opts.tsgId,
|
|
3904
|
+
baseUrl: apiEndpoint,
|
|
3905
|
+
numRetries: opts.numRetries,
|
|
3906
|
+
tokenEndpoint: opts.tokenEndpoint,
|
|
3907
|
+
primaryEnvPrefix: "PANW_MGMT"
|
|
3883
3908
|
});
|
|
3884
3909
|
this.profiles = new ProfilesClient({
|
|
3885
|
-
baseUrl
|
|
3910
|
+
baseUrl,
|
|
3886
3911
|
oauthClient,
|
|
3887
3912
|
tsgId,
|
|
3888
3913
|
numRetries
|
|
3889
3914
|
});
|
|
3890
3915
|
this.topics = new TopicsClient({
|
|
3891
|
-
baseUrl
|
|
3916
|
+
baseUrl,
|
|
3892
3917
|
oauthClient,
|
|
3893
3918
|
tsgId,
|
|
3894
3919
|
numRetries
|
|
3895
3920
|
});
|
|
3896
3921
|
this.apiKeys = new ApiKeysClient({
|
|
3897
|
-
baseUrl
|
|
3922
|
+
baseUrl,
|
|
3898
3923
|
oauthClient,
|
|
3899
3924
|
tsgId,
|
|
3900
3925
|
numRetries
|
|
3901
3926
|
});
|
|
3902
3927
|
this.customerApps = new CustomerAppsClient({
|
|
3903
|
-
baseUrl
|
|
3928
|
+
baseUrl,
|
|
3904
3929
|
oauthClient,
|
|
3905
3930
|
tsgId,
|
|
3906
3931
|
numRetries
|
|
3907
3932
|
});
|
|
3908
3933
|
this.dlpProfiles = new DlpProfilesClient({
|
|
3909
|
-
baseUrl
|
|
3934
|
+
baseUrl,
|
|
3910
3935
|
oauthClient,
|
|
3911
3936
|
numRetries
|
|
3912
3937
|
});
|
|
3913
3938
|
this.deploymentProfiles = new DeploymentProfilesClient({
|
|
3914
|
-
baseUrl
|
|
3939
|
+
baseUrl,
|
|
3915
3940
|
oauthClient,
|
|
3916
3941
|
numRetries
|
|
3917
3942
|
});
|
|
3918
3943
|
this.scanLogs = new ScanLogsClient({
|
|
3919
|
-
baseUrl
|
|
3944
|
+
baseUrl,
|
|
3920
3945
|
oauthClient,
|
|
3921
3946
|
numRetries
|
|
3922
3947
|
});
|
|
3923
3948
|
this.oauth = new OAuthManagementClient({
|
|
3924
|
-
baseUrl
|
|
3949
|
+
baseUrl,
|
|
3925
3950
|
oauthClient,
|
|
3926
3951
|
numRetries
|
|
3927
3952
|
});
|
|
@@ -4537,55 +4562,34 @@ var ModelSecurityClient = class {
|
|
|
4537
4562
|
oauthClient;
|
|
4538
4563
|
numRetries;
|
|
4539
4564
|
constructor(opts = {}) {
|
|
4540
|
-
const clientId = opts.clientId ?? process.env[MODEL_SEC_CLIENT_ID] ?? process.env[MGMT_CLIENT_ID];
|
|
4541
|
-
const clientSecret = opts.clientSecret ?? process.env[MODEL_SEC_CLIENT_SECRET] ?? process.env[MGMT_CLIENT_SECRET];
|
|
4542
|
-
const tsgId = opts.tsgId ?? process.env[MODEL_SEC_TSG_ID] ?? process.env[MGMT_TSG_ID];
|
|
4543
4565
|
const dataEndpoint = opts.dataEndpoint ?? process.env[MODEL_SEC_DATA_ENDPOINT] ?? DEFAULT_MODEL_SEC_DATA_ENDPOINT;
|
|
4544
4566
|
const mgmtEndpoint = opts.mgmtEndpoint ?? process.env[MODEL_SEC_MGMT_ENDPOINT] ?? DEFAULT_MODEL_SEC_MGMT_ENDPOINT;
|
|
4545
|
-
const
|
|
4546
|
-
|
|
4547
|
-
|
|
4548
|
-
|
|
4549
|
-
|
|
4550
|
-
|
|
4551
|
-
|
|
4552
|
-
|
|
4553
|
-
|
|
4554
|
-
);
|
|
4555
|
-
}
|
|
4556
|
-
if (!clientSecret) {
|
|
4557
|
-
throw new AISecSDKException(
|
|
4558
|
-
"clientSecret is required (option or PANW_MODEL_SEC_CLIENT_SECRET / PANW_MGMT_CLIENT_SECRET env var)",
|
|
4559
|
-
"AISEC_MISSING_VARIABLE" /* MISSING_VARIABLE */
|
|
4560
|
-
);
|
|
4561
|
-
}
|
|
4562
|
-
if (!tsgId) {
|
|
4563
|
-
throw new AISecSDKException(
|
|
4564
|
-
"tsgId is required (option or PANW_MODEL_SEC_TSG_ID / PANW_MGMT_TSG_ID env var)",
|
|
4565
|
-
"AISEC_MISSING_VARIABLE" /* MISSING_VARIABLE */
|
|
4566
|
-
);
|
|
4567
|
-
}
|
|
4568
|
-
this.oauthClient = new OAuthClient({
|
|
4569
|
-
clientId,
|
|
4570
|
-
clientSecret,
|
|
4571
|
-
tsgId,
|
|
4572
|
-
tokenEndpoint
|
|
4567
|
+
const { oauthClient, numRetries } = resolveOAuthConfig({
|
|
4568
|
+
clientId: opts.clientId,
|
|
4569
|
+
clientSecret: opts.clientSecret,
|
|
4570
|
+
tsgId: opts.tsgId,
|
|
4571
|
+
baseUrl: mgmtEndpoint,
|
|
4572
|
+
numRetries: opts.numRetries,
|
|
4573
|
+
tokenEndpoint: opts.tokenEndpoint,
|
|
4574
|
+
primaryEnvPrefix: "PANW_MODEL_SEC",
|
|
4575
|
+
fallbackEnvPrefix: "PANW_MGMT"
|
|
4573
4576
|
});
|
|
4577
|
+
this.oauthClient = oauthClient;
|
|
4574
4578
|
this.mgmtEndpoint = mgmtEndpoint;
|
|
4575
4579
|
this.numRetries = numRetries;
|
|
4576
4580
|
this.scans = new ModelSecurityScansClient({
|
|
4577
4581
|
baseUrl: dataEndpoint,
|
|
4578
|
-
oauthClient
|
|
4582
|
+
oauthClient,
|
|
4579
4583
|
numRetries
|
|
4580
4584
|
});
|
|
4581
4585
|
this.securityGroups = new ModelSecurityGroupsClient({
|
|
4582
4586
|
baseUrl: mgmtEndpoint,
|
|
4583
|
-
oauthClient
|
|
4587
|
+
oauthClient,
|
|
4584
4588
|
numRetries
|
|
4585
4589
|
});
|
|
4586
4590
|
this.securityRules = new ModelSecurityRulesClient({
|
|
4587
4591
|
baseUrl: mgmtEndpoint,
|
|
4588
|
-
oauthClient
|
|
4592
|
+
oauthClient,
|
|
4589
4593
|
numRetries
|
|
4590
4594
|
});
|
|
4591
4595
|
}
|
|
@@ -4713,11 +4717,6 @@ var RedTeamScansClient = class {
|
|
|
4713
4717
|
};
|
|
4714
4718
|
|
|
4715
4719
|
// src/red-team/reports-client.ts
|
|
4716
|
-
function validateJobId(jobId) {
|
|
4717
|
-
if (!isValidUuid(jobId)) {
|
|
4718
|
-
throw new AISecSDKException(`Invalid job id: ${jobId}`, "AISEC_USER_REQUEST_PAYLOAD_ERROR" /* USER_REQUEST_PAYLOAD_ERROR */);
|
|
4719
|
-
}
|
|
4720
|
-
}
|
|
4721
4720
|
var RedTeamReportsClient = class {
|
|
4722
4721
|
baseUrl;
|
|
4723
4722
|
oauthClient;
|
|
@@ -4975,7 +4974,7 @@ var RedTeamReportsClient = class {
|
|
|
4975
4974
|
* Download a report in the specified format.
|
|
4976
4975
|
* @param jobId - The job UUID.
|
|
4977
4976
|
* @param format - The file format (e.g. "pdf", "csv").
|
|
4978
|
-
* @returns The
|
|
4977
|
+
* @returns The report data in the requested format (untyped — shape depends on `format`).
|
|
4979
4978
|
*/
|
|
4980
4979
|
async downloadReport(jobId, format) {
|
|
4981
4980
|
validateJobId(jobId);
|
|
@@ -4993,7 +4992,7 @@ var RedTeamReportsClient = class {
|
|
|
4993
4992
|
/**
|
|
4994
4993
|
* Generate a partial report for a running scan.
|
|
4995
4994
|
* @param jobId - The job UUID.
|
|
4996
|
-
* @returns The partial report
|
|
4995
|
+
* @returns The partial report payload (untyped — schema not yet defined by the API).
|
|
4997
4996
|
*/
|
|
4998
4997
|
async generatePartialReport(jobId) {
|
|
4999
4998
|
validateJobId(jobId);
|
|
@@ -5009,11 +5008,6 @@ var RedTeamReportsClient = class {
|
|
|
5009
5008
|
};
|
|
5010
5009
|
|
|
5011
5010
|
// src/red-team/custom-attack-reports-client.ts
|
|
5012
|
-
function validateJobId2(jobId) {
|
|
5013
|
-
if (!isValidUuid(jobId)) {
|
|
5014
|
-
throw new AISecSDKException(`Invalid job id: ${jobId}`, "AISEC_USER_REQUEST_PAYLOAD_ERROR" /* USER_REQUEST_PAYLOAD_ERROR */);
|
|
5015
|
-
}
|
|
5016
|
-
}
|
|
5017
5011
|
var RedTeamCustomAttackReportsClient = class {
|
|
5018
5012
|
baseUrl;
|
|
5019
5013
|
oauthClient;
|
|
@@ -5029,7 +5023,7 @@ var RedTeamCustomAttackReportsClient = class {
|
|
|
5029
5023
|
* @returns The custom attack report response.
|
|
5030
5024
|
*/
|
|
5031
5025
|
async getReport(jobId) {
|
|
5032
|
-
|
|
5026
|
+
validateJobId(jobId);
|
|
5033
5027
|
const res = await managementHttpRequest({
|
|
5034
5028
|
method: "GET",
|
|
5035
5029
|
baseUrl: this.baseUrl,
|
|
@@ -5045,7 +5039,7 @@ var RedTeamCustomAttackReportsClient = class {
|
|
|
5045
5039
|
* @returns The prompt sets report response.
|
|
5046
5040
|
*/
|
|
5047
5041
|
async getPromptSets(jobId) {
|
|
5048
|
-
|
|
5042
|
+
validateJobId(jobId);
|
|
5049
5043
|
const res = await managementHttpRequest({
|
|
5050
5044
|
method: "GET",
|
|
5051
5045
|
baseUrl: this.baseUrl,
|
|
@@ -5063,7 +5057,7 @@ var RedTeamCustomAttackReportsClient = class {
|
|
|
5063
5057
|
* @returns The list of prompt detail responses.
|
|
5064
5058
|
*/
|
|
5065
5059
|
async getPromptsBySet(jobId, promptSetId, opts) {
|
|
5066
|
-
|
|
5060
|
+
validateJobId(jobId);
|
|
5067
5061
|
if (!isValidUuid(promptSetId)) {
|
|
5068
5062
|
throw new AISecSDKException(
|
|
5069
5063
|
`Invalid prompt set id: ${promptSetId}`,
|
|
@@ -5089,7 +5083,7 @@ var RedTeamCustomAttackReportsClient = class {
|
|
|
5089
5083
|
* @returns The prompt detail response.
|
|
5090
5084
|
*/
|
|
5091
5085
|
async getPromptDetail(jobId, promptId) {
|
|
5092
|
-
|
|
5086
|
+
validateJobId(jobId);
|
|
5093
5087
|
if (!isValidUuid(promptId)) {
|
|
5094
5088
|
throw new AISecSDKException(
|
|
5095
5089
|
`Invalid prompt id: ${promptId}`,
|
|
@@ -5112,7 +5106,7 @@ var RedTeamCustomAttackReportsClient = class {
|
|
|
5112
5106
|
* @returns The paginated list of custom attacks.
|
|
5113
5107
|
*/
|
|
5114
5108
|
async listCustomAttacks(jobId, opts) {
|
|
5115
|
-
|
|
5109
|
+
validateJobId(jobId);
|
|
5116
5110
|
const params = buildRedTeamListParams(opts);
|
|
5117
5111
|
if (opts?.threat !== void 0) params.threat = String(opts.threat);
|
|
5118
5112
|
if (opts?.prompt_set_id !== void 0) params.prompt_set_id = opts.prompt_set_id;
|
|
@@ -5134,7 +5128,7 @@ var RedTeamCustomAttackReportsClient = class {
|
|
|
5134
5128
|
* @returns The list of attack outputs.
|
|
5135
5129
|
*/
|
|
5136
5130
|
async getAttackOutputs(jobId, attackId) {
|
|
5137
|
-
|
|
5131
|
+
validateJobId(jobId);
|
|
5138
5132
|
if (!isValidUuid(attackId)) {
|
|
5139
5133
|
throw new AISecSDKException(
|
|
5140
5134
|
`Invalid attack id: ${attackId}`,
|
|
@@ -5156,7 +5150,7 @@ var RedTeamCustomAttackReportsClient = class {
|
|
|
5156
5150
|
* @returns The list of property statistics.
|
|
5157
5151
|
*/
|
|
5158
5152
|
async getPropertyStats(jobId) {
|
|
5159
|
-
|
|
5153
|
+
validateJobId(jobId);
|
|
5160
5154
|
const res = await managementHttpRequest({
|
|
5161
5155
|
method: "GET",
|
|
5162
5156
|
baseUrl: this.baseUrl,
|
|
@@ -5503,7 +5497,7 @@ var RedTeamCustomAttacksClient = class {
|
|
|
5503
5497
|
/**
|
|
5504
5498
|
* Download CSV template for a prompt set.
|
|
5505
5499
|
* @param uuid - The prompt set UUID.
|
|
5506
|
-
* @returns The CSV template
|
|
5500
|
+
* @returns The CSV template content (untyped — raw response from the API).
|
|
5507
5501
|
*/
|
|
5508
5502
|
async downloadTemplate(uuid) {
|
|
5509
5503
|
validateUuid(uuid, "prompt set uuid");
|
|
@@ -5747,61 +5741,45 @@ var RedTeamClient = class {
|
|
|
5747
5741
|
oauthClient;
|
|
5748
5742
|
numRetries;
|
|
5749
5743
|
constructor(opts = {}) {
|
|
5750
|
-
const clientId = opts.clientId ?? process.env[RED_TEAM_CLIENT_ID] ?? process.env[MGMT_CLIENT_ID];
|
|
5751
|
-
const clientSecret = opts.clientSecret ?? process.env[RED_TEAM_CLIENT_SECRET] ?? process.env[MGMT_CLIENT_SECRET];
|
|
5752
|
-
const tsgId = opts.tsgId ?? process.env[RED_TEAM_TSG_ID] ?? process.env[MGMT_TSG_ID];
|
|
5753
5744
|
const dataEndpoint = opts.dataEndpoint ?? process.env[RED_TEAM_DATA_ENDPOINT] ?? DEFAULT_RED_TEAM_DATA_ENDPOINT;
|
|
5754
5745
|
const mgmtEndpoint = opts.mgmtEndpoint ?? process.env[RED_TEAM_MGMT_ENDPOINT] ?? DEFAULT_RED_TEAM_MGMT_ENDPOINT;
|
|
5755
|
-
const
|
|
5756
|
-
|
|
5757
|
-
|
|
5758
|
-
|
|
5759
|
-
|
|
5760
|
-
|
|
5761
|
-
|
|
5762
|
-
|
|
5763
|
-
|
|
5764
|
-
|
|
5765
|
-
|
|
5766
|
-
if (!clientSecret) {
|
|
5767
|
-
throw new AISecSDKException(
|
|
5768
|
-
"clientSecret is required (option or PANW_RED_TEAM_CLIENT_SECRET / PANW_MGMT_CLIENT_SECRET env var)",
|
|
5769
|
-
"AISEC_MISSING_VARIABLE" /* MISSING_VARIABLE */
|
|
5770
|
-
);
|
|
5771
|
-
}
|
|
5772
|
-
if (!tsgId) {
|
|
5773
|
-
throw new AISecSDKException(
|
|
5774
|
-
"tsgId is required (option or PANW_RED_TEAM_TSG_ID / PANW_MGMT_TSG_ID env var)",
|
|
5775
|
-
"AISEC_MISSING_VARIABLE" /* MISSING_VARIABLE */
|
|
5776
|
-
);
|
|
5777
|
-
}
|
|
5778
|
-
this.oauthClient = new OAuthClient({ clientId, clientSecret, tsgId, tokenEndpoint });
|
|
5746
|
+
const { oauthClient, numRetries } = resolveOAuthConfig({
|
|
5747
|
+
clientId: opts.clientId,
|
|
5748
|
+
clientSecret: opts.clientSecret,
|
|
5749
|
+
tsgId: opts.tsgId,
|
|
5750
|
+
baseUrl: dataEndpoint,
|
|
5751
|
+
numRetries: opts.numRetries,
|
|
5752
|
+
tokenEndpoint: opts.tokenEndpoint,
|
|
5753
|
+
primaryEnvPrefix: "PANW_RED_TEAM",
|
|
5754
|
+
fallbackEnvPrefix: "PANW_MGMT"
|
|
5755
|
+
});
|
|
5756
|
+
this.oauthClient = oauthClient;
|
|
5779
5757
|
this.dataEndpoint = dataEndpoint;
|
|
5780
5758
|
this.mgmtEndpoint = mgmtEndpoint;
|
|
5781
5759
|
this.numRetries = numRetries;
|
|
5782
5760
|
this.scans = new RedTeamScansClient({
|
|
5783
5761
|
baseUrl: dataEndpoint,
|
|
5784
|
-
oauthClient
|
|
5762
|
+
oauthClient,
|
|
5785
5763
|
numRetries
|
|
5786
5764
|
});
|
|
5787
5765
|
this.reports = new RedTeamReportsClient({
|
|
5788
5766
|
baseUrl: dataEndpoint,
|
|
5789
|
-
oauthClient
|
|
5767
|
+
oauthClient,
|
|
5790
5768
|
numRetries
|
|
5791
5769
|
});
|
|
5792
5770
|
this.customAttackReports = new RedTeamCustomAttackReportsClient({
|
|
5793
5771
|
baseUrl: dataEndpoint,
|
|
5794
|
-
oauthClient
|
|
5772
|
+
oauthClient,
|
|
5795
5773
|
numRetries
|
|
5796
5774
|
});
|
|
5797
5775
|
this.targets = new RedTeamTargetsClient({
|
|
5798
5776
|
baseUrl: mgmtEndpoint,
|
|
5799
|
-
oauthClient
|
|
5777
|
+
oauthClient,
|
|
5800
5778
|
numRetries
|
|
5801
5779
|
});
|
|
5802
5780
|
this.customAttacks = new RedTeamCustomAttacksClient({
|
|
5803
5781
|
baseUrl: mgmtEndpoint,
|
|
5804
|
-
oauthClient
|
|
5782
|
+
oauthClient,
|
|
5805
5783
|
numRetries
|
|
5806
5784
|
});
|
|
5807
5785
|
}
|