fix(shared): redact repeated URL userinfo · openclaw/openclaw@04cd861
vincentkoc
·
2026-05-02
·
via Recent Commits to openclaw:main
| Original file line number | Diff line number | Diff line change |
|---|
@@ -204,7 +204,8 @@ describe("installPluginFromGitSpec", () => {
|
204 | 204 | runCommandWithTimeoutMock.mockResolvedValueOnce({ |
205 | 205 | code: 1, |
206 | 206 | stdout: "", |
207 | | -stderr: "fatal: could not read Username for 'https://token:secret@github.com/acme/demo.git'", |
| 207 | +stderr: |
| 208 | +"fatal: could not read Username for 'https://token:secret@github.com/acme/demo.git' while retrying https://other:credential@github.com/acme/fallback.git", |
208 | 209 | }); |
209 | 210 | |
210 | 211 | const result = await installPluginFromGitSpec({ |
@@ -215,8 +216,11 @@ describe("installPluginFromGitSpec", () => {
|
215 | 216 | if (!result.ok) { |
216 | 217 | expect(result.error).toContain("failed to clone github.com/acme/demo"); |
217 | 218 | expect(result.error).toContain("https://***:***@github.com/acme/demo.git"); |
| 219 | +expect(result.error).toContain("https://***:***@github.com/acme/fallback.git"); |
218 | 220 | expect(result.error).not.toContain("token"); |
219 | 221 | expect(result.error).not.toContain("secret"); |
| 222 | +expect(result.error).not.toContain("other"); |
| 223 | +expect(result.error).not.toContain("credential"); |
220 | 224 | } |
221 | 225 | expect(installPluginFromInstalledPackageDirMock).not.toHaveBeenCalled(); |
222 | 226 | }); |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -35,6 +35,14 @@ describe("redactSensitiveUrlLikeString", () => {
|
35 | 35 | ); |
36 | 36 | }); |
37 | 37 | |
| 38 | +it("redacts every URL-like userinfo occurrence in arbitrary text", () => { |
| 39 | +expect( |
| 40 | +redactSensitiveUrlLikeString( |
| 41 | +"fatal https://a:b@github.com/one.git and https://c:d@github.com/two.git", |
| 42 | +), |
| 43 | +).toBe("fatal https://***:***@github.com/one.git and https://***:***@github.com/two.git"); |
| 44 | +}); |
| 45 | + |
38 | 46 | it("redacts protocol URLs that are too malformed to parse", () => { |
39 | 47 | expect( |
40 | 48 | redactSensitiveUrlLikeString( |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -70,7 +70,7 @@ export function redactSensitiveUrlLikeString(value: string): string {
|
70 | 70 | return redactedUrl; |
71 | 71 | } |
72 | 72 | return value |
73 | | -.replace(/\/\/([^@/?#]+)@/, "//***:***@") |
| 73 | +.replace(/\/\/([^@/?#\s]+)@/g, "//***:***@") |
74 | 74 | .replace(/([?&])([^=&]+)=([^&]*)/g, (match, prefix: string, key: string) => |
75 | 75 | isSensitiveUrlQueryParamName(key) ? `${prefix}${key}=***` : match, |
76 | 76 | ); |
|
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。