惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

D
Docker
IT之家
IT之家
Microsoft Security Blog
Microsoft Security Blog
博客园 - 司徒正美
云风的 BLOG
云风的 BLOG
P
Proofpoint News Feed
D
DataBreaches.Net
B
Blog RSS Feed
博客园_首页
The GitHub Blog
The GitHub Blog
I
InfoQ
L
LangChain Blog
G
Google Developers Blog
M
MIT News - Artificial intelligence
美团技术团队
腾讯CDC
V
Visual Studio Blog
aimingoo的专栏
aimingoo的专栏
博客园 - 聂微东
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
Apple Machine Learning Research
Apple Machine Learning Research
A
About on SuperTechFans
博客园 - 三生石上(FineUI控件)
博客园 - 叶小钗

Recent Commits to openclaw:main

test: merge chat side-result checks · openclaw/openclaw@ddd2c2a test: merge cron history checks · openclaw/openclaw@f7eb746 test: merge responsive navigation shell checks · openclaw/openclaw@c2e4b47 docs(changelog): add codex oauth fixes · openclaw/openclaw@628e6cd test: merge navigation routing cases · openclaw/openclaw@5d8cecb Tests: mock channel registry bundled fallback · openclaw/openclaw@2b08233 Secrets: avoid broad web search discovery for single plugin config · openclaw/openclaw@a464f59 test: merge config view browser checks · openclaw/openclaw@20cf511 fix(status): align oauth health with runtime · openclaw/openclaw@eed7116 feat: add macOS screen snapshots for monitor preview (#67954) thanks … · openclaw/openclaw@f377db1 fix: report shared auth scopes in hello-ok (#67810) thanks @BunsDev · openclaw/openclaw@0b6c39b Auto-reply: avoid eager bundled route fallback · openclaw/openclaw@3ea1bf4 Tests: narrow session binding contract setup · openclaw/openclaw@54e4e16 fix(macOS): enable undo/redo in webchat composer text input (#34962) · openclaw/openclaw@00951dc Tests: speed up channel setup promotion · openclaw/openclaw@82b529a Docs: refresh agent instructions · openclaw/openclaw@5775fe2 fix(auth): serialize OAuth refresh across agents to fix #26322 (#67876) · openclaw/openclaw@8e79080 test: allow ollama public surface boundary test · openclaw/openclaw@7d4f1a6 Docs: add test performance guardrails · openclaw/openclaw@89706d3 Tests: restore context-engine usage proof · openclaw/openclaw@e4c4f95 Tests: slim context engine runtime coverage · openclaw/openclaw@74c198f ci: retry failed custom checkouts · openclaw/openclaw@0ee5baf test: trim duplicate provider auth onboarding cases · openclaw/openclaw@1ffc02e matrix: fix sessions_spawn --thread subagent session spawning (#67643) · openclaw/openclaw@1ce2596 test: reduce auth choice fixture churn · openclaw/openclaw@857b9cd test: mock health status config boundaries · openclaw/openclaw@9d5ab4a test: mock onboard config io boundary · openclaw/openclaw@299694d test: mock legacy state plugin boundaries · openclaw/openclaw@2713089 test: mock channel install boundaries · openclaw/openclaw@b945248 test: mock doctor preview channel boundaries · openclaw/openclaw@b1a3ad4
fix(security): bound prod audit registry responses · open...
vincentkoc · 2026-05-29 · via Recent Commits to openclaw:main

@@ -9,6 +9,8 @@ const DEFAULT_REGISTRY = "https://registry.npmjs.org";

99

const BULK_ADVISORY_PATH = "/-/npm/v1/security/advisories/bulk";

1010

const MIN_SEVERITY = "high";

1111

export const BULK_ADVISORY_ERROR_BODY_MAX_CHARS = 4096;

12+

export const BULK_ADVISORY_RESPONSE_BODY_MAX_BYTES = 8 * 1024 * 1024;

13+

export const BULK_ADVISORY_REQUEST_TIMEOUT_MS = 60_000;

1214

const SEVERITY_RANK = {

1315

info: 0,

1416

low: 1,

@@ -677,6 +679,92 @@ function resolveRegistryBaseUrl() {

677679

return configured.replace(/\/+$/u, "");

678680

}

679681682+

function parsePositiveIntegerEnv(name, fallback) {

683+

const raw = process.env[name]?.trim();

684+

if (!raw) {

685+

return fallback;

686+

}

687+

const parsed = Number.parseInt(raw, 10);

688+

if (!Number.isSafeInteger(parsed) || parsed < 1 || String(parsed) !== raw) {

689+

throw new Error(`${name} must be a positive integer`);

690+

}

691+

return parsed;

692+

}

693+694+

function resolveBulkAdvisoryRequestTimeoutMs() {

695+

return parsePositiveIntegerEnv(

696+

"OPENCLAW_PNPM_AUDIT_BULK_TIMEOUT_MS",

697+

BULK_ADVISORY_REQUEST_TIMEOUT_MS,

698+

);

699+

}

700+701+

function resolveBulkAdvisoryResponseBodyMaxBytes() {

702+

return parsePositiveIntegerEnv(

703+

"OPENCLAW_PNPM_AUDIT_BULK_RESPONSE_MAX_BYTES",

704+

BULK_ADVISORY_RESPONSE_BODY_MAX_BYTES,

705+

);

706+

}

707+708+

async function withBulkAdvisoryTimeout({ label, timeoutMs, run }) {

709+

const controller = new AbortController();

710+

let timeout;

711+

try {

712+

return await Promise.race([

713+

run(controller.signal),

714+

new Promise((_resolve, reject) => {

715+

timeout = setTimeout(() => {

716+

const error = new Error(`${label} exceeded timeout of ${timeoutMs}ms`);

717+

controller.abort(error);

718+

reject(error);

719+

}, timeoutMs);

720+

}),

721+

]);

722+

} finally {

723+

if (timeout) {

724+

clearTimeout(timeout);

725+

}

726+

}

727+

}

728+729+

async function readBoundedResponseText(response, maxBytes, label) {

730+

const contentLength = Number.parseInt(response.headers?.get?.("content-length") ?? "", 10);

731+

if (Number.isFinite(contentLength) && contentLength > maxBytes) {

732+

throw Object.assign(new Error(`${label} exceeded ${maxBytes} bytes`), { code: "ETOOBIG" });

733+

}

734+735+

if (!response.body) {

736+

return "";

737+

}

738+739+

const reader = response.body.getReader();

740+

const decoder = new TextDecoder();

741+

const chunks = [];

742+

let totalBytes = 0;

743+

try {

744+

for (;;) {

745+

const { done, value } = await reader.read();

746+

if (done) {

747+

const tail = decoder.decode();

748+

if (tail) {

749+

chunks.push(tail);

750+

}

751+

break;

752+

}

753+754+

totalBytes += value.byteLength;

755+

if (totalBytes > maxBytes) {

756+

await reader.cancel().catch(() => undefined);

757+

throw Object.assign(new Error(`${label} exceeded ${maxBytes} bytes`), { code: "ETOOBIG" });

758+

}

759+

chunks.push(decoder.decode(value, { stream: true }));

760+

}

761+

} finally {

762+

reader.releaseLock();

763+

}

764+765+

return chunks.join("");

766+

}

767+680768

export async function readBoundedBulkAdvisoryErrorText(

681769

response,

682770

maxChars = BULK_ADVISORY_ERROR_BODY_MAX_CHARS,

@@ -716,29 +804,46 @@ export async function readBoundedBulkAdvisoryErrorText(

716804

return truncated ? `${text}\n[truncated]` : text;

717805

}

718806807+

async function readBulkAdvisoryJson(response, maxBytes) {

808+

const text = await readBoundedResponseText(response, maxBytes, "Bulk advisory response body");

809+

if (!text.trim()) {

810+

throw new Error("Bulk advisory response body was empty");

811+

}

812+

return JSON.parse(text);

813+

}

814+719815

export async function fetchBulkAdvisories({

720816

payload,

721817

fetchImpl = fetch,

722818

registryBaseUrl = resolveRegistryBaseUrl(),

819+

responseBodyMaxBytes = resolveBulkAdvisoryResponseBodyMaxBytes(),

820+

timeoutMs = resolveBulkAdvisoryRequestTimeoutMs(),

723821

}) {

724822

const url = `${registryBaseUrl}${BULK_ADVISORY_PATH}`;

725-

const response = await fetchImpl(url, {

726-

method: "POST",

727-

headers: {

728-

accept: "application/json",

729-

"content-type": "application/json",

730-

},

731-

body: JSON.stringify(payload),

732-

});

823+

return await withBulkAdvisoryTimeout({

824+

label: "Bulk advisory request",

825+

timeoutMs,

826+

run: async (signal) => {

827+

const response = await fetchImpl(url, {

828+

method: "POST",

829+

headers: {

830+

accept: "application/json",

831+

"content-type": "application/json",

832+

},

833+

body: JSON.stringify(payload),

834+

signal,

835+

});

733836734-

if (!response.ok) {

735-

const bodyText = await readBoundedBulkAdvisoryErrorText(response);

736-

throw new Error(

737-

`Bulk advisory request failed (${response.status} ${response.statusText}): ${bodyText}`,

738-

);

739-

}

837+

if (!response.ok) {

838+

const bodyText = await readBoundedBulkAdvisoryErrorText(response);

839+

throw new Error(

840+

`Bulk advisory request failed (${response.status} ${response.statusText}): ${bodyText}`,

841+

);

842+

}

740843741-

return response.json();

844+

return await readBulkAdvisoryJson(response, responseBodyMaxBytes);

845+

},

846+

});

742847

}

743848744849

export async function runPnpmAuditProd({