shield-llm 0.6.8 → 0.7.0
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 +55 -2
- package/dist/{chunk-HQGV3UIF.js → chunk-WGJYDA2Q.js} +422 -83
- package/dist/cli.js +221 -85
- package/dist/index.js +1 -1
- package/package.json +2 -2
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { createRequire as __cjs_createRequire } from "module"; import { fileURLToPath as __cjs_fileURLToPath } from "url"; import { dirname as __cjs_dirname } from "path"; const __filename = __cjs_fileURLToPath(import.meta.url); const __dirname = __cjs_dirname(__filename); const require = __cjs_createRequire(import.meta.url);
|
|
2
2
|
|
|
3
3
|
// package.json
|
|
4
|
-
var version = "0.
|
|
4
|
+
var version = "0.7.0";
|
|
5
5
|
|
|
6
6
|
// src/config/schema.ts
|
|
7
7
|
import { z as z2 } from "zod";
|
|
@@ -156,6 +156,7 @@ var ANSSI_PA_102 = {
|
|
|
156
156
|
var ANSSI_PA_102_REFS = Object.keys(ANSSI_PA_102);
|
|
157
157
|
|
|
158
158
|
// ../../packages/shared/src/types/dora.ts
|
|
159
|
+
var DORA_REGULATION_LABEL = "R\xE8glement (UE) 2022/2554";
|
|
159
160
|
var DORA_ARTICLES = {
|
|
160
161
|
"Art. 5": { title: "Gouvernance et organisation" },
|
|
161
162
|
"Art. 6": { title: "Cadre de gestion du risque li\xE9 aux TIC" },
|
|
@@ -177,6 +178,18 @@ var DORA_ARTICLES = {
|
|
|
177
178
|
}
|
|
178
179
|
};
|
|
179
180
|
var DORA_ARTICLE_REFS = Object.keys(DORA_ARTICLES);
|
|
181
|
+
var DORA_PARAGRAPHS_VERIFIED_ON = "2026-10-01";
|
|
182
|
+
var DORA_PARAGRAPHS = {
|
|
183
|
+
"Art. 24(5)": {
|
|
184
|
+
article: "Art. 24",
|
|
185
|
+
paragraph: 5,
|
|
186
|
+
fr: "Les entit\xE9s financi\xE8res, autres que les microentreprises, d\xE9finissent des proc\xE9dures et des strat\xE9gies destin\xE9es \xE0 hi\xE9rarchiser, classer et r\xE9soudre tous les probl\xE8mes mis en \xE9vidence au cours des tests et \xE9laborent des m\xE9thodes de validation interne pour veiller \xE0 ce que toutes les faiblesses, d\xE9faillances ou lacunes recens\xE9es soient enti\xE8rement corrig\xE9es.",
|
|
187
|
+
en: "Financial entities, other than microenterprises, shall establish procedures and policies to prioritise, classify and remedy all issues revealed throughout the performance of the tests and shall establish internal validation methodologies to ascertain that all identified weaknesses, deficiencies or gaps are fully addressed."
|
|
188
|
+
}
|
|
189
|
+
};
|
|
190
|
+
var DORA_PARAGRAPH_REFS = Object.keys(
|
|
191
|
+
DORA_PARAGRAPHS
|
|
192
|
+
);
|
|
180
193
|
|
|
181
194
|
// ../../packages/shared/src/types/vulnerability.ts
|
|
182
195
|
var VULN_TO_OWASP = {
|
|
@@ -742,7 +755,7 @@ function remapOwaspRef(ref, version2 = CURRENT_OWASP_TAXONOMY) {
|
|
|
742
755
|
}
|
|
743
756
|
|
|
744
757
|
// ../../packages/shared/src/attacks/version.ts
|
|
745
|
-
var ATTACK_PACK_VERSION = "2.2.
|
|
758
|
+
var ATTACK_PACK_VERSION = "2.2.1";
|
|
746
759
|
|
|
747
760
|
// ../../packages/shared/src/attacks/mutators.ts
|
|
748
761
|
var MUTATOR_SEPARATOR = "::";
|
|
@@ -954,37 +967,103 @@ function owaspKeyForAttack(id) {
|
|
|
954
967
|
return VULN_TO_OWASP[id] ?? VULN_TO_OWASP[baseAttackId(id)];
|
|
955
968
|
}
|
|
956
969
|
|
|
970
|
+
// ../../packages/shared/src/regex-guard.ts
|
|
971
|
+
var REGEX_DEADLINE_MS = 100;
|
|
972
|
+
function regexBudget(totalMs = REGEX_DEADLINE_MS) {
|
|
973
|
+
return { deadline: performance.now() + totalMs, timedOut: false };
|
|
974
|
+
}
|
|
975
|
+
var exec;
|
|
976
|
+
var watched = false;
|
|
977
|
+
function getExec() {
|
|
978
|
+
if (exec !== void 0) return exec;
|
|
979
|
+
const proc = globalThis.process;
|
|
980
|
+
const vm = typeof proc?.getBuiltinModule === "function" ? proc.getBuiltinModule("node:vm") : void 0;
|
|
981
|
+
if (!vm) {
|
|
982
|
+
exec = null;
|
|
983
|
+
return exec;
|
|
984
|
+
}
|
|
985
|
+
const sandbox = {};
|
|
986
|
+
const context = vm.createContext(sandbox);
|
|
987
|
+
const script = new vm.Script("__fn()");
|
|
988
|
+
exec = (fn, timeoutMs) => {
|
|
989
|
+
sandbox.__fn = fn;
|
|
990
|
+
try {
|
|
991
|
+
return script.runInContext(context, { timeout: timeoutMs });
|
|
992
|
+
} finally {
|
|
993
|
+
sandbox.__fn = void 0;
|
|
994
|
+
}
|
|
995
|
+
};
|
|
996
|
+
return exec;
|
|
997
|
+
}
|
|
998
|
+
function isTimeout(err) {
|
|
999
|
+
return typeof err === "object" && err !== null && err.code === "ERR_SCRIPT_EXECUTION_TIMEOUT";
|
|
1000
|
+
}
|
|
1001
|
+
function guardedRun(fn, budget) {
|
|
1002
|
+
const run = getExec();
|
|
1003
|
+
if (!run || watched) return { completed: true, value: fn() };
|
|
1004
|
+
const remaining = Math.floor(budget.deadline - performance.now());
|
|
1005
|
+
if (remaining < 1) {
|
|
1006
|
+
budget.timedOut = true;
|
|
1007
|
+
return { completed: false };
|
|
1008
|
+
}
|
|
1009
|
+
watched = true;
|
|
1010
|
+
try {
|
|
1011
|
+
return { completed: true, value: run(fn, remaining) };
|
|
1012
|
+
} catch (err) {
|
|
1013
|
+
if (!isTimeout(err)) throw err;
|
|
1014
|
+
budget.timedOut = true;
|
|
1015
|
+
return { completed: false };
|
|
1016
|
+
} finally {
|
|
1017
|
+
watched = false;
|
|
1018
|
+
}
|
|
1019
|
+
}
|
|
1020
|
+
|
|
957
1021
|
// ../../packages/shared/src/scoring.ts
|
|
958
|
-
var MAX_REGEX_INPUT_CHARS =
|
|
1022
|
+
var MAX_REGEX_INPUT_CHARS = 2e4;
|
|
959
1023
|
function boundRegexInput(response) {
|
|
960
|
-
|
|
1024
|
+
if (response.length <= MAX_REGEX_INPUT_CHARS) return response;
|
|
1025
|
+
const half = Math.floor(MAX_REGEX_INPUT_CHARS / 2);
|
|
1026
|
+
return `${response.slice(0, half)}
|
|
1027
|
+
${response.slice(-half)}`;
|
|
961
1028
|
}
|
|
962
1029
|
function analyzeResponse(payload, rawResponse) {
|
|
963
1030
|
const response = boundRegexInput(rawResponse);
|
|
1031
|
+
const budget = regexBudget();
|
|
964
1032
|
let matchedPattern;
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
matchedPattern = pattern.source;
|
|
968
|
-
break;
|
|
969
|
-
}
|
|
970
|
-
}
|
|
971
|
-
let matchedRefusalPattern;
|
|
972
|
-
if (payload.refusalPatterns) {
|
|
973
|
-
for (const pattern of payload.refusalPatterns) {
|
|
1033
|
+
guardedRun(() => {
|
|
1034
|
+
for (const pattern of payload.detectPatterns) {
|
|
974
1035
|
if (pattern.test(response)) {
|
|
975
|
-
|
|
1036
|
+
matchedPattern = pattern.source;
|
|
976
1037
|
break;
|
|
977
1038
|
}
|
|
978
1039
|
}
|
|
1040
|
+
}, budget);
|
|
1041
|
+
let matchedRefusalPattern;
|
|
1042
|
+
const refusals = payload.refusalPatterns;
|
|
1043
|
+
if (refusals) {
|
|
1044
|
+
guardedRun(() => {
|
|
1045
|
+
for (const pattern of refusals) {
|
|
1046
|
+
if (pattern.test(response)) {
|
|
1047
|
+
matchedRefusalPattern = pattern.source;
|
|
1048
|
+
break;
|
|
1049
|
+
}
|
|
1050
|
+
}
|
|
1051
|
+
}, budget);
|
|
979
1052
|
}
|
|
980
1053
|
const detectMatch = !!matchedPattern;
|
|
981
1054
|
const refusalDetected = !!matchedRefusalPattern;
|
|
1055
|
+
if (budget.timedOut) {
|
|
1056
|
+
console.warn(
|
|
1057
|
+
`[regex-guard] ${payload.id ?? "unknown attack"}: pattern budget exhausted on a ${response.length}-char response; the regex verdict is incomplete`
|
|
1058
|
+
);
|
|
1059
|
+
}
|
|
982
1060
|
return {
|
|
983
1061
|
vulnerable: detectMatch,
|
|
984
1062
|
matchedPattern,
|
|
985
1063
|
refusalDetected,
|
|
986
1064
|
matchedRefusalPattern,
|
|
987
|
-
hasConflict: detectMatch && refusalDetected
|
|
1065
|
+
hasConflict: detectMatch && refusalDetected,
|
|
1066
|
+
...budget.timedOut ? { timedOut: true } : {}
|
|
988
1067
|
};
|
|
989
1068
|
}
|
|
990
1069
|
function didNotExecute(attack) {
|
|
@@ -1084,14 +1163,17 @@ var RATE_LIMIT_PATTERNS = [
|
|
|
1084
1163
|
platform: "generic"
|
|
1085
1164
|
}
|
|
1086
1165
|
];
|
|
1166
|
+
var RATE_LIMIT_SCAN_CHARS = 8192;
|
|
1087
1167
|
function detectRateLimit(text) {
|
|
1088
1168
|
if (!text) return null;
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1169
|
+
const head = text.length > RATE_LIMIT_SCAN_CHARS ? text.slice(0, RATE_LIMIT_SCAN_CHARS) : text;
|
|
1170
|
+
const run = guardedRun(() => {
|
|
1171
|
+
for (const { pattern, platform } of RATE_LIMIT_PATTERNS) {
|
|
1172
|
+
if (pattern.test(head)) return platform;
|
|
1092
1173
|
}
|
|
1093
|
-
|
|
1094
|
-
|
|
1174
|
+
return null;
|
|
1175
|
+
}, regexBudget());
|
|
1176
|
+
return run.completed ? run.value : null;
|
|
1095
1177
|
}
|
|
1096
1178
|
|
|
1097
1179
|
// ../../packages/shared/src/unicode.ts
|
|
@@ -7674,7 +7756,9 @@ function resolveClaim(input) {
|
|
|
7674
7756
|
notExecutedAttackIds: []
|
|
7675
7757
|
};
|
|
7676
7758
|
}
|
|
7677
|
-
const designOpen = c3.designAttackIds.filter(
|
|
7759
|
+
const designOpen = c3.designAttackIds.filter(
|
|
7760
|
+
(id) => verdicts.get(id) === true
|
|
7761
|
+
);
|
|
7678
7762
|
if (designOpen.length > 0) {
|
|
7679
7763
|
return {
|
|
7680
7764
|
status: "refuted_or_not_deployed",
|
|
@@ -7682,7 +7766,9 @@ function resolveClaim(input) {
|
|
|
7682
7766
|
notExecutedAttackIds: []
|
|
7683
7767
|
};
|
|
7684
7768
|
}
|
|
7685
|
-
const holdoutOpen = c3.holdoutAttackIds.filter(
|
|
7769
|
+
const holdoutOpen = c3.holdoutAttackIds.filter(
|
|
7770
|
+
(id) => verdicts.get(id) === true
|
|
7771
|
+
);
|
|
7686
7772
|
if (holdoutOpen.length > 0) {
|
|
7687
7773
|
return {
|
|
7688
7774
|
status: "confirmed_overfit",
|
|
@@ -7714,6 +7800,40 @@ function isExpired(claim, nowMs) {
|
|
|
7714
7800
|
function mayStampFixed(status) {
|
|
7715
7801
|
return status === "confirmed";
|
|
7716
7802
|
}
|
|
7803
|
+
var MAX_RECORDED_VERIFICATIONS = 20;
|
|
7804
|
+
function recordVerification(claim, input) {
|
|
7805
|
+
const result = (id) => {
|
|
7806
|
+
if (!input.verdicts.has(id)) return "not_executed";
|
|
7807
|
+
return input.verdicts.get(id) ? "still_vulnerable" : "closed";
|
|
7808
|
+
};
|
|
7809
|
+
const record = {
|
|
7810
|
+
verifiedAt: new Date(input.nowMs).toISOString(),
|
|
7811
|
+
trigger: input.trigger,
|
|
7812
|
+
status: input.outcome.status,
|
|
7813
|
+
reason: input.outcome.reason,
|
|
7814
|
+
attacks: [
|
|
7815
|
+
...claim.contract.designAttackIds.map((attackId) => ({
|
|
7816
|
+
attackId,
|
|
7817
|
+
role: "design",
|
|
7818
|
+
result: result(attackId)
|
|
7819
|
+
})),
|
|
7820
|
+
...claim.contract.holdoutAttackIds.map((attackId) => ({
|
|
7821
|
+
attackId,
|
|
7822
|
+
role: "holdout",
|
|
7823
|
+
result: result(attackId)
|
|
7824
|
+
}))
|
|
7825
|
+
],
|
|
7826
|
+
benign: { ...input.benign },
|
|
7827
|
+
judgeDegraded: input.judgeDegraded,
|
|
7828
|
+
sessionIsolated: input.sessionIsolated
|
|
7829
|
+
};
|
|
7830
|
+
return {
|
|
7831
|
+
...claim,
|
|
7832
|
+
verifications: [...claim.verifications ?? [], record].slice(
|
|
7833
|
+
-MAX_RECORDED_VERIFICATIONS
|
|
7834
|
+
)
|
|
7835
|
+
};
|
|
7836
|
+
}
|
|
7717
7837
|
|
|
7718
7838
|
// ../../packages/shared/src/remediation/index.ts
|
|
7719
7839
|
function remapRemediationRefs(remediation, version2) {
|
|
@@ -8541,6 +8661,114 @@ async function assertPublicHost(url) {
|
|
|
8541
8661
|
};
|
|
8542
8662
|
}
|
|
8543
8663
|
|
|
8664
|
+
// ../../packages/scanner-core/src/session-isolation.ts
|
|
8665
|
+
var SESSION_PLACEHOLDER = /\{\{\s*(sessionId|threadId)\s*\}\}/;
|
|
8666
|
+
var PLACEHOLDER = SESSION_PLACEHOLDER;
|
|
8667
|
+
function containsPlaceholder(value) {
|
|
8668
|
+
if (typeof value === "string") return PLACEHOLDER.test(value);
|
|
8669
|
+
if (Array.isArray(value)) return value.some(containsPlaceholder);
|
|
8670
|
+
if (value && typeof value === "object") {
|
|
8671
|
+
return Object.values(value).some(
|
|
8672
|
+
containsPlaceholder
|
|
8673
|
+
);
|
|
8674
|
+
}
|
|
8675
|
+
return false;
|
|
8676
|
+
}
|
|
8677
|
+
function containsHistoryPlaceholder(value) {
|
|
8678
|
+
if (value === "{{history}}") return true;
|
|
8679
|
+
if (Array.isArray(value)) return value.some(containsHistoryPlaceholder);
|
|
8680
|
+
if (value && typeof value === "object") {
|
|
8681
|
+
return Object.values(value).some(
|
|
8682
|
+
containsHistoryPlaceholder
|
|
8683
|
+
);
|
|
8684
|
+
}
|
|
8685
|
+
return false;
|
|
8686
|
+
}
|
|
8687
|
+
function checkConversationContext(target) {
|
|
8688
|
+
const body = target.request?.body;
|
|
8689
|
+
if (containsHistoryPlaceholder(body)) {
|
|
8690
|
+
return { carried: true, via: "history", warning: "" };
|
|
8691
|
+
}
|
|
8692
|
+
if (checkSessionIsolation(target).isolated) {
|
|
8693
|
+
return { carried: true, via: "session", warning: "" };
|
|
8694
|
+
}
|
|
8695
|
+
if (target.statefulConversation) {
|
|
8696
|
+
return { carried: true, via: "stateful", warning: "" };
|
|
8697
|
+
}
|
|
8698
|
+
return {
|
|
8699
|
+
carried: false,
|
|
8700
|
+
warning: `Multi-turn attacks will NOT run: this config gives the target no way to see the conversation (no {{history}} in the body, no {{sessionId}}, not statefulConversation). Each turn would arrive as a new conversation, so a crescendo could only ever 'resist'.
|
|
8701
|
+
Stateless chat API \u2014 send the history before the current turn:
|
|
8702
|
+
"messages": ["{{history}}", { "role": "user", "content": "{{prompt}}" }]
|
|
8703
|
+
(Gemini / Vertex AI: "contents" with parts, and "historyFormat": "gemini")
|
|
8704
|
+
Stateful chatbot \u2014 add {{sessionId}} to the request, or set statefulConversation: true.`
|
|
8705
|
+
};
|
|
8706
|
+
}
|
|
8707
|
+
function checkSessionIsolation(target) {
|
|
8708
|
+
const req = target.request;
|
|
8709
|
+
if (containsPlaceholder(target.url))
|
|
8710
|
+
return { isolated: true, foundIn: "url", warning: "" };
|
|
8711
|
+
if (containsPlaceholder(req?.body))
|
|
8712
|
+
return { isolated: true, foundIn: "body", warning: "" };
|
|
8713
|
+
if (containsPlaceholder(req?.headers)) {
|
|
8714
|
+
return { isolated: true, foundIn: "headers", warning: "" };
|
|
8715
|
+
}
|
|
8716
|
+
return {
|
|
8717
|
+
isolated: false,
|
|
8718
|
+
warning: 'This scan sends no session identifier, so a target that keeps conversation state will handle every attack in ONE conversation: each verdict then depends on the attacks that ran before it, and on catalogue order.\n If your chatbot is stateful, add the placeholder to your request template:\n "body": { "message": "{{prompt}}", "sessionId": "{{sessionId}}" }\n (or a header / URL segment \u2014 anywhere in the template works). Stateless endpoints can ignore this.'
|
|
8719
|
+
};
|
|
8720
|
+
}
|
|
8721
|
+
|
|
8722
|
+
// ../../packages/scanner-core/src/provider-response.ts
|
|
8723
|
+
var GEMINI_FILTER_FINISH_REASONS = /* @__PURE__ */ new Set([
|
|
8724
|
+
"SAFETY",
|
|
8725
|
+
"RECITATION",
|
|
8726
|
+
"BLOCKLIST",
|
|
8727
|
+
"PROHIBITED_CONTENT",
|
|
8728
|
+
"SPII",
|
|
8729
|
+
"IMAGE_SAFETY"
|
|
8730
|
+
]);
|
|
8731
|
+
function at(obj, ...keys) {
|
|
8732
|
+
let current = obj;
|
|
8733
|
+
for (const key of keys) {
|
|
8734
|
+
if (current === null || typeof current !== "object") return void 0;
|
|
8735
|
+
current = current[key];
|
|
8736
|
+
}
|
|
8737
|
+
return current;
|
|
8738
|
+
}
|
|
8739
|
+
function contentFilterReason(body) {
|
|
8740
|
+
const blockReason = at(body, "promptFeedback", "blockReason");
|
|
8741
|
+
if (typeof blockReason === "string" && blockReason !== "BLOCK_REASON_UNSPECIFIED") {
|
|
8742
|
+
return blockReason;
|
|
8743
|
+
}
|
|
8744
|
+
const finishReason = at(body, "candidates", 0, "finishReason");
|
|
8745
|
+
if (typeof finishReason === "string" && GEMINI_FILTER_FINISH_REASONS.has(finishReason)) {
|
|
8746
|
+
return finishReason;
|
|
8747
|
+
}
|
|
8748
|
+
if (at(body, "choices", 0, "finish_reason") === "content_filter") {
|
|
8749
|
+
return "content_filter";
|
|
8750
|
+
}
|
|
8751
|
+
return null;
|
|
8752
|
+
}
|
|
8753
|
+
function contentFilterRefusal(reason) {
|
|
8754
|
+
return `[No answer: the provider's content filter withheld the response (${reason})]`;
|
|
8755
|
+
}
|
|
8756
|
+
function nestAtPath(path2, value) {
|
|
8757
|
+
const segments = path2.replace(/\[(\d+)\]/g, ".$1").split(".");
|
|
8758
|
+
let nested = value;
|
|
8759
|
+
for (let i = segments.length - 1; i >= 0; i--) {
|
|
8760
|
+
const segment = segments[i];
|
|
8761
|
+
if (/^\d+$/.test(segment)) {
|
|
8762
|
+
const arr = [];
|
|
8763
|
+
arr[Number(segment)] = nested;
|
|
8764
|
+
nested = arr;
|
|
8765
|
+
} else {
|
|
8766
|
+
nested = { [segment]: nested };
|
|
8767
|
+
}
|
|
8768
|
+
}
|
|
8769
|
+
return Array.isArray(nested) ? { ...nested } : nested;
|
|
8770
|
+
}
|
|
8771
|
+
|
|
8544
8772
|
// ../../packages/scanner-core/src/http-sse.ts
|
|
8545
8773
|
var MAX_RESPONSE_BYTES = 50 * 1024 * 1024;
|
|
8546
8774
|
function extractSseChunk(parsed) {
|
|
@@ -8830,14 +9058,30 @@ var HttpTargetClient = class {
|
|
|
8830
9058
|
}
|
|
8831
9059
|
// ── Internal (exposed for session classes) ──
|
|
8832
9060
|
async sendRaw(prompt, history, options) {
|
|
9061
|
+
try {
|
|
9062
|
+
return await this.sendRawOnce(prompt, history, options);
|
|
9063
|
+
} catch (error) {
|
|
9064
|
+
if (error instanceof HttpTargetError && error.statusCode === 401 && this.config.auth?.type === "oauth2") {
|
|
9065
|
+
this.resolvedAuth = null;
|
|
9066
|
+
return this.sendRawOnce(prompt, history, options);
|
|
9067
|
+
}
|
|
9068
|
+
throw error;
|
|
9069
|
+
}
|
|
9070
|
+
}
|
|
9071
|
+
async sendRawOnce(prompt, history, options) {
|
|
8833
9072
|
const auth = await this.getAuth();
|
|
8834
9073
|
const sessionId = options?.sessionId ?? randomUUID();
|
|
8835
9074
|
const body = renderTemplate(this.config.request.body, {
|
|
8836
9075
|
prompt,
|
|
8837
9076
|
history,
|
|
8838
|
-
sessionId
|
|
9077
|
+
sessionId,
|
|
9078
|
+
historyFormat: this.config.request.historyFormat
|
|
8839
9079
|
});
|
|
9080
|
+
const url = withSessionId(this.config.url, sessionId, encodeURIComponent);
|
|
8840
9081
|
const headers = this.buildHeaders(auth);
|
|
9082
|
+
for (const [name, value] of Object.entries(headers)) {
|
|
9083
|
+
headers[name] = withSessionId(value, sessionId);
|
|
9084
|
+
}
|
|
8841
9085
|
const { body: encodedBody, contentType } = encodeRequestBody(
|
|
8842
9086
|
body,
|
|
8843
9087
|
this.config.request.encoding
|
|
@@ -8848,7 +9092,7 @@ var HttpTargetClient = class {
|
|
|
8848
9092
|
headers["Content-Type"] = contentType;
|
|
8849
9093
|
}
|
|
8850
9094
|
return fetchWithTimeout(
|
|
8851
|
-
|
|
9095
|
+
url,
|
|
8852
9096
|
{
|
|
8853
9097
|
method: this.config.request.method ?? "POST",
|
|
8854
9098
|
headers,
|
|
@@ -8864,6 +9108,8 @@ var HttpTargetClient = class {
|
|
|
8864
9108
|
extractResponse(responseBody) {
|
|
8865
9109
|
const value = getByPath(responseBody, this.config.response.field);
|
|
8866
9110
|
if (value === void 0 || value === null) {
|
|
9111
|
+
const filtered = contentFilterReason(responseBody);
|
|
9112
|
+
if (filtered) return contentFilterRefusal(filtered);
|
|
8867
9113
|
const hint = responseBody && typeof responseBody === "object" ? `top-level keys: ${Object.keys(responseBody).slice(0, 8).join(", ")}` : `body type: ${typeof responseBody}`;
|
|
8868
9114
|
throw new HttpTargetError(
|
|
8869
9115
|
`Response field "${this.config.response.field}" not found (${hint})`,
|
|
@@ -8968,31 +9214,55 @@ var StatelessHttpSession = class extends LazyAllocatedSession {
|
|
|
8968
9214
|
return text;
|
|
8969
9215
|
}
|
|
8970
9216
|
};
|
|
9217
|
+
function formatHistory(history, format = "openai") {
|
|
9218
|
+
if (format === "gemini") {
|
|
9219
|
+
return history.map((t) => ({
|
|
9220
|
+
role: t.role === "assistant" ? "model" : "user",
|
|
9221
|
+
parts: [{ text: t.content }]
|
|
9222
|
+
}));
|
|
9223
|
+
}
|
|
9224
|
+
return history;
|
|
9225
|
+
}
|
|
8971
9226
|
function renderTemplate(template, context) {
|
|
8972
9227
|
const sessionId = context.sessionId ?? randomUUID();
|
|
8973
9228
|
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
8974
9229
|
const nowUnix = Math.floor(Date.now() / 1e3).toString();
|
|
8975
9230
|
function substitute(value) {
|
|
8976
9231
|
if (value === "{{prompt}}") return context.prompt;
|
|
8977
|
-
if (value === "{{history}}")
|
|
8978
|
-
|
|
9232
|
+
if (value === "{{history}}") {
|
|
9233
|
+
return formatHistory(context.history, context.historyFormat);
|
|
9234
|
+
}
|
|
9235
|
+
if (WHOLE_SESSION_PLACEHOLDER.test(value)) return sessionId;
|
|
8979
9236
|
if (value === "{{now}}") return now;
|
|
8980
9237
|
if (value === "{{nowUnix}}") return nowUnix;
|
|
8981
9238
|
if (value === "{{uuid}}") return randomUUID();
|
|
8982
9239
|
if (!value.includes("{{")) return value;
|
|
8983
|
-
return
|
|
9240
|
+
return withSessionId(
|
|
9241
|
+
// Function replacer: a payload is data, never a `$&` / `$$` pattern.
|
|
9242
|
+
value.replace(/\{\{prompt\}\}/g, () => context.prompt),
|
|
9243
|
+
sessionId
|
|
9244
|
+
).replace(/\{\{now\}\}/g, now).replace(/\{\{nowUnix\}\}/g, nowUnix).replace(/\{\{uuid\}\}/g, () => randomUUID());
|
|
8984
9245
|
}
|
|
8985
9246
|
const result = {};
|
|
8986
9247
|
for (const [key, value] of Object.entries(template)) {
|
|
8987
9248
|
if (typeof value === "string") {
|
|
8988
9249
|
result[key] = substitute(value);
|
|
8989
9250
|
} else if (Array.isArray(value)) {
|
|
8990
|
-
result[key] = value.
|
|
8991
|
-
(item
|
|
8992
|
-
|
|
8993
|
-
|
|
8994
|
-
|
|
8995
|
-
|
|
9251
|
+
result[key] = value.flatMap((item) => {
|
|
9252
|
+
if (item === "{{history}}") {
|
|
9253
|
+
return formatHistory(context.history, context.historyFormat);
|
|
9254
|
+
}
|
|
9255
|
+
if (typeof item === "string") return [substitute(item)];
|
|
9256
|
+
if (typeof item === "object" && item !== null) {
|
|
9257
|
+
return [
|
|
9258
|
+
renderTemplate(item, {
|
|
9259
|
+
...context,
|
|
9260
|
+
sessionId
|
|
9261
|
+
})
|
|
9262
|
+
];
|
|
9263
|
+
}
|
|
9264
|
+
return [item];
|
|
9265
|
+
});
|
|
8996
9266
|
} else if (typeof value === "object" && value !== null) {
|
|
8997
9267
|
result[key] = renderTemplate(value, {
|
|
8998
9268
|
...context,
|
|
@@ -9004,6 +9274,11 @@ function renderTemplate(template, context) {
|
|
|
9004
9274
|
}
|
|
9005
9275
|
return result;
|
|
9006
9276
|
}
|
|
9277
|
+
var SESSION_PLACEHOLDER_ALL = new RegExp(SESSION_PLACEHOLDER.source, "g");
|
|
9278
|
+
var WHOLE_SESSION_PLACEHOLDER = new RegExp(`^${SESSION_PLACEHOLDER.source}$`);
|
|
9279
|
+
function withSessionId(value, sessionId, encode = (s) => s) {
|
|
9280
|
+
return value.replace(SESSION_PLACEHOLDER_ALL, () => encode(sessionId));
|
|
9281
|
+
}
|
|
9007
9282
|
function getByPath(obj, path2) {
|
|
9008
9283
|
const segments = path2.replace(/\[(\d+)\]/g, ".$1").split(".");
|
|
9009
9284
|
let current = obj;
|
|
@@ -9106,14 +9381,14 @@ async function fetchWithTimeout(url, init, timeoutMs, responseField, allowPrivat
|
|
|
9106
9381
|
const retryAfterSec = retryAfterFromHeader(
|
|
9107
9382
|
response.headers.get("retry-after")
|
|
9108
9383
|
);
|
|
9109
|
-
const body2 = await response
|
|
9384
|
+
const body2 = await readErrorBodyHead(response);
|
|
9110
9385
|
throw new RateLimitError(
|
|
9111
9386
|
`Rate limited (HTTP 429)${retryAfterSec ? ` \u2014 retry after ${retryAfterSec}s` : ""}${body2 ? `: ${body2.slice(0, 500)}` : ""}`,
|
|
9112
9387
|
retryAfterSec
|
|
9113
9388
|
);
|
|
9114
9389
|
}
|
|
9115
9390
|
if (!response.ok) {
|
|
9116
|
-
const body2 = await response
|
|
9391
|
+
const body2 = await readErrorBodyHead(response);
|
|
9117
9392
|
const throttle = detectRateLimit(body2);
|
|
9118
9393
|
if (throttle) {
|
|
9119
9394
|
throw new RateLimitError(
|
|
@@ -9129,13 +9404,11 @@ async function fetchWithTimeout(url, init, timeoutMs, responseField, allowPrivat
|
|
|
9129
9404
|
const contentType = response.headers.get("content-type") ?? "";
|
|
9130
9405
|
if (contentType.includes("text/event-stream")) {
|
|
9131
9406
|
const text = await collectSSE(response);
|
|
9132
|
-
|
|
9133
|
-
return { [field]: text };
|
|
9407
|
+
return nestAtPath(responseField ?? "response", text);
|
|
9134
9408
|
}
|
|
9135
9409
|
if (contentType.includes("ndjson")) {
|
|
9136
9410
|
const text = await collectNDJSON(response);
|
|
9137
|
-
|
|
9138
|
-
return { [field]: text };
|
|
9411
|
+
return nestAtPath(responseField ?? "response", text);
|
|
9139
9412
|
}
|
|
9140
9413
|
if (!contentType.includes("json")) {
|
|
9141
9414
|
const text = await readBodyWithLimit(response);
|
|
@@ -9157,6 +9430,34 @@ async function fetchWithTimeout(url, init, timeoutMs, responseField, allowPrivat
|
|
|
9157
9430
|
clearTimeout(timeout);
|
|
9158
9431
|
}
|
|
9159
9432
|
}
|
|
9433
|
+
var ERROR_BODY_HEAD_BYTES = 8192;
|
|
9434
|
+
async function readErrorBodyHead(response) {
|
|
9435
|
+
try {
|
|
9436
|
+
if (!response.body) {
|
|
9437
|
+
const text = typeof response.text === "function" ? await response.text() : "";
|
|
9438
|
+
return text.slice(0, ERROR_BODY_HEAD_BYTES);
|
|
9439
|
+
}
|
|
9440
|
+
const reader = response.body.getReader();
|
|
9441
|
+
const decoder = new TextDecoder();
|
|
9442
|
+
let result = "";
|
|
9443
|
+
let total = 0;
|
|
9444
|
+
try {
|
|
9445
|
+
while (total < ERROR_BODY_HEAD_BYTES) {
|
|
9446
|
+
const { done, value } = await reader.read();
|
|
9447
|
+
if (done) break;
|
|
9448
|
+
total += value.byteLength;
|
|
9449
|
+
result += decoder.decode(value, { stream: true });
|
|
9450
|
+
}
|
|
9451
|
+
} finally {
|
|
9452
|
+
await reader.cancel().catch(() => {
|
|
9453
|
+
});
|
|
9454
|
+
reader.releaseLock();
|
|
9455
|
+
}
|
|
9456
|
+
return result.slice(0, ERROR_BODY_HEAD_BYTES);
|
|
9457
|
+
} catch {
|
|
9458
|
+
return "";
|
|
9459
|
+
}
|
|
9460
|
+
}
|
|
9160
9461
|
async function readBodyWithLimit(response) {
|
|
9161
9462
|
const contentLength = response.headers.get("content-length");
|
|
9162
9463
|
if (contentLength) {
|
|
@@ -9379,6 +9680,8 @@ var Scanner = class {
|
|
|
9379
9680
|
let consecutiveFailures = 0;
|
|
9380
9681
|
let attackIndex = 0;
|
|
9381
9682
|
let rateLimited = false;
|
|
9683
|
+
let authFailed = false;
|
|
9684
|
+
let terminalSkip = false;
|
|
9382
9685
|
this.currentDelayMs = this.options.delayMs;
|
|
9383
9686
|
this.throttleFloorStreak = 0;
|
|
9384
9687
|
this.pauseUntil = 0;
|
|
@@ -9404,7 +9707,8 @@ var Scanner = class {
|
|
|
9404
9707
|
this.aimdLimit = this.aimdMax;
|
|
9405
9708
|
this.aimdSuccessStreak = 0;
|
|
9406
9709
|
this.inConcurrentPhase = true;
|
|
9407
|
-
const stop = () => rateLimited || consecutiveFailures >= this.options.maxConsecutiveFailures;
|
|
9710
|
+
const stop = () => rateLimited || authFailed || consecutiveFailures >= this.options.maxConsecutiveFailures;
|
|
9711
|
+
const skipReason = () => authFailed ? SKIP_AUTH : rateLimited ? "Skipped: target rate limited" : "Skipped: too many consecutive failures";
|
|
9408
9712
|
let nextPending = 0;
|
|
9409
9713
|
let active = 0;
|
|
9410
9714
|
await new Promise((resolve2, reject) => {
|
|
@@ -9445,7 +9749,8 @@ var Scanner = class {
|
|
|
9445
9749
|
rateLimited = true;
|
|
9446
9750
|
}
|
|
9447
9751
|
} else if (result.error) {
|
|
9448
|
-
if (
|
|
9752
|
+
if (result.authFailed) authFailed = true;
|
|
9753
|
+
else if (!result.payloadRejected) consecutiveFailures++;
|
|
9449
9754
|
} else {
|
|
9450
9755
|
consecutiveFailures = 0;
|
|
9451
9756
|
this.handleSuccess();
|
|
@@ -9505,10 +9810,11 @@ var Scanner = class {
|
|
|
9505
9810
|
}
|
|
9506
9811
|
for (let i = 0; i < attacks.length; i++) {
|
|
9507
9812
|
if (singleResults[i] === void 0) {
|
|
9813
|
+
terminalSkip = true;
|
|
9508
9814
|
const skip = this.createSkippedResult(
|
|
9509
9815
|
attacks[i],
|
|
9510
|
-
|
|
9511
|
-
rateLimited
|
|
9816
|
+
skipReason(),
|
|
9817
|
+
rateLimited && !authFailed
|
|
9512
9818
|
);
|
|
9513
9819
|
singleResults[i] = skip;
|
|
9514
9820
|
this.emit({
|
|
@@ -9521,6 +9827,7 @@ var Scanner = class {
|
|
|
9521
9827
|
}
|
|
9522
9828
|
for (const r of singleResults) results.push(r);
|
|
9523
9829
|
attackIndex = attacks.length;
|
|
9830
|
+
const conversation = checkConversationContext(this.options.target);
|
|
9524
9831
|
for (const crescendo of crescendoAttacks) {
|
|
9525
9832
|
const resumed = done.get(crescendo.id);
|
|
9526
9833
|
if (resumed) {
|
|
@@ -9534,8 +9841,10 @@ var Scanner = class {
|
|
|
9534
9841
|
attackIndex++;
|
|
9535
9842
|
continue;
|
|
9536
9843
|
}
|
|
9537
|
-
if (
|
|
9538
|
-
|
|
9844
|
+
if (stop() || !conversation.carried) {
|
|
9845
|
+
const terminal = stop();
|
|
9846
|
+
if (terminal) terminalSkip = true;
|
|
9847
|
+
const skip = {
|
|
9539
9848
|
id: crescendo.id,
|
|
9540
9849
|
name: crescendo.name,
|
|
9541
9850
|
severity: crescendo.severity,
|
|
@@ -9544,8 +9853,15 @@ var Scanner = class {
|
|
|
9544
9853
|
response: "",
|
|
9545
9854
|
multiTurn: true,
|
|
9546
9855
|
durationMs: 0,
|
|
9547
|
-
error:
|
|
9548
|
-
...rateLimited ? { rateLimited: true } : {}
|
|
9856
|
+
error: terminal ? skipReason() : SKIP_NO_CONVERSATION,
|
|
9857
|
+
...terminal && rateLimited && !authFailed ? { rateLimited: true } : {}
|
|
9858
|
+
};
|
|
9859
|
+
results.push(skip);
|
|
9860
|
+
this.emit({
|
|
9861
|
+
type: "attack:complete",
|
|
9862
|
+
result: skip,
|
|
9863
|
+
index: attackIndex,
|
|
9864
|
+
total: totalAttacks
|
|
9549
9865
|
});
|
|
9550
9866
|
attackIndex++;
|
|
9551
9867
|
continue;
|
|
@@ -9568,7 +9884,8 @@ var Scanner = class {
|
|
|
9568
9884
|
rateLimited = true;
|
|
9569
9885
|
}
|
|
9570
9886
|
} else if (result.error) {
|
|
9571
|
-
if (
|
|
9887
|
+
if (result.authFailed) authFailed = true;
|
|
9888
|
+
else if (!result.payloadRejected) consecutiveFailures++;
|
|
9572
9889
|
} else {
|
|
9573
9890
|
consecutiveFailures = 0;
|
|
9574
9891
|
this.handleSuccess();
|
|
@@ -9589,18 +9906,18 @@ var Scanner = class {
|
|
|
9589
9906
|
mtProgress = false;
|
|
9590
9907
|
for (let k = 0; k < crescendoAttacks.length; k++) {
|
|
9591
9908
|
if (stop()) break;
|
|
9592
|
-
const
|
|
9593
|
-
const prior = results[
|
|
9909
|
+
const at2 = attacks.length + k;
|
|
9910
|
+
const prior = results[at2];
|
|
9594
9911
|
if (!prior || !prior.rateLimited || prior.error?.startsWith("Skipped")) {
|
|
9595
9912
|
continue;
|
|
9596
9913
|
}
|
|
9597
9914
|
if (this.currentDelayMs > 0) await sleep(this.currentDelayMs);
|
|
9598
9915
|
const retry = await this.executeMultiTurnAttack(crescendoAttacks[k]);
|
|
9599
|
-
results[
|
|
9916
|
+
results[at2] = retry;
|
|
9600
9917
|
await store?.record(retry);
|
|
9601
9918
|
if (retry.rateLimited) {
|
|
9602
9919
|
if (this.handleThrottle(
|
|
9603
|
-
|
|
9920
|
+
at2,
|
|
9604
9921
|
totalAttacks,
|
|
9605
9922
|
parseRetryAfterSec(retry.error)
|
|
9606
9923
|
)) {
|
|
@@ -9613,7 +9930,7 @@ var Scanner = class {
|
|
|
9613
9930
|
this.emit({
|
|
9614
9931
|
type: "attack:complete",
|
|
9615
9932
|
result: retry,
|
|
9616
|
-
index:
|
|
9933
|
+
index: at2,
|
|
9617
9934
|
total: totalAttacks
|
|
9618
9935
|
});
|
|
9619
9936
|
}
|
|
@@ -9631,6 +9948,27 @@ var Scanner = class {
|
|
|
9631
9948
|
attackIndex++;
|
|
9632
9949
|
continue;
|
|
9633
9950
|
}
|
|
9951
|
+
if (authFailed) {
|
|
9952
|
+
const skip = {
|
|
9953
|
+
id: `custom_${customTest.name}`,
|
|
9954
|
+
name: customTest.name,
|
|
9955
|
+
severity: "HIGH",
|
|
9956
|
+
vulnerable: false,
|
|
9957
|
+
prompt: customTest.prompt,
|
|
9958
|
+
response: "",
|
|
9959
|
+
durationMs: 0,
|
|
9960
|
+
error: SKIP_AUTH
|
|
9961
|
+
};
|
|
9962
|
+
results.push(skip);
|
|
9963
|
+
this.emit({
|
|
9964
|
+
type: "attack:complete",
|
|
9965
|
+
result: skip,
|
|
9966
|
+
index: attackIndex,
|
|
9967
|
+
total: totalAttacks
|
|
9968
|
+
});
|
|
9969
|
+
attackIndex++;
|
|
9970
|
+
continue;
|
|
9971
|
+
}
|
|
9634
9972
|
this.emit({
|
|
9635
9973
|
type: "attack:start",
|
|
9636
9974
|
attack: {
|
|
@@ -9644,6 +9982,7 @@ var Scanner = class {
|
|
|
9644
9982
|
const result = await this.executeCustomTest(customTest);
|
|
9645
9983
|
results.push(result);
|
|
9646
9984
|
await store?.record(result);
|
|
9985
|
+
if (result.authFailed) authFailed = true;
|
|
9647
9986
|
this.emit({
|
|
9648
9987
|
type: "attack:complete",
|
|
9649
9988
|
result,
|
|
@@ -9673,6 +10012,11 @@ var Scanner = class {
|
|
|
9673
10012
|
customTests: customTests.length
|
|
9674
10013
|
}
|
|
9675
10014
|
};
|
|
10015
|
+
if (authFailed) {
|
|
10016
|
+
report.stopReason = "auth";
|
|
10017
|
+
} else if (terminalSkip) {
|
|
10018
|
+
report.stopReason = rateLimited ? "rate_limited" : "consecutive_failures";
|
|
10019
|
+
}
|
|
9676
10020
|
this.emit({ type: "scan:complete", report });
|
|
9677
10021
|
return report;
|
|
9678
10022
|
}
|
|
@@ -9734,7 +10078,8 @@ var Scanner = class {
|
|
|
9734
10078
|
durationMs: Date.now() - startTime,
|
|
9735
10079
|
error: error instanceof Error ? error.message : "Unknown error",
|
|
9736
10080
|
...isRateLimit ? { rateLimited: true } : {},
|
|
9737
|
-
...isPayloadRejection(error) ? { payloadRejected: true } : {}
|
|
10081
|
+
...isPayloadRejection(error) ? { payloadRejected: true } : {},
|
|
10082
|
+
...isAuthFailure(error) ? { authFailed: true } : {}
|
|
9738
10083
|
};
|
|
9739
10084
|
} finally {
|
|
9740
10085
|
await session.dispose?.();
|
|
@@ -9817,7 +10162,8 @@ var Scanner = class {
|
|
|
9817
10162
|
durationMs: Date.now() - startTime,
|
|
9818
10163
|
error: errorMsg,
|
|
9819
10164
|
...isRateLimit ? { rateLimited: true } : {},
|
|
9820
|
-
...isPayloadRejection(error) ? { payloadRejected: true } : {}
|
|
10165
|
+
...isPayloadRejection(error) ? { payloadRejected: true } : {},
|
|
10166
|
+
...isAuthFailure(error) ? { authFailed: true } : {}
|
|
9821
10167
|
};
|
|
9822
10168
|
} finally {
|
|
9823
10169
|
await session.dispose?.();
|
|
@@ -9868,7 +10214,8 @@ var Scanner = class {
|
|
|
9868
10214
|
prompt: test.prompt,
|
|
9869
10215
|
response: "",
|
|
9870
10216
|
durationMs: Date.now() - startTime,
|
|
9871
|
-
error: errorMsg
|
|
10217
|
+
error: errorMsg,
|
|
10218
|
+
...isAuthFailure(error) ? { authFailed: true } : {}
|
|
9872
10219
|
};
|
|
9873
10220
|
} finally {
|
|
9874
10221
|
await session.dispose?.();
|
|
@@ -10081,8 +10428,13 @@ function isRetryable(error) {
|
|
|
10081
10428
|
return false;
|
|
10082
10429
|
}
|
|
10083
10430
|
function isPayloadRejection(error) {
|
|
10084
|
-
return error instanceof HttpTargetError && !(error instanceof RateLimitError) && error.statusCode >= 400 && error.statusCode < 500;
|
|
10431
|
+
return error instanceof HttpTargetError && !(error instanceof RateLimitError) && !isAuthFailure(error) && error.statusCode >= 400 && error.statusCode < 500;
|
|
10432
|
+
}
|
|
10433
|
+
function isAuthFailure(error) {
|
|
10434
|
+
return error instanceof HttpTargetError && error.statusCode === 401;
|
|
10085
10435
|
}
|
|
10436
|
+
var SKIP_AUTH = "Skipped: the target rejected the scan's credentials (HTTP 401)";
|
|
10437
|
+
var SKIP_NO_CONVERSATION = "Skipped: the target config carries no conversation context \u2014 multi-turn not run (add {{history}} to the body, a {{sessionId}}, or statefulConversation: true)";
|
|
10086
10438
|
function sleep(ms) {
|
|
10087
10439
|
return new Promise((resolve2) => setTimeout(resolve2, ms));
|
|
10088
10440
|
}
|
|
@@ -10130,29 +10482,6 @@ var RegexOnlyEvaluator = class {
|
|
|
10130
10482
|
}
|
|
10131
10483
|
};
|
|
10132
10484
|
|
|
10133
|
-
// ../../packages/scanner-core/src/session-isolation.ts
|
|
10134
|
-
var PLACEHOLDER = /\{\{\s*(sessionId|threadId)\s*\}\}/;
|
|
10135
|
-
function containsPlaceholder(value) {
|
|
10136
|
-
if (typeof value === "string") return PLACEHOLDER.test(value);
|
|
10137
|
-
if (Array.isArray(value)) return value.some(containsPlaceholder);
|
|
10138
|
-
if (value && typeof value === "object") {
|
|
10139
|
-
return Object.values(value).some(containsPlaceholder);
|
|
10140
|
-
}
|
|
10141
|
-
return false;
|
|
10142
|
-
}
|
|
10143
|
-
function checkSessionIsolation(target) {
|
|
10144
|
-
const req = target.request;
|
|
10145
|
-
if (containsPlaceholder(target.url)) return { isolated: true, foundIn: "url", warning: "" };
|
|
10146
|
-
if (containsPlaceholder(req?.body)) return { isolated: true, foundIn: "body", warning: "" };
|
|
10147
|
-
if (containsPlaceholder(req?.headers)) {
|
|
10148
|
-
return { isolated: true, foundIn: "headers", warning: "" };
|
|
10149
|
-
}
|
|
10150
|
-
return {
|
|
10151
|
-
isolated: false,
|
|
10152
|
-
warning: 'This scan sends no session identifier, so a target that keeps conversation state will handle every attack in ONE conversation: each verdict then depends on the attacks that ran before it, and on catalogue order.\n If your chatbot is stateful, add the placeholder to your request template:\n "body": { "message": "{{prompt}}", "sessionId": "{{sessionId}}" }\n (or a header / URL segment \u2014 anywhere in the template works). Stateless endpoints can ignore this.'
|
|
10153
|
-
};
|
|
10154
|
-
}
|
|
10155
|
-
|
|
10156
10485
|
// ../../packages/scanner-core/src/schemas.ts
|
|
10157
10486
|
import { z } from "zod";
|
|
10158
10487
|
var AuthConfigSchema = z.discriminatedUnion("type", [
|
|
@@ -10182,7 +10511,10 @@ var RequestTemplateSchema = z.object({
|
|
|
10182
10511
|
// application/json). "form" = application/x-www-form-urlencoded, "multipart"
|
|
10183
10512
|
// = multipart/form-data (Content-Type is left to fetch so the boundary is
|
|
10184
10513
|
// set). Real chatbots often expect form encodings (e.g. FastAPI `Form(...)`).
|
|
10185
|
-
encoding: z.enum(["json", "form", "multipart"]).optional()
|
|
10514
|
+
encoding: z.enum(["json", "form", "multipart"]).optional(),
|
|
10515
|
+
// Shape of each {{history}} turn: OpenAI-style {role, content} (default) or
|
|
10516
|
+
// Gemini {role: user|model, parts: [{text}]} for generateContent / Vertex AI.
|
|
10517
|
+
historyFormat: z.enum(["openai", "gemini"]).optional()
|
|
10186
10518
|
});
|
|
10187
10519
|
var ResponseTemplateSchema = z.object({
|
|
10188
10520
|
field: z.string().min(1),
|
|
@@ -10222,7 +10554,9 @@ var EndpointConfigSchema = z.object({
|
|
|
10222
10554
|
session: SessionConfigSchema.optional(),
|
|
10223
10555
|
// Known secret(s) / canary — server judge flags any response that surfaces
|
|
10224
10556
|
// one as a confirmed extraction. min(8) is a hard floor; prefer high-entropy.
|
|
10225
|
-
|
|
10557
|
+
// max(256) per secret: the canary floor matches each one (and five encodings)
|
|
10558
|
+
// against every response, so 20 unbounded secrets were a cost amplifier.
|
|
10559
|
+
knownSecrets: z.array(z.string().min(8).max(256)).max(20).optional()
|
|
10226
10560
|
});
|
|
10227
10561
|
var CustomTestSchema = z.object({
|
|
10228
10562
|
name: z.string().min(1),
|
|
@@ -13097,6 +13431,9 @@ function buildMessage(attack) {
|
|
|
13097
13431
|
|
|
13098
13432
|
export {
|
|
13099
13433
|
version,
|
|
13434
|
+
DORA_REGULATION_LABEL,
|
|
13435
|
+
DORA_PARAGRAPHS_VERIFIED_ON,
|
|
13436
|
+
DORA_PARAGRAPHS,
|
|
13100
13437
|
ATTACK_PACK_VERSION,
|
|
13101
13438
|
MUTATORS,
|
|
13102
13439
|
getMutator,
|
|
@@ -13124,6 +13461,7 @@ export {
|
|
|
13124
13461
|
resolveClaim,
|
|
13125
13462
|
isExpired,
|
|
13126
13463
|
mayStampFixed,
|
|
13464
|
+
recordVerification,
|
|
13127
13465
|
getStructuredRemediation,
|
|
13128
13466
|
CONSENT_SCOPES,
|
|
13129
13467
|
parseSegmentKey,
|
|
@@ -13137,13 +13475,14 @@ export {
|
|
|
13137
13475
|
BENIGN_SUITE_ID,
|
|
13138
13476
|
BENIGN_CORE_V1,
|
|
13139
13477
|
evaluateBenign,
|
|
13478
|
+
checkConversationContext,
|
|
13479
|
+
checkSessionIsolation,
|
|
13140
13480
|
createTargetClient,
|
|
13141
13481
|
computeCatalogHash,
|
|
13142
13482
|
computeScanKey,
|
|
13143
13483
|
FileCheckpointStore,
|
|
13144
13484
|
Scanner,
|
|
13145
13485
|
RegexOnlyEvaluator,
|
|
13146
|
-
checkSessionIsolation,
|
|
13147
13486
|
ConfigSchema,
|
|
13148
13487
|
loadConfig,
|
|
13149
13488
|
buildTargetConfig,
|