@cdot65/prisma-airs-sdk 0.5.2 → 0.6.1
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 +167 -51
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2452 -2129
- package/dist/index.d.ts +2452 -2129
- package/dist/index.js +158 -51
- package/dist/index.js.map +1 -1
- package/package.json +3 -2
package/dist/index.js
CHANGED
|
@@ -23,7 +23,7 @@ var MAX_NUMBER_OF_BATCH_SCAN_OBJECTS = 5;
|
|
|
23
23
|
var MAX_CONNECTION_POOL_SIZE = 100;
|
|
24
24
|
var MAX_NUMBER_OF_RETRIES = 5;
|
|
25
25
|
var HTTP_FORCE_RETRY_STATUS_CODES = [500, 502, 503, 504];
|
|
26
|
-
var SDK_VERSION = "0.
|
|
26
|
+
var SDK_VERSION = "0.6.1";
|
|
27
27
|
var USER_AGENT = `PAN-AIRS/${SDK_VERSION}-typescript-sdk`;
|
|
28
28
|
var DEFAULT_MGMT_ENDPOINT = "https://api.sase.paloaltonetworks.com/aisec";
|
|
29
29
|
var DEFAULT_TOKEN_ENDPOINT = "https://auth.apps.paloaltonetworks.com/oauth2/access_token";
|
|
@@ -1481,33 +1481,83 @@ var ValidationErrorSchema = z18.object({
|
|
|
1481
1481
|
});
|
|
1482
1482
|
var HTTPValidationErrorSchema = z18.object({ detail: z18.array(ValidationErrorSchema).optional() }).passthrough();
|
|
1483
1483
|
var TargetBackgroundSchema = z18.object({
|
|
1484
|
-
industry: z18.
|
|
1485
|
-
use_case: z18.
|
|
1486
|
-
competitors: z18.
|
|
1484
|
+
industry: z18.string().nullable().optional(),
|
|
1485
|
+
use_case: z18.string().nullable().optional(),
|
|
1486
|
+
competitors: z18.array(z18.string()).nullable().optional()
|
|
1487
1487
|
}).passthrough();
|
|
1488
1488
|
var TargetAdditionalContextSchema = z18.object({
|
|
1489
|
-
base_model: z18.
|
|
1490
|
-
core_architecture: z18.
|
|
1491
|
-
system_prompt: z18.
|
|
1492
|
-
languages_supported: z18.
|
|
1493
|
-
banned_keywords: z18.
|
|
1494
|
-
tools_accessible: z18.
|
|
1489
|
+
base_model: z18.string().nullable().optional(),
|
|
1490
|
+
core_architecture: z18.string().nullable().optional(),
|
|
1491
|
+
system_prompt: z18.string().nullable().optional(),
|
|
1492
|
+
languages_supported: z18.array(z18.string()).nullable().optional(),
|
|
1493
|
+
banned_keywords: z18.array(z18.string()).nullable().optional(),
|
|
1494
|
+
tools_accessible: z18.array(z18.string()).nullable().optional()
|
|
1495
1495
|
}).passthrough();
|
|
1496
1496
|
var TargetMetadataSchema = z18.object({
|
|
1497
1497
|
multi_turn: z18.boolean().optional(),
|
|
1498
|
-
multi_turn_error_message: z18.
|
|
1499
|
-
rate_limit: z18.
|
|
1498
|
+
multi_turn_error_message: z18.string().nullable().optional(),
|
|
1499
|
+
rate_limit: z18.number().int().nullable().optional(),
|
|
1500
1500
|
rate_limit_enabled: z18.boolean().optional(),
|
|
1501
|
-
rate_limit_error_code: z18.
|
|
1502
|
-
rate_limit_error_json: z18.unknown().optional(),
|
|
1503
|
-
rate_limit_error_message: z18.
|
|
1501
|
+
rate_limit_error_code: z18.number().int().nullable().optional(),
|
|
1502
|
+
rate_limit_error_json: z18.record(z18.unknown()).nullable().optional(),
|
|
1503
|
+
rate_limit_error_message: z18.string().nullable().optional(),
|
|
1504
1504
|
content_filter_enabled: z18.boolean().optional(),
|
|
1505
|
-
content_filter_error_code: z18.
|
|
1506
|
-
content_filter_error_json: z18.unknown().optional(),
|
|
1507
|
-
content_filter_error_message: z18.
|
|
1505
|
+
content_filter_error_code: z18.number().int().nullable().optional(),
|
|
1506
|
+
content_filter_error_json: z18.record(z18.unknown()).nullable().optional(),
|
|
1507
|
+
content_filter_error_message: z18.string().nullable().optional(),
|
|
1508
1508
|
probe_message: z18.string().optional(),
|
|
1509
1509
|
request_timeout: z18.number().optional()
|
|
1510
1510
|
}).passthrough();
|
|
1511
|
+
var MultiTurnStatefulConfigSchema = z18.object({
|
|
1512
|
+
type: z18.string().default("stateful"),
|
|
1513
|
+
response_id_field: z18.string(),
|
|
1514
|
+
request_id_field: z18.string()
|
|
1515
|
+
}).passthrough();
|
|
1516
|
+
var MultiTurnStatelessConfigSchema = z18.object({
|
|
1517
|
+
type: z18.string().default("stateless"),
|
|
1518
|
+
assistant_role: z18.string().nullable().optional()
|
|
1519
|
+
}).passthrough();
|
|
1520
|
+
var OpenAIConnectionParamsSchema = z18.object({
|
|
1521
|
+
api_key: z18.string(),
|
|
1522
|
+
model_name: z18.string()
|
|
1523
|
+
}).passthrough();
|
|
1524
|
+
var HuggingfaceConnectionParamsSchema = z18.object({
|
|
1525
|
+
api_key: z18.string(),
|
|
1526
|
+
model_name: z18.string()
|
|
1527
|
+
}).passthrough();
|
|
1528
|
+
var DatabricksConnectionParamsSchema = z18.object({
|
|
1529
|
+
auth_type: z18.string(),
|
|
1530
|
+
workspace_url: z18.string(),
|
|
1531
|
+
model_name: z18.string(),
|
|
1532
|
+
access_token: z18.string().nullable().optional(),
|
|
1533
|
+
client_id: z18.string().nullable().optional(),
|
|
1534
|
+
secret: z18.string().nullable().optional()
|
|
1535
|
+
}).passthrough();
|
|
1536
|
+
var BedrockAccessConnectionParamsSchema = z18.object({
|
|
1537
|
+
access_id: z18.string(),
|
|
1538
|
+
access_secret: z18.string(),
|
|
1539
|
+
region: z18.string(),
|
|
1540
|
+
model_id: z18.string(),
|
|
1541
|
+
session_token: z18.string().nullable().optional()
|
|
1542
|
+
}).passthrough();
|
|
1543
|
+
var RestConnectionParamsSchema = z18.object({
|
|
1544
|
+
api_endpoint: z18.string().nullable().optional(),
|
|
1545
|
+
request_headers: z18.record(z18.unknown()).nullable().optional(),
|
|
1546
|
+
request_json: z18.record(z18.unknown()).nullable().optional(),
|
|
1547
|
+
response_json: z18.record(z18.unknown()).nullable().optional(),
|
|
1548
|
+
response_key: z18.string().nullable().optional(),
|
|
1549
|
+
target_connection_config: z18.unknown().nullable().optional(),
|
|
1550
|
+
curl: z18.string().nullable().optional(),
|
|
1551
|
+
multi_turn_config: z18.unknown().nullable().optional()
|
|
1552
|
+
}).passthrough();
|
|
1553
|
+
var StreamingConnectionParamsSchema = RestConnectionParamsSchema.extend({
|
|
1554
|
+
response_stop_key: z18.string(),
|
|
1555
|
+
response_stop_value: z18.string()
|
|
1556
|
+
}).passthrough();
|
|
1557
|
+
var ConnectionParamsSchema = z18.union([
|
|
1558
|
+
StreamingConnectionParamsSchema,
|
|
1559
|
+
RestConnectionParamsSchema
|
|
1560
|
+
]);
|
|
1511
1561
|
var TargetJobRequestSchema = z18.object({
|
|
1512
1562
|
uuid: z18.string(),
|
|
1513
1563
|
version: z18.number().int().nullable().optional()
|
|
@@ -2233,9 +2283,9 @@ var CustomPromptSetVersionInfoSchema = z18.object({
|
|
|
2233
2283
|
uuid: z18.string(),
|
|
2234
2284
|
status: z18.string(),
|
|
2235
2285
|
is_latest: z18.boolean(),
|
|
2236
|
-
version: z18.
|
|
2237
|
-
stats:
|
|
2238
|
-
snapshot_created_at: z18.
|
|
2286
|
+
version: z18.string().nullable().optional(),
|
|
2287
|
+
stats: PromptSetStatsSchema.nullable().optional(),
|
|
2288
|
+
snapshot_created_at: z18.string().nullable().optional()
|
|
2239
2289
|
}).passthrough();
|
|
2240
2290
|
var CustomPromptCreateRequestSchema = z18.object({
|
|
2241
2291
|
prompt: z18.string(),
|
|
@@ -2440,7 +2490,13 @@ async function managementHttpRequest(opts) {
|
|
|
2440
2490
|
const url = new URL(`${stripped}${path}`);
|
|
2441
2491
|
if (params) {
|
|
2442
2492
|
for (const [key, value] of Object.entries(params)) {
|
|
2443
|
-
|
|
2493
|
+
if (Array.isArray(value)) {
|
|
2494
|
+
for (const v of value) {
|
|
2495
|
+
url.searchParams.append(key, v);
|
|
2496
|
+
}
|
|
2497
|
+
} else {
|
|
2498
|
+
url.searchParams.set(key, value);
|
|
2499
|
+
}
|
|
2444
2500
|
}
|
|
2445
2501
|
}
|
|
2446
2502
|
const headers = {
|
|
@@ -3028,13 +3084,23 @@ var ModelSecurityScansClient = class {
|
|
|
3028
3084
|
};
|
|
3029
3085
|
|
|
3030
3086
|
// src/model-security/security-groups-client.ts
|
|
3031
|
-
function
|
|
3087
|
+
function buildGroupListParams(opts) {
|
|
3032
3088
|
const params = {};
|
|
3033
3089
|
if (opts?.skip !== void 0) params.skip = String(opts.skip);
|
|
3034
3090
|
if (opts?.limit !== void 0) params.limit = String(opts.limit);
|
|
3035
|
-
if (opts?.
|
|
3036
|
-
if (opts?.
|
|
3037
|
-
if (opts?.
|
|
3091
|
+
if (opts?.sort_field !== void 0) params.sort_field = opts.sort_field;
|
|
3092
|
+
if (opts?.sort_dir !== void 0) params.sort_dir = opts.sort_dir;
|
|
3093
|
+
if (opts?.source_types !== void 0) params.source_types = opts.source_types;
|
|
3094
|
+
if (opts?.search_query !== void 0) params.search_query = opts.search_query;
|
|
3095
|
+
if (opts?.enabled_rules !== void 0) params.enabled_rules = opts.enabled_rules;
|
|
3096
|
+
return params;
|
|
3097
|
+
}
|
|
3098
|
+
function buildRuleInstanceListParams(opts) {
|
|
3099
|
+
const params = {};
|
|
3100
|
+
if (opts?.skip !== void 0) params.skip = String(opts.skip);
|
|
3101
|
+
if (opts?.limit !== void 0) params.limit = String(opts.limit);
|
|
3102
|
+
if (opts?.security_rule_uuid !== void 0) params.security_rule_uuid = opts.security_rule_uuid;
|
|
3103
|
+
if (opts?.state !== void 0) params.state = opts.state;
|
|
3038
3104
|
return params;
|
|
3039
3105
|
}
|
|
3040
3106
|
var ModelSecurityGroupsClient = class {
|
|
@@ -3072,7 +3138,7 @@ var ModelSecurityGroupsClient = class {
|
|
|
3072
3138
|
method: "GET",
|
|
3073
3139
|
baseUrl: this.baseUrl,
|
|
3074
3140
|
path: MODEL_SEC_SECURITY_GROUPS_PATH,
|
|
3075
|
-
params:
|
|
3141
|
+
params: buildGroupListParams(opts),
|
|
3076
3142
|
oauthClient: this.oauthClient,
|
|
3077
3143
|
numRetries: this.numRetries
|
|
3078
3144
|
});
|
|
@@ -3158,7 +3224,7 @@ var ModelSecurityGroupsClient = class {
|
|
|
3158
3224
|
method: "GET",
|
|
3159
3225
|
baseUrl: this.baseUrl,
|
|
3160
3226
|
path: `${MODEL_SEC_SECURITY_GROUPS_PATH}/${securityGroupUuid}/rule-instances`,
|
|
3161
|
-
params:
|
|
3227
|
+
params: buildRuleInstanceListParams(opts),
|
|
3162
3228
|
oauthClient: this.oauthClient,
|
|
3163
3229
|
numRetries: this.numRetries
|
|
3164
3230
|
});
|
|
@@ -3225,13 +3291,12 @@ var ModelSecurityGroupsClient = class {
|
|
|
3225
3291
|
};
|
|
3226
3292
|
|
|
3227
3293
|
// src/model-security/security-rules-client.ts
|
|
3228
|
-
function
|
|
3294
|
+
function buildRuleListParams(opts) {
|
|
3229
3295
|
const params = {};
|
|
3230
3296
|
if (opts?.skip !== void 0) params.skip = String(opts.skip);
|
|
3231
3297
|
if (opts?.limit !== void 0) params.limit = String(opts.limit);
|
|
3232
|
-
if (opts?.
|
|
3233
|
-
if (opts?.
|
|
3234
|
-
if (opts?.search !== void 0) params.search = opts.search;
|
|
3298
|
+
if (opts?.source_type !== void 0) params.source_type = opts.source_type;
|
|
3299
|
+
if (opts?.search_query !== void 0) params.search_query = opts.search_query;
|
|
3235
3300
|
return params;
|
|
3236
3301
|
}
|
|
3237
3302
|
var ModelSecurityRulesClient = class {
|
|
@@ -3253,7 +3318,7 @@ var ModelSecurityRulesClient = class {
|
|
|
3253
3318
|
method: "GET",
|
|
3254
3319
|
baseUrl: this.baseUrl,
|
|
3255
3320
|
path: MODEL_SEC_SECURITY_RULES_PATH,
|
|
3256
|
-
params:
|
|
3321
|
+
params: buildRuleListParams(opts),
|
|
3257
3322
|
oauthClient: this.oauthClient,
|
|
3258
3323
|
numRetries: this.numRetries
|
|
3259
3324
|
});
|
|
@@ -3363,7 +3428,7 @@ var ModelSecurityClient = class {
|
|
|
3363
3428
|
};
|
|
3364
3429
|
|
|
3365
3430
|
// src/red-team/scans-client.ts
|
|
3366
|
-
function
|
|
3431
|
+
function buildListParams2(opts) {
|
|
3367
3432
|
const params = {};
|
|
3368
3433
|
if (opts?.skip !== void 0) params.skip = String(opts.skip);
|
|
3369
3434
|
if (opts?.limit !== void 0) params.limit = String(opts.limit);
|
|
@@ -3395,7 +3460,7 @@ var RedTeamScansClient = class {
|
|
|
3395
3460
|
}
|
|
3396
3461
|
/** List red team scan jobs with optional filters. */
|
|
3397
3462
|
async list(opts) {
|
|
3398
|
-
const params =
|
|
3463
|
+
const params = buildListParams2(opts);
|
|
3399
3464
|
if (opts?.status !== void 0) params.status = opts.status;
|
|
3400
3465
|
if (opts?.job_type !== void 0) params.job_type = opts.job_type;
|
|
3401
3466
|
if (opts?.target_id !== void 0) params.target_id = opts.target_id;
|
|
@@ -3451,7 +3516,7 @@ var RedTeamScansClient = class {
|
|
|
3451
3516
|
};
|
|
3452
3517
|
|
|
3453
3518
|
// src/red-team/reports-client.ts
|
|
3454
|
-
function
|
|
3519
|
+
function buildListParams3(opts) {
|
|
3455
3520
|
const params = {};
|
|
3456
3521
|
if (opts?.skip !== void 0) params.skip = String(opts.skip);
|
|
3457
3522
|
if (opts?.limit !== void 0) params.limit = String(opts.limit);
|
|
@@ -3480,7 +3545,7 @@ var RedTeamReportsClient = class {
|
|
|
3480
3545
|
/** List attacks for a static scan. */
|
|
3481
3546
|
async listAttacks(jobId, opts) {
|
|
3482
3547
|
validateJobId(jobId);
|
|
3483
|
-
const params =
|
|
3548
|
+
const params = buildListParams3(opts);
|
|
3484
3549
|
if (opts?.status !== void 0) params.status = opts.status;
|
|
3485
3550
|
if (opts?.severity !== void 0) params.severity = opts.severity;
|
|
3486
3551
|
if (opts?.category !== void 0) params.category = opts.category;
|
|
@@ -3609,7 +3674,7 @@ var RedTeamReportsClient = class {
|
|
|
3609
3674
|
/** List goals for a dynamic scan. */
|
|
3610
3675
|
async listGoals(jobId, opts) {
|
|
3611
3676
|
validateJobId(jobId);
|
|
3612
|
-
const params =
|
|
3677
|
+
const params = buildListParams3(opts);
|
|
3613
3678
|
if (opts?.goal_type !== void 0) params.goal_type = opts.goal_type;
|
|
3614
3679
|
const res = await managementHttpRequest({
|
|
3615
3680
|
method: "GET",
|
|
@@ -3634,7 +3699,7 @@ var RedTeamReportsClient = class {
|
|
|
3634
3699
|
method: "GET",
|
|
3635
3700
|
baseUrl: this.baseUrl,
|
|
3636
3701
|
path: `${RED_TEAM_REPORT_DYNAMIC_PATH}/${jobId}/goal/${goalId}/list-streams`,
|
|
3637
|
-
params:
|
|
3702
|
+
params: buildListParams3(opts),
|
|
3638
3703
|
oauthClient: this.oauthClient,
|
|
3639
3704
|
numRetries: this.numRetries
|
|
3640
3705
|
});
|
|
@@ -3690,7 +3755,7 @@ var RedTeamReportsClient = class {
|
|
|
3690
3755
|
};
|
|
3691
3756
|
|
|
3692
3757
|
// src/red-team/custom-attack-reports-client.ts
|
|
3693
|
-
function
|
|
3758
|
+
function buildListParams4(opts) {
|
|
3694
3759
|
const params = {};
|
|
3695
3760
|
if (opts?.skip !== void 0) params.skip = String(opts.skip);
|
|
3696
3761
|
if (opts?.limit !== void 0) params.limit = String(opts.limit);
|
|
@@ -3750,7 +3815,7 @@ var RedTeamCustomAttackReportsClient = class {
|
|
|
3750
3815
|
method: "GET",
|
|
3751
3816
|
baseUrl: this.baseUrl,
|
|
3752
3817
|
path: `${RED_TEAM_CUSTOM_ATTACKS_REPORT_PATH}/report/${jobId}/prompt-set/${promptSetId}/prompts`,
|
|
3753
|
-
params:
|
|
3818
|
+
params: buildListParams4(opts),
|
|
3754
3819
|
oauthClient: this.oauthClient,
|
|
3755
3820
|
numRetries: this.numRetries
|
|
3756
3821
|
});
|
|
@@ -3781,7 +3846,7 @@ var RedTeamCustomAttackReportsClient = class {
|
|
|
3781
3846
|
method: "GET",
|
|
3782
3847
|
baseUrl: this.baseUrl,
|
|
3783
3848
|
path: `${RED_TEAM_CUSTOM_ATTACKS_REPORT_PATH}/job/${jobId}/list-custom-attacks`,
|
|
3784
|
-
params:
|
|
3849
|
+
params: buildListParams4(opts),
|
|
3785
3850
|
oauthClient: this.oauthClient,
|
|
3786
3851
|
numRetries: this.numRetries
|
|
3787
3852
|
});
|
|
@@ -3820,7 +3885,7 @@ var RedTeamCustomAttackReportsClient = class {
|
|
|
3820
3885
|
};
|
|
3821
3886
|
|
|
3822
3887
|
// src/red-team/targets-client.ts
|
|
3823
|
-
function
|
|
3888
|
+
function buildListParams5(opts) {
|
|
3824
3889
|
const params = {};
|
|
3825
3890
|
if (opts?.skip !== void 0) params.skip = String(opts.skip);
|
|
3826
3891
|
if (opts?.limit !== void 0) params.limit = String(opts.limit);
|
|
@@ -3839,12 +3904,15 @@ var RedTeamTargetsClient = class {
|
|
|
3839
3904
|
this.numRetries = opts.numRetries;
|
|
3840
3905
|
}
|
|
3841
3906
|
/** Create a new target. */
|
|
3842
|
-
async create(request) {
|
|
3907
|
+
async create(request, opts) {
|
|
3908
|
+
const params = {};
|
|
3909
|
+
if (opts?.validate !== void 0) params.validate = String(opts.validate);
|
|
3843
3910
|
const res = await managementHttpRequest({
|
|
3844
3911
|
method: "POST",
|
|
3845
3912
|
baseUrl: this.baseUrl,
|
|
3846
3913
|
path: RED_TEAM_TARGET_PATH,
|
|
3847
3914
|
body: request,
|
|
3915
|
+
params: Object.keys(params).length > 0 ? params : void 0,
|
|
3848
3916
|
oauthClient: this.oauthClient,
|
|
3849
3917
|
numRetries: this.numRetries
|
|
3850
3918
|
});
|
|
@@ -3852,7 +3920,7 @@ var RedTeamTargetsClient = class {
|
|
|
3852
3920
|
}
|
|
3853
3921
|
/** List targets with optional filters. */
|
|
3854
3922
|
async list(opts) {
|
|
3855
|
-
const params =
|
|
3923
|
+
const params = buildListParams5(opts);
|
|
3856
3924
|
if (opts?.target_type !== void 0) params.target_type = opts.target_type;
|
|
3857
3925
|
if (opts?.status !== void 0) params.status = opts.status;
|
|
3858
3926
|
if (opts?.active !== void 0) params.active = String(opts.active);
|
|
@@ -3884,18 +3952,21 @@ var RedTeamTargetsClient = class {
|
|
|
3884
3952
|
return res.data;
|
|
3885
3953
|
}
|
|
3886
3954
|
/** Update a target. */
|
|
3887
|
-
async update(uuid, request) {
|
|
3955
|
+
async update(uuid, request, opts) {
|
|
3888
3956
|
if (!isValidUuid(uuid)) {
|
|
3889
3957
|
throw new AISecSDKException(
|
|
3890
3958
|
`Invalid target uuid: ${uuid}`,
|
|
3891
3959
|
"AISEC_USER_REQUEST_PAYLOAD_ERROR" /* USER_REQUEST_PAYLOAD_ERROR */
|
|
3892
3960
|
);
|
|
3893
3961
|
}
|
|
3962
|
+
const params = {};
|
|
3963
|
+
if (opts?.validate !== void 0) params.validate = String(opts.validate);
|
|
3894
3964
|
const res = await managementHttpRequest({
|
|
3895
3965
|
method: "PUT",
|
|
3896
3966
|
baseUrl: this.baseUrl,
|
|
3897
3967
|
path: `${RED_TEAM_TARGET_PATH}/${uuid}`,
|
|
3898
3968
|
body: request,
|
|
3969
|
+
params: Object.keys(params).length > 0 ? params : void 0,
|
|
3899
3970
|
oauthClient: this.oauthClient,
|
|
3900
3971
|
numRetries: this.numRetries
|
|
3901
3972
|
});
|
|
@@ -3968,7 +4039,7 @@ var RedTeamTargetsClient = class {
|
|
|
3968
4039
|
};
|
|
3969
4040
|
|
|
3970
4041
|
// src/red-team/custom-attacks-client.ts
|
|
3971
|
-
function
|
|
4042
|
+
function buildListParams6(opts) {
|
|
3972
4043
|
const params = {};
|
|
3973
4044
|
if (opts?.skip !== void 0) params.skip = String(opts.skip);
|
|
3974
4045
|
if (opts?.limit !== void 0) params.limit = String(opts.limit);
|
|
@@ -4008,7 +4079,7 @@ var RedTeamCustomAttacksClient = class {
|
|
|
4008
4079
|
}
|
|
4009
4080
|
/** List custom prompt sets. */
|
|
4010
4081
|
async listPromptSets(opts) {
|
|
4011
|
-
const params =
|
|
4082
|
+
const params = buildListParams6(opts);
|
|
4012
4083
|
if (opts?.active !== void 0) params.active = String(opts.active);
|
|
4013
4084
|
if (opts?.archive !== void 0) params.archive = String(opts.archive);
|
|
4014
4085
|
const res = await managementHttpRequest({
|
|
@@ -4106,6 +4177,33 @@ var RedTeamCustomAttacksClient = class {
|
|
|
4106
4177
|
});
|
|
4107
4178
|
return res.data;
|
|
4108
4179
|
}
|
|
4180
|
+
/** Upload a CSV file of custom prompts for a prompt set. */
|
|
4181
|
+
async uploadPromptsCsv(promptSetUuid, file) {
|
|
4182
|
+
validateUuid(promptSetUuid, "prompt set uuid");
|
|
4183
|
+
const token = await this.oauthClient.getToken();
|
|
4184
|
+
const url = new URL(
|
|
4185
|
+
`${this.baseUrl.replace(/\/+$/, "")}${RED_TEAM_CUSTOM_ATTACK_PATH}/upload-custom-prompts-csv`
|
|
4186
|
+
);
|
|
4187
|
+
url.searchParams.set("prompt_set_uuid", promptSetUuid);
|
|
4188
|
+
const formData = new FormData();
|
|
4189
|
+
formData.append("file", file);
|
|
4190
|
+
const response = await fetch(url.toString(), {
|
|
4191
|
+
method: "POST",
|
|
4192
|
+
headers: {
|
|
4193
|
+
Authorization: `Bearer ${token}`,
|
|
4194
|
+
"User-Agent": USER_AGENT
|
|
4195
|
+
},
|
|
4196
|
+
body: formData
|
|
4197
|
+
});
|
|
4198
|
+
const text = await response.text();
|
|
4199
|
+
if (!response.ok) {
|
|
4200
|
+
throw new AISecSDKException(
|
|
4201
|
+
`Upload failed (${response.status}): ${text}`,
|
|
4202
|
+
"AISEC_SERVER_SIDE_ERROR" /* SERVER_SIDE_ERROR */
|
|
4203
|
+
);
|
|
4204
|
+
}
|
|
4205
|
+
return text ? JSON.parse(text) : { message: "ok", status: 201 };
|
|
4206
|
+
}
|
|
4109
4207
|
// -----------------------------------------------------------------------
|
|
4110
4208
|
// Prompt operations
|
|
4111
4209
|
// -----------------------------------------------------------------------
|
|
@@ -4124,7 +4222,7 @@ var RedTeamCustomAttacksClient = class {
|
|
|
4124
4222
|
/** List prompts in a prompt set. */
|
|
4125
4223
|
async listPrompts(promptSetUuid, opts) {
|
|
4126
4224
|
validateUuid(promptSetUuid, "prompt set uuid");
|
|
4127
|
-
const params =
|
|
4225
|
+
const params = buildListParams6(opts);
|
|
4128
4226
|
if (opts?.active !== void 0) params.active = String(opts.active);
|
|
4129
4227
|
const res = await managementHttpRequest({
|
|
4130
4228
|
method: "GET",
|
|
@@ -4245,7 +4343,7 @@ var RedTeamCustomAttacksClient = class {
|
|
|
4245
4343
|
};
|
|
4246
4344
|
|
|
4247
4345
|
// src/red-team/client.ts
|
|
4248
|
-
function
|
|
4346
|
+
function buildListParams7(opts) {
|
|
4249
4347
|
const params = {};
|
|
4250
4348
|
if (opts?.skip !== void 0) params.skip = String(opts.skip);
|
|
4251
4349
|
if (opts?.limit !== void 0) params.limit = String(opts.limit);
|
|
@@ -4384,7 +4482,7 @@ var RedTeamClient = class {
|
|
|
4384
4482
|
method: "GET",
|
|
4385
4483
|
baseUrl: this.dataEndpoint,
|
|
4386
4484
|
path: `${RED_TEAM_ERROR_LOG_PATH}/${jobId}`,
|
|
4387
|
-
params:
|
|
4485
|
+
params: buildListParams7(opts),
|
|
4388
4486
|
oauthClient: this.oauthClient,
|
|
4389
4487
|
numRetries: this.numRetries
|
|
4390
4488
|
});
|
|
@@ -4454,6 +4552,7 @@ export {
|
|
|
4454
4552
|
AuthType,
|
|
4455
4553
|
BEARER,
|
|
4456
4554
|
BaseResponseSchema,
|
|
4555
|
+
BedrockAccessConnectionParamsSchema,
|
|
4457
4556
|
BrandSubCategory,
|
|
4458
4557
|
Category,
|
|
4459
4558
|
CategoryModelSchema,
|
|
@@ -4461,6 +4560,7 @@ export {
|
|
|
4461
4560
|
ComplianceReportSchema,
|
|
4462
4561
|
ComplianceSubCategory,
|
|
4463
4562
|
ComplianceTechniqueSchema,
|
|
4563
|
+
ConnectionParamsSchema,
|
|
4464
4564
|
Content,
|
|
4465
4565
|
CountByNameSchema,
|
|
4466
4566
|
CountedQuotaEnum,
|
|
@@ -4496,6 +4596,7 @@ export {
|
|
|
4496
4596
|
DSDetailResultSchema,
|
|
4497
4597
|
DSResultMetadataSchema,
|
|
4498
4598
|
DashboardOverviewResponseSchema,
|
|
4599
|
+
DatabricksConnectionParamsSchema,
|
|
4499
4600
|
DateRangeFilter,
|
|
4500
4601
|
DeleteProfileConflictSchema,
|
|
4501
4602
|
DeleteProfileResponseSchema,
|
|
@@ -4529,6 +4630,7 @@ export {
|
|
|
4529
4630
|
HEADER_AUTH_TOKEN,
|
|
4530
4631
|
HTTPValidationErrorSchema,
|
|
4531
4632
|
HTTP_FORCE_RETRY_STATUS_CODES,
|
|
4633
|
+
HuggingfaceConnectionParamsSchema,
|
|
4532
4634
|
IODetectedSchema,
|
|
4533
4635
|
JobAbortResponseSchema,
|
|
4534
4636
|
JobCreateRequestSchema,
|
|
@@ -4600,7 +4702,10 @@ export {
|
|
|
4600
4702
|
ModelSecurityRuleResponseSchema,
|
|
4601
4703
|
ModelSecurityRulesClient,
|
|
4602
4704
|
ModelSecurityScansClient,
|
|
4705
|
+
MultiTurnStatefulConfigSchema,
|
|
4706
|
+
MultiTurnStatelessConfigSchema,
|
|
4603
4707
|
OAuthClient,
|
|
4708
|
+
OpenAIConnectionParamsSchema,
|
|
4604
4709
|
PAYLOAD_HASH,
|
|
4605
4710
|
PolicySchema,
|
|
4606
4711
|
PolicyType,
|
|
@@ -4658,6 +4763,7 @@ export {
|
|
|
4658
4763
|
ResponseDetectedSchema,
|
|
4659
4764
|
ResponseDetectionDetailsSchema,
|
|
4660
4765
|
ResponseMode,
|
|
4766
|
+
RestConnectionParamsSchema,
|
|
4661
4767
|
RiskLevelSchema,
|
|
4662
4768
|
RiskRating,
|
|
4663
4769
|
RuleConfigurationSchema,
|
|
@@ -4714,6 +4820,7 @@ export {
|
|
|
4714
4820
|
StreamIterationDataSchema,
|
|
4715
4821
|
StreamListResponseSchema,
|
|
4716
4822
|
StreamType,
|
|
4823
|
+
StreamingConnectionParamsSchema,
|
|
4717
4824
|
SubCategoryModelSchema,
|
|
4718
4825
|
SubCategoryStatsSchema,
|
|
4719
4826
|
TargetAdditionalContextSchema,
|