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

推荐订阅源

Martin Fowler
Martin Fowler
WordPress大学
WordPress大学
月光博客
月光博客
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
大猫的无限游戏
大猫的无限游戏
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
博客园 - 聂微东
Apple Machine Learning Research
Apple Machine Learning Research
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
雷峰网
雷峰网
小众软件
小众软件
酷 壳 – CoolShell
酷 壳 – CoolShell
博客园 - 叶小钗
美团技术团队
宝玉的分享
宝玉的分享
Hugging Face - Blog
Hugging Face - Blog
阮一峰的网络日志
阮一峰的网络日志
A
About on SuperTechFans
Jina AI
Jina AI
D
Docker
Last Week in AI
Last Week in AI
MongoDB | Blog
MongoDB | Blog
Stack Overflow Blog
Stack Overflow Blog
Microsoft Azure Blog
Microsoft Azure Blog

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(maintainer): gate body notifications after redaction ...
hxy91819 · 2026-05-16 · via Recent Commits to openclaw:main

@@ -7,6 +7,7 @@ import crypto from "node:crypto";

77

import fs from "node:fs";

88

import os from "node:os";

99

import path from "node:path";

10+

import { pathToFileURL } from "node:url";

10111112

const REPO = "openclaw/openclaw";

1213

const REPO_URL = `https://github.com/${REPO}`;

@@ -50,6 +51,34 @@ function ghGraphQL(query, options = {}) {

5051

return gh(["api", "graphql", "-f", `query=${query}`], options);

5152

}

525354+

function isBodyLocationType(locationType) {

55+

return locationType === "issue_body" || locationType === "pull_request_body";

56+

}

57+58+

export function decideBodyRedaction(currentBody, redactedBody) {

59+

const bodyChanged = String(currentBody) !== String(redactedBody);

60+

return {

61+

body_changed: bodyChanged,

62+

notify_required: bodyChanged,

63+

};

64+

}

65+66+

export function loadBodyRedactionResult(locationType, resultFile) {

67+

if (!isBodyLocationType(locationType)) {

68+

return { notify_required: true };

69+

}

70+

if (!resultFile) {

71+

fail("Body notifications require a redaction result file from redact-body-if-needed");

72+

}

73+

if (!fs.existsSync(resultFile)) fail(`File not found: ${resultFile}`);

74+75+

const result = JSON.parse(fs.readFileSync(resultFile, "utf8"));

76+

if (typeof result.notify_required !== "boolean") {

77+

fail(`Invalid redaction result file: missing boolean notify_required in ${resultFile}`);

78+

}

79+

return result;

80+

}

81+5382

