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

推荐订阅源

Google DeepMind News
Google DeepMind News
L
LangChain Blog
H
Help Net Security
博客园_首页
T
Tailwind CSS Blog
Microsoft Security Blog
Microsoft Security Blog
T
The Blog of Author Tim Ferriss
雷峰网
雷峰网
Recent Announcements
Recent Announcements
D
DataBreaches.Net
U
Unit 42
Vercel News
Vercel News
I
InfoQ
Martin Fowler
Martin Fowler
Microsoft Azure Blog
Microsoft Azure Blog
Apple Machine Learning Research
Apple Machine Learning Research
S
SegmentFault 最新的问题
Jina AI
Jina AI
博客园 - 叶小钗
博客园 - 【当耐特】
罗磊的独立博客
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
月光博客
月光博客
Last Week in AI
Last Week in AI

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
refactor(whatsapp): use async fs-safe credential checks ·...
steipete · 2026-05-21 · via Recent Commits to openclaw:main

@@ -1,8 +1,10 @@

11

import path from "node:path";

22

import {

3+

assertNoSymlinkParents,

34

assertNoSymlinkParentsSync,

45

readRegularFile,

56

readRegularFileSync,

7+

statRegularFile,

68

statRegularFileSync,

79

} from "openclaw/plugin-sdk/security-runtime";

810

@@ -14,22 +16,30 @@ export function resolveWebCredsBackupPath(authDir: string): string {

1416

return path.join(authDir, "creds.json.bak");

1517

}

161817-

function assertWebCredsParentPathSafe(filePath: string): void {

19+

function resolveWebCredsParentCheck(filePath: string) {

1820

const dir = path.resolve(path.dirname(filePath));

19-

assertNoSymlinkParentsSync({

21+

return {

2022

rootDir: path.parse(dir).root,

2123

targetPath: dir,

2224

allowMissing: true,

2325

allowRootChildSymlink: true,

2426

requireDirectories: true,

2527

messagePrefix: "WhatsApp credential file path",

26-

});

28+

} as const;

2729

}

283029-

export function assertWebCredsPathRegularFileOrMissing(filePath: string): void {

31+

async function assertWebCredsParentPathSafe(filePath: string): Promise<void> {

32+

await assertNoSymlinkParents(resolveWebCredsParentCheck(filePath));

33+

}

34+35+

function assertWebCredsParentPathSafeSync(filePath: string): void {

36+

assertNoSymlinkParentsSync(resolveWebCredsParentCheck(filePath));

37+

}

38+39+

export async function assertWebCredsPathRegularFileOrMissing(filePath: string): Promise<void> {

3040

try {

31-

assertWebCredsParentPathSafe(filePath);

32-

statRegularFileSync(filePath);

41+

await assertWebCredsParentPathSafe(filePath);

42+

await statRegularFile(filePath);

3343

} catch (error) {

3444

throw new Error(

3545

`WhatsApp credential file path is unsafe; creds.json must be a regular file or missing: ${filePath}`,

@@ -38,18 +48,9 @@ export function assertWebCredsPathRegularFileOrMissing(filePath: string): void {

3848

}

3949

}

405041-

export function isWebCredsPathRegularFileOrMissing(filePath: string): boolean {

42-

try {

43-

assertWebCredsPathRegularFileOrMissing(filePath);

44-

return true;

45-

} catch {

46-

return false;

47-

}

48-

}

49-5051

export function readWebCredsJsonRawSync(filePath: string): string | null {

5152

try {

52-

assertWebCredsParentPathSafe(filePath);

53+

assertWebCredsParentPathSafeSync(filePath);

5354

const { buffer, stat } = readRegularFileSync({

5455

filePath,

5556

});

@@ -61,7 +62,7 @@ export function readWebCredsJsonRawSync(filePath: string): string | null {

61626263

export async function readWebCredsJsonRaw(filePath: string): Promise<string | null> {

6364

try {

64-

assertWebCredsParentPathSafe(filePath);

65+

await assertWebCredsParentPathSafe(filePath);

6566

const { buffer, stat } = await readRegularFile({

6667

filePath,

6768

});

@@ -73,7 +74,7 @@ export async function readWebCredsJsonRaw(filePath: string): Promise<string | nu

73747475

export function statWebCredsFileSync(filePath: string): { mtimeMs: number; size: number } | null {

7576

try {

76-

assertWebCredsParentPathSafe(filePath);

77+

assertWebCredsParentPathSafeSync(filePath);

7778

const result = statRegularFileSync(filePath);

7879

if (result.missing || result.stat.size <= 1) {

7980

return null;

@@ -90,7 +91,7 @@ export function statWebCredsFileSync(filePath: string): { mtimeMs: number; size:

9091

export function hasWebCredsRegularFileSync(authDir: string): boolean {

9192

try {

9293

const credsPath = resolveWebCredsPath(authDir);

93-

assertWebCredsParentPathSafe(credsPath);

94+

assertWebCredsParentPathSafeSync(credsPath);

9495

return !statRegularFileSync(credsPath).missing;

9596

} catch {

9697

return false;