@jeffusion/bungee-types 5.4.5 → 5.5.0

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.
@@ -14,6 +14,7 @@ export type WindowsAclEntry = {
14
14
  readonly inherited: boolean;
15
15
  };
16
16
  export type WindowsAclSnapshot = {
17
+ readonly ownerSid?: string;
17
18
  readonly currentSid: string;
18
19
  readonly entries: readonly WindowsAclEntry[];
19
20
  };
@@ -42,6 +43,8 @@ export type DaemonFileOptions = {
42
43
  export declare function formatDaemonFileAclError(error: unknown): string | null;
43
44
  /** @internal source-test probe; not re-exported from the package root. */
44
45
  export declare function __testSelectWindowsAclExecutable(environment: NodeJS.ProcessEnv): string;
46
+ /** Read-only validation: untrusted input files must never have their ACL repaired. */
47
+ export declare function assertWindowsOwnerOnlyFileAcl(path: string, adapter?: WindowsAclAdapter): Promise<void>;
45
48
  /** @internal source-test probe; not re-exported from the package root. */
46
49
  export declare function __testReadWindowsAcl(path: string, deadlineMs?: number): Promise<WindowsAclSnapshot>;
47
50
  /** @internal source-test probe; not re-exported from the package root. */
@@ -619,15 +619,15 @@ function defaultWindowsAclAdapter(deadlineMs = WINDOWS_ACL_DEADLINE_MS) {
619
619
  + 'Import-Module Microsoft.PowerShell.Security -ErrorAction Stop;';
620
620
  const readScript = phase('started') + moduleBootstrap + phase('before_get_acl')
621
621
  + '$item=Get-Item -LiteralPath $env:BUNGEE_DAEMON_ACL_PATH -Force;'
622
- + '$a=if($item -is [System.IO.DirectoryInfo]){[System.IO.FileSystemAclExtensions]::GetAccessControl([System.IO.DirectoryInfo]$item,[System.Security.AccessControl.AccessControlSections]::Access)}'
623
- + 'elseif($item -is [System.IO.FileInfo]){[System.IO.FileSystemAclExtensions]::GetAccessControl([System.IO.FileInfo]$item,[System.Security.AccessControl.AccessControlSections]::Access)}'
622
+ + '$a=if($item -is [System.IO.DirectoryInfo]){[System.IO.FileSystemAclExtensions]::GetAccessControl([System.IO.DirectoryInfo]$item,([System.Security.AccessControl.AccessControlSections]::Access -bor [System.Security.AccessControl.AccessControlSections]::Owner))}'
623
+ + 'elseif($item -is [System.IO.FileInfo]){[System.IO.FileSystemAclExtensions]::GetAccessControl([System.IO.FileInfo]$item,([System.Security.AccessControl.AccessControlSections]::Access -bor [System.Security.AccessControl.AccessControlSections]::Owner))}'
624
624
  + 'else{throw "Windows ACL target is not a file or directory"};'
625
625
  + phase('after_get_acl')
626
626
  + '$sid=[System.Security.Principal.WindowsIdentity]::GetCurrent().User.Value;'
627
627
  + '$e=@($a.GetAccessRules($true,$true,[System.Security.Principal.SecurityIdentifier])|ForEach-Object { @{sid=$_.IdentityReference.Value;'
628
628
  + 'access=$(if([int]$_.AccessControlType -eq 0){"allow"}else{"deny"});rights=[int]$_.FileSystemRights;'
629
629
  + 'inheritance=[int]$_.InheritanceFlags;propagation=[int]$_.PropagationFlags;inherited=[bool]$_.IsInherited} });'
630
- + '[Console]::Out.Write((ConvertTo-Json -Compress -Depth 4 @{currentSid=$sid;entries=$e}))';
630
+ + '[Console]::Out.Write((ConvertTo-Json -Compress -Depth 4 @{currentSid=$sid;ownerSid=$a.GetOwner([System.Security.Principal.SecurityIdentifier]).Value;entries=$e}))';
631
631
  const setScript = phase('started') + moduleBootstrap + '$p=$env:BUNGEE_DAEMON_ACL_PATH;$u=$env:BUNGEE_DAEMON_ACL_SID;'
632
632
  + '$k=$env:BUNGEE_DAEMON_ACL_KIND;$a=if($k -eq "directory"){[System.Security.AccessControl.DirectorySecurity]::new()}else{[System.Security.AccessControl.FileSecurity]::new()};'
633
633
  + '$a.SetAccessRuleProtection($true,$false);$i=if($k -eq "directory"){[System.Security.AccessControl.InheritanceFlags]::ObjectInherit -bor [System.Security.AccessControl.InheritanceFlags]::ContainerInherit}else{[System.Security.AccessControl.InheritanceFlags]::None};'
@@ -717,6 +717,15 @@ function defaultWindowsAclAdapter(deadlineMs = WINDOWS_ACL_DEADLINE_MS) {
717
717
  },
718
718
  };
719
719
  }
720
+ /** Read-only validation: untrusted input files must never have their ACL repaired. */
721
+ export async function assertWindowsOwnerOnlyFileAcl(path, adapter = defaultWindowsAclAdapter()) {
722
+ const snapshot = await adapter.read(path);
723
+ if (!canonicalSid(snapshot.ownerSid) || snapshot.ownerSid !== snapshot.currentSid)
724
+ fail('acl', 'Recovery input must be owned by the current user');
725
+ const validation = windowsAclSecure(snapshot, 'file');
726
+ if (validation !== null)
727
+ throw new WindowsAclValidationError(validation);
728
+ }
720
729
  /** @internal source-test probe; not re-exported from the package root. */
721
730
  export async function __testReadWindowsAcl(path, deadlineMs = WINDOWS_ACL_DEADLINE_MS) {
722
731
  return defaultWindowsAclAdapter(deadlineMs).read(path);
package/dist/types.d.ts CHANGED
@@ -134,6 +134,8 @@ export interface LoadBalancingConfig {
134
134
  hash_policy?: HashPolicyConfig;
135
135
  }
136
136
  export interface Service {
137
+ /** Stable identity supplied by the runtime compiler. */
138
+ id?: string;
137
139
  name: string;
138
140
  endpoints: Endpoint[];
139
141
  plugins?: Array<PluginConfig | string>;
@@ -207,6 +209,7 @@ export interface RouteConfig extends ModificationRules {
207
209
  id?: string;
208
210
  path: string;
209
211
  service?: string;
212
+ service_id?: string;
210
213
  endpoints?: Endpoint[];
211
214
  path_rewrite?: Record<string, string>;
212
215
  auth?: AuthConfig;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jeffusion/bungee-types",
3
- "version": "5.4.5",
3
+ "version": "5.5.0",
4
4
  "description": "TypeScript type definitions for Bungee",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",