@ai-workbench/connect 0.7.55-rc.3 → 0.7.55-rc.4
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/lib/private-files.js
CHANGED
|
@@ -12,7 +12,7 @@ async function windowsPrivate(path, directory, before) {
|
|
|
12
12
|
if (s.isSymbolicLink() || (directory ? !s.isDirectory() : !s.isFile() || s.nlink !== 1))
|
|
13
13
|
throw new Error(directory ? 'PRIVATE_DIRECTORY_REQUIRED' : 'PRIVATE_FILE_REQUIRED');
|
|
14
14
|
const acl = await host.security.inspect(path);
|
|
15
|
-
if (acl.reparse || !privateSddl(acl.sddl, host.security.sid()))
|
|
15
|
+
if (acl.reparse || !privateSddl(acl.sddl, host.security.sid(), directory))
|
|
16
16
|
throw new Error(directory ? 'PRIVATE_DIRECTORY_REQUIRED' : 'PRIVATE_FILE_REQUIRED');
|
|
17
17
|
return s;
|
|
18
18
|
}
|
|
@@ -14,6 +14,10 @@ export interface WindowsSecurity {
|
|
|
14
14
|
export declare function parseWhoami(text: string): string | undefined;
|
|
15
15
|
/** SID 末段(RID):Windows 上与 macOS uid 同用途(节点名后缀)。 */
|
|
16
16
|
export declare function rid(sid: string): string;
|
|
17
|
-
/**
|
|
18
|
-
|
|
17
|
+
/**
|
|
18
|
+
* SDDL 判定:所有者是本人、每条 ACE 都是“允许”且对象只在 本人/SYSTEM/Administrators 之内;目录还须 DACL 受保护(不继承)。
|
|
19
|
+
* 文件不要求受保护:L 读的私有文件都在 L 已核为受保护私有的目录里,其继承项只能来自该目录;N 写入交接配置(network-config\config.json)
|
|
20
|
+
* 用“临时文件 + 改名”,新文件继承所在私有目录的 ACE(awtest 实机读回 D:AI(A;ID;FA;;;BA)(A;ID;FA;;;SY)(A;ID;FA;;;本人)),有效访问者同样只有三方。
|
|
21
|
+
*/
|
|
22
|
+
export declare function privateSddl(sddl: string, sid: string, directory?: boolean): boolean;
|
|
19
23
|
export declare const windowsSecurity: WindowsSecurity;
|
package/lib/windows-security.js
CHANGED
|
@@ -10,13 +10,17 @@ export function parseWhoami(text) { return /"(S-1-\d+(?:-\d+)+)"\s*$/.exec(text.
|
|
|
10
10
|
/** SID 末段(RID):Windows 上与 macOS uid 同用途(节点名后缀)。 */
|
|
11
11
|
export function rid(sid) { const last = /-(\d+)$/.exec(sid)?.[1]; if (!last)
|
|
12
12
|
throw Error('WINDOWS_SID_INVALID'); return last; }
|
|
13
|
-
/**
|
|
14
|
-
|
|
13
|
+
/**
|
|
14
|
+
* SDDL 判定:所有者是本人、每条 ACE 都是“允许”且对象只在 本人/SYSTEM/Administrators 之内;目录还须 DACL 受保护(不继承)。
|
|
15
|
+
* 文件不要求受保护:L 读的私有文件都在 L 已核为受保护私有的目录里,其继承项只能来自该目录;N 写入交接配置(network-config\config.json)
|
|
16
|
+
* 用“临时文件 + 改名”,新文件继承所在私有目录的 ACE(awtest 实机读回 D:AI(A;ID;FA;;;BA)(A;ID;FA;;;SY)(A;ID;FA;;;本人)),有效访问者同样只有三方。
|
|
17
|
+
*/
|
|
18
|
+
export function privateSddl(sddl, sid, directory = true) {
|
|
15
19
|
const owner = /^O:([^:]+?)(?=[GDS]:|$)/.exec(sddl)?.[1];
|
|
16
20
|
if (owner === undefined || (ALIAS[owner] ?? owner) !== sid)
|
|
17
21
|
return false;
|
|
18
22
|
const dacl = /D:([A-Z_]*)((?:\([^)]*\))*)$/.exec(sddl);
|
|
19
|
-
if (!dacl || !dacl[1].includes('P') || dacl[1].includes('NO_ACCESS_CONTROL'))
|
|
23
|
+
if (!dacl || directory && !dacl[1].includes('P') || dacl[1].includes('NO_ACCESS_CONTROL'))
|
|
20
24
|
return false;
|
|
21
25
|
const allowed = new Set([sid, SYSTEM, ADMINS]);
|
|
22
26
|
for (const ace of dacl[2].match(/\([^)]*\)/g) ?? []) {
|