Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 15 additions & 6 deletions integrations/cindy/plugins/powercontext-hooks/node/worker.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -2172,13 +2172,22 @@ function validatePreparedContext(response, path = "/v1/context/prepare", maxByte

//#endregion
//#region src/secrets.ts
const SECRET_MARKERS = [
"sk-",
"api_key",
"BEGIN PRIVATE"
const SECRET_PATTERNS = [
/-----BEGIN [A-Z0-9 ]*PRIVATE KEY-----[\s\S]*?(?:-----END [A-Z0-9 ]*PRIVATE KEY-----|$)/giu,
/(?<![\w-])["']?\b(?:authorization|proxy-authorization|cookie|set-cookie)\b["']?[ \t]*[:=][ \t]*[^\r\n]*(?:\r?\n[ \t]+[^\r\n]*)*/giu,
/(?<![\w-])["']?\b(?:api[_ -]?key|access[_ -]?(?:key|token)|client[_ -]?secret|secret(?:[_ -]?key)?|private[_ -]?key|password|passwd|passphrase|token|authorization|cookie)\b["']?\s*[:=]\s*(?:"[^"\r\n]*"|'[^'\r\n]*'|`[^`\r\n]*`|[^\s,;}\]]+)/giu,
/(?<![\w-])bearer\s+[A-Za-z0-9._~+/=-]{8,}(?![\w-])/giu,
/(?<![\w-])(?:sk-[A-Za-z0-9][A-Za-z0-9_-]{7,}|github_pat_[A-Za-z0-9_]{8,}|gh[pousr]_[A-Za-z0-9_]{8,}|xox[baprs]-[A-Za-z0-9-]{8,})(?![\w-])/giu
];
function containsSecret(text) {
return SECRET_MARKERS.some((marker) => text.includes(marker));
/** Return text with recognized credential-shaped values replaced. */
function scrubSecrets(text, authorization$1) {
const credential = authorization$1?.replace(/^Bearer\s+/iu, "");
if (credential) text = text.replaceAll(credential, "[REDACTED]");
return SECRET_PATTERNS.reduce((scrubbed, pattern) => scrubbed.replace(pattern, "[REDACTED]"), text);
}
/** Detect secrets without rejecting ordinary words that merely contain a marker. */
function containsSecret(text, authorization$1) {
return scrubSecrets(text, authorization$1) !== text;
}

//#endregion
Expand Down
23 changes: 16 additions & 7 deletions integrations/dsh/plugins/dsh-pet/lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -580,7 +580,7 @@ const OPERATIONS = {
scopeMode: "current",
pathParameters: [],
queryParams: [],
headerParams: [],
headerParams: ["X-PowerContext-Resolve-Target"],
successStatuses: [200],
emptyStatuses: []
},
Expand Down Expand Up @@ -2174,13 +2174,22 @@ function boundedRecallQuery(prompt) {

//#endregion
//#region src/secrets.ts
const SECRET_MARKERS = [
"sk-",
"api_key",
"BEGIN PRIVATE"
const SECRET_PATTERNS = [
/-----BEGIN [A-Z0-9 ]*PRIVATE KEY-----[\s\S]*?(?:-----END [A-Z0-9 ]*PRIVATE KEY-----|$)/giu,
/(?<![\w-])["']?\b(?:authorization|proxy-authorization|cookie|set-cookie)\b["']?[ \t]*[:=][ \t]*[^\r\n]*(?:\r?\n[ \t]+[^\r\n]*)*/giu,
/(?<![\w-])["']?\b(?:api[_ -]?key|access[_ -]?(?:key|token)|client[_ -]?secret|secret(?:[_ -]?key)?|private[_ -]?key|password|passwd|passphrase|token|authorization|cookie)\b["']?\s*[:=]\s*(?:"[^"\r\n]*"|'[^'\r\n]*'|`[^`\r\n]*`|[^\s,;}\]]+)/giu,
/(?<![\w-])bearer\s+[A-Za-z0-9._~+/=-]{8,}(?![\w-])/giu,
/(?<![\w-])(?:sk-[A-Za-z0-9][A-Za-z0-9_-]{7,}|github_pat_[A-Za-z0-9_]{8,}|gh[pousr]_[A-Za-z0-9_]{8,}|xox[baprs]-[A-Za-z0-9-]{8,})(?![\w-])/giu
];
function containsSecret(text) {
return SECRET_MARKERS.some((marker) => text.includes(marker));
/** Return text with recognized credential-shaped values replaced. */
function scrubSecrets(text, authorization) {
const credential = authorization?.replace(/^Bearer\s+/iu, "");
if (credential) text = text.replaceAll(credential, "[REDACTED]");
return SECRET_PATTERNS.reduce((scrubbed, pattern) => scrubbed.replace(pattern, "[REDACTED]"), text);
}
/** Detect secrets without rejecting ordinary words that merely contain a marker. */
function containsSecret(text, authorization) {
return scrubSecrets(text, authorization) !== text;
}

//#endregion
Expand Down
Loading