function failOnGraphQLFailure(result, message) {

5483

if (result?.gh_failed) {

5584

const details = (

@@ -470,6 +499,43 @@ function cmdRedactBody(kind, number, bodyFile) {

470499

console.log(JSON.stringify({ ok: true, kind, number: Number(number) }));

471500

}

472501502+

/**

503+

* redact-body-if-needed <issue|pr> <number> <current-body-file> <redacted-body-file> <result-file>

504+

* PATCH only when the agent-produced redacted body differs from the current body.

505+

*/

506+

function cmdRedactBodyIfNeeded(kind, number, currentBodyFile, redactedBodyFile, resultFile) {

507+

if (!kind || !number || !currentBodyFile || !redactedBodyFile || !resultFile) {

508+

fail(

509+

"Usage: redact-body-if-needed <issue|pr> <number> <current-body-file> <redacted-body-file> <result-file>",

510+

);

511+

}

512+

if (!fs.existsSync(currentBodyFile)) fail(`File not found: ${currentBodyFile}`);

513+

if (!fs.existsSync(redactedBodyFile)) fail(`File not found: ${redactedBodyFile}`);

514+515+

const currentBody = fs.readFileSync(currentBodyFile, "utf8");

516+

const redactedBody = fs.readFileSync(redactedBodyFile, "utf8");

517+

const decision = decideBodyRedaction(currentBody, redactedBody);

518+

const result = {

519+

ok: true,

520+

kind,

521+

number: Number(number),

522+

...decision,

523+

};

524+525+

if (decision.body_changed) {

526+

const endpoint =

527+

kind === "pr" ? `repos/${REPO}/pulls/${number}` : `repos/${REPO}/issues/${number}`;

528+

gh(["api", endpoint, "-X", "PATCH", "-F", `body=@${redactedBodyFile}`]);

529+

result.redacted = true;

530+

} else {

531+

result.redacted = false;

532+

result.reason = "current_body_already_redacted";

533+

}

534+535+

fs.writeFileSync(resultFile, `${JSON.stringify(result, null, 2)}\n`, { mode: 0o600 });

536+

console.log(JSON.stringify(result));

537+

}

538+473539

/**

474540

* delete-comment <comment-id>

475541

* Delete a comment (and all its edit history).

@@ -555,6 +621,17 @@ function cmdNotify(target, author, locationType, secretTypes, replyToNodeId) {

555621556622

const types = secretTypes.split(",").map((s) => s.trim());

557623

const typeList = types.map((t, i) => `${i + 1}. **${t}**`).join("\n");

624+

const redactionResult = loadBodyRedactionResult(locationType, replyToNodeId);

625+

if (isBodyLocationType(locationType) && !redactionResult.notify_required) {

626+

console.log(

627+

JSON.stringify({

628+

ok: true,

629+

skipped: true,

630+

reason: "current_body_already_redacted",

631+

}),

632+

);

633+

return;

634+

}

558635559636

let locationDesc;

560637

let actionDesc;

@@ -758,12 +835,13 @@ function cmdSummary(jsonFile) {

758835759836

// ─── Dispatch ───────────────────────────────────────────────────────────────

760837761-

const [command, ...args] = process.argv.slice(2);

838+

const args = [];

762839763-

const commands = {

840+

export const commands = {

764841

"fetch-alert": () => cmdFetchAlert(args[0]),

765842

"fetch-content": () => cmdFetchContent(args[0]),

766843

"redact-body": () => cmdRedactBody(args[0], args[1], args[2]),

844+

"redact-body-if-needed": () => cmdRedactBodyIfNeeded(args[0], args[1], args[2], args[3], args[4]),

767845

"delete-comment": () => cmdDeleteComment(args[0]),

768846

"delete-discussion-comment": () => cmdDeleteDiscussionComment(args[0]),

769847

"recreate-comment": () => cmdRecreateComment(args[0], args[1]),

@@ -774,26 +852,37 @@ const commands = {

774852

summary: () => cmdSummary(args[0]),

775853

};

776854777-

if (!command || !commands[command]) {

778-

console.error(

779-

[

780-

"Usage: node secret-scanning.mjs <command> [args]",

781-

"",

782-

"Commands:",

783-

" fetch-alert <number> Fetch alert metadata + locations",

784-

" fetch-content '<location-json>' Fetch content for a location",

785-

" redact-body <issue|pr> <n> <file> PATCH body with redacted file",

786-

" delete-comment <comment-id> Delete a comment",

787-

" delete-discussion-comment <node-id> Delete a discussion comment (GraphQL)",

788-

" recreate-comment <issue-n> <file> Create replacement comment",

789-

" recreate-discussion-comment <disc-node-id> <file> [reply-to-node-id] Create discussion comment (GraphQL)",

790-

" notify <target> <author> <type> <types> [reply-to-node-id] Post notification",

791-

" resolve <n> [resolution] [comment] Close alert",

792-

" list-open List open alerts",

793-

" summary <json-file> Print formatted summary",

794-

].join("\n"),

795-

);

796-

process.exit(1);

855+

function main(argv = process.argv.slice(2)) {

856+

const [command, ...commandArgs] = argv;

857+

args.length = 0;

858+

args.push(...commandArgs);

859+860+

if (!command || !commands[command]) {

861+

console.error(

862+

[

863+

"Usage: node secret-scanning.mjs <command> [args]",

864+

"",

865+

"Commands:",

866+

" fetch-alert <number> Fetch alert metadata + locations",

867+

" fetch-content '<location-json>' Fetch content for a location",

868+

" redact-body <issue|pr> <n> <file> PATCH body with redacted file",

869+

" redact-body-if-needed <issue|pr> <n> <current-file> <redacted-file> <result-file> PATCH body only if redaction changed it",

870+

" delete-comment <comment-id> Delete a comment",

871+

" delete-discussion-comment <node-id> Delete a discussion comment (GraphQL)",

872+

" recreate-comment <issue-n> <file> Create replacement comment",

873+

" recreate-discussion-comment <disc-node-id> <file> [reply-to-node-id] Create discussion comment (GraphQL)",

874+

" notify <target> <author> <type> <types> [reply-to-node-id|body-result-file] Post notification",

875+

" resolve <n> [resolution] [comment] Close alert",

876+

" list-open List open alerts",

877+

" summary <json-file> Print formatted summary",

878+

].join("\n"),

879+

);

880+

process.exit(1);

881+

}

882+883+

commands[command]();

797884

}

798885799-

commands[command]();

886+

if (process.argv[1] && import.meta.url === pathToFileURL(process.argv[1]).href) {

887+

main();

888+

}