fix: resolve lint errors from transformation phases

- Remove unnecessary escape character in exec-blocklist regex
- Fix header spread in clawdhub client to handle all HeadersInit types
- Remove unused InjectionSeverity import from chat-sanitize test

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
ronitchidara 2026-01-27 20:38:21 +05:30
parent 8e00cbf27d
commit 676e3a1254
3 changed files with 20 additions and 7 deletions

View File

@ -92,14 +92,28 @@ async function fetchJson<T>(url: string, options: RequestInit = {}, timeoutMs =
const timeoutId = setTimeout(() => controller.abort(), timeoutMs); const timeoutId = setTimeout(() => controller.abort(), timeoutMs);
try { try {
const headers: Record<string, string> = {
Accept: "application/json",
"User-Agent": "clawdbot-gateway",
};
if (options.headers) {
const h = options.headers;
if (h instanceof Headers) {
h.forEach((value, key) => {
headers[key] = value;
});
} else if (Array.isArray(h)) {
for (const [key, value] of h) {
headers[key] = value;
}
} else {
Object.assign(headers, h);
}
}
const response = await fetch(url, { const response = await fetch(url, {
...options, ...options,
signal: controller.signal, signal: controller.signal,
headers: { headers,
Accept: "application/json",
"User-Agent": "clawdbot-gateway",
...options.headers,
},
}); });
if (!response.ok) { if (!response.ok) {

View File

@ -6,7 +6,6 @@ import {
wrapWithBoundaries, wrapWithBoundaries,
sanitizeIncomingMessage, sanitizeIncomingMessage,
PROMPT_BOUNDARIES, PROMPT_BOUNDARIES,
type InjectionSeverity,
} from "./chat-sanitize.js"; } from "./chat-sanitize.js";
describe("stripEnvelopeFromMessage", () => { describe("stripEnvelopeFromMessage", () => {

View File

@ -37,7 +37,7 @@ type BlocklistEntry = {
const CRITICAL_BLOCKLIST: BlocklistEntry[] = [ const CRITICAL_BLOCKLIST: BlocklistEntry[] = [
// Destructive filesystem operations // Destructive filesystem operations
{ {
pattern: /\brm\s+(-[a-zA-Z]*r[a-zA-Z]*\s+)?(-[a-zA-Z]*f[a-zA-Z]*\s+)?[\/~]\s*$/i, pattern: /\brm\s+(-[a-zA-Z]*r[a-zA-Z]*\s+)?(-[a-zA-Z]*f[a-zA-Z]*\s+)?[/~]\s*$/i,
description: "rm -rf / (root filesystem deletion)", description: "rm -rf / (root filesystem deletion)",
severity: "critical", severity: "critical",
requiresExplicitApproval: true, requiresExplicitApproval: true,