@code-sentinel-cli/code-sentinel-cli 4.0.13-avtest.1 → 4.0.14
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/bin.js +401 -75
- package/dist/builtin-rules/ai/angular/api-service-contract-risk.prompt.md +7 -0
- package/dist/builtin-rules/ai/angular/api-service-contract-risk.rule.yaml +1 -1
- package/dist/builtin-rules/ai/angular/rxjs-flow-risk.prompt.md +17 -4
- package/dist/builtin-rules/ai/angular/rxjs-flow-risk.rule.yaml +3 -2
- package/dist/builtin-rules/static/angular/no-leaky-subscription.rule.js +124 -30
- package/dist/builtin-rules/static/angular/template-dom-xss.rule.js +14 -38
- package/dist/index.d.ts +1 -1
- package/dist/index.js +401 -75
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -1036,7 +1036,7 @@ function correlateFindings(doc, perf) {
|
|
|
1036
1036
|
endpointsUnmatched
|
|
1037
1037
|
};
|
|
1038
1038
|
}
|
|
1039
|
-
var SEVERITY_ORDER, severityRank, meetsSeverity, LANGUAGES, languageFromExtension, languageFromPath, SOURCE_TOOLS, CORE_PACK, rulePackOf, compareFindings, editsOverlap, AI_GATE_POLICIES, isAiGatePolicy, AI_SKIP_GATE_POLICIES, isAiSkipGatePolicy, aiCoverageGates, findingGates, toRunIngestDto, AI_SKIP_REASONS, isRecallRiskSkip, isRetryableSkip, countRecallRiskSkips, LAYER_FLOW_MAP, sortEdges, createAstDependencyGraph, scenarioVerdictFromOutcome, CLIENT_TIERS, isClientTier, summarizeClientCoverage, summarizeComponentCoverage, CLIENT_TEST_OUTCOMES, isClientTestOutcome, CLIENT_ORACLE_FAILURE_MARKER, CLIENT_RT_ORACLE_FAILURE_MARKER, isClientOracleFailure, isClientRtOracleFailure, clientScenarioVerdictFromOutcome, clientScenarioVerdictFromTieredOutcome, AUTH_FILL_KINDS, isAuthFillKind, STR, STR_LIST, MOCK_USER_RE, ANONYMOUS_RE, JWT_AUTHORITY, JWT_AUTHORITY_LIST, JWT_RE, WMU_ARG, WITH_MOCK_USER_RE, WITH_USER_DETAILS_RE, ALLOWED_IMPORT_RE, isRecord, isSafeLine, validateImports, validateAuthFill, MAX_STATE_WRITES, MAX_HASH_FIELDS, MAX_CLAIMS, MAX_CLAIM_ARRAY, MAX_EVIDENCE, MAX_KEY_LEN, MAX_VALUE_LEN, MAX_EVIDENCE_LEN, TRANSPORTS, ALGORITHMS, VALUE_SOURCES, NAME_RE, CLAIM_NAME_RE, SCHEME_RE, FORBIDDEN_KEY_RE, CONTROL_RE, isRecord2, isSafeText, isSafeKey, isSafeField, INVALID, normaliseKeyFromClaim, normaliseClaimValue, normaliseClaims, normaliseHashFields, normaliseStateWrite, normaliseEvidence, validateRuntimeAuthHypothesis, resolveStateWriteKeys, describeRuntimeAuthHypothesisProblem, MAX_TARGETS, MAX_ROWS, MAX_COLUMNS, MAX_EVIDENCE2, MAX_STRING_VALUE, MAX_EVIDENCE_LEN2, MAX_OBJECT_KEY, MAX_SEED_OBJECT_BYTES, MAX_CONTENT_BASE64, MAX_JSON_BODY_CHARS, MAX_JSON_STRING_VALUE, MAX_JSON_BODY_DEPTH, SQL_IDENTIFIER_RE, isSqlIdentifier, OBJECT_BUCKET_RE, isIpShaped, isObjectBucket, isObjectKey, BASE64_RE, isBase64Content, CONTENT_TYPE_RE, isObjectContentType, PATH_RE, METHOD_RE, CONTROL_RE2, isRecord3, isSafeText2, normaliseValue, normaliseRow, normaliseEvidence2, normaliseTarget, normaliseObjectTarget, jsonShapeOk, normaliseApiCreateRequest, normaliseApiCreateTarget, validateRuntimeDataSeedHypothesis, validateSqlInsertHypothesis, validateObjectPutHypothesis, validateApiCreateHypothesis, describeRuntimeDataSeedHypothesisProblem, runtimeDataSeedDeviationBanner, CHECKLIST_VERDICTS, rollupChecklistDecisions, UNASSESSED_REASONS, CWE_PROFILES, CLASS_FALLBACK, enrichItem, ASSESSMENT_SCHEMA_VERSION, emptyByVerdict, summarize, toAssessmentDocument, rollupRuntime, combinedRuntimeStance, DEFAULT_PENTEST_POLICY, PENTEST_POLICY_PROVENANCE, resolvePentestPolicy, policyProvenanceNote, PENTEST_POLICY_CONSUMERS, PENTEST_POLICY_CONDITIONAL_CONSUMERS, flattenPolicy, readPath, policyOverriddenPaths, appliedPolicyThresholds, PROVENANCE_POLICIES, isProvenancePolicy, canonicalDastId, normalizeRouteTemplate, dastExecutionTargetId, dastScenarioId, dastScenarioVerdict, DAST_TARGET_COVERAGES, classifyDastCoverage, COVERAGE_FIELD, rollupDastCoverage, dastReportHash, dastScanPlanHash, dastTargetManifestHash, resolveDastProvenance, cmpStr, COVERAGE_BINDING_WINDOW_MS, parseInstant, hasExplicitOffset, resolveDastCoverageProvenance, TRUST_TIERS, isTrustTier, PRODUCER_AUTHORITIES, isProducerAuthority, assuranceForAuthority, AUTHORITY_BY_TIER, isAuthorityPermitted, ORACLE_CATALOG, verdictContextFor, isProvenanceSound, deriveVerdict, VALIDATION_REJECT_CLASSES, DAST_NEGATIVE_ORACLE_CATALOG, dastNegativeOracleSpecFor, evaluateDastNegativeOracle, sastCorroborationState, rollupE1Provenance, canonicalE1Id, cmpStr2, e1SuiteHash, parseIso, hasExplicitOffset2, AMBIGUOUS_TIMESTAMP_TOLERANCE_MS, STATUS_RANK, resolveCurrentRunId, classify, resolveE1Provenance, HYPOTHESIS_KINDS, HYPOTHESIS_ENVELOPE_SCHEMA_VERSION, MAX_TEXT_LEN, MAX_ATTEMPTS, MAX_TEMPERATURE, SHA256_HEX_RE, EXPLICIT_OFFSET_RE, CONTROL_RE3, isRecord4, isSafeText3, isSha256Hex, stableStringify, canonicalHypothesisInput, hypothesisInputHash, hypothesisContentHash, validateHypothesisProvenance, readPinnedHypothesis, resolveHypothesisProvenance, describeHypothesisProvenance, TRUST_RANK, canonicalHarnessPlan, validateHarnessPlan, KAFKA_BROKER_STATES, isKafkaBrokerState, CLEAN_STATES, KNOWN_KAFKA_LANES, isKnownKafkaLane, parseKafkaStateArg, CONSEQUENCE, brokerStateDeviation, unrecognizedDeviation, inconsistentDeviation, inconsistentFlagDeviation, kafkaStateDeviations, RUNTIME_OUTCOME_SCHEMA_VERSION, RUNTIME_TIERS, isRuntimeTier, RUNTIME_STOP_REASONS, isRuntimeStopReason, tierForStopReason, REQUIRED_DELIVERABLES, reachedTier, classifyRuntimeOutcome, classifyPreflight, BOOT_CAUSE_SOURCES, isBootCauseSource, validateRuntimeOutcome, PERF_SCHEMA_VERSION, LOAD_PLAN_SCHEMA_VERSION, ENV_CLASSES, isEnvClass, SOAK_DURATION_MARGIN_SECONDS, SOAK_DEFAULT_DRIFT_RATIO, SPIKE_MAX_PEAK_SECONDS, SPIKE_PHASE, TOKEN_REFRESH_MARGIN_SECONDS, TOKEN_REFRESH_MAX_FAILURES, MIN_RAMP_SECONDS, WRITE_METHODS, WRITE_ALLOWED_ENV_CLASSES, computePlanHash, TOOL_DEFAULT_SLO, LOAD_RUN_SCHEMA_VERSION, SYSTEMIC_REQUEST_CLASSES, MAX_DROPPED_ITERATION_SHARE,
|
|
1039
|
+
var SEVERITY_ORDER, severityRank, meetsSeverity, LANGUAGES, languageFromExtension, languageFromPath, SOURCE_TOOLS, CORE_PACK, rulePackOf, compareFindings, normalizePath, createFindingContextEnricher, formatFindingSnippet, editsOverlap, AI_GATE_POLICIES, isAiGatePolicy, AI_SKIP_GATE_POLICIES, isAiSkipGatePolicy, aiCoverageGates, findingGates, toRunIngestDto, AI_SKIP_REASONS, isRecallRiskSkip, isRetryableSkip, countRecallRiskSkips, LAYER_FLOW_MAP, sortEdges, createAstDependencyGraph, scenarioVerdictFromOutcome, CLIENT_TIERS, isClientTier, summarizeClientCoverage, summarizeComponentCoverage, CLIENT_TEST_OUTCOMES, isClientTestOutcome, CLIENT_ORACLE_FAILURE_MARKER, CLIENT_RT_ORACLE_FAILURE_MARKER, isClientOracleFailure, isClientRtOracleFailure, clientScenarioVerdictFromOutcome, clientScenarioVerdictFromTieredOutcome, AUTH_FILL_KINDS, isAuthFillKind, STR, STR_LIST, MOCK_USER_RE, ANONYMOUS_RE, JWT_AUTHORITY, JWT_AUTHORITY_LIST, JWT_RE, WMU_ARG, WITH_MOCK_USER_RE, WITH_USER_DETAILS_RE, ALLOWED_IMPORT_RE, isRecord, isSafeLine, validateImports, validateAuthFill, MAX_STATE_WRITES, MAX_HASH_FIELDS, MAX_CLAIMS, MAX_CLAIM_ARRAY, MAX_EVIDENCE, MAX_KEY_LEN, MAX_VALUE_LEN, MAX_EVIDENCE_LEN, TRANSPORTS, ALGORITHMS, VALUE_SOURCES, NAME_RE, CLAIM_NAME_RE, SCHEME_RE, FORBIDDEN_KEY_RE, CONTROL_RE, isRecord2, isSafeText, isSafeKey, isSafeField, INVALID, normaliseKeyFromClaim, normaliseClaimValue, normaliseClaims, normaliseHashFields, normaliseStateWrite, normaliseEvidence, validateRuntimeAuthHypothesis, resolveStateWriteKeys, describeRuntimeAuthHypothesisProblem, MAX_TARGETS, MAX_ROWS, MAX_COLUMNS, MAX_EVIDENCE2, MAX_STRING_VALUE, MAX_EVIDENCE_LEN2, MAX_OBJECT_KEY, MAX_SEED_OBJECT_BYTES, MAX_CONTENT_BASE64, MAX_JSON_BODY_CHARS, MAX_JSON_STRING_VALUE, MAX_JSON_BODY_DEPTH, SQL_IDENTIFIER_RE, isSqlIdentifier, OBJECT_BUCKET_RE, isIpShaped, isObjectBucket, isObjectKey, BASE64_RE, isBase64Content, CONTENT_TYPE_RE, isObjectContentType, PATH_RE, METHOD_RE, CONTROL_RE2, isRecord3, isSafeText2, normaliseValue, normaliseRow, normaliseEvidence2, normaliseTarget, normaliseObjectTarget, jsonShapeOk, normaliseApiCreateRequest, normaliseApiCreateTarget, validateRuntimeDataSeedHypothesis, validateSqlInsertHypothesis, validateObjectPutHypothesis, validateApiCreateHypothesis, describeRuntimeDataSeedHypothesisProblem, runtimeDataSeedDeviationBanner, CHECKLIST_VERDICTS, rollupChecklistDecisions, UNASSESSED_REASONS, CWE_PROFILES, CLASS_FALLBACK, enrichItem, ASSESSMENT_SCHEMA_VERSION, emptyByVerdict, summarize, toAssessmentDocument, rollupRuntime, combinedRuntimeStance, DEFAULT_PENTEST_POLICY, PENTEST_POLICY_PROVENANCE, resolvePentestPolicy, policyProvenanceNote, PENTEST_POLICY_CONSUMERS, PENTEST_POLICY_CONDITIONAL_CONSUMERS, flattenPolicy, readPath, policyOverriddenPaths, appliedPolicyThresholds, PROVENANCE_POLICIES, isProvenancePolicy, canonicalDastId, normalizeRouteTemplate, dastExecutionTargetId, dastScenarioId, dastScenarioVerdict, DAST_TARGET_COVERAGES, classifyDastCoverage, COVERAGE_FIELD, rollupDastCoverage, dastReportHash, dastScanPlanHash, dastTargetManifestHash, resolveDastProvenance, cmpStr, COVERAGE_BINDING_WINDOW_MS, parseInstant, hasExplicitOffset, resolveDastCoverageProvenance, TRUST_TIERS, isTrustTier, PRODUCER_AUTHORITIES, isProducerAuthority, assuranceForAuthority, AUTHORITY_BY_TIER, isAuthorityPermitted, ORACLE_CATALOG, verdictContextFor, isProvenanceSound, deriveVerdict, VALIDATION_REJECT_CLASSES, DAST_NEGATIVE_ORACLE_CATALOG, dastNegativeOracleSpecFor, evaluateDastNegativeOracle, sastCorroborationState, rollupE1Provenance, canonicalE1Id, cmpStr2, e1SuiteHash, parseIso, hasExplicitOffset2, AMBIGUOUS_TIMESTAMP_TOLERANCE_MS, STATUS_RANK, resolveCurrentRunId, classify, resolveE1Provenance, HYPOTHESIS_KINDS, HYPOTHESIS_ENVELOPE_SCHEMA_VERSION, MAX_TEXT_LEN, MAX_ATTEMPTS, MAX_TEMPERATURE, SHA256_HEX_RE, EXPLICIT_OFFSET_RE, CONTROL_RE3, isRecord4, isSafeText3, isSha256Hex, stableStringify, canonicalHypothesisInput, hypothesisInputHash, hypothesisContentHash, validateHypothesisProvenance, readPinnedHypothesis, resolveHypothesisProvenance, describeHypothesisProvenance, TRUST_RANK, canonicalHarnessPlan, validateHarnessPlan, KAFKA_BROKER_STATES, isKafkaBrokerState, CLEAN_STATES, KNOWN_KAFKA_LANES, isKnownKafkaLane, parseKafkaStateArg, CONSEQUENCE, brokerStateDeviation, unrecognizedDeviation, inconsistentDeviation, inconsistentFlagDeviation, kafkaStateDeviations, RUNTIME_OUTCOME_SCHEMA_VERSION, RUNTIME_TIERS, isRuntimeTier, RUNTIME_STOP_REASONS, isRuntimeStopReason, tierForStopReason, REQUIRED_DELIVERABLES, runtimeEnvBlockerNames, reachedTier, classifyRuntimeOutcome, classifyPreflight, BOOT_CAUSE_SOURCES, isBootCauseSource, validateRuntimeOutcome, PERF_SCHEMA_VERSION, LOAD_PLAN_SCHEMA_VERSION, ENV_CLASSES, isEnvClass, SOAK_DURATION_MARGIN_SECONDS, SOAK_DEFAULT_DRIFT_RATIO, SPIKE_MAX_PEAK_SECONDS, SPIKE_PHASE, TOKEN_REFRESH_MARGIN_SECONDS, TOKEN_REFRESH_MAX_FAILURES, MIN_RAMP_SECONDS, WRITE_METHODS, WRITE_ALLOWED_ENV_CLASSES, computePlanHash, TOOL_DEFAULT_SLO, LOAD_RUN_SCHEMA_VERSION, SYSTEMIC_REQUEST_CLASSES, MAX_DROPPED_ITERATION_SHARE, normalizePath2, normalizedEntry, normalizedModuleRoot, DEFAULT_RELEASE_HEADROOM, NETWORK_PATH_UNDECLARED, stepAt, MIN_SOAK_VALID_WINDOWS, errorRate, total, SERVER_SIGNALS, FINDING_MECHANISM, normMethod, computeRuleSetHash, buildRuleResults, reviewProject;
|
|
1040
1040
|
var init_dist2 = __esm({
|
|
1041
1041
|
"../core/dist/index.js"() {
|
|
1042
1042
|
init_dist();
|
|
@@ -1160,6 +1160,40 @@ var init_dist2 = __esm({
|
|
|
1160
1160
|
if (a.ruleId !== b.ruleId) return a.ruleId < b.ruleId ? -1 : 1;
|
|
1161
1161
|
return 0;
|
|
1162
1162
|
};
|
|
1163
|
+
normalizePath = (path) => path.replace(/\\/g, "/").replace(/^\.\//, "");
|
|
1164
|
+
createFindingContextEnricher = (files) => {
|
|
1165
|
+
const sources = new Map(files.map((file) => [normalizePath(file.path), file]));
|
|
1166
|
+
const linesByPath = /* @__PURE__ */ new Map();
|
|
1167
|
+
return (finding) => {
|
|
1168
|
+
const path = normalizePath(finding.file);
|
|
1169
|
+
const source = sources.get(path);
|
|
1170
|
+
const line2 = finding.range.line;
|
|
1171
|
+
if (!source || !Number.isSafeInteger(line2) || line2 < 1) return finding;
|
|
1172
|
+
let lines = linesByPath.get(path);
|
|
1173
|
+
if (!lines) {
|
|
1174
|
+
lines = (source.originalContent ?? source.content).replace(/\r\n/g, "\n").split("\n");
|
|
1175
|
+
if (lines.length > 1 && lines.at(-1) === "") lines = lines.slice(0, -1);
|
|
1176
|
+
linesByPath.set(path, lines);
|
|
1177
|
+
}
|
|
1178
|
+
if (line2 > lines.length) return finding;
|
|
1179
|
+
const start = Math.max(0, Math.min(line2 - 5, lines.length - 10));
|
|
1180
|
+
const snippet = lines.slice(start, start + 10).map((text2) => text2.length > 1600 ? `${text2.slice(0, 1599)}\u2026` : text2).join("\n");
|
|
1181
|
+
if (!snippet.trim()) return finding;
|
|
1182
|
+
return { ...finding, snippet, snippetStartLine: start + 1 };
|
|
1183
|
+
};
|
|
1184
|
+
};
|
|
1185
|
+
formatFindingSnippet = (finding) => {
|
|
1186
|
+
if (!finding.snippet) return void 0;
|
|
1187
|
+
if (finding.snippetStartLine === void 0) return finding.snippet;
|
|
1188
|
+
const start = finding.snippetStartLine;
|
|
1189
|
+
const lines = finding.snippet.split("\n");
|
|
1190
|
+
const width = String(start + lines.length - 1).length;
|
|
1191
|
+
return lines.map((text2, index2) => {
|
|
1192
|
+
const line2 = start + index2;
|
|
1193
|
+
const marker = line2 >= finding.range.line && line2 <= (finding.range.endLine ?? finding.range.line) ? ">" : " ";
|
|
1194
|
+
return `${marker} ${String(line2).padStart(width)} | ${text2}`;
|
|
1195
|
+
}).join("\n");
|
|
1196
|
+
};
|
|
1163
1197
|
editsOverlap = (a, b) => {
|
|
1164
1198
|
if (a.file !== b.file) return false;
|
|
1165
1199
|
const aStartsAfterBEnd = a.startLine > b.endLine || a.startLine === b.endLine && a.startColumn >= b.endColumn;
|
|
@@ -3060,6 +3094,7 @@ var init_dist2 = __esm({
|
|
|
3060
3094
|
"nothing-to-verify",
|
|
3061
3095
|
"auth-gate",
|
|
3062
3096
|
"baseline-unreachable",
|
|
3097
|
+
"synthetic-env-blocked",
|
|
3063
3098
|
"complete",
|
|
3064
3099
|
"runner-fault"
|
|
3065
3100
|
];
|
|
@@ -3077,6 +3112,7 @@ var init_dist2 = __esm({
|
|
|
3077
3112
|
case "nothing-to-verify":
|
|
3078
3113
|
case "auth-gate":
|
|
3079
3114
|
case "baseline-unreachable":
|
|
3115
|
+
case "synthetic-env-blocked":
|
|
3080
3116
|
return "T3";
|
|
3081
3117
|
case "complete":
|
|
3082
3118
|
return "T4";
|
|
@@ -3098,6 +3134,22 @@ var init_dist2 = __esm({
|
|
|
3098
3134
|
"correlation"
|
|
3099
3135
|
]
|
|
3100
3136
|
};
|
|
3137
|
+
runtimeEnvBlockerNames = (evidence18) => {
|
|
3138
|
+
const names = /* @__PURE__ */ new Set();
|
|
3139
|
+
for (const row2 of evidence18) {
|
|
3140
|
+
if (row2.source !== "correlation.runtimeEnvBlockers") continue;
|
|
3141
|
+
try {
|
|
3142
|
+
const raw = JSON.parse(row2.verbatim);
|
|
3143
|
+
if (!Array.isArray(raw) || raw.length > 256 || !raw.every(
|
|
3144
|
+
(value) => typeof value === "string" && /^[A-Za-z_][A-Za-z0-9_]{0,255}$/.test(value)
|
|
3145
|
+
))
|
|
3146
|
+
continue;
|
|
3147
|
+
for (const value of raw) names.add(value);
|
|
3148
|
+
} catch {
|
|
3149
|
+
}
|
|
3150
|
+
}
|
|
3151
|
+
return [...names].sort().slice(0, 256);
|
|
3152
|
+
};
|
|
3101
3153
|
reachedTier = (s) => {
|
|
3102
3154
|
if (!s.archiveReadable || s.sourceFilesFound === 0) return "T0";
|
|
3103
3155
|
if (!s.staticAssessmentCompleted) return "T0";
|
|
@@ -3122,6 +3174,9 @@ var init_dist2 = __esm({
|
|
|
3122
3174
|
if (s.scenariosGenerated === 0) return { tier: "T3", stopReason: "nothing-to-verify" };
|
|
3123
3175
|
if (s.scenariosConcluded === 0) {
|
|
3124
3176
|
if (s.appDiedAbnormally === true) return { tier: "T3", stopReason: "runner-fault" };
|
|
3177
|
+
if ((s.syntheticEnvBlockedCount ?? 0) > 0) {
|
|
3178
|
+
return { tier: "T3", stopReason: "synthetic-env-blocked" };
|
|
3179
|
+
}
|
|
3125
3180
|
const baseline = s.authBaselineStatus;
|
|
3126
3181
|
const e2Scanned = s.e2ScannedCount;
|
|
3127
3182
|
const e2Gated = s.e2AuthGatedCount;
|
|
@@ -3194,6 +3249,12 @@ var init_dist2 = __esm({
|
|
|
3194
3249
|
detail: `stopReason '${o.stopReason}' carries no evidence`
|
|
3195
3250
|
});
|
|
3196
3251
|
}
|
|
3252
|
+
if (o.stopReason === "synthetic-env-blocked" && runtimeEnvBlockerNames(o.evidence).length === 0) {
|
|
3253
|
+
violations.push({
|
|
3254
|
+
invariant: "I4",
|
|
3255
|
+
detail: "stopReason 'synthetic-env-blocked' must carry named correlation.runtimeEnvBlockers"
|
|
3256
|
+
});
|
|
3257
|
+
}
|
|
3197
3258
|
if (o.stopReason === "boot-blocked" && !o.evidence.some((e) => isBootCauseSource(e.source))) {
|
|
3198
3259
|
violations.push({
|
|
3199
3260
|
invariant: "I4",
|
|
@@ -3247,9 +3308,9 @@ var init_dist2 = __esm({
|
|
|
3247
3308
|
"timeout"
|
|
3248
3309
|
];
|
|
3249
3310
|
MAX_DROPPED_ITERATION_SHARE = 0.01;
|
|
3250
|
-
|
|
3311
|
+
normalizePath2 = (path) => path.replaceAll("\\", "/").replace(/\/{2,}/g, "/").replace(/\/+$/, "");
|
|
3251
3312
|
normalizedEntry = (path) => {
|
|
3252
|
-
let p =
|
|
3313
|
+
let p = normalizePath2(path);
|
|
3253
3314
|
while (p.startsWith("./")) p = p.slice(2);
|
|
3254
3315
|
if (p === "" || p === ".") return null;
|
|
3255
3316
|
const segments = p.split("/");
|
|
@@ -3260,7 +3321,7 @@ var init_dist2 = __esm({
|
|
|
3260
3321
|
};
|
|
3261
3322
|
normalizedModuleRoot = (moduleRoot) => {
|
|
3262
3323
|
if (moduleRoot === void 0) return "";
|
|
3263
|
-
let p =
|
|
3324
|
+
let p = normalizePath2(moduleRoot);
|
|
3264
3325
|
while (p.startsWith("./")) p = p.slice(2);
|
|
3265
3326
|
if (p === "" || p === ".") return "";
|
|
3266
3327
|
if (p.startsWith("/") || /^[a-zA-Z]:/.test(p)) return null;
|
|
@@ -3409,12 +3470,16 @@ var init_dist2 = __esm({
|
|
|
3409
3470
|
);
|
|
3410
3471
|
const findings2 = [...input4.initialFindings ?? []];
|
|
3411
3472
|
const addedFindings = [];
|
|
3473
|
+
const enrichFinding = createFindingContextEnricher([
|
|
3474
|
+
...input4.contextFiles ?? [],
|
|
3475
|
+
...input4.files
|
|
3476
|
+
]);
|
|
3412
3477
|
const findingKeys = new Set(
|
|
3413
3478
|
findings2.map(
|
|
3414
3479
|
(finding) => `${finding.ruleId}\0${finding.file}\0${finding.range.line}\0${finding.range.endLine ?? ""}\0${finding.message}\0${finding.suggestion ?? ""}`
|
|
3415
3480
|
)
|
|
3416
3481
|
);
|
|
3417
|
-
for await (const
|
|
3482
|
+
for await (const rawFinding of executor.execute(executionRules, input4.files, {
|
|
3418
3483
|
runId,
|
|
3419
3484
|
projectRoot: input4.projectPath,
|
|
3420
3485
|
...input4.minSeverity !== void 0 ? { minSeverity: input4.minSeverity } : {},
|
|
@@ -3427,9 +3492,10 @@ var init_dist2 = __esm({
|
|
|
3427
3492
|
// Each is optional; passing them conditionally keeps Zod's
|
|
3428
3493
|
// strict-undefined contract happy when the executor's options
|
|
3429
3494
|
// pass through a schema check downstream.
|
|
3430
|
-
...input4.onFinding !== void 0 ? { onFinding: input4.onFinding } : {},
|
|
3495
|
+
...input4.onFinding !== void 0 ? { onFinding: (finding) => input4.onFinding?.(enrichFinding(finding)) } : {},
|
|
3431
3496
|
...input4.onFileComplete !== void 0 ? { onFileComplete: input4.onFileComplete } : {}
|
|
3432
3497
|
})) {
|
|
3498
|
+
const finding = enrichFinding(rawFinding);
|
|
3433
3499
|
const key = `${finding.ruleId}\0${finding.file}\0${finding.range.line}\0${finding.range.endLine ?? ""}\0${finding.message}\0${finding.suggestion ?? ""}`;
|
|
3434
3500
|
if (findingKeys.has(key)) continue;
|
|
3435
3501
|
findingKeys.add(key);
|
|
@@ -10276,12 +10342,12 @@ async function createDefaultTaintAnalyzer() {
|
|
|
10276
10342
|
createJavaTaintAnalyzer(javaLanguage)
|
|
10277
10343
|
]);
|
|
10278
10344
|
}
|
|
10279
|
-
function
|
|
10345
|
+
function normalizePath3(p) {
|
|
10280
10346
|
return posix.normalize(p.replace(/\\/g, "/")).replace(/^\.\//, "");
|
|
10281
10347
|
}
|
|
10282
10348
|
function resolveTemplatePath(componentPath, templateUrl) {
|
|
10283
|
-
const dir = posix.dirname(
|
|
10284
|
-
return
|
|
10349
|
+
const dir = posix.dirname(normalizePath3(componentPath));
|
|
10350
|
+
return normalizePath3(posix.join(dir, templateUrl.replace(/\\/g, "/")));
|
|
10285
10351
|
}
|
|
10286
10352
|
function templateUrlMatches(componentFile, htmlPath) {
|
|
10287
10353
|
const re = /templateUrl\s*:\s*['"`]([^'"`]+)['"`]/g;
|
|
@@ -10424,7 +10490,7 @@ function createTemplateComponentLinker() {
|
|
|
10424
10490
|
return {
|
|
10425
10491
|
link(htmlFile, options) {
|
|
10426
10492
|
if (htmlFile.language !== "html") return null;
|
|
10427
|
-
const htmlPath =
|
|
10493
|
+
const htmlPath = normalizePath3(htmlFile.path);
|
|
10428
10494
|
try {
|
|
10429
10495
|
for (const f of options.files) {
|
|
10430
10496
|
if (f.language !== "typescript" && f.language !== "javascript") continue;
|
|
@@ -10839,7 +10905,7 @@ function resolveVueRoutes(files, options = {}) {
|
|
|
10839
10905
|
}
|
|
10840
10906
|
};
|
|
10841
10907
|
}
|
|
10842
|
-
function
|
|
10908
|
+
function normalizePath32(p) {
|
|
10843
10909
|
return posix.normalize(p.replace(/\\/g, "/")).replace(/^\.\//, "");
|
|
10844
10910
|
}
|
|
10845
10911
|
function pathSegments2(value) {
|
|
@@ -10970,9 +11036,9 @@ function loadTsConfig(projectRoot) {
|
|
|
10970
11036
|
const paths = /* @__PURE__ */ new Map();
|
|
10971
11037
|
let baseUrl = "";
|
|
10972
11038
|
const visited = /* @__PURE__ */ new Set();
|
|
10973
|
-
const root =
|
|
11039
|
+
const root = normalizePath32(projectRoot);
|
|
10974
11040
|
const load = (tsRelToRoot) => {
|
|
10975
|
-
const norm2 =
|
|
11041
|
+
const norm2 = normalizePath32(tsRelToRoot);
|
|
10976
11042
|
if (visited.has(norm2) || visited.size > 8) return;
|
|
10977
11043
|
visited.add(norm2);
|
|
10978
11044
|
let json;
|
|
@@ -10984,16 +11050,16 @@ function loadTsConfig(projectRoot) {
|
|
|
10984
11050
|
const dir = posix.dirname(norm2);
|
|
10985
11051
|
if (typeof json.extends === "string" && json.extends.startsWith(".")) {
|
|
10986
11052
|
const ext = json.extends.endsWith(".json") ? json.extends : `${json.extends}.json`;
|
|
10987
|
-
load(
|
|
11053
|
+
load(normalizePath32(posix.join(dir, ext)));
|
|
10988
11054
|
}
|
|
10989
11055
|
const co = json.compilerOptions ?? {};
|
|
10990
11056
|
const fileBaseUrl = typeof co.baseUrl === "string" ? co.baseUrl : ".";
|
|
10991
|
-
if (typeof co.baseUrl === "string") baseUrl =
|
|
11057
|
+
if (typeof co.baseUrl === "string") baseUrl = normalizePath32(posix.join(dir, co.baseUrl));
|
|
10992
11058
|
const rawPaths = co.paths;
|
|
10993
11059
|
if (rawPaths && typeof rawPaths === "object" && !Array.isArray(rawPaths)) {
|
|
10994
11060
|
for (const [pattern, targets] of Object.entries(rawPaths)) {
|
|
10995
11061
|
if (!Array.isArray(targets)) continue;
|
|
10996
|
-
const resolved = targets.filter((t) => typeof t === "string").map((t) =>
|
|
11062
|
+
const resolved = targets.filter((t) => typeof t === "string").map((t) => normalizePath32(posix.join(dir, fileBaseUrl, t)));
|
|
10997
11063
|
if (resolved.length > 0) paths.set(pattern, resolved);
|
|
10998
11064
|
}
|
|
10999
11065
|
}
|
|
@@ -11014,7 +11080,7 @@ function matchPathPattern2(specifier, pattern) {
|
|
|
11014
11080
|
}
|
|
11015
11081
|
function resolveSpecifier(fromPath, specifier, filesByPath, tsconfig) {
|
|
11016
11082
|
if (specifier.startsWith(".")) {
|
|
11017
|
-
const base =
|
|
11083
|
+
const base = normalizePath32(posix.join(posix.dirname(fromPath), specifier));
|
|
11018
11084
|
for (const c of candidatePaths2(base)) if (filesByPath.has(c)) return c;
|
|
11019
11085
|
return null;
|
|
11020
11086
|
}
|
|
@@ -11024,11 +11090,11 @@ function resolveSpecifier(fromPath, specifier, filesByPath, tsconfig) {
|
|
|
11024
11090
|
if (!matched) continue;
|
|
11025
11091
|
for (const target of mapping.targets) {
|
|
11026
11092
|
const applied = target.includes("*") ? target.replace("*", matched.wildcard) : target;
|
|
11027
|
-
for (const c of candidatePaths2(
|
|
11093
|
+
for (const c of candidatePaths2(normalizePath32(applied))) if (filesByPath.has(c)) return c;
|
|
11028
11094
|
}
|
|
11029
11095
|
}
|
|
11030
11096
|
if (tsconfig.baseUrl) {
|
|
11031
|
-
for (const c of candidatePaths2(
|
|
11097
|
+
for (const c of candidatePaths2(normalizePath32(posix.join(tsconfig.baseUrl, specifier)))) {
|
|
11032
11098
|
if (filesByPath.has(c)) return c;
|
|
11033
11099
|
}
|
|
11034
11100
|
}
|
|
@@ -11286,7 +11352,7 @@ function resolveComponentFile2(eng, specifier, fromPath) {
|
|
|
11286
11352
|
if (specifier.startsWith(".")) {
|
|
11287
11353
|
const resolved = resolveSpecifier(fromPath, specifier, eng.filesByPath, eng.tsconfig);
|
|
11288
11354
|
if (resolved) return resolved;
|
|
11289
|
-
const base =
|
|
11355
|
+
const base = normalizePath32(posix.join(posix.dirname(fromPath), specifier));
|
|
11290
11356
|
return TS_EXT_CANDIDATES2.includes(posix.extname(base)) ? base : `${base}.ts`;
|
|
11291
11357
|
}
|
|
11292
11358
|
return resolveSpecifier(fromPath, specifier, eng.filesByPath, eng.tsconfig) ?? specifier;
|
|
@@ -11502,7 +11568,7 @@ function resolveComponentRoutes(files, options = {}) {
|
|
|
11502
11568
|
const filesByPath = /* @__PURE__ */ new Map();
|
|
11503
11569
|
for (const f of files) {
|
|
11504
11570
|
if (TS_LANGS2.has(f.language) && !isVueSfcPath(f.path))
|
|
11505
|
-
filesByPath.set(
|
|
11571
|
+
filesByPath.set(normalizePath32(f.path), f);
|
|
11506
11572
|
}
|
|
11507
11573
|
let tsconfig = options.tsconfig;
|
|
11508
11574
|
if (!tsconfig && options.projectRoot) {
|
|
@@ -11516,7 +11582,7 @@ function resolveComponentRoutes(files, options = {}) {
|
|
|
11516
11582
|
const sfCache = /* @__PURE__ */ new Map();
|
|
11517
11583
|
const ctxCache = /* @__PURE__ */ new Map();
|
|
11518
11584
|
const getSf = (path2) => {
|
|
11519
|
-
const norm2 =
|
|
11585
|
+
const norm2 = normalizePath32(path2);
|
|
11520
11586
|
if (sfCache.has(norm2)) return sfCache.get(norm2) ?? null;
|
|
11521
11587
|
const file = filesByPath.get(norm2);
|
|
11522
11588
|
let sf = null;
|
|
@@ -11531,7 +11597,7 @@ function resolveComponentRoutes(files, options = {}) {
|
|
|
11531
11597
|
return sf;
|
|
11532
11598
|
};
|
|
11533
11599
|
const getContext = (path2) => {
|
|
11534
|
-
const norm2 =
|
|
11600
|
+
const norm2 = normalizePath32(path2);
|
|
11535
11601
|
if (ctxCache.has(norm2)) return ctxCache.get(norm2) ?? null;
|
|
11536
11602
|
const sf = getSf(norm2);
|
|
11537
11603
|
const ctx = sf ? buildFileContext2(sf, norm2) : null;
|
|
@@ -24540,7 +24606,7 @@ ${window}`;
|
|
|
24540
24606
|
DEFAULT_PACKAGE_POLICY = {
|
|
24541
24607
|
exclude: DEFAULT_PACKAGE_EXCLUDES,
|
|
24542
24608
|
maxFileBytes: MAX_FILE_BYTES,
|
|
24543
|
-
maxArchiveBytes:
|
|
24609
|
+
maxArchiveBytes: 1024 * 1024 * 1024
|
|
24544
24610
|
};
|
|
24545
24611
|
toPosix22 = (p) => p.split(sep).join(posix.sep);
|
|
24546
24612
|
isFile2 = (p) => {
|
|
@@ -37608,7 +37674,7 @@ Language guard retry: the previous response contained an empty or English explan
|
|
|
37608
37674
|
return { status: "error", vulnerable: false, reason: `L\u1ED7i th\u1EF1c thi LLM: ${message}` };
|
|
37609
37675
|
}
|
|
37610
37676
|
}
|
|
37611
|
-
var OLLAMA_DEFAULT_BASE, NETMIND_DEFAULT_BASE, OPENCODE_GO_DEFAULT_BASE, stripTrailingSlash2, buildLanguageModel, resolveModelOverride, pingTarget, shouldUseRawJsonChat, openAICompatibleChatUrl, REASONING_HEADROOM_TOKENS, NETMIND_MINIMAX_M3_MODEL, NETMIND_SMALL_PROMPT_MAX_CHARS, NETMIND_MEDIUM_PROMPT_MAX_CHARS, NETMIND_SMALL_OUTPUT_TOKENS, NETMIND_MEDIUM_OUTPUT_TOKENS, NETMIND_LARGE_OUTPUT_TOKENS, NETMIND_MAX_OUTPUT_TOKENS, supportsNetmindJsonResponseFormat, emptyResponseDiagnostics, effectiveMaxTokensFor, completeRawOpenAICompatibleJsonChat, createAiSdkProvider, createFallbackClient, DEFAULT_RESET_SAFETY_MS, parseProviderRetryDelayMs, numberLines, renderPrompt, cache, loadPromptTemplate, nullableOptional, AI_VIOLATION_MESSAGE_MAX_LENGTH, aiViolationSchema, aiResponseSchema, stripCodeFence, parseAiResponse, createInMemoryCache, VIETNAMESE_OUTPUT_POLICY_VERSION, VIETNAMESE_OUTPUT_INSTRUCTION, TOKEN_BUDGET_WARN_DEFAULT, CHARS_PER_TOKEN, SAFETY_MARGIN, estimateTokens, formatTokenWarning, braceDelta, chunkSourceForAi, renderAuthorizationGuards, CACHE_NAMESPACE, DEFAULT_PROVIDER_RETRY_MAX_RETRIES, DEFAULT_PROVIDER_RETRY_MAX_DELAY_MS, DEFAULT_ADAPTIVE_RETRY_MAX_RETRIES, DEFAULT_ADAPTIVE_CONTEXT_REDUCTION_FACTOR, DEFAULT_ADAPTIVE_TIMEOUT_MULTIPLIER, DEFAULT_ADAPTIVE_MAX_DELAY_MS, DEFAULT_PROVIDER_TIMEOUT_MS, sleep2, providerRetryDelayMs, adaptiveFailureKind, compactClusterContext, findingDedupeKey, dedupeFindings, capFindings, createAiExecutor, PATH_FAST_PATHS, SPRING_BOOT_PATTERNS, ANGULAR_PATTERNS, FLUTTER_PATTERNS, ENTRY_HINTS, ALL_PATTERNS, matchesRule, classifyLayer, classifyLayers, PRIMARY_LAYER_CANDIDATES, TEST_AND_GENERATED, LAYER_SUFFIXES, FILE_SUFFIX_RE, ANY_EXT_RE, dropExt, stripPascalSuffix, normalize2, extractDomainTokens, extractDomainTokensBatch, TRIVIAL_TOKENS, sharesDomainToken, TS_IMPORT_RE, JAVA_IMPORT_RE, extractImports, POSIX_SEP_RE, sharedDirDepth, resolveImportTarget, KIND_STRENGTH, upsertEdge, buildEdges, ADVICE_ANNOTATION, isGlobalAdviceFile, findGlobalAdvicePaths, DEFAULT_MAX_CANDIDATES, DEFAULT_MAX_SUPPORT_FILES, DEFAULT_TOKEN_BUDGET, SCORE_DIRECT_NEIGHBOR, SCORE_SECOND_DEGREE, SCORE_SIBLING_STEM, SCORE_ANGULAR_TEMPLATE_SIBLING, SCORE_DOMAIN_TOKEN, PENALTY_TEST_VS_NON_TEST, PENALTY_GENERATED, SCORE_GLOBAL_ADVICE, prefilterCandidates, layerFlowBonus, isTest, isGenerated, scoreFor, tokensOf, trimToBudget, toMember, clusterIdFor, createClusterAssembler, CLUSTER_TREE_BUILDER_VERSION, DEFAULT_MODULE_DEPTH, posixDirname, moduleGroupKey, uniqueSortedPaths, memberFingerprint, featureNodeFor, moduleNodeFor, appNodeFor, countCrossModuleEdges, createClusterTreeBuilder, TRANSACTIONAL, TYPE_DECL3, METHOD_NAME2, MUTATION_CALL, LEADING_ANNOTATION2, SPRING_TX_SUPPORT_IMPORT, PROGRAMMATIC_TYPE, PROGRAMMATIC_CALL, INLINE_TEMPLATE_CALL, CONTROL_FLOW_NAMES, maskNonCode, methodNameFromHeader, methodAt, delegatedTargetAt, collectProgrammaticReceivers, readAttr, skipToDeclaration2, countMutations, lineOf25, configuredReadOnly, extractProgrammaticFromFile, extractFromFile2, extractTransactionBoundaries, renderPrDiffPrompt, nullableOptional2, prDiffResponseSchema, createPrDiffReviewer, renderGroupedRulePrompt, confidenceLabelSchema, severitySchema, groupedResponseSchema, labelToConfidence, createGroupedRuleReviewer, renderPerRulePrompt, createPerRuleReviewer, DEFAULT_MAX_TOKENS, SYSTEM_PROMPT, SCHEMA_PROMPT, clip, buildUserPrompt, extractJsonObject, describeUnusableAnswer, createRuntimeAuthHypothesisResolver, DEFAULT_MAX_TOKENS2, SYSTEM_PROMPT2, SCHEMA_PROMPT2, clip2, buildUserPrompt2, describeUnusableAnswer2, createRuntimeDataSeedResolver, endpointSchema, extractJsonObject2, HTTP_METHODS, PARAMETER_KINDS, ENGLISH_REASON_WORDS, ENGLISH_TECHNICAL_WORDS, VIETNAMESE_DIACRITICS, isLikelyEnglishReason, normalizeTriageReason, parseEndpointHint;
|
|
37677
|
+
var OLLAMA_DEFAULT_BASE, NETMIND_DEFAULT_BASE, OPENCODE_GO_DEFAULT_BASE, stripTrailingSlash2, buildLanguageModel, resolveModelOverride, pingTarget, shouldUseRawJsonChat, openAICompatibleChatUrl, REASONING_HEADROOM_TOKENS, NETMIND_MINIMAX_M3_MODEL, NETMIND_SMALL_PROMPT_MAX_CHARS, NETMIND_MEDIUM_PROMPT_MAX_CHARS, NETMIND_SMALL_OUTPUT_TOKENS, NETMIND_MEDIUM_OUTPUT_TOKENS, NETMIND_LARGE_OUTPUT_TOKENS, NETMIND_MAX_OUTPUT_TOKENS, supportsNetmindJsonResponseFormat, emptyResponseDiagnostics, effectiveMaxTokensFor, completeRawOpenAICompatibleJsonChat, createAiSdkProvider, createFallbackClient, DEFAULT_MAX_RETRIES, DEFAULT_BASE_DELAY_MS, DEFAULT_MAX_DELAY_MS, DEFAULT_RESET_SAFETY_MS, DEFAULT_JITTER_MS, sleep, isRateLimitError, parseProviderRetryDelayMs, rateLimitRetryDelayMs, createRateLimitRetryClient, numberLines, renderPrompt, cache, loadPromptTemplate, nullableOptional, AI_VIOLATION_MESSAGE_MAX_LENGTH, aiViolationSchema, aiResponseSchema, stripCodeFence, parseAiResponse, createInMemoryCache, VIETNAMESE_OUTPUT_POLICY_VERSION, VIETNAMESE_OUTPUT_INSTRUCTION, TOKEN_BUDGET_WARN_DEFAULT, CHARS_PER_TOKEN, SAFETY_MARGIN, estimateTokens, formatTokenWarning, braceDelta, chunkSourceForAi, renderAuthorizationGuards, CACHE_NAMESPACE, DEFAULT_PROVIDER_RETRY_MAX_RETRIES, DEFAULT_PROVIDER_RETRY_MAX_DELAY_MS, DEFAULT_ADAPTIVE_RETRY_MAX_RETRIES, DEFAULT_ADAPTIVE_CONTEXT_REDUCTION_FACTOR, DEFAULT_ADAPTIVE_TIMEOUT_MULTIPLIER, DEFAULT_ADAPTIVE_MAX_DELAY_MS, DEFAULT_PROVIDER_TIMEOUT_MS, sleep2, providerRetryDelayMs, adaptiveFailureKind, compactClusterContext, findingDedupeKey, dedupeFindings, capFindings, createAiExecutor, PATH_FAST_PATHS, SPRING_BOOT_PATTERNS, ANGULAR_PATTERNS, FLUTTER_PATTERNS, ENTRY_HINTS, ALL_PATTERNS, matchesRule, classifyLayer, classifyLayers, PRIMARY_LAYER_CANDIDATES, TEST_AND_GENERATED, LAYER_SUFFIXES, FILE_SUFFIX_RE, ANY_EXT_RE, dropExt, stripPascalSuffix, normalize2, extractDomainTokens, extractDomainTokensBatch, TRIVIAL_TOKENS, sharesDomainToken, TS_IMPORT_RE, JAVA_IMPORT_RE, extractImports, POSIX_SEP_RE, sharedDirDepth, resolveImportTarget, KIND_STRENGTH, upsertEdge, buildEdges, ADVICE_ANNOTATION, isGlobalAdviceFile, findGlobalAdvicePaths, DEFAULT_MAX_CANDIDATES, DEFAULT_MAX_SUPPORT_FILES, DEFAULT_TOKEN_BUDGET, SCORE_DIRECT_NEIGHBOR, SCORE_SECOND_DEGREE, SCORE_SIBLING_STEM, SCORE_ANGULAR_TEMPLATE_SIBLING, SCORE_DOMAIN_TOKEN, PENALTY_TEST_VS_NON_TEST, PENALTY_GENERATED, SCORE_GLOBAL_ADVICE, prefilterCandidates, layerFlowBonus, isTest, isGenerated, scoreFor, tokensOf, trimToBudget, toMember, clusterIdFor, createClusterAssembler, CLUSTER_TREE_BUILDER_VERSION, DEFAULT_MODULE_DEPTH, posixDirname, moduleGroupKey, uniqueSortedPaths, memberFingerprint, featureNodeFor, moduleNodeFor, appNodeFor, countCrossModuleEdges, createClusterTreeBuilder, TRANSACTIONAL, TYPE_DECL3, METHOD_NAME2, MUTATION_CALL, LEADING_ANNOTATION2, SPRING_TX_SUPPORT_IMPORT, PROGRAMMATIC_TYPE, PROGRAMMATIC_CALL, INLINE_TEMPLATE_CALL, CONTROL_FLOW_NAMES, maskNonCode, methodNameFromHeader, methodAt, delegatedTargetAt, collectProgrammaticReceivers, readAttr, skipToDeclaration2, countMutations, lineOf25, configuredReadOnly, extractProgrammaticFromFile, extractFromFile2, extractTransactionBoundaries, renderPrDiffPrompt, nullableOptional2, prDiffResponseSchema, createPrDiffReviewer, renderGroupedRulePrompt, confidenceLabelSchema, severitySchema, groupedResponseSchema, labelToConfidence, createGroupedRuleReviewer, renderPerRulePrompt, createPerRuleReviewer, DEFAULT_MAX_TOKENS, SYSTEM_PROMPT, SCHEMA_PROMPT, clip, buildUserPrompt, extractJsonObject, describeUnusableAnswer, createRuntimeAuthHypothesisResolver, DEFAULT_MAX_TOKENS2, SYSTEM_PROMPT2, SCHEMA_PROMPT2, clip2, buildUserPrompt2, describeUnusableAnswer2, createRuntimeDataSeedResolver, endpointSchema, extractJsonObject2, HTTP_METHODS, PARAMETER_KINDS, ENGLISH_REASON_WORDS, ENGLISH_TECHNICAL_WORDS, VIETNAMESE_DIACRITICS, isLikelyEnglishReason, normalizeTriageReason, parseEndpointHint, checkAiConnection;
|
|
37612
37678
|
var init_dist4 = __esm({
|
|
37613
37679
|
"../ai-engine/dist/index.js"() {
|
|
37614
37680
|
init_dist();
|
|
@@ -38057,7 +38123,13 @@ The previous attempt returned reasoning but no final answer. Return the final JS
|
|
|
38057
38123
|
}
|
|
38058
38124
|
};
|
|
38059
38125
|
};
|
|
38126
|
+
DEFAULT_MAX_RETRIES = 1;
|
|
38127
|
+
DEFAULT_BASE_DELAY_MS = 1e3;
|
|
38128
|
+
DEFAULT_MAX_DELAY_MS = 3e5;
|
|
38060
38129
|
DEFAULT_RESET_SAFETY_MS = 1e3;
|
|
38130
|
+
DEFAULT_JITTER_MS = 1e3;
|
|
38131
|
+
sleep = (ms) => new Promise((resolveSleep) => setTimeout(resolveSleep, ms));
|
|
38132
|
+
isRateLimitError = (message) => /(?:\bHTTP\s*429\b|\b429\b|rate[ -]?limit|too many requests)/i.test(message);
|
|
38061
38133
|
parseProviderRetryDelayMs = (message, now = Date.now(), resetSafetyMs = DEFAULT_RESET_SAFETY_MS) => {
|
|
38062
38134
|
const resetMatch = message.match(/limit resets at:\s*([^"}\n]+)/i);
|
|
38063
38135
|
if (resetMatch?.[1]) {
|
|
@@ -38086,6 +38158,60 @@ The previous attempt returned reasoning but no final answer. Return the final JS
|
|
|
38086
38158
|
}, 0);
|
|
38087
38159
|
return totalMs > 0 ? Math.ceil(totalMs) : null;
|
|
38088
38160
|
};
|
|
38161
|
+
rateLimitRetryDelayMs = (options) => {
|
|
38162
|
+
if (!isRateLimitError(options.message)) return null;
|
|
38163
|
+
const baseDelayMs = Math.max(1, options.baseDelayMs ?? DEFAULT_BASE_DELAY_MS);
|
|
38164
|
+
const maxDelayMs = Math.max(baseDelayMs, options.maxDelayMs ?? DEFAULT_MAX_DELAY_MS);
|
|
38165
|
+
const random = Math.min(1, Math.max(0, options.random ?? Math.random()));
|
|
38166
|
+
const jitterMs = Math.max(0, options.jitterMs ?? DEFAULT_JITTER_MS);
|
|
38167
|
+
const hintedDelay = parseProviderRetryDelayMs(
|
|
38168
|
+
options.message,
|
|
38169
|
+
options.now ?? Date.now(),
|
|
38170
|
+
options.resetSafetyMs ?? DEFAULT_RESET_SAFETY_MS
|
|
38171
|
+
);
|
|
38172
|
+
const exponentialDelay = Math.min(
|
|
38173
|
+
maxDelayMs,
|
|
38174
|
+
baseDelayMs * 2 ** Math.max(0, options.attempt - 1)
|
|
38175
|
+
);
|
|
38176
|
+
if (hintedDelay !== null && hintedDelay > maxDelayMs) return null;
|
|
38177
|
+
const delayMs = hintedDelay ?? exponentialDelay;
|
|
38178
|
+
return Math.min(maxDelayMs, delayMs + Math.floor(random * jitterMs));
|
|
38179
|
+
};
|
|
38180
|
+
createRateLimitRetryClient = (options) => {
|
|
38181
|
+
const maxRetries = Math.max(0, Math.floor(options.maxRetries ?? DEFAULT_MAX_RETRIES));
|
|
38182
|
+
const sleepFor = options.sleep ?? sleep;
|
|
38183
|
+
const now = options.now ?? Date.now;
|
|
38184
|
+
const random = options.random ?? Math.random;
|
|
38185
|
+
return {
|
|
38186
|
+
name: options.client.name,
|
|
38187
|
+
ping: () => options.client.ping(),
|
|
38188
|
+
async complete(request) {
|
|
38189
|
+
let result = await options.client.complete(request);
|
|
38190
|
+
for (let attempt = 1; !result.ok && attempt <= maxRetries; attempt += 1) {
|
|
38191
|
+
const delayMs = rateLimitRetryDelayMs({
|
|
38192
|
+
message: result.error.message,
|
|
38193
|
+
attempt,
|
|
38194
|
+
now: now(),
|
|
38195
|
+
random: random(),
|
|
38196
|
+
...options.baseDelayMs !== void 0 ? { baseDelayMs: options.baseDelayMs } : {},
|
|
38197
|
+
...options.maxDelayMs !== void 0 ? { maxDelayMs: options.maxDelayMs } : {},
|
|
38198
|
+
...options.resetSafetyMs !== void 0 ? { resetSafetyMs: options.resetSafetyMs } : {},
|
|
38199
|
+
...options.jitterMs !== void 0 ? { jitterMs: options.jitterMs } : {}
|
|
38200
|
+
});
|
|
38201
|
+
if (delayMs === null) break;
|
|
38202
|
+
options.onRetry?.({
|
|
38203
|
+
attempt,
|
|
38204
|
+
maxRetries,
|
|
38205
|
+
delayMs,
|
|
38206
|
+
error: result.error
|
|
38207
|
+
});
|
|
38208
|
+
await sleepFor(delayMs);
|
|
38209
|
+
result = await options.client.complete(request);
|
|
38210
|
+
}
|
|
38211
|
+
return result;
|
|
38212
|
+
}
|
|
38213
|
+
};
|
|
38214
|
+
};
|
|
38089
38215
|
numberLines = (text2) => {
|
|
38090
38216
|
const lines = text2.split("\n");
|
|
38091
38217
|
const maxWidth = String(lines.length).length;
|
|
@@ -40764,6 +40890,30 @@ ${buildUserPrompt2(request, options.maxEvidenceChars, logger)}`,
|
|
|
40764
40890
|
sinkLine
|
|
40765
40891
|
};
|
|
40766
40892
|
};
|
|
40893
|
+
checkAiConnection = async (client) => {
|
|
40894
|
+
try {
|
|
40895
|
+
const result = await client.complete({
|
|
40896
|
+
user: "Reply with OK.",
|
|
40897
|
+
model: "",
|
|
40898
|
+
maxTokens: 64,
|
|
40899
|
+
timeoutMs: 15e3
|
|
40900
|
+
});
|
|
40901
|
+
if (result.ok && result.value.text.trim().length > 0) {
|
|
40902
|
+
return { status: "connected", provider: client.name, message: "AI connection succeeded." };
|
|
40903
|
+
}
|
|
40904
|
+
return {
|
|
40905
|
+
status: "failed",
|
|
40906
|
+
provider: client.name,
|
|
40907
|
+
message: "AI connection failed. Check API key, model, quota and server network access."
|
|
40908
|
+
};
|
|
40909
|
+
} catch {
|
|
40910
|
+
return {
|
|
40911
|
+
status: "failed",
|
|
40912
|
+
provider: client.name,
|
|
40913
|
+
message: "AI connection failed. Check API key, model, quota and server network access."
|
|
40914
|
+
};
|
|
40915
|
+
}
|
|
40916
|
+
};
|
|
40767
40917
|
}
|
|
40768
40918
|
});
|
|
40769
40919
|
function renderPerfMarkdown(doc) {
|
|
@@ -42000,7 +42150,7 @@ function renderSlowEndpoints(L, doc) {
|
|
|
42000
42150
|
);
|
|
42001
42151
|
L.push("");
|
|
42002
42152
|
}
|
|
42003
|
-
var escapeInline, escapeInlinePreservingCodeSpans, escapeCodeSpan, escapeTableCell, fenceFor, SEVERITY_DESC, severityLabel, groupBySeverity, groupByField, categoryOf, groupFindings, countBySeverity2, topFiles, topRootCauses, SEVERITY_SYMBOL, formatDuration, renderHeader, ruleRecallRiskSkips, ruleSkipReasons, renderAiStats, renderSummary, renderSnippet, languageHintFromPath, renderFinding, renderGroup, renderFindingsSection, renderFooter, renderReport, createMarkdownReporter, SEVERITY_DESC2, SEVERITY_RANK, SEVERITY_LABEL, pickModal, groupByRule, formatDuration2, renderCompactHeader, renderSeverityTable, renderRulesTable, renderCompactSummary, MAX_INLINE_LOCATIONS, renderRuleSection, renderCompactFindings, renderCompactFooter, renderCompactReport, createMarkdownCompactReporter, JSON_SCHEMA_VERSION, buildRunBlock, buildRangeBlock, buildFindingBlock, projectSkipReasons, buildAiStatsBlock, buildJsonDocument, renderJsonReport, createJsonReporter, SARIF_SCHEMA, SARIF_VERSION, SEVERITY_TO_LEVEL, toFileUri, toArtifactUri, buildRegion, buildResult, buildRules, sarifSkipReasons, buildInvocation, buildSarifReport, renderSarifReport, createSarifReporter, VERDICT_LABEL, noteFor, renderHeader2, renderPolicy, countVerdict, renderOverview, renderChecklistTable, renderEvidence, renderScenario, renderConfirmedDetails, renderControlGaps, renderInconclusiveLeads, renderExtraFindings, renderChecklistCoverage, REASON_HEADING, REASON_NOTE, renderUnassessedGroup, renderUnassessed, renderCoverage, renderFooter2, renderEndpointLinks, renderAssessmentReport, renderAssessmentJson, renderVerificationManifest, renderClientVerificationReadme, E1_PROVENANCE_BADGE, VERDICT_BADGE, renderVerificationRunReport, VERDICT_BADGE2, renderClientVerificationRunReport, RUNTIME_BADGE, meaningFor, countSuffix, renderChecklistCorrelation, DB_INVARIANT_CHECKLIST_IDS, schemaInvariantCaveat, CODE_BADGE, DAST_PROVENANCE_BADGE, RUNTIME_BADGE2, runtimeCell, dastFullyUnscanned, dastRuntimeCell, clientRuntimeCell, sastCell, meaningFor2, renderHeader3, renderRuntimeDeviations, renderOverview2, renderClientArtifacts, renderCorrelationReport, PLAN_FILE, MANIFEST_FILE, REPORT_FILE, DAST_PROBE_SCRIPT_FILE2, DAST_PROBE_FILE, DAST_API_SEED_SCRIPT_FILE2, renderDastReadme, VERDICT_BADGE3, verdictCell, PROVENANCE_BADGE, COVERAGE_BADGE, hoursOf2, coverageCause, COVERAGE_COUNT, renderDastRunReport, locationOf, renderSastRunReport, UNASSESSED_LABEL, renderUnassessedSection, metaLine, fileNameOf, renderHandoffPacket, renderHandoffManifest, renderPerfJson, fenceLanguageFor, DANGEROUS_PREFIXES, K6_REQUEST_TIMEOUT, STEP_STRESS_START_SECONDS, jsString, SERVER_SIGNAL_STEP_SECONDS, shellExpr, defOf, TICK, REACH_TEXT, NOT_MEASURED, rps, pct, VERDICT_LABEL2, BLOCKER_TEXT, stepAt2, SOAK_LABEL, SOAK_INCONCLUSIVE_TEXT, SPIKE_LABEL, SPIKE_INCONCLUSIVE_TEXT, cell, TOP_ENDPOINTS;
|
|
42153
|
+
var escapeInline, escapeInlinePreservingCodeSpans, escapeCodeSpan, escapeTableCell, fenceFor, SEVERITY_DESC, severityLabel, groupBySeverity, groupByField, categoryOf, groupFindings, countBySeverity2, topFiles, topRootCauses, SEVERITY_SYMBOL, formatDuration, renderHeader, ruleRecallRiskSkips, ruleSkipReasons, renderAiStats, renderSummary, renderSnippet, languageHintFromPath, renderFindingCodeContext, renderFinding, renderGroup, renderFindingsSection, renderFooter, renderReport, createMarkdownReporter, SEVERITY_DESC2, SEVERITY_RANK, SEVERITY_LABEL, pickModal, groupByRule, formatDuration2, renderCompactHeader, renderSeverityTable, renderRulesTable, renderCompactSummary, MAX_INLINE_LOCATIONS, renderRuleSection, renderCompactFindings, renderCompactFooter, renderCompactReport, createMarkdownCompactReporter, JSON_SCHEMA_VERSION, buildRunBlock, buildRangeBlock, buildFindingBlock, projectSkipReasons, buildAiStatsBlock, buildJsonDocument, renderJsonReport, createJsonReporter, SARIF_SCHEMA, SARIF_VERSION, SEVERITY_TO_LEVEL, toFileUri, toArtifactUri, buildRegion, buildResult, buildRules, sarifSkipReasons, buildInvocation, buildSarifReport, renderSarifReport, createSarifReporter, VERDICT_LABEL, noteFor, renderHeader2, renderPolicy, countVerdict, renderOverview, renderChecklistTable, renderEvidence, renderScenario, renderConfirmedDetails, renderControlGaps, renderInconclusiveLeads, renderExtraFindings, renderChecklistCoverage, REASON_HEADING, REASON_NOTE, renderUnassessedGroup, renderUnassessed, renderCoverage, renderFooter2, renderEndpointLinks, renderAssessmentReport, renderAssessmentJson, renderVerificationManifest, renderClientVerificationReadme, E1_PROVENANCE_BADGE, VERDICT_BADGE, renderVerificationRunReport, VERDICT_BADGE2, renderClientVerificationRunReport, RUNTIME_BADGE, meaningFor, countSuffix, renderChecklistCorrelation, DB_INVARIANT_CHECKLIST_IDS, schemaInvariantCaveat, CODE_BADGE, DAST_PROVENANCE_BADGE, RUNTIME_BADGE2, runtimeCell, dastFullyUnscanned, dastRuntimeCell, clientRuntimeCell, sastCell, meaningFor2, renderHeader3, renderRuntimeDeviations, renderOverview2, renderClientArtifacts, renderCorrelationReport, PLAN_FILE, MANIFEST_FILE, REPORT_FILE, DAST_PROBE_SCRIPT_FILE2, DAST_PROBE_FILE, DAST_API_SEED_SCRIPT_FILE2, renderDastReadme, VERDICT_BADGE3, verdictCell, PROVENANCE_BADGE, COVERAGE_BADGE, hoursOf2, coverageCause, COVERAGE_COUNT, renderDastRunReport, locationOf, renderSastRunReport, UNASSESSED_LABEL, renderUnassessedSection, metaLine, fileNameOf, renderHandoffPacket, renderHandoffManifest, renderPerfJson, fenceLanguageFor, DANGEROUS_PREFIXES, K6_REQUEST_TIMEOUT, STEP_STRESS_START_SECONDS, jsString, SERVER_SIGNAL_STEP_SECONDS, shellExpr, defOf, TICK, REACH_TEXT, NOT_MEASURED, rps, pct, VERDICT_LABEL2, BLOCKER_TEXT, stepAt2, SOAK_LABEL, SOAK_INCONCLUSIVE_TEXT, SPIKE_LABEL, SPIKE_INCONCLUSIVE_TEXT, cell, TOP_ENDPOINTS;
|
|
42004
42154
|
var init_dist5 = __esm({
|
|
42005
42155
|
"../reporters/dist/index.js"() {
|
|
42006
42156
|
init_dist2();
|
|
@@ -42249,6 +42399,14 @@ ${fence}`;
|
|
|
42249
42399
|
return "";
|
|
42250
42400
|
}
|
|
42251
42401
|
};
|
|
42402
|
+
renderFindingCodeContext = (finding) => {
|
|
42403
|
+
const snippet = formatFindingSnippet(finding);
|
|
42404
|
+
if (!snippet) return "";
|
|
42405
|
+
const label = finding.snippetStartLine === void 0 ? "Source context" : `Source context (from line ${finding.snippetStartLine}; > marks the violation)`;
|
|
42406
|
+
return `**${label}**
|
|
42407
|
+
|
|
42408
|
+
${renderSnippet(snippet, languageHintFromPath(finding.file))}`;
|
|
42409
|
+
};
|
|
42252
42410
|
renderFinding = (finding) => {
|
|
42253
42411
|
const lines = [];
|
|
42254
42412
|
const sym = SEVERITY_SYMBOL[finding.severity];
|
|
@@ -42261,7 +42419,7 @@ ${fence}`;
|
|
|
42261
42419
|
lines.push(`> ${escapeInlinePreservingCodeSpans(finding.message)}`);
|
|
42262
42420
|
if (finding.snippet) {
|
|
42263
42421
|
lines.push("");
|
|
42264
|
-
lines.push(
|
|
42422
|
+
lines.push(renderFindingCodeContext(finding));
|
|
42265
42423
|
}
|
|
42266
42424
|
if (finding.suggestion) {
|
|
42267
42425
|
lines.push("");
|
|
@@ -42495,7 +42653,15 @@ ${body}`;
|
|
|
42495
42653
|
const locationLines = group2.findings.map((f) => {
|
|
42496
42654
|
const loc = `${f.file}:${f.range.line}:${f.range.column}`;
|
|
42497
42655
|
const confBadge = f.confidence !== void 0 && f.confidence !== baseline ? ` _(${f.confidence}%)_` : "";
|
|
42498
|
-
|
|
42656
|
+
const context = renderFindingCodeContext(f);
|
|
42657
|
+
return `- ${escapeCodeSpan(loc)}${confBadge}${context ? `
|
|
42658
|
+
|
|
42659
|
+
<details><summary>Code context</summary>
|
|
42660
|
+
|
|
42661
|
+
${context}
|
|
42662
|
+
|
|
42663
|
+
</details>
|
|
42664
|
+
` : ""}`;
|
|
42499
42665
|
});
|
|
42500
42666
|
bodyLines.push("");
|
|
42501
42667
|
if (group2.findings.length > MAX_INLINE_LOCATIONS) {
|
|
@@ -42592,6 +42758,7 @@ ${body}`;
|
|
|
42592
42758
|
file: f.file,
|
|
42593
42759
|
range: buildRangeBlock(f.range),
|
|
42594
42760
|
...f.snippet !== void 0 ? { snippet: f.snippet } : {},
|
|
42761
|
+
...f.snippetStartLine !== void 0 ? { snippetStartLine: f.snippetStartLine } : {},
|
|
42595
42762
|
...f.suggestion !== void 0 ? { suggestion: f.suggestion } : {},
|
|
42596
42763
|
...f.fix !== void 0 ? { fix: f.fix } : {}
|
|
42597
42764
|
});
|
|
@@ -42718,7 +42885,15 @@ ${body}`;
|
|
|
42718
42885
|
{
|
|
42719
42886
|
physicalLocation: {
|
|
42720
42887
|
artifactLocation: { uri: toArtifactUri(f.file), uriBaseId: "%SRCROOT%" },
|
|
42721
|
-
region: buildRegion(f.range, f.snippet)
|
|
42888
|
+
region: buildRegion(f.range, f.snippetStartLine === void 0 ? f.snippet : void 0),
|
|
42889
|
+
...f.snippet && f.snippetStartLine !== void 0 ? {
|
|
42890
|
+
contextRegion: {
|
|
42891
|
+
startLine: f.snippetStartLine,
|
|
42892
|
+
startColumn: 1,
|
|
42893
|
+
endLine: f.snippetStartLine + f.snippet.split("\n").length - 1,
|
|
42894
|
+
snippet: { text: f.snippet }
|
|
42895
|
+
}
|
|
42896
|
+
} : {}
|
|
42722
42897
|
}
|
|
42723
42898
|
}
|
|
42724
42899
|
],
|
|
@@ -49188,7 +49363,7 @@ ${validated.error.issues.map((i) => ` - ${i.path.join(".")}: ${i.message}`).joi
|
|
|
49188
49363
|
"spring-boot/cache-consistency-risk@2",
|
|
49189
49364
|
"angular/trackby-required@2",
|
|
49190
49365
|
"angular/onpush-required@3",
|
|
49191
|
-
"angular/no-leaky-subscription@
|
|
49366
|
+
"angular/no-leaky-subscription@6"
|
|
49192
49367
|
];
|
|
49193
49368
|
PERF_PACK_RULES = [
|
|
49194
49369
|
"spring-boot/transaction-holds-remote-call@1",
|
|
@@ -54482,7 +54657,7 @@ var init_libsql = __esm({
|
|
|
54482
54657
|
init_session2();
|
|
54483
54658
|
}
|
|
54484
54659
|
});
|
|
54485
|
-
var __defProp2, __export2, schema_exports, reviewRuns, findings, buildCacheTable, aiCache, ruleCache, parseCache, astGraphNodes, astGraphEdges, astGraphMeta, SQLITE_BUSY_TIMEOUT_MS, isInMemory, toLibsqlUrl, createDb, DEFAULT_RETRY_DELAYS_MS, isSqliteBusyError, wait, withSqliteBusyRetry, hereDir, defaultMigrationsDir, ensureTrackingTable, listMigrations, alreadyApplied, runMigrations, RULE_EXECUTION_SKIP_REASONS, decodeSkipReasons, encodeSkipReasons, decodeRetryBacklog, decodeRetryIds, parseAiStatsJson, parseRuleResultsJson, parseFixJson, parseFindingMetadataJson, serializeAiStats, serializeRuleResults, serializeFix, serializeFindingMetadata, rowToSummary, rowToFinding, findingFingerprint, runUpsertStatement, findingInsertStatement, createReviewStore, TABLE_BY_NAMESPACE, purgeExpired, createSqliteCacheStore, AST_GRAPH_SCHEMA_VERSION, KNOWN_EDGE_KINDS, parseSymbols, rowToNode, rowToEdge, stringOrNull, createAstGraphStore, clearAstGraphForProject, migration0001, migration0002, migration0003, migration0004, migration0005, migration0006, migration0007, migration0008, migration0009, migration0010, migration0011, migration0012, migration0013, migration0014, migration0015, migration0016, migration0017, migration0018, migration0019, migration0020, migration0021, migration0022, migration0023, migration0024, migration0025, migration0026, migration0027, migration0028, migration0029, migration0030, migration0031, migration0032, migration0033, migration0034, migration0035, migration0036, migration0037, migration0038, migration0039, migration0040, migration0041, migration0042, migration0043, migration0044, migration0045, migration0046, migration0047, mutableRequestStatusPredicate, migration0048, migration0049, previousDefaultAndRetiredModels, mutableRequestPredicate, updatedAt, migration0050, migration0051, migration0052, migration0053, migration0054, migration0055, migration0056, migration0057, migration0058, migration0059, migration0060, migration0061, migration0062, migration0063, migration0064, migration0065, migration0066, migration0067, migration0068, MARIADB_MIGRATIONS;
|
|
54660
|
+
var __defProp2, __export2, schema_exports, reviewRuns, findings, buildCacheTable, aiCache, ruleCache, parseCache, astGraphNodes, astGraphEdges, astGraphMeta, SQLITE_BUSY_TIMEOUT_MS, isInMemory, toLibsqlUrl, createDb, DEFAULT_RETRY_DELAYS_MS, isSqliteBusyError, wait, withSqliteBusyRetry, hereDir, defaultMigrationsDir, ensureTrackingTable, listMigrations, alreadyApplied, runMigrations, RULE_EXECUTION_SKIP_REASONS, decodeSkipReasons, encodeSkipReasons, decodeRetryBacklog, decodeRetryIds, parseAiStatsJson, parseRuleResultsJson, parseFixJson, parseFindingMetadataJson, serializeAiStats, serializeRuleResults, serializeFix, serializeFindingMetadata, rowToSummary, rowToFinding, findingFingerprint, runUpsertStatement, findingInsertStatement, createReviewStore, TABLE_BY_NAMESPACE, purgeExpired, createSqliteCacheStore, AST_GRAPH_SCHEMA_VERSION, KNOWN_EDGE_KINDS, parseSymbols, rowToNode, rowToEdge, stringOrNull, createAstGraphStore, clearAstGraphForProject, migration0001, migration0002, migration0003, migration0004, migration0005, migration0006, migration0007, migration0008, migration0009, migration0010, migration0011, migration0012, migration0013, migration0014, migration0015, migration0016, migration0017, migration0018, migration0019, migration0020, migration0021, migration0022, migration0023, migration0024, migration0025, migration0026, migration0027, migration0028, migration0029, migration0030, migration0031, migration0032, migration0033, migration0034, migration0035, migration0036, migration0037, migration0038, migration0039, migration0040, migration0041, migration0042, migration0043, migration0044, migration0045, migration0046, migration0047, mutableRequestStatusPredicate, migration0048, migration0049, previousDefaultAndRetiredModels, mutableRequestPredicate, updatedAt, migration0050, migration0051, migration0052, migration0053, migration0054, migration0055, migration0056, migration0057, migration0058, migration0059, migration0060, migration0061, migration0062, migration0063, migration0069, migration0070, migration0064, migration0065, migration0066, migration0067, migration0068, MARIADB_MIGRATIONS;
|
|
54486
54661
|
var init_dist9 = __esm({
|
|
54487
54662
|
"../storage/dist/index.js"() {
|
|
54488
54663
|
init_libsql();
|
|
@@ -54939,6 +55114,8 @@ var init_dist9 = __esm({
|
|
|
54939
55114
|
if (typeof p.profileApplicability === "string" && p.profileApplicability.length > 0) {
|
|
54940
55115
|
out.profileApplicability = p.profileApplicability;
|
|
54941
55116
|
}
|
|
55117
|
+
if (typeof p.snippetStartLine === "number" && Number.isSafeInteger(p.snippetStartLine) && p.snippetStartLine > 0)
|
|
55118
|
+
out.snippetStartLine = p.snippetStartLine;
|
|
54942
55119
|
return Object.keys(out).length > 0 ? out : void 0;
|
|
54943
55120
|
};
|
|
54944
55121
|
serializeAiStats = (run, options = {}) => {
|
|
@@ -54996,6 +55173,7 @@ var init_dist9 = __esm({
|
|
|
54996
55173
|
};
|
|
54997
55174
|
serializeFindingMetadata = (finding) => {
|
|
54998
55175
|
const metadata = {
|
|
55176
|
+
...finding.snippetStartLine !== void 0 ? { snippetStartLine: finding.snippetStartLine } : {},
|
|
54999
55177
|
...finding.category !== void 0 ? { category: finding.category } : {},
|
|
55000
55178
|
...finding.rootCauseKey !== void 0 ? { rootCauseKey: finding.rootCauseKey } : {},
|
|
55001
55179
|
...finding.tags !== void 0 ? { tags: finding.tags } : {},
|
|
@@ -57787,6 +57965,49 @@ var init_dist9 = __esm({
|
|
|
57787
57965
|
MODIFY COLUMN input_id VARCHAR(64) NOT NULL DEFAULT '-'`
|
|
57788
57966
|
]
|
|
57789
57967
|
};
|
|
57968
|
+
migration0069 = {
|
|
57969
|
+
version: 69,
|
|
57970
|
+
name: "investigation-reviews",
|
|
57971
|
+
statements: [
|
|
57972
|
+
`CREATE TABLE IF NOT EXISTS pentest_sandbox_attempt_reviews (
|
|
57973
|
+
id VARCHAR(64) PRIMARY KEY,
|
|
57974
|
+
attempt_id VARCHAR(64) NOT NULL,
|
|
57975
|
+
reviewed_by VARCHAR(384) NOT NULL,
|
|
57976
|
+
decision VARCHAR(32) NOT NULL,
|
|
57977
|
+
reason TEXT NOT NULL,
|
|
57978
|
+
evidence_ids_json TEXT NOT NULL,
|
|
57979
|
+
created_at BIGINT NOT NULL,
|
|
57980
|
+
FOREIGN KEY (attempt_id) REFERENCES pentest_sandbox_attempts(id) ON DELETE CASCADE,
|
|
57981
|
+
INDEX idx_attempt_reviews (attempt_id,created_at)
|
|
57982
|
+
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci`
|
|
57983
|
+
]
|
|
57984
|
+
};
|
|
57985
|
+
migration0070 = {
|
|
57986
|
+
version: 70,
|
|
57987
|
+
name: "sandbox-executions",
|
|
57988
|
+
statements: [
|
|
57989
|
+
`CREATE TABLE IF NOT EXISTS pentest_sandbox_executions (
|
|
57990
|
+
id VARCHAR(64) PRIMARY KEY,
|
|
57991
|
+
project_id VARCHAR(255) NOT NULL,
|
|
57992
|
+
request_id VARCHAR(384) NOT NULL,
|
|
57993
|
+
sandbox_id VARCHAR(384) NOT NULL,
|
|
57994
|
+
runtime_generation INT NOT NULL,
|
|
57995
|
+
actor_id VARCHAR(384) NOT NULL,
|
|
57996
|
+
idempotency_key VARCHAR(128) NOT NULL,
|
|
57997
|
+
request_fingerprint VARCHAR(64) NOT NULL,
|
|
57998
|
+
state VARCHAR(32) NOT NULL,
|
|
57999
|
+
record_json MEDIUMTEXT NOT NULL,
|
|
58000
|
+
created_at BIGINT NOT NULL,
|
|
58001
|
+
retention_expires_at BIGINT NOT NULL,
|
|
58002
|
+
UNIQUE KEY uq_sandbox_execution_key (project_id, request_id, idempotency_key),
|
|
58003
|
+
INDEX idx_sandbox_execution_active (sandbox_id, state),
|
|
58004
|
+
INDEX idx_sandbox_execution_history (project_id, request_id, id),
|
|
58005
|
+
FOREIGN KEY (project_id) REFERENCES projects(id) ON DELETE CASCADE,
|
|
58006
|
+
FOREIGN KEY (request_id) REFERENCES pentest_requests(id) ON DELETE CASCADE,
|
|
58007
|
+
FOREIGN KEY (sandbox_id) REFERENCES pentest_sandboxes(id) ON DELETE CASCADE
|
|
58008
|
+
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci`
|
|
58009
|
+
]
|
|
58010
|
+
};
|
|
57790
58011
|
migration0064 = {
|
|
57791
58012
|
version: 64,
|
|
57792
58013
|
name: "pentest-sandboxes",
|
|
@@ -57968,17 +58189,19 @@ var init_dist9 = __esm({
|
|
|
57968
58189
|
`CREATE TABLE IF NOT EXISTS pentest_sandbox_investigations (
|
|
57969
58190
|
id VARCHAR(64) PRIMARY KEY,
|
|
57970
58191
|
project_id VARCHAR(255) NOT NULL,
|
|
57971
|
-
request_id VARCHAR(
|
|
58192
|
+
request_id VARCHAR(384) NOT NULL,
|
|
57972
58193
|
assessment_id VARCHAR(255) NULL,
|
|
57973
58194
|
scenario_id VARCHAR(128) NOT NULL,
|
|
57974
58195
|
variant_id VARCHAR(128) NOT NULL,
|
|
57975
|
-
sandbox_id VARCHAR(
|
|
58196
|
+
sandbox_id VARCHAR(384) NOT NULL,
|
|
57976
58197
|
runtime_generation INT NOT NULL DEFAULT 1,
|
|
57977
58198
|
recipe_version INT NOT NULL DEFAULT 1,
|
|
57978
58199
|
created_by_user_id VARCHAR(384) NULL,
|
|
57979
58200
|
created_at BIGINT NOT NULL,
|
|
57980
58201
|
updated_at BIGINT NOT NULL,
|
|
57981
58202
|
FOREIGN KEY (project_id) REFERENCES projects(id) ON DELETE CASCADE,
|
|
58203
|
+
FOREIGN KEY (request_id) REFERENCES pentest_requests(id) ON DELETE CASCADE,
|
|
58204
|
+
FOREIGN KEY (sandbox_id) REFERENCES pentest_sandboxes(id) ON DELETE CASCADE,
|
|
57982
58205
|
FOREIGN KEY (created_by_user_id) REFERENCES dashboard_users(id) ON DELETE SET NULL,
|
|
57983
58206
|
INDEX idx_investigations_req_scen (request_id, scenario_id),
|
|
57984
58207
|
INDEX idx_investigations_sandbox (sandbox_id)
|
|
@@ -58087,7 +58310,9 @@ var init_dist9 = __esm({
|
|
|
58087
58310
|
migration0065,
|
|
58088
58311
|
migration0066,
|
|
58089
58312
|
migration0067,
|
|
58090
|
-
migration0068
|
|
58313
|
+
migration0068,
|
|
58314
|
+
migration0069,
|
|
58315
|
+
migration0070
|
|
58091
58316
|
];
|
|
58092
58317
|
MARIADB_MIGRATIONS[MARIADB_MIGRATIONS.length - 1]?.version ?? 0;
|
|
58093
58318
|
}
|
|
@@ -58217,7 +58442,7 @@ var init_authorization_guard_context = __esm({
|
|
|
58217
58442
|
};
|
|
58218
58443
|
}
|
|
58219
58444
|
});
|
|
58220
|
-
var buildOneProvider, resolveActiveModel, buildAiClient, buildContainer;
|
|
58445
|
+
var buildOneProvider, resolveActiveModel, buildAiClient, AI_RATE_LIMIT_RETRY, withRateLimitRetry, buildContainer;
|
|
58221
58446
|
var init_composition = __esm({
|
|
58222
58447
|
"src/composition.ts"() {
|
|
58223
58448
|
init_dist4();
|
|
@@ -58339,9 +58564,26 @@ var init_composition = __esm({
|
|
|
58339
58564
|
}
|
|
58340
58565
|
}
|
|
58341
58566
|
if (chain.length === 0) return null;
|
|
58342
|
-
|
|
58343
|
-
return
|
|
58567
|
+
const client = chain.length === 1 ? chain[0] : createFallbackClient({ providers: chain, logger });
|
|
58568
|
+
return client ? withRateLimitRetry(client, logger) : null;
|
|
58344
58569
|
};
|
|
58570
|
+
AI_RATE_LIMIT_RETRY = {
|
|
58571
|
+
maxRetries: 3,
|
|
58572
|
+
baseDelayMs: 15e3,
|
|
58573
|
+
maxDelayMs: 12e4,
|
|
58574
|
+
jitterMs: 5e3
|
|
58575
|
+
};
|
|
58576
|
+
withRateLimitRetry = (client, logger, sleep5) => createRateLimitRetryClient({
|
|
58577
|
+
client,
|
|
58578
|
+
...AI_RATE_LIMIT_RETRY,
|
|
58579
|
+
...sleep5 ? { sleep: sleep5 } : {},
|
|
58580
|
+
onRetry: ({ attempt, maxRetries, delayMs }) => {
|
|
58581
|
+
logger.warn(
|
|
58582
|
+
{ provider: client.name, retryAttempt: attempt, retryMaxRetries: maxRetries, delayMs },
|
|
58583
|
+
`AI provider rate-limited (HTTP 429); retrying in ${Math.round(delayMs / 1e3)}s`
|
|
58584
|
+
);
|
|
58585
|
+
}
|
|
58586
|
+
});
|
|
58345
58587
|
buildContainer = async (options) => {
|
|
58346
58588
|
const { config, logger, projectPath } = options;
|
|
58347
58589
|
const clock = options.clock ?? new SystemClock();
|
|
@@ -58579,7 +58821,7 @@ var init_schema = __esm({
|
|
|
58579
58821
|
targets: external_exports.record(packagingTargetSchema).default({}),
|
|
58580
58822
|
exclude: external_exports.array(external_exports.string().trim().min(1)).default([]).transform((patterns) => [.../* @__PURE__ */ new Set([...DEFAULT_PACKAGING_EXCLUDES, ...patterns])]),
|
|
58581
58823
|
maxFileBytes: configInt({ min: 1, default: 32 * 1024 * 1024 }),
|
|
58582
|
-
maxArchiveBytes: configInt({ min: 1, default:
|
|
58824
|
+
maxArchiveBytes: configInt({ min: 1, default: 1024 * 1024 * 1024 })
|
|
58583
58825
|
}).superRefine((packaging, ctx) => {
|
|
58584
58826
|
if (packaging.defaultTarget !== void 0 && packaging.targets[packaging.defaultTarget] === void 0) {
|
|
58585
58827
|
ctx.addIssue({
|
|
@@ -59766,6 +60008,7 @@ var init_find_files = __esm({
|
|
|
59766
60008
|
absolutePath: resolve(absPath),
|
|
59767
60009
|
language: projected?.language ?? language,
|
|
59768
60010
|
content: effectiveContent,
|
|
60011
|
+
...projected ? { originalContent: content } : {},
|
|
59769
60012
|
hash: sha256(content),
|
|
59770
60013
|
size,
|
|
59771
60014
|
...projected?.template !== void 0 ? { vueTemplate: projected.template } : {}
|
|
@@ -60121,11 +60364,11 @@ var definedBuildValue = (value, fallback) => typeof value === "string" && value.
|
|
|
60121
60364
|
var getCliBuildMetadata = (version2) => ({
|
|
60122
60365
|
version: version2,
|
|
60123
60366
|
gitSha: definedBuildValue(
|
|
60124
|
-
"
|
|
60367
|
+
"45c292a280ad" ,
|
|
60125
60368
|
"unknown"
|
|
60126
60369
|
),
|
|
60127
60370
|
buildTimestamp: definedBuildValue(
|
|
60128
|
-
"2026-
|
|
60371
|
+
"2026-11-27T02:52:58.766Z" ,
|
|
60129
60372
|
"unknown"
|
|
60130
60373
|
),
|
|
60131
60374
|
configSchemaRange: definedBuildValue(
|
|
@@ -60763,7 +61006,7 @@ var resolveAiFlowReviewPromptPath = () => {
|
|
|
60763
61006
|
for (const c of candidates) if (existsSync(c)) return c;
|
|
60764
61007
|
return candidates[0] ?? resolve(here2, "../../../prompt/templates/ai-flow-review.md");
|
|
60765
61008
|
};
|
|
60766
|
-
var
|
|
61009
|
+
var isRateLimitError2 = (error) => JSON.stringify(error ?? {}).includes("Rate limit");
|
|
60767
61010
|
var askAi = async (client, prompt, logger) => {
|
|
60768
61011
|
if (!client) return null;
|
|
60769
61012
|
const retryMax = Math.max(0, Number(process.env.CODE_SENTINEL_AI_FLOW_RETRY_MAX ?? 3) || 0);
|
|
@@ -60783,7 +61026,7 @@ var askAi = async (client, prompt, logger) => {
|
|
|
60783
61026
|
maxTokens: 1500
|
|
60784
61027
|
});
|
|
60785
61028
|
if (!res.ok) {
|
|
60786
|
-
const rateLimited =
|
|
61029
|
+
const rateLimited = isRateLimitError2(res.error);
|
|
60787
61030
|
if (rateLimited && attempt < retryMax) {
|
|
60788
61031
|
logger?.warn(
|
|
60789
61032
|
{},
|
|
@@ -60800,7 +61043,7 @@ var askAi = async (client, prompt, logger) => {
|
|
|
60800
61043
|
}
|
|
60801
61044
|
return parseAiVerdict(res.value.text);
|
|
60802
61045
|
} catch (e) {
|
|
60803
|
-
const rateLimited =
|
|
61046
|
+
const rateLimited = isRateLimitError2(e);
|
|
60804
61047
|
if (rateLimited && attempt < retryMax) {
|
|
60805
61048
|
logger?.warn(
|
|
60806
61049
|
{},
|
|
@@ -65382,7 +65625,7 @@ var openBrowser = async (url) => {
|
|
|
65382
65625
|
else await execFile3("xdg-open", [url]);
|
|
65383
65626
|
};
|
|
65384
65627
|
var credentialStore = () => createPlatformCredentialStore();
|
|
65385
|
-
var
|
|
65628
|
+
var sleep3 = (milliseconds) => new Promise((resolve62) => setTimeout(resolve62, milliseconds));
|
|
65386
65629
|
var defaults = () => ({
|
|
65387
65630
|
store: credentialStore(),
|
|
65388
65631
|
start: startDeviceAuthorization,
|
|
@@ -65390,7 +65633,7 @@ var defaults = () => ({
|
|
|
65390
65633
|
refresh: refreshDeviceCredential,
|
|
65391
65634
|
revoke: revokeDeviceCredential,
|
|
65392
65635
|
openBrowser,
|
|
65393
|
-
sleep,
|
|
65636
|
+
sleep: sleep3,
|
|
65394
65637
|
now: Date.now
|
|
65395
65638
|
});
|
|
65396
65639
|
var runAuthLogin = async (options) => {
|
|
@@ -67491,6 +67734,7 @@ var createGitLabClient = (options) => {
|
|
|
67491
67734
|
|
|
67492
67735
|
// src/pr/publisher.ts
|
|
67493
67736
|
init_dist2();
|
|
67737
|
+
init_dist5();
|
|
67494
67738
|
init_dist();
|
|
67495
67739
|
var SUMMARY_MARKER = "<!-- code-sentinel:pr-review -->";
|
|
67496
67740
|
var fingerprintMarker = (fingerprint) => `<!-- code-sentinel:finding ${fingerprint} -->`;
|
|
@@ -67546,6 +67790,17 @@ var renderPrSummary = (options) => {
|
|
|
67546
67790
|
lines.push("### Findings", "");
|
|
67547
67791
|
lines.push("| Severity | Rule | Location | Message |", "|---|---|---|---|");
|
|
67548
67792
|
for (const finding of allFindings) lines.push(renderFindingRow(finding));
|
|
67793
|
+
for (const finding of allFindings) {
|
|
67794
|
+
if (finding.snippet)
|
|
67795
|
+
lines.push(
|
|
67796
|
+
"",
|
|
67797
|
+
`<details><summary>${finding.file.replace(/[&<>]/g, (c) => ({ "&": "&", "<": "<", ">": ">" })[c] ?? c)}:${finding.range.line} \u2014 code context</summary>`,
|
|
67798
|
+
"",
|
|
67799
|
+
renderFindingCodeContext(finding),
|
|
67800
|
+
"",
|
|
67801
|
+
"</details>"
|
|
67802
|
+
);
|
|
67803
|
+
}
|
|
67549
67804
|
}
|
|
67550
67805
|
return lines.join("\n");
|
|
67551
67806
|
};
|
|
@@ -67554,6 +67809,7 @@ var renderInlineComment = (item16) => [
|
|
|
67554
67809
|
`**${item16.finding.ruleId}** (${item16.finding.severity})`,
|
|
67555
67810
|
"",
|
|
67556
67811
|
item16.finding.message,
|
|
67812
|
+
renderFindingCodeContext(item16.finding),
|
|
67557
67813
|
item16.finding.suggestion ? `
|
|
67558
67814
|
Suggestion: ${item16.finding.suggestion}` : ""
|
|
67559
67815
|
].filter((part) => part.length > 0).join("\n");
|
|
@@ -67627,6 +67883,7 @@ var publishPrReview = async (options) => {
|
|
|
67627
67883
|
};
|
|
67628
67884
|
|
|
67629
67885
|
// src/pr/static-review.ts
|
|
67886
|
+
init_dist4();
|
|
67630
67887
|
init_dist2();
|
|
67631
67888
|
init_dist5();
|
|
67632
67889
|
init_dist8();
|
|
@@ -67668,6 +67925,18 @@ var executePrStaticReview = async (options) => {
|
|
|
67668
67925
|
...aiOverrides ? { aiOverrides } : {}
|
|
67669
67926
|
});
|
|
67670
67927
|
try {
|
|
67928
|
+
if (!options.aiOff && options.config.ai.provider !== "none") {
|
|
67929
|
+
if (container.aiClient) {
|
|
67930
|
+
const connection = await checkAiConnection(container.aiClient);
|
|
67931
|
+
if (connection.status !== "connected") {
|
|
67932
|
+
console.error(`WARNING: ${connection.message} PR AI review may be incomplete.`);
|
|
67933
|
+
}
|
|
67934
|
+
} else {
|
|
67935
|
+
console.error(
|
|
67936
|
+
"WARNING: PR AI review has no usable AI client. Check provider settings and API key; AI stages will be skipped."
|
|
67937
|
+
);
|
|
67938
|
+
}
|
|
67939
|
+
}
|
|
67671
67940
|
const trustedResources = resolveTrustedPrResources(options.trustedRuleRoot);
|
|
67672
67941
|
const filesResult = await findFiles({
|
|
67673
67942
|
projectRoot: options.projectRoot,
|
|
@@ -68863,9 +69132,10 @@ var runPrReview = async (options) => {
|
|
|
68863
69132
|
options.aiOff === true ? "AI disabled by --ai-off" : aiClient === null ? "AI client is unavailable" : "No changed diff packets"
|
|
68864
69133
|
);
|
|
68865
69134
|
}
|
|
69135
|
+
const enrichFinding = createFindingContextEnricher(staticResult.allSourceFiles);
|
|
68866
69136
|
const mergedFindings = [
|
|
68867
69137
|
...mergePrCandidateFindings(staticResult.run.findings, aiFindings, changedPaths)
|
|
68868
|
-
].sort(compareFindings);
|
|
69138
|
+
].map(enrichFinding).sort(compareFindings);
|
|
68869
69139
|
const classified = classifyPrFindings(mergedFindings, changedPaths, lineMap);
|
|
68870
69140
|
const aiStats = mergePrAiStats(
|
|
68871
69141
|
staticResult.run.aiStats,
|
|
@@ -71158,7 +71428,7 @@ var rulesToRerun = (aiStats) => {
|
|
|
71158
71428
|
}
|
|
71159
71429
|
return ids.sort();
|
|
71160
71430
|
};
|
|
71161
|
-
var
|
|
71431
|
+
var sleep4 = (ms) => new Promise((r) => setTimeout(r, ms));
|
|
71162
71432
|
var runReview = async (options = {}) => {
|
|
71163
71433
|
const target = resolve(options.path ?? process.cwd());
|
|
71164
71434
|
const silent = options.silent === true;
|
|
@@ -71379,6 +71649,21 @@ var runReview = async (options = {}) => {
|
|
|
71379
71649
|
console.error(red(`Failed to initialize: ${e.message}`));
|
|
71380
71650
|
return EXIT.RUNTIME;
|
|
71381
71651
|
}
|
|
71652
|
+
if (!effectiveAiOff && container.aiClient) {
|
|
71653
|
+
const connection = await checkAiConnection(container.aiClient);
|
|
71654
|
+
if (connection.status !== "connected") {
|
|
71655
|
+
console.error(yellow(`WARNING: ${connection.message} AI review may be incomplete.`));
|
|
71656
|
+
} else if (!silent) {
|
|
71657
|
+
console.log(`AI connection OK (${connection.provider}).`);
|
|
71658
|
+
}
|
|
71659
|
+
}
|
|
71660
|
+
if (!effectiveAiOff && config.ai.provider !== "none" && !container.aiClient) {
|
|
71661
|
+
console.error(
|
|
71662
|
+
yellow(
|
|
71663
|
+
"WARNING: AI is configured but no usable AI client is available. Check provider settings and API key; AI review will be skipped."
|
|
71664
|
+
)
|
|
71665
|
+
);
|
|
71666
|
+
}
|
|
71382
71667
|
const activeAiProvider = effectiveAiOff ? null : container.aiClient?.name ?? null;
|
|
71383
71668
|
const activeAiModel = activeAiProvider === null ? null : resolveActiveModel(config);
|
|
71384
71669
|
const aiEnabled = !effectiveAiOff && container.aiExecutor !== void 0;
|
|
@@ -71854,7 +72139,7 @@ var runReview = async (options = {}) => {
|
|
|
71854
72139
|
)
|
|
71855
72140
|
);
|
|
71856
72141
|
rerunTracker.reset();
|
|
71857
|
-
if (rerunCfg.delayMs > 0) await
|
|
72142
|
+
if (rerunCfg.delayMs > 0) await sleep4(rerunCfg.delayMs);
|
|
71858
72143
|
const rerun = await reviewProject(
|
|
71859
72144
|
{ ...reviewDeps, aiTracker: rerunTracker },
|
|
71860
72145
|
{
|
|
@@ -71991,7 +72276,10 @@ var runReview = async (options = {}) => {
|
|
|
71991
72276
|
includeSnippets: false
|
|
71992
72277
|
})
|
|
71993
72278
|
);
|
|
71994
|
-
for (const finding of archiveDoc.findings ?? [])
|
|
72279
|
+
for (const finding of archiveDoc.findings ?? []) {
|
|
72280
|
+
finding.snippet = void 0;
|
|
72281
|
+
finding.snippetStartLine = void 0;
|
|
72282
|
+
}
|
|
71995
72283
|
await writeFile(findingsArchivePath, JSON.stringify(archiveDoc), "utf8");
|
|
71996
72284
|
log2(quiet, dim(` Findings archive: ${findingsArchivePath}`));
|
|
71997
72285
|
await pruneFindingsArchives(dirname(findingsArchivePath), config.storage.retainRuns);
|
|
@@ -77126,32 +77414,28 @@ H\xE3y ch\u1EA1y \`cs auth login\`.`
|
|
|
77126
77414
|
}
|
|
77127
77415
|
}
|
|
77128
77416
|
try {
|
|
77129
|
-
const
|
|
77130
|
-
|
|
77131
|
-
|
|
77132
|
-
|
|
77133
|
-
|
|
77134
|
-
|
|
77135
|
-
const remoteConfig = payload.config ?? payload;
|
|
77136
|
-
const ai = remoteConfig?.ai;
|
|
77137
|
-
const provider = ai?.provider ?? remoteConfig?.aiProvider ?? "viettel-netmind";
|
|
77138
|
-
if (provider && provider !== "none" && provider !== "ollama") {
|
|
77139
|
-
const STORED_SECRET_PLACEHOLDER = "${CODE_SENTINEL_STORED_SECRET}";
|
|
77140
|
-
const pKey = provider === "viettel-netmind" ? "viettelNetmind" : provider === "openai-compatible" ? "openaiCompatible" : provider === "opencode-go" ? "opencodeGo" : provider;
|
|
77141
|
-
const providerConf = typeof ai?.[pKey] === "object" && ai?.[pKey] !== null ? ai[pKey] : {};
|
|
77142
|
-
const rawProviderApiKey = typeof providerConf.apiKey === "string" ? providerConf.apiKey.trim() : typeof ai?.apiKey === "string" ? ai.apiKey.trim() : "";
|
|
77143
|
-
const hasServerSecret = rawProviderApiKey === STORED_SECRET_PLACEHOLDER || rawProviderApiKey === "<configured server secret>" || rawProviderApiKey.startsWith("csenc:v1:");
|
|
77144
|
-
const hasExplicitKey = rawProviderApiKey.length > 0 && !hasServerSecret && !/^\$\{[A-Z0-9_]+\}$/.test(rawProviderApiKey);
|
|
77145
|
-
if (!hasServerSecret && !hasExplicitKey) {
|
|
77146
|
-
process.stderr.write(
|
|
77147
|
-
`
|
|
77148
|
-
\u26A0 Project ch\u01B0a c\xF3 API key cho ${provider}; request v\u1EABn \u0111\u01B0\u1EE3c g\u1EEDi v\xE0 server s\u1EBD d\xF9ng to\xE0n b\u1ED9 resolver deterministic. Tr\u1EA1ng th\xE1i AI degraded ch\u1EC9 l\xE0 metadata preparation.
|
|
77149
|
-
`
|
|
77150
|
-
);
|
|
77151
|
-
}
|
|
77417
|
+
const checkRes = await fetch(
|
|
77418
|
+
`${serverUrl.replace(/\/+$/, "")}/api/projects/${encodeURIComponent(link.projectId)}/ai-connection`,
|
|
77419
|
+
{
|
|
77420
|
+
method: "POST",
|
|
77421
|
+
headers: { authorization: `Bearer ${token}` },
|
|
77422
|
+
signal: AbortSignal.timeout(2e4)
|
|
77152
77423
|
}
|
|
77424
|
+
);
|
|
77425
|
+
const check = checkRes.ok ? await checkRes.json() : null;
|
|
77426
|
+
if (check?.status === "connected") {
|
|
77427
|
+
process.stderr.write("\n\u2713 AI connection OK tr\xEAn server.\n");
|
|
77428
|
+
} else {
|
|
77429
|
+
process.stderr.write(
|
|
77430
|
+
`
|
|
77431
|
+
\u26A0 ${check?.message ?? "Kh\xF4ng ki\u1EC3m tra \u0111\u01B0\u1EE3c k\u1EBFt n\u1ED1i AI tr\xEAn server."} Request v\u1EABn \u0111\u01B0\u1EE3c g\u1EEDi; c\xE1c b\u01B0\u1EDBc AI c\xF3 th\u1EC3 b\u1ECB b\u1ECF qua.
|
|
77432
|
+
`
|
|
77433
|
+
);
|
|
77153
77434
|
}
|
|
77154
77435
|
} catch {
|
|
77436
|
+
process.stderr.write(
|
|
77437
|
+
"\n\u26A0 Kh\xF4ng ki\u1EC3m tra \u0111\u01B0\u1EE3c k\u1EBFt n\u1ED1i AI tr\xEAn server. Request v\u1EABn \u0111\u01B0\u1EE3c g\u1EEDi; c\xE1c b\u01B0\u1EDBc AI c\xF3 th\u1EC3 b\u1ECB b\u1ECF qua.\n"
|
|
77438
|
+
);
|
|
77155
77439
|
}
|
|
77156
77440
|
}
|
|
77157
77441
|
const rawPlan = planServicePackage(repoRoot, modulePath, {
|
|
@@ -77499,7 +77783,7 @@ var bundleXcarchiveToTmpZip = (xcarchiveDir) => {
|
|
|
77499
77783
|
missingSystemJars: [],
|
|
77500
77784
|
totalBytes: 0,
|
|
77501
77785
|
excludedBytes: 0,
|
|
77502
|
-
maxArchiveBytes:
|
|
77786
|
+
maxArchiveBytes: 1024 * 1024 * 1024,
|
|
77503
77787
|
excludedFiles: picked.skippedDirs.map((dir) => ({
|
|
77504
77788
|
name: posix5(relative(xcarchiveDir, dir)),
|
|
77505
77789
|
reason: "generated-or-local-directory"
|
|
@@ -77878,7 +78162,7 @@ var runPentestMobileCommand = async (options) => {
|
|
|
77878
78162
|
missingSystemJars: [],
|
|
77879
78163
|
totalBytes: 0,
|
|
77880
78164
|
excludedBytes: 0,
|
|
77881
|
-
maxArchiveBytes:
|
|
78165
|
+
maxArchiveBytes: 1024 * 1024 * 1024,
|
|
77882
78166
|
excludedFiles: collected.skippedDirs.map((name) => ({
|
|
77883
78167
|
name: posix5(relative(repoRootCanonical, join(moduleDir, name))),
|
|
77884
78168
|
reason: "generated-or-local-directory"
|
|
@@ -81834,6 +82118,36 @@ var countConcluded = (doc) => {
|
|
|
81834
82118
|
}
|
|
81835
82119
|
return concluded;
|
|
81836
82120
|
};
|
|
82121
|
+
var syntheticEnvImpact = (doc) => {
|
|
82122
|
+
const root = asRecord8(doc);
|
|
82123
|
+
let count = 0;
|
|
82124
|
+
const names = /* @__PURE__ */ new Set();
|
|
82125
|
+
for (const rawItem of asArray2(root?.items)) {
|
|
82126
|
+
const item16 = asRecord8(rawItem);
|
|
82127
|
+
if (!item16) continue;
|
|
82128
|
+
for (const bucket of [
|
|
82129
|
+
item16.resolutions,
|
|
82130
|
+
asRecord8(item16.dast)?.resolutions,
|
|
82131
|
+
asRecord8(item16.client)?.resolutions
|
|
82132
|
+
]) {
|
|
82133
|
+
for (const rawResolution of asArray2(bucket)) {
|
|
82134
|
+
const resolution = asRecord8(rawResolution);
|
|
82135
|
+
if (resolution?.verdict !== "not-tested" || !CONCLUDED_VERDICTS.has(String(resolution.sandboxVerdict)))
|
|
82136
|
+
continue;
|
|
82137
|
+
const blockers = runtimeEnvBlockerNames([
|
|
82138
|
+
{
|
|
82139
|
+
source: "correlation.runtimeEnvBlockers",
|
|
82140
|
+
verbatim: JSON.stringify(asArray2(resolution.runtimeEnvBlockers))
|
|
82141
|
+
}
|
|
82142
|
+
]);
|
|
82143
|
+
if (blockers.length === 0) continue;
|
|
82144
|
+
count += 1;
|
|
82145
|
+
for (const name of blockers) names.add(name);
|
|
82146
|
+
}
|
|
82147
|
+
}
|
|
82148
|
+
}
|
|
82149
|
+
return { count, names: [...names].sort().slice(0, 256) };
|
|
82150
|
+
};
|
|
81837
82151
|
var BASELINE_STATUS_RE = /trả HTTP (\d{3})/;
|
|
81838
82152
|
var detectBaselineRefusal = async (dir) => {
|
|
81839
82153
|
let entries;
|
|
@@ -81955,6 +82269,13 @@ var runRuntimeOutcome = async (options) => {
|
|
|
81955
82269
|
const scenariosGenerated = countSuiteScenarios(suiteDoc) + countDastScenarios(dastDoc);
|
|
81956
82270
|
const correlationDoc = options.correlation === void 0 ? null : await readJson(resolve(cwd, options.correlation));
|
|
81957
82271
|
const scenariosConcluded = countConcluded(correlationDoc);
|
|
82272
|
+
const envImpact = syntheticEnvImpact(correlationDoc);
|
|
82273
|
+
if (envImpact.count > 0) {
|
|
82274
|
+
evidence18.push({
|
|
82275
|
+
source: "correlation.runtimeEnvBlockers",
|
|
82276
|
+
verbatim: JSON.stringify(envImpact.names)
|
|
82277
|
+
});
|
|
82278
|
+
}
|
|
81958
82279
|
if (correlationDoc !== null) delivered.push("correlation");
|
|
81959
82280
|
let oracleRefusedOnBaseline = false;
|
|
81960
82281
|
let measuredBaselineStatus;
|
|
@@ -81975,6 +82296,7 @@ var runRuntimeOutcome = async (options) => {
|
|
|
81975
82296
|
appServedHttp,
|
|
81976
82297
|
scenariosGenerated,
|
|
81977
82298
|
scenariosConcluded,
|
|
82299
|
+
...envImpact.count > 0 ? { syntheticEnvBlockedCount: envImpact.count } : {},
|
|
81978
82300
|
...measuredBaselineStatus !== void 0 ? { authBaselineStatus: measuredBaselineStatus } : {},
|
|
81979
82301
|
...oracleRefusedOnBaseline ? { oracleRefusedOnBaseline: true } : {},
|
|
81980
82302
|
...options.e2Scanned !== void 0 ? { e2ScannedCount: options.e2Scanned } : {},
|
|
@@ -82018,7 +82340,11 @@ var runRuntimeOutcome = async (options) => {
|
|
|
82018
82340
|
stopReason,
|
|
82019
82341
|
evidence: evidence18,
|
|
82020
82342
|
delivered: [...new Set(delivered)],
|
|
82021
|
-
deviations: [
|
|
82343
|
+
deviations: [
|
|
82344
|
+
...options.deviations ?? [],
|
|
82345
|
+
...kafkaDeviationRows,
|
|
82346
|
+
...envImpact.count > 0 ? [`synthetic runtime dependencies: ${envImpact.names.join(", ")}`] : []
|
|
82347
|
+
]
|
|
82022
82348
|
};
|
|
82023
82349
|
const violations = validateRuntimeOutcome(outcome);
|
|
82024
82350
|
if (violations.length > 0) {
|