plugin-git-manager 1.2.26 → 1.2.28
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +133 -108
- package/client-v2.d.ts +2 -2
- package/client-v2.js +1 -1
- package/client.d.ts +3 -3
- package/client.js +1 -1
- package/dist/client/{326.90c276058682b536.js → 313.d38fc1d40c4589b9.js} +1 -1
- package/dist/client/900.a48beac7e2ebee7d.js +10 -0
- package/dist/client/index.js +1 -1
- package/dist/client-v2/156.445366026c1cc9a8.js +10 -0
- package/dist/client-v2/{326.42b7b53651ffab3a.js → 313.3c867179c3a1e817.js} +1 -1
- package/dist/client-v2/434.19c7579c06b9077c.js +10 -0
- package/dist/client-v2/900.e6155002a9c97e7f.js +10 -0
- package/dist/client-v2/928.bba701b5a1ece58e.js +10 -0
- package/dist/client-v2/index.js +1 -1
- package/dist/externalVersion.js +9 -8
- package/dist/locale/en-US.json +307 -297
- package/dist/locale/vi-VN.json +295 -292
- package/dist/locale/zh-CN.json +61 -51
- package/dist/node_modules/simple-git/dist/cjs/index.js +25 -25
- package/dist/node_modules/simple-git/package.json +1 -1
- package/dist/node_modules/zod/index.cjs +1 -1
- package/dist/node_modules/zod/package.json +1 -1
- package/dist/server/actions/git-actions.js +90 -36
- package/dist/server/actions/gitlab-api.js +4 -2
- package/dist/server/actions/poller.js +5 -2
- package/dist/server/actions/review.js +20 -10
- package/dist/server/plugin.js +6 -4
- package/dist/server/poller.js +46 -45
- package/dist/server/request-method-policy.js +75 -0
- package/dist/server/services/registry-content-service.js +23 -10
- package/dist/server/utils/get-repo-account.js +3 -2
- package/dist/server/utils/url-security.js +24 -0
- package/package.json +61 -43
- package/server.d.ts +2 -2
- package/server.js +1 -1
- package/src/client/__tests__/RunReviewButton.test.tsx +73 -0
- package/src/client/ai-context.tsx +114 -114
- package/src/client/components/AIEmployeeSelect.tsx +63 -63
- package/src/client/components/CommitHistory.tsx +374 -374
- package/src/client/components/FileExplorer.tsx +386 -386
- package/src/client/components/GitAccounts.tsx +179 -179
- package/src/client/components/GitManagerSettings.tsx +160 -160
- package/src/client/components/GitOperations.tsx +220 -220
- package/src/client/components/LLMModelSelect.tsx +63 -63
- package/src/client/components/LLMServiceSelect.tsx +58 -58
- package/src/client/components/MarkdownView.tsx +80 -80
- package/src/client/components/MergeRequests.tsx +790 -790
- package/src/client/components/PollingStatus.tsx +225 -225
- package/src/client/components/RepositoryConfig.tsx +335 -335
- package/src/client/components/RepositoryPermissions.tsx +123 -123
- package/src/client/components/ReviewFlows.tsx +303 -303
- package/src/client/components/ReviewHistory.tsx +566 -566
- package/src/client/components/RunReviewButton.tsx +63 -55
- package/src/client/context/GitManagerContext.tsx +92 -92
- package/src/client/index.tsx +91 -82
- package/src/client/locale.ts +9 -9
- package/src/client/promptTemplates.ts +31 -31
- package/src/client-v2/ai-context.tsx +99 -0
- package/src/client-v2/components/SubtreeSplits.tsx +547 -547
- package/src/client-v2/index.tsx +1 -1
- package/src/client-v2/locale.ts +8 -8
- package/src/client-v2/plugin.tsx +67 -39
- package/src/index.ts +2 -2
- package/src/locale/en-US.json +307 -297
- package/src/locale/vi-VN.json +295 -292
- package/src/locale/zh-CN.json +61 -51
- package/src/server/__tests__/git-actions.test.ts +24 -24
- package/src/server/__tests__/git-security.test.ts +170 -0
- package/src/server/__tests__/plugin-url-security.test.ts +17 -17
- package/src/server/__tests__/poller-lifecycle.test.ts +71 -0
- package/src/server/__tests__/poller.test.ts +37 -37
- package/src/server/__tests__/repository-access.test.ts +752 -752
- package/src/server/__tests__/review.test.ts +137 -137
- package/src/server/__tests__/role-permissions.test.ts +147 -147
- package/src/server/__tests__/smoke.test.ts +139 -17
- package/src/server/__tests__/subtree.test.ts +85 -85
- package/src/server/actions/git-actions.ts +540 -480
- package/src/server/actions/gitlab-api.ts +422 -411
- package/src/server/actions/poller.ts +39 -27
- package/src/server/actions/review.ts +1388 -1369
- package/src/server/actions/role-permissions.ts +321 -321
- package/src/server/actions/subtree.ts +508 -508
- package/src/server/ai-tools.ts +319 -319
- package/src/server/collections/gitAccounts.ts +56 -56
- package/src/server/collections/gitCodeReviews.ts +199 -199
- package/src/server/collections/gitRepositories.ts +87 -87
- package/src/server/collections/gitReviewFlows.ts +108 -108
- package/src/server/collections/gitSubtreeConfigs.ts +38 -38
- package/src/server/collections/gitSubtreeRuns.ts +30 -30
- package/src/server/index.ts +2 -2
- package/src/server/migrations/20260508000000-add-auto-review-flow-id.ts +29 -29
- package/src/server/migrations/20260712000000-add-git-accounts.ts +198 -198
- package/src/server/migrations/20260730000000-migrate-legacy-repository-permissions.ts +81 -81
- package/src/server/plugin.ts +372 -361
- package/src/server/poller.ts +351 -352
- package/src/server/repository-access.ts +773 -773
- package/src/server/request-method-policy.ts +55 -0
- package/src/server/services/__tests__/registry-content-service.test.ts +359 -345
- package/src/server/services/registry-content-service.ts +33 -11
- package/src/server/utils/__tests__/redact.test.ts +56 -56
- package/src/server/utils/__tests__/url-security.test.ts +85 -85
- package/src/server/utils/get-repo-account.ts +51 -41
- package/src/server/utils/gitlab-url.ts +38 -38
- package/src/server/utils/redact.ts +87 -87
- package/src/server/utils/url-security.ts +128 -95
- package/dist/client/900.acf7d1fa22f95e71.js +0 -10
- package/dist/client-v2/434.7a27051db18526c0.js +0 -10
- package/dist/client-v2/900.f32b9dc85249fc0a.js +0 -10
|
@@ -1,87 +1,87 @@
|
|
|
1
|
-
import { redactUrlUserInfo } from './url-security';
|
|
2
|
-
|
|
3
|
-
export const REDACTED_PAT = '••••••••';
|
|
4
|
-
|
|
5
|
-
const GIT_MANAGER_RESOURCE_SEGMENTS = new Set([
|
|
6
|
-
'gitManager',
|
|
7
|
-
'gitRepositories',
|
|
8
|
-
'gitAccounts',
|
|
9
|
-
'gitReviewFlows',
|
|
10
|
-
'gitCodeReviews',
|
|
11
|
-
'gitSubtreeConfigs',
|
|
12
|
-
'gitSubtreeRuns',
|
|
13
|
-
]);
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* Association routes use names such as `gitAccounts.1.repositories`, not the
|
|
17
|
-
* raw collection name. Redact every Git Manager resource response so those
|
|
18
|
-
* routes cannot bypass credential scrubbing merely because their name is
|
|
19
|
-
* nested.
|
|
20
|
-
*/
|
|
21
|
-
export function isGitManagerResourceResponse(resourceName: unknown): boolean {
|
|
22
|
-
return (
|
|
23
|
-
typeof resourceName === 'string' &&
|
|
24
|
-
resourceName.split(/[.[\],:/()=\s]+/).some((segment) => GIT_MANAGER_RESOURCE_SEGMENTS.has(segment))
|
|
25
|
-
);
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
* Redact embedded credentials from URLs in arbitrary strings.
|
|
30
|
-
* Matches `scheme://user:password@host` and replaces with `scheme://***:***@host`.
|
|
31
|
-
* Used to scrub error messages before persisting them to the DB or
|
|
32
|
-
* returning them to the client, since simple-git often echoes the
|
|
33
|
-
* authenticated remote URL in stderr.
|
|
34
|
-
*/
|
|
35
|
-
export function redactPat(s: unknown): string {
|
|
36
|
-
if (typeof s !== 'string') return s == null ? '' : String(s);
|
|
37
|
-
return redactUrlUserInfo(s);
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
/**
|
|
41
|
-
* Mutate `err.message` (and common fields where simple-git stashes stderr)
|
|
42
|
-
* to remove any embedded PAT before the error propagates further.
|
|
43
|
-
*/
|
|
44
|
-
export function redactError<T>(err: T): T {
|
|
45
|
-
if (!err || typeof err !== 'object') return err;
|
|
46
|
-
const error = err as { message?: unknown; stderr?: unknown; stdout?: unknown };
|
|
47
|
-
if (typeof error.message === 'string') error.message = redactPat(error.message);
|
|
48
|
-
if (typeof error.stderr === 'string') error.stderr = redactPat(error.stderr);
|
|
49
|
-
if (typeof error.stdout === 'string') error.stdout = redactPat(error.stdout);
|
|
50
|
-
return err;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
/**
|
|
54
|
-
* Redact PAT fields anywhere in a serializable API response. Repository
|
|
55
|
-
* responses can contain a nested `gitAccount` (and Sequelize's nested
|
|
56
|
-
* `dataValues`), so a shallow top-level scrub is not sufficient.
|
|
57
|
-
*/
|
|
58
|
-
export function redactCredentialFields(value: unknown): void {
|
|
59
|
-
const visited = new WeakSet<object>();
|
|
60
|
-
|
|
61
|
-
const visit = (current: unknown): void => {
|
|
62
|
-
if (!current || typeof current !== 'object' || visited.has(current)) {
|
|
63
|
-
return;
|
|
64
|
-
}
|
|
65
|
-
visited.add(current);
|
|
66
|
-
|
|
67
|
-
if (Array.isArray(current)) {
|
|
68
|
-
current.forEach(visit);
|
|
69
|
-
return;
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
const record = current as Record<string, unknown>;
|
|
73
|
-
for (const [key, nestedValue] of Object.entries(record)) {
|
|
74
|
-
if (key === 'pat') {
|
|
75
|
-
record[key] = REDACTED_PAT;
|
|
76
|
-
continue;
|
|
77
|
-
}
|
|
78
|
-
if ((key === 'repoUrl' || key === 'baseUrl') && typeof nestedValue === 'string') {
|
|
79
|
-
record[key] = redactUrlUserInfo(nestedValue);
|
|
80
|
-
continue;
|
|
81
|
-
}
|
|
82
|
-
visit(nestedValue);
|
|
83
|
-
}
|
|
84
|
-
};
|
|
85
|
-
|
|
86
|
-
visit(value);
|
|
87
|
-
}
|
|
1
|
+
import { redactUrlUserInfo } from './url-security';
|
|
2
|
+
|
|
3
|
+
export const REDACTED_PAT = '••••••••';
|
|
4
|
+
|
|
5
|
+
const GIT_MANAGER_RESOURCE_SEGMENTS = new Set([
|
|
6
|
+
'gitManager',
|
|
7
|
+
'gitRepositories',
|
|
8
|
+
'gitAccounts',
|
|
9
|
+
'gitReviewFlows',
|
|
10
|
+
'gitCodeReviews',
|
|
11
|
+
'gitSubtreeConfigs',
|
|
12
|
+
'gitSubtreeRuns',
|
|
13
|
+
]);
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Association routes use names such as `gitAccounts.1.repositories`, not the
|
|
17
|
+
* raw collection name. Redact every Git Manager resource response so those
|
|
18
|
+
* routes cannot bypass credential scrubbing merely because their name is
|
|
19
|
+
* nested.
|
|
20
|
+
*/
|
|
21
|
+
export function isGitManagerResourceResponse(resourceName: unknown): boolean {
|
|
22
|
+
return (
|
|
23
|
+
typeof resourceName === 'string' &&
|
|
24
|
+
resourceName.split(/[.[\],:/()=\s]+/).some((segment) => GIT_MANAGER_RESOURCE_SEGMENTS.has(segment))
|
|
25
|
+
);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Redact embedded credentials from URLs in arbitrary strings.
|
|
30
|
+
* Matches `scheme://user:password@host` and replaces with `scheme://***:***@host`.
|
|
31
|
+
* Used to scrub error messages before persisting them to the DB or
|
|
32
|
+
* returning them to the client, since simple-git often echoes the
|
|
33
|
+
* authenticated remote URL in stderr.
|
|
34
|
+
*/
|
|
35
|
+
export function redactPat(s: unknown): string {
|
|
36
|
+
if (typeof s !== 'string') return s == null ? '' : String(s);
|
|
37
|
+
return redactUrlUserInfo(s);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Mutate `err.message` (and common fields where simple-git stashes stderr)
|
|
42
|
+
* to remove any embedded PAT before the error propagates further.
|
|
43
|
+
*/
|
|
44
|
+
export function redactError<T>(err: T): T {
|
|
45
|
+
if (!err || typeof err !== 'object') return err;
|
|
46
|
+
const error = err as { message?: unknown; stderr?: unknown; stdout?: unknown };
|
|
47
|
+
if (typeof error.message === 'string') error.message = redactPat(error.message);
|
|
48
|
+
if (typeof error.stderr === 'string') error.stderr = redactPat(error.stderr);
|
|
49
|
+
if (typeof error.stdout === 'string') error.stdout = redactPat(error.stdout);
|
|
50
|
+
return err;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Redact PAT fields anywhere in a serializable API response. Repository
|
|
55
|
+
* responses can contain a nested `gitAccount` (and Sequelize's nested
|
|
56
|
+
* `dataValues`), so a shallow top-level scrub is not sufficient.
|
|
57
|
+
*/
|
|
58
|
+
export function redactCredentialFields(value: unknown): void {
|
|
59
|
+
const visited = new WeakSet<object>();
|
|
60
|
+
|
|
61
|
+
const visit = (current: unknown): void => {
|
|
62
|
+
if (!current || typeof current !== 'object' || visited.has(current)) {
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
visited.add(current);
|
|
66
|
+
|
|
67
|
+
if (Array.isArray(current)) {
|
|
68
|
+
current.forEach(visit);
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
const record = current as Record<string, unknown>;
|
|
73
|
+
for (const [key, nestedValue] of Object.entries(record)) {
|
|
74
|
+
if (key === 'pat') {
|
|
75
|
+
record[key] = REDACTED_PAT;
|
|
76
|
+
continue;
|
|
77
|
+
}
|
|
78
|
+
if ((key === 'repoUrl' || key === 'baseUrl') && typeof nestedValue === 'string') {
|
|
79
|
+
record[key] = redactUrlUserInfo(nestedValue);
|
|
80
|
+
continue;
|
|
81
|
+
}
|
|
82
|
+
visit(nestedValue);
|
|
83
|
+
}
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
visit(value);
|
|
87
|
+
}
|
|
@@ -1,95 +1,128 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
return
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
return
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
1
|
+
/**
|
|
2
|
+
* This file is part of the NocoBase (R) project.
|
|
3
|
+
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
+
* Authors: NocoBase Team.
|
|
5
|
+
*
|
|
6
|
+
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
+
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
export const URL_USERINFO_NOT_ALLOWED = 'Credential-bearing URLs are not allowed';
|
|
11
|
+
|
|
12
|
+
export function assertAccountRepositoryUrl(repoUrl: string, baseUrl: string | null, provider: string): void {
|
|
13
|
+
assertUrlHasNoUserInfo(repoUrl);
|
|
14
|
+
const trustedUrl = baseUrl || (provider === 'github' ? 'https://github.com' : 'https://gitlab.com');
|
|
15
|
+
assertUrlHasNoUserInfo(trustedUrl);
|
|
16
|
+
let repository: URL;
|
|
17
|
+
let account: URL;
|
|
18
|
+
try {
|
|
19
|
+
repository = new URL(repoUrl);
|
|
20
|
+
account = new URL(trustedUrl);
|
|
21
|
+
} catch {
|
|
22
|
+
throw new Error('Invalid repository or account URL');
|
|
23
|
+
}
|
|
24
|
+
if (repository.protocol !== 'https:' || account.protocol !== 'https:') {
|
|
25
|
+
throw new Error('Only HTTPS repository and account URLs are allowed');
|
|
26
|
+
}
|
|
27
|
+
if (repository.origin !== account.origin) {
|
|
28
|
+
throw new Error('Repository URL must match the Git account origin');
|
|
29
|
+
}
|
|
30
|
+
// This plugin currently implements the public GitHub API, not GitHub Enterprise endpoints.
|
|
31
|
+
if (provider === 'github' && repository.origin !== 'https://github.com') {
|
|
32
|
+
throw new Error('GitHub accounts currently require github.com');
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
function pathSegments(value: string): string[] {
|
|
37
|
+
return value.split(/[.[\],:/()=\s'"]+/);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
function parseStructuredValue(value: string): unknown {
|
|
41
|
+
const trimmed = value.trim();
|
|
42
|
+
if (!trimmed.startsWith('{') && !trimmed.startsWith('[')) {
|
|
43
|
+
return undefined;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
try {
|
|
47
|
+
return JSON.parse(trimmed);
|
|
48
|
+
} catch {
|
|
49
|
+
return undefined;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export function hasUrlUserInfo(value: unknown): boolean {
|
|
54
|
+
if (typeof value !== 'string' || !value.trim()) {
|
|
55
|
+
return false;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
try {
|
|
59
|
+
const url = new URL(value.trim());
|
|
60
|
+
return Boolean(url.username || url.password);
|
|
61
|
+
} catch {
|
|
62
|
+
return false;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
export function assertUrlHasNoUserInfo(value: unknown): void {
|
|
67
|
+
if (hasUrlUserInfo(value)) {
|
|
68
|
+
throw new Error(URL_USERINFO_NOT_ALLOWED);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
function containsUrlUserInfo(value: unknown, visited = new WeakSet<object>()): boolean {
|
|
73
|
+
if (typeof value === 'string') {
|
|
74
|
+
return hasUrlUserInfo(value);
|
|
75
|
+
}
|
|
76
|
+
if (!value || typeof value !== 'object' || visited.has(value)) {
|
|
77
|
+
return false;
|
|
78
|
+
}
|
|
79
|
+
visited.add(value);
|
|
80
|
+
|
|
81
|
+
if (Array.isArray(value)) {
|
|
82
|
+
return value.some((item) => containsUrlUserInfo(item, visited));
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
return Object.values(value as Record<string, unknown>).some((item) => containsUrlUserInfo(item, visited));
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* Generic NocoBase actions can place values directly, inside `values`, or in
|
|
90
|
+
* dotted/bracket paths that UpdateGuard normalizes later. Find userinfo only
|
|
91
|
+
* when it belongs to one of the URL-bearing configuration fields.
|
|
92
|
+
*/
|
|
93
|
+
export function containsCredentialBearingUrlField(
|
|
94
|
+
value: unknown,
|
|
95
|
+
fieldNames: ReadonlySet<string>,
|
|
96
|
+
visited = new WeakSet<object>(),
|
|
97
|
+
): boolean {
|
|
98
|
+
if (typeof value === 'string') {
|
|
99
|
+
const structuredValue = parseStructuredValue(value);
|
|
100
|
+
return structuredValue ? containsCredentialBearingUrlField(structuredValue, fieldNames, visited) : false;
|
|
101
|
+
}
|
|
102
|
+
if (!value || typeof value !== 'object' || visited.has(value)) {
|
|
103
|
+
return false;
|
|
104
|
+
}
|
|
105
|
+
visited.add(value);
|
|
106
|
+
|
|
107
|
+
if (Array.isArray(value)) {
|
|
108
|
+
return value.some((item) => containsCredentialBearingUrlField(item, fieldNames, visited));
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
return Object.entries(value as Record<string, unknown>).some(([key, item]) => {
|
|
112
|
+
if (pathSegments(key).some((segment) => fieldNames.has(segment)) && containsUrlUserInfo(item)) {
|
|
113
|
+
return true;
|
|
114
|
+
}
|
|
115
|
+
return containsCredentialBearingUrlField(item, fieldNames, visited);
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
/**
|
|
120
|
+
* Preserve the rest of a URL while masking URL userinfo in legacy data or an
|
|
121
|
+
* accidentally nested API response.
|
|
122
|
+
*/
|
|
123
|
+
export function redactUrlUserInfo(value: string): string {
|
|
124
|
+
// Userinfo may itself contain an unescaped `@`; match through the final
|
|
125
|
+
// authority `@` rather than stopping at the first one and leaking part of
|
|
126
|
+
// a password in a malformed or legacy URL.
|
|
127
|
+
return value.replace(/([a-z][a-z\d+.-]*:\/\/)([^/?#\s]+)@/gi, '$1***:***@');
|
|
128
|
+
}
|