zedbee 0.1.0-beta.13 → 0.1.0-beta.14
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/SECURITY.md +2 -0
- package/dist/attribution/entities.d.ts.map +1 -1
- package/dist/attribution/entities.js +47 -68
- package/dist/attribution/entities.js.map +1 -1
- package/dist/attribution/metrics.d.ts +2 -0
- package/dist/attribution/metrics.d.ts.map +1 -1
- package/dist/attribution/metrics.js +8 -0
- package/dist/attribution/metrics.js.map +1 -1
- package/dist/attribution/pair-locations.js +1 -1
- package/dist/attribution/pair-locations.js.map +1 -1
- package/dist/attribution/source-identity.d.ts +6 -0
- package/dist/attribution/source-identity.d.ts.map +1 -0
- package/dist/attribution/source-identity.js +60 -0
- package/dist/attribution/source-identity.js.map +1 -0
- package/dist/cache/key.d.ts +6 -1
- package/dist/cache/key.d.ts.map +1 -1
- package/dist/cache/key.js +54 -21
- package/dist/cache/key.js.map +1 -1
- package/dist/cache/store.d.ts.map +1 -1
- package/dist/cache/store.js +7 -7
- package/dist/cache/store.js.map +1 -1
- package/dist/checks/applicability.d.ts.map +1 -1
- package/dist/checks/applicability.js +9 -6
- package/dist/checks/applicability.js.map +1 -1
- package/dist/checks/complexity/adapter.d.ts.map +1 -1
- package/dist/checks/complexity/adapter.js +61 -12
- package/dist/checks/complexity/adapter.js.map +1 -1
- package/dist/checks/complexity/pair-class-metrics.d.ts.map +1 -1
- package/dist/checks/complexity/pair-class-metrics.js +52 -19
- package/dist/checks/complexity/pair-class-metrics.js.map +1 -1
- package/dist/checks/dead-code/framework-entrypoints.d.ts +9 -0
- package/dist/checks/dead-code/framework-entrypoints.d.ts.map +1 -0
- package/dist/checks/dead-code/framework-entrypoints.js +47 -0
- package/dist/checks/dead-code/framework-entrypoints.js.map +1 -0
- package/dist/checks/dead-code/managed-config.d.ts +1 -0
- package/dist/checks/dead-code/managed-config.d.ts.map +1 -1
- package/dist/checks/dead-code/managed-config.js +6 -1
- package/dist/checks/dead-code/managed-config.js.map +1 -1
- package/dist/checks/dead-code/parse-report.d.ts.map +1 -1
- package/dist/checks/dead-code/parse-report.js +26 -23
- package/dist/checks/dead-code/parse-report.js.map +1 -1
- package/dist/checks/diagnostic-messages.d.ts +4 -0
- package/dist/checks/diagnostic-messages.d.ts.map +1 -0
- package/dist/checks/diagnostic-messages.js +50 -0
- package/dist/checks/diagnostic-messages.js.map +1 -0
- package/dist/checks/dispatch-adapter.d.ts +25 -0
- package/dist/checks/dispatch-adapter.d.ts.map +1 -0
- package/dist/checks/dispatch-adapter.js +133 -0
- package/dist/checks/dispatch-adapter.js.map +1 -0
- package/dist/checks/dispatch-cache.d.ts +9 -0
- package/dist/checks/dispatch-cache.d.ts.map +1 -0
- package/dist/checks/dispatch-cache.js +154 -0
- package/dist/checks/dispatch-cache.js.map +1 -0
- package/dist/checks/dispatch-context.d.ts +11 -0
- package/dist/checks/dispatch-context.d.ts.map +1 -0
- package/dist/checks/dispatch-context.js +155 -0
- package/dist/checks/dispatch-context.js.map +1 -0
- package/dist/checks/dispatch-target.d.ts +17 -0
- package/dist/checks/dispatch-target.d.ts.map +1 -0
- package/dist/checks/dispatch-target.js +167 -0
- package/dist/checks/dispatch-target.js.map +1 -0
- package/dist/checks/dispatcher.d.ts +3 -7
- package/dist/checks/dispatcher.d.ts.map +1 -1
- package/dist/checks/dispatcher.js +12 -642
- package/dist/checks/dispatcher.js.map +1 -1
- package/dist/checks/duplication/adapter.d.ts.map +1 -1
- package/dist/checks/duplication/adapter.js +44 -6
- package/dist/checks/duplication/adapter.js.map +1 -1
- package/dist/checks/duplication/clone-comparison.d.ts +6 -0
- package/dist/checks/duplication/clone-comparison.d.ts.map +1 -0
- package/dist/checks/duplication/clone-comparison.js +163 -0
- package/dist/checks/duplication/clone-comparison.js.map +1 -0
- package/dist/checks/duplication/normalize-clone.d.ts.map +1 -1
- package/dist/checks/duplication/normalize-clone.js +9 -0
- package/dist/checks/duplication/normalize-clone.js.map +1 -1
- package/dist/checks/duplication/source-tokens.d.ts +18 -0
- package/dist/checks/duplication/source-tokens.d.ts.map +1 -0
- package/dist/checks/duplication/source-tokens.js +68 -0
- package/dist/checks/duplication/source-tokens.js.map +1 -0
- package/dist/checks/duplication/types.d.ts +2 -0
- package/dist/checks/duplication/types.d.ts.map +1 -1
- package/dist/checks/engine-identity.d.ts.map +1 -1
- package/dist/checks/engine-identity.js +8 -7
- package/dist/checks/engine-identity.js.map +1 -1
- package/dist/checks/eslint/convert-message.d.ts +2 -0
- package/dist/checks/eslint/convert-message.d.ts.map +1 -1
- package/dist/checks/eslint/convert-message.js +34 -1
- package/dist/checks/eslint/convert-message.js.map +1 -1
- package/dist/checks/metadata.d.ts +4 -2
- package/dist/checks/metadata.d.ts.map +1 -1
- package/dist/checks/metadata.js +7 -4
- package/dist/checks/metadata.js.map +1 -1
- package/dist/checks/observation-result.d.ts.map +1 -1
- package/dist/checks/observation-result.js +24 -12
- package/dist/checks/observation-result.js.map +1 -1
- package/dist/checks/prettier/project-engine.d.ts +8 -14
- package/dist/checks/prettier/project-engine.d.ts.map +1 -1
- package/dist/checks/prettier/project-engine.js +33 -281
- package/dist/checks/prettier/project-engine.js.map +1 -1
- package/dist/checks/prettier/project-error.d.ts +7 -0
- package/dist/checks/prettier/project-error.d.ts.map +1 -0
- package/dist/checks/prettier/project-error.js +12 -0
- package/dist/checks/prettier/project-error.js.map +1 -0
- package/dist/checks/prettier/project-import-capture.d.ts +20 -0
- package/dist/checks/prettier/project-import-capture.d.ts.map +1 -0
- package/dist/checks/prettier/project-import-capture.js +173 -0
- package/dist/checks/prettier/project-import-capture.js.map +1 -0
- package/dist/checks/prettier/project-import-dependencies.d.ts +5 -0
- package/dist/checks/prettier/project-import-dependencies.d.ts.map +1 -0
- package/dist/checks/prettier/project-import-dependencies.js +84 -0
- package/dist/checks/prettier/project-import-dependencies.js.map +1 -0
- package/dist/checks/prettier/project-installation.d.ts +3 -0
- package/dist/checks/prettier/project-installation.d.ts.map +1 -0
- package/dist/checks/prettier/project-installation.js +204 -0
- package/dist/checks/prettier/project-installation.js.map +1 -0
- package/dist/checks/prettier/project-protocol.d.ts.map +1 -1
- package/dist/checks/prettier/project-protocol.js +15 -3
- package/dist/checks/prettier/project-protocol.js.map +1 -1
- package/dist/checks/prettier/project-snapshot-identity.d.ts +7 -0
- package/dist/checks/prettier/project-snapshot-identity.d.ts.map +1 -0
- package/dist/checks/prettier/project-snapshot-identity.js +63 -0
- package/dist/checks/prettier/project-snapshot-identity.js.map +1 -0
- package/dist/checks/prettier/project-types.d.ts +2 -0
- package/dist/checks/prettier/project-types.d.ts.map +1 -1
- package/dist/checks/prettier/project-worker.js +25 -3
- package/dist/checks/prettier/project-worker.js.map +1 -1
- package/dist/checks/prettier/project-workspace.d.ts +7 -0
- package/dist/checks/prettier/project-workspace.d.ts.map +1 -1
- package/dist/checks/prettier/project-workspace.js +101 -40
- package/dist/checks/prettier/project-workspace.js.map +1 -1
- package/dist/checks/project-inputs.d.ts.map +1 -1
- package/dist/checks/project-inputs.js +50 -12
- package/dist/checks/project-inputs.js.map +1 -1
- package/dist/checks/runner/process-group.d.ts.map +1 -1
- package/dist/checks/runner/process-group.js +30 -2
- package/dist/checks/runner/process-group.js.map +1 -1
- package/dist/checks/secrets/content.d.ts.map +1 -1
- package/dist/checks/secrets/content.js +19 -9
- package/dist/checks/secrets/content.js.map +1 -1
- package/dist/checks/typescript/configuration-paths.d.ts +4 -3
- package/dist/checks/typescript/configuration-paths.d.ts.map +1 -1
- package/dist/checks/typescript/configuration-paths.js +127 -58
- package/dist/checks/typescript/configuration-paths.js.map +1 -1
- package/dist/checks/typescript/convert-diagnostic.d.ts +2 -0
- package/dist/checks/typescript/convert-diagnostic.d.ts.map +1 -1
- package/dist/checks/typescript/convert-diagnostic.js +23 -5
- package/dist/checks/typescript/convert-diagnostic.js.map +1 -1
- package/dist/checks/vulnerabilities/inventory/normalize.d.ts +1 -0
- package/dist/checks/vulnerabilities/inventory/normalize.d.ts.map +1 -1
- package/dist/checks/vulnerabilities/inventory/normalize.js +5 -2
- package/dist/checks/vulnerabilities/inventory/normalize.js.map +1 -1
- package/dist/checks/vulnerabilities/inventory/parse-bun.d.ts.map +1 -1
- package/dist/checks/vulnerabilities/inventory/parse-bun.js +18 -7
- package/dist/checks/vulnerabilities/inventory/parse-bun.js.map +1 -1
- package/dist/checks/vulnerabilities/inventory/parse-yarn.d.ts.map +1 -1
- package/dist/checks/vulnerabilities/inventory/parse-yarn.js +21 -11
- package/dist/checks/vulnerabilities/inventory/parse-yarn.js.map +1 -1
- package/dist/commands/checks.d.ts +5 -2
- package/dist/commands/checks.d.ts.map +1 -1
- package/dist/commands/checks.js +18 -5
- package/dist/commands/checks.js.map +1 -1
- package/dist/commands/fix.d.ts.map +1 -1
- package/dist/commands/fix.js +6 -297
- package/dist/commands/fix.js.map +1 -1
- package/dist/commands/init.d.ts +4 -2
- package/dist/commands/init.d.ts.map +1 -1
- package/dist/commands/init.js +36 -379
- package/dist/commands/init.js.map +1 -1
- package/dist/commands/scan.d.ts.map +1 -1
- package/dist/commands/scan.js +1 -13
- package/dist/commands/scan.js.map +1 -1
- package/dist/config/load-config.d.ts.map +1 -1
- package/dist/config/load-config.js +6 -15
- package/dist/config/load-config.js.map +1 -1
- package/dist/config/selection-path.d.ts +7 -0
- package/dist/config/selection-path.d.ts.map +1 -0
- package/dist/config/selection-path.js +20 -0
- package/dist/config/selection-path.js.map +1 -0
- package/dist/core/check-label.d.ts +2 -0
- package/dist/core/check-label.d.ts.map +1 -0
- package/dist/core/check-label.js +19 -0
- package/dist/core/check-label.js.map +1 -0
- package/dist/core/freeze-result.d.ts +3 -0
- package/dist/core/freeze-result.d.ts.map +1 -0
- package/dist/core/freeze-result.js +10 -0
- package/dist/core/freeze-result.js.map +1 -0
- package/dist/core/immutable-map.d.ts +3 -0
- package/dist/core/immutable-map.d.ts.map +1 -0
- package/dist/core/immutable-map.js +33 -0
- package/dist/core/immutable-map.js.map +1 -0
- package/dist/core/kernel-lease.d.ts +17 -0
- package/dist/core/kernel-lease.d.ts.map +1 -0
- package/dist/core/kernel-lease.js +55 -0
- package/dist/core/kernel-lease.js.map +1 -0
- package/dist/fixes/apply-plan.d.ts.map +1 -1
- package/dist/fixes/apply-plan.js +2 -9
- package/dist/fixes/apply-plan.js.map +1 -1
- package/dist/fixes/build-plan.d.ts +4 -5
- package/dist/fixes/build-plan.d.ts.map +1 -1
- package/dist/fixes/build-plan.js +10 -465
- package/dist/fixes/build-plan.js.map +1 -1
- package/dist/fixes/exact-edits.d.ts +11 -1
- package/dist/fixes/exact-edits.d.ts.map +1 -1
- package/dist/fixes/exact-edits.js +101 -46
- package/dist/fixes/exact-edits.js.map +1 -1
- package/dist/fixes/plan-candidates.d.ts +8 -0
- package/dist/fixes/plan-candidates.d.ts.map +1 -0
- package/dist/fixes/plan-candidates.js +144 -0
- package/dist/fixes/plan-candidates.js.map +1 -0
- package/dist/fixes/prettier-provider.d.ts +3 -2
- package/dist/fixes/prettier-provider.d.ts.map +1 -1
- package/dist/fixes/prettier-provider.js +53 -0
- package/dist/fixes/prettier-provider.js.map +1 -1
- package/dist/fixes/public-plan.d.ts +8 -0
- package/dist/fixes/public-plan.d.ts.map +1 -0
- package/dist/fixes/public-plan.js +194 -0
- package/dist/fixes/public-plan.js.map +1 -0
- package/dist/fixes/working-preview.d.ts +18 -0
- package/dist/fixes/working-preview.d.ts.map +1 -0
- package/dist/fixes/working-preview.js +162 -0
- package/dist/fixes/working-preview.js.map +1 -0
- package/dist/git/change-set.d.ts.map +1 -1
- package/dist/git/change-set.js +1 -9
- package/dist/git/change-set.js.map +1 -1
- package/dist/git/client.d.ts +1 -1
- package/dist/git/client.d.ts.map +1 -1
- package/dist/git/client.js +14 -12
- package/dist/git/client.js.map +1 -1
- package/dist/init/formatter-setup.d.ts +29 -0
- package/dist/init/formatter-setup.d.ts.map +1 -0
- package/dist/init/formatter-setup.js +166 -0
- package/dist/init/formatter-setup.js.map +1 -0
- package/dist/init/import-provenance.d.ts +7 -0
- package/dist/init/import-provenance.d.ts.map +1 -0
- package/dist/init/import-provenance.js +58 -0
- package/dist/init/import-provenance.js.map +1 -0
- package/dist/init/install-dependency.d.mts +40 -0
- package/dist/init/install-dependency.mjs +427 -0
- package/dist/init/install-project.d.ts +1 -0
- package/dist/init/install-project.d.ts.map +1 -1
- package/dist/init/install-project.js +12 -31
- package/dist/init/install-project.js.map +1 -1
- package/dist/init/presentation.d.ts +54 -0
- package/dist/init/presentation.d.ts.map +1 -0
- package/dist/init/presentation.js +139 -0
- package/dist/init/presentation.js.map +1 -0
- package/dist/init/selection-policy.d.ts +29 -0
- package/dist/init/selection-policy.d.ts.map +1 -0
- package/dist/init/selection-policy.js +59 -0
- package/dist/init/selection-policy.js.map +1 -0
- package/dist/init/types.d.ts +7 -0
- package/dist/init/types.d.ts.map +1 -1
- package/dist/init/types.js.map +1 -1
- package/dist/init/write-config.d.ts.map +1 -1
- package/dist/init/write-config.js +3 -13
- package/dist/init/write-config.js.map +1 -1
- package/dist/inspection/inspect-repository.d.ts.map +1 -1
- package/dist/inspection/inspect-repository.js +4 -3
- package/dist/inspection/inspect-repository.js.map +1 -1
- package/dist/inspection/snapshot-registry.d.ts.map +1 -1
- package/dist/inspection/snapshot-registry.js +24 -2
- package/dist/inspection/snapshot-registry.js.map +1 -1
- package/dist/reporting/check-label.d.ts +1 -1
- package/dist/reporting/check-label.d.ts.map +1 -1
- package/dist/reporting/check-label.js +1 -18
- package/dist/reporting/check-label.js.map +1 -1
- package/dist/reporting/fix-plan-store.d.ts +7 -0
- package/dist/reporting/fix-plan-store.d.ts.map +1 -0
- package/dist/reporting/fix-plan-store.js +29 -0
- package/dist/reporting/fix-plan-store.js.map +1 -0
- package/dist/reporting/fix-presentation.d.ts +77 -0
- package/dist/reporting/fix-presentation.d.ts.map +1 -0
- package/dist/reporting/fix-presentation.js +262 -0
- package/dist/reporting/fix-presentation.js.map +1 -0
- package/dist/reporting/temporary-report-common.d.ts +27 -0
- package/dist/reporting/temporary-report-common.d.ts.map +1 -0
- package/dist/reporting/temporary-report-common.js +33 -0
- package/dist/reporting/temporary-report-common.js.map +1 -0
- package/dist/reporting/temporary-report-filesystem.d.ts +6 -0
- package/dist/reporting/temporary-report-filesystem.d.ts.map +1 -0
- package/dist/reporting/temporary-report-filesystem.js +124 -0
- package/dist/reporting/temporary-report-filesystem.js.map +1 -0
- package/dist/reporting/temporary-report-lifecycle.d.ts +19 -0
- package/dist/reporting/temporary-report-lifecycle.d.ts.map +1 -0
- package/dist/reporting/temporary-report-lifecycle.js +278 -0
- package/dist/reporting/temporary-report-lifecycle.js.map +1 -0
- package/dist/reporting/temporary-report-lock.d.ts +21 -0
- package/dist/reporting/temporary-report-lock.d.ts.map +1 -0
- package/dist/reporting/temporary-report-lock.js +106 -0
- package/dist/reporting/temporary-report-lock.js.map +1 -0
- package/dist/reporting/temporary-reports.d.ts +3 -24
- package/dist/reporting/temporary-reports.d.ts.map +1 -1
- package/dist/reporting/temporary-reports.js +10 -534
- package/dist/reporting/temporary-reports.js.map +1 -1
- package/dist/scan/run-scan.d.ts.map +1 -1
- package/dist/scan/run-scan.js +4 -12
- package/dist/scan/run-scan.js.map +1 -1
- package/dist/scan/source-excerpts.d.ts +1 -1
- package/dist/scan/source-excerpts.d.ts.map +1 -1
- package/dist/scan/source-excerpts.js +25 -27
- package/dist/scan/source-excerpts.js.map +1 -1
- package/dist/service/client-connection.d.ts +21 -0
- package/dist/service/client-connection.d.ts.map +1 -0
- package/dist/service/client-connection.js +219 -0
- package/dist/service/client-connection.js.map +1 -0
- package/dist/service/client-executor.d.ts +10 -0
- package/dist/service/client-executor.d.ts.map +1 -0
- package/dist/service/client-executor.js +69 -0
- package/dist/service/client-executor.js.map +1 -0
- package/dist/service/client-ownership.d.ts +16 -0
- package/dist/service/client-ownership.d.ts.map +1 -0
- package/dist/service/client-ownership.js +104 -0
- package/dist/service/client-ownership.js.map +1 -0
- package/dist/service/client-startup.d.ts +3 -0
- package/dist/service/client-startup.d.ts.map +1 -0
- package/dist/service/client-startup.js +123 -0
- package/dist/service/client-startup.js.map +1 -0
- package/dist/service/client.d.ts +2 -27
- package/dist/service/client.d.ts.map +1 -1
- package/dist/service/client.js +7 -490
- package/dist/service/client.js.map +1 -1
- package/dist/service/server-connection.d.ts +43 -0
- package/dist/service/server-connection.d.ts.map +1 -0
- package/dist/service/server-connection.js +327 -0
- package/dist/service/server-connection.js.map +1 -0
- package/dist/service/server.d.ts +1 -1
- package/dist/service/server.d.ts.map +1 -1
- package/dist/service/server.js +77 -343
- package/dist/service/server.js.map +1 -1
- package/dist/service/state.d.ts.map +1 -1
- package/dist/service/state.js +2 -25
- package/dist/service/state.js.map +1 -1
- package/dist/service/windows-pipe.d.ts +22 -14
- package/dist/service/windows-pipe.d.ts.map +1 -1
- package/dist/service/windows-pipe.js +384 -350
- package/dist/service/windows-pipe.js.map +1 -1
- package/dist/telemetry/details-store.js +1 -1
- package/dist/telemetry/details-store.js.map +1 -1
- package/dist/telemetry/schema.d.ts +5 -5
- package/dist/telemetry/state.d.ts +3 -2
- package/dist/telemetry/state.d.ts.map +1 -1
- package/dist/telemetry/state.js +112 -66
- package/dist/telemetry/state.js.map +1 -1
- package/dist/ui/init-app.d.ts +6 -14
- package/dist/ui/init-app.d.ts.map +1 -1
- package/dist/ui/init-app.js +39 -203
- package/dist/ui/init-app.js.map +1 -1
- package/dist/ui/init-operation.d.ts +19 -0
- package/dist/ui/init-operation.d.ts.map +1 -0
- package/dist/ui/init-operation.js +54 -0
- package/dist/ui/init-operation.js.map +1 -0
- package/dist/ui/init-view.d.ts +42 -0
- package/dist/ui/init-view.d.ts.map +1 -0
- package/dist/ui/init-view.js +199 -0
- package/dist/ui/init-view.js.map +1 -0
- package/docs/checks.md +24 -0
- package/docs/cli-reference.md +3 -1
- package/docs/managed-fixes.md +14 -0
- package/docs/privacy.md +22 -1
- package/package.json +1 -1
- package/plugins/swarm/references/scan.md +6 -13
|
@@ -1,397 +1,431 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { createRequire } from "node:module";
|
|
2
2
|
import { ServiceUnavailableError } from "./protocol.js";
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const
|
|
6
|
-
|
|
7
|
-
const
|
|
8
|
-
const
|
|
9
|
-
const
|
|
10
|
-
const
|
|
11
|
-
const
|
|
12
|
-
const
|
|
13
|
-
const
|
|
14
|
-
const
|
|
15
|
-
"void *"
|
|
16
|
-
"
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
"
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
]);
|
|
30
|
-
const parseSid = security.func("__stdcall", "ConvertStringSidToSidW", "int", [
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
]);
|
|
34
|
-
const convert = security.func("__stdcall", "ConvertStringSecurityDescriptorToSecurityDescriptorW", "int", ["str16", "uint32", ptr, "void *"]);
|
|
35
|
-
const getDacl = security.func("__stdcall", "GetSecurityDescriptorDacl", "int", [
|
|
36
|
-
"
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
"void *"
|
|
47
|
-
|
|
48
|
-
"void *"
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
const
|
|
55
|
-
"void *"
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
const
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
});
|
|
73
|
-
function fail() {
|
|
74
|
-
const code = errorCode();
|
|
75
|
-
if (code === 2 || code === 3)
|
|
76
|
-
throw Object.assign(new ServiceUnavailableError(), { code: "ENOENT" });
|
|
77
|
-
throw new ServiceUnavailableError();
|
|
78
|
-
}
|
|
79
|
-
function validHandle(handle) {
|
|
80
|
-
return (!!handle &&
|
|
81
|
-
koffi.address(handle) !== (1n << BigInt(koffi.sizeof("void *") * 8)) - 1n);
|
|
82
|
-
}
|
|
83
|
-
function checkedClose(handle) {
|
|
84
|
-
if (!close(handle))
|
|
3
|
+
const require = createRequire(import.meta.url);
|
|
4
|
+
function loadBindings() {
|
|
5
|
+
const koffi = require("koffi");
|
|
6
|
+
// Loaded only on Windows. All handles are noninherited and every descriptor is freed.
|
|
7
|
+
const kernel = koffi.load("kernel32.dll"), security = koffi.load("advapi32.dll");
|
|
8
|
+
const ptr = koffi.out(koffi.pointer("void *"));
|
|
9
|
+
const uint = koffi.out(koffi.pointer("uint32"));
|
|
10
|
+
const integer = koffi.out(koffi.pointer("int"));
|
|
11
|
+
const close = kernel.func("int __stdcall CloseHandle(void *)");
|
|
12
|
+
const free = kernel.func("void * __stdcall LocalFree(void *)");
|
|
13
|
+
const errorCode = kernel.func("uint32 __stdcall GetLastError()");
|
|
14
|
+
const open = kernel.func("void * __stdcall CreateFileW(const char16_t *, uint32, uint32, void *, uint32, uint32, void *)");
|
|
15
|
+
const createDirectory = kernel.func("int __stdcall CreateDirectoryW(const char16_t *, void *)");
|
|
16
|
+
const currentProcess = kernel.func("void * __stdcall GetCurrentProcess()");
|
|
17
|
+
const openToken = security.func("__stdcall", "OpenProcessToken", "int", [
|
|
18
|
+
"void *",
|
|
19
|
+
"uint32",
|
|
20
|
+
ptr,
|
|
21
|
+
]);
|
|
22
|
+
const getToken = security.func("__stdcall", "GetTokenInformation", "int", [
|
|
23
|
+
"void *",
|
|
24
|
+
"int",
|
|
25
|
+
"void *",
|
|
26
|
+
"uint32",
|
|
27
|
+
uint,
|
|
28
|
+
]);
|
|
29
|
+
const sidString = security.func("__stdcall", "ConvertSidToStringSidW", "int", ["void *", ptr]);
|
|
30
|
+
const parseSid = security.func("__stdcall", "ConvertStringSidToSidW", "int", [
|
|
31
|
+
"str16",
|
|
32
|
+
ptr,
|
|
33
|
+
]);
|
|
34
|
+
const convert = security.func("__stdcall", "ConvertStringSecurityDescriptorToSecurityDescriptorW", "int", ["str16", "uint32", ptr, "void *"]);
|
|
35
|
+
const getDacl = security.func("__stdcall", "GetSecurityDescriptorDacl", "int", ["void *", integer, ptr, integer]);
|
|
36
|
+
const getSecurity = security.func("__stdcall", "GetSecurityInfo", "uint32", [
|
|
37
|
+
"void *",
|
|
38
|
+
"int",
|
|
39
|
+
"uint32",
|
|
40
|
+
ptr,
|
|
41
|
+
"void *",
|
|
42
|
+
ptr,
|
|
43
|
+
"void *",
|
|
44
|
+
ptr,
|
|
45
|
+
]);
|
|
46
|
+
const setSecurity = security.func("uint32 __stdcall SetSecurityInfo(void *, int, uint32, void *, void *, void *, void *)");
|
|
47
|
+
const getControl = security.func("__stdcall", "GetSecurityDescriptorControl", "int", ["void *", koffi.out(koffi.pointer("uint16")), uint]);
|
|
48
|
+
const equalSid = security.func("int __stdcall EqualSid(void *, void *)");
|
|
49
|
+
const getAce = security.func("__stdcall", "GetAce", "int", [
|
|
50
|
+
"void *",
|
|
51
|
+
"uint32",
|
|
52
|
+
ptr,
|
|
53
|
+
]);
|
|
54
|
+
const fileInfo = kernel.func("int __stdcall GetFileInformationByHandleEx(void *, int, void *, uint32)");
|
|
55
|
+
const lockFile = kernel.func("int __stdcall LockFileEx(void *, uint32, uint32, uint32, uint32, void *)");
|
|
56
|
+
const attributes = koffi.struct({
|
|
57
|
+
length: "uint32",
|
|
58
|
+
descriptor: "void *",
|
|
59
|
+
inherit: "int",
|
|
60
|
+
});
|
|
61
|
+
const overlapped = koffi.struct({
|
|
62
|
+
internal: "uintptr_t",
|
|
63
|
+
internalHigh: "uintptr_t",
|
|
64
|
+
offset: "uint32",
|
|
65
|
+
offsetHigh: "uint32",
|
|
66
|
+
event: "void *",
|
|
67
|
+
});
|
|
68
|
+
function fail() {
|
|
69
|
+
const code = errorCode();
|
|
70
|
+
if (code === 2 || code === 3)
|
|
71
|
+
throw Object.assign(new ServiceUnavailableError(), { code: "ENOENT" });
|
|
85
72
|
throw new ServiceUnavailableError();
|
|
86
|
-
}
|
|
87
|
-
function withIdentity(run) {
|
|
88
|
-
const token = [null];
|
|
89
|
-
if (!openToken(currentProcess(), 8, token))
|
|
90
|
-
fail();
|
|
91
|
-
try {
|
|
92
|
-
const length = [0];
|
|
93
|
-
getToken(token[0], 1, null, 0, length);
|
|
94
|
-
if (errorCode() !== 122 || !length[0] || length[0] > 65536)
|
|
95
|
-
fail();
|
|
96
|
-
const bytes = Buffer.alloc(length[0]);
|
|
97
|
-
if (!getToken(token[0], 1, bytes, bytes.length, length))
|
|
98
|
-
fail();
|
|
99
|
-
const sid = koffi.decode(bytes, "void *");
|
|
100
|
-
const text = [null];
|
|
101
|
-
if (!sidString(sid, text))
|
|
102
|
-
fail();
|
|
103
|
-
try {
|
|
104
|
-
return run(sid, koffi.decode(text[0], "char16_t", -1));
|
|
105
|
-
}
|
|
106
|
-
finally {
|
|
107
|
-
free(text[0]);
|
|
108
|
-
}
|
|
109
73
|
}
|
|
110
|
-
|
|
111
|
-
|
|
74
|
+
function validHandle(handle) {
|
|
75
|
+
return (!!handle &&
|
|
76
|
+
koffi.address(handle) !== (1n << BigInt(koffi.sizeof("void *") * 8)) - 1n);
|
|
112
77
|
}
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
78
|
+
function checkedClose(handle) {
|
|
79
|
+
if (!close(handle))
|
|
80
|
+
throw new ServiceUnavailableError();
|
|
81
|
+
}
|
|
82
|
+
function withIdentity(run) {
|
|
83
|
+
const token = [null];
|
|
84
|
+
if (!openToken(currentProcess(), 8, token))
|
|
118
85
|
fail();
|
|
119
86
|
try {
|
|
120
|
-
const
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
87
|
+
const length = [0];
|
|
88
|
+
getToken(token[0], 1, null, 0, length);
|
|
89
|
+
if (errorCode() !== 122 || !length[0] || length[0] > 65536)
|
|
90
|
+
fail();
|
|
91
|
+
const bytes = Buffer.alloc(length[0]);
|
|
92
|
+
if (!getToken(token[0], 1, bytes, bytes.length, length))
|
|
124
93
|
fail();
|
|
125
|
-
|
|
94
|
+
const sid = koffi.decode(bytes, "void *");
|
|
95
|
+
const text = [null];
|
|
96
|
+
if (!sidString(sid, text))
|
|
97
|
+
fail();
|
|
98
|
+
try {
|
|
99
|
+
return run(sid, koffi.decode(text[0], "char16_t", -1));
|
|
100
|
+
}
|
|
101
|
+
finally {
|
|
102
|
+
free(text[0]);
|
|
103
|
+
}
|
|
126
104
|
}
|
|
127
105
|
finally {
|
|
128
|
-
|
|
106
|
+
checkedClose(token[0]);
|
|
129
107
|
}
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
!equalSid(owner[0], sid) ||
|
|
142
|
-
!getControl(descriptor[0], control, revision) ||
|
|
143
|
-
!(control[0] & 0x1000))
|
|
144
|
-
throw new ServiceUnavailableError();
|
|
145
|
-
const header = Buffer.from(koffi.decode(acl[0], "uint8", 8));
|
|
146
|
-
const count = pipe ? 2 : 1;
|
|
147
|
-
if (header.readUInt16LE(4) !== count)
|
|
148
|
-
throw new ServiceUnavailableError();
|
|
149
|
-
for (let index = 0; index < count; index++) {
|
|
150
|
-
const denyNetwork = pipe && index === 0;
|
|
151
|
-
const ace = [null];
|
|
152
|
-
if (!getAce(acl[0], index, ace))
|
|
108
|
+
}
|
|
109
|
+
function withDescriptor(run, mode = "state") {
|
|
110
|
+
return withIdentity((sid, text) => {
|
|
111
|
+
const descriptor = [null];
|
|
112
|
+
if (!convert(`O:${text}D:P${mode === "pipe" ? "(D;;FA;;;S-1-5-2)" : ""}(A;${mode === "state" ? "OICI" : ""};${mode === "job" ? "GA" : "FA"};;;${text})`, 1, descriptor, null))
|
|
113
|
+
fail();
|
|
114
|
+
try {
|
|
115
|
+
const present = [0], acl = [null], defaulted = [0];
|
|
116
|
+
if (!getDacl(descriptor[0], present, acl, defaulted) ||
|
|
117
|
+
!present[0] ||
|
|
118
|
+
!acl[0])
|
|
153
119
|
fail();
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
120
|
+
return run(descriptor[0], acl[0], sid);
|
|
121
|
+
}
|
|
122
|
+
finally {
|
|
123
|
+
free(descriptor[0]);
|
|
124
|
+
}
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
function verify(handle, kind, pipe = false) {
|
|
128
|
+
withIdentity((sid) => {
|
|
129
|
+
const descriptor = [null], owner = [null], acl = [null];
|
|
130
|
+
if (getSecurity(handle, kind, 1 | 4, owner, null, acl, null, descriptor) !==
|
|
131
|
+
0)
|
|
132
|
+
throw new ServiceUnavailableError();
|
|
133
|
+
try {
|
|
134
|
+
const control = [0], revision = [0];
|
|
135
|
+
if (!owner[0] ||
|
|
136
|
+
!acl[0] ||
|
|
137
|
+
!equalSid(owner[0], sid) ||
|
|
138
|
+
!getControl(descriptor[0], control, revision) ||
|
|
139
|
+
!(control[0] & 0x1000))
|
|
140
|
+
throw new ServiceUnavailableError();
|
|
141
|
+
const header = Buffer.from(koffi.decode(acl[0], "uint8", 8));
|
|
142
|
+
const count = pipe ? 2 : 1;
|
|
143
|
+
if (header.readUInt16LE(4) !== count)
|
|
166
144
|
throw new ServiceUnavailableError();
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
const
|
|
170
|
-
if (!
|
|
145
|
+
for (let index = 0; index < count; index++) {
|
|
146
|
+
const denyNetwork = pipe && index === 0;
|
|
147
|
+
const ace = [null];
|
|
148
|
+
if (!getAce(acl[0], index, ace))
|
|
171
149
|
fail();
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
150
|
+
const entry = Buffer.from(koffi.decode(ace[0], "uint8", 8));
|
|
151
|
+
const size = entry.readUInt16LE(2), mask = entry.readUInt32LE(4);
|
|
152
|
+
if (entry[0] !== (denyNetwork ? 1 : 0) ||
|
|
153
|
+
(pipe ? entry[1] !== 0 : (entry[1] & ~3) !== 0) ||
|
|
154
|
+
size < 16 ||
|
|
155
|
+
size > 1024 ||
|
|
156
|
+
(pipe
|
|
157
|
+
? mask !== 0x001f01ff
|
|
158
|
+
: mask !== 0x001f01ff &&
|
|
159
|
+
mask !== 0x10000000 &&
|
|
160
|
+
mask !== 0x001f001f &&
|
|
161
|
+
mask !== 0x001f003f))
|
|
162
|
+
throw new ServiceUnavailableError();
|
|
163
|
+
const aceBytes = Buffer.from(koffi.decode(ace[0], "uint8", size));
|
|
164
|
+
if (denyNetwork) {
|
|
165
|
+
const network = [null];
|
|
166
|
+
if (!parseSid("S-1-5-2", network))
|
|
167
|
+
fail();
|
|
168
|
+
try {
|
|
169
|
+
if (!equalSid(aceBytes.subarray(8), network[0]))
|
|
170
|
+
throw new ServiceUnavailableError();
|
|
171
|
+
}
|
|
172
|
+
finally {
|
|
173
|
+
free(network[0]);
|
|
174
|
+
}
|
|
178
175
|
}
|
|
176
|
+
else if (!equalSid(aceBytes.subarray(8), sid))
|
|
177
|
+
throw new ServiceUnavailableError();
|
|
179
178
|
}
|
|
180
|
-
else if (!equalSid(aceBytes.subarray(8), sid))
|
|
181
|
-
throw new ServiceUnavailableError();
|
|
182
179
|
}
|
|
180
|
+
finally {
|
|
181
|
+
free(descriptor[0]);
|
|
182
|
+
}
|
|
183
|
+
});
|
|
184
|
+
}
|
|
185
|
+
function pathHandle(path, access = 0x20000 | 0x80) {
|
|
186
|
+
// OPEN_REPARSE_POINT inspects the lexical entry; BACKUP_SEMANTICS permits dirs.
|
|
187
|
+
const handle = open(path, access, 1 | 2, null, 3, 0x00200000 | 0x02000000, null);
|
|
188
|
+
if (!validHandle(handle))
|
|
189
|
+
fail();
|
|
190
|
+
try {
|
|
191
|
+
const info = Buffer.alloc(8);
|
|
192
|
+
if (!fileInfo(handle, 9, info, info.length) ||
|
|
193
|
+
info.readUInt32LE() & 0x400)
|
|
194
|
+
throw new ServiceUnavailableError();
|
|
195
|
+
return handle;
|
|
196
|
+
}
|
|
197
|
+
catch (error) {
|
|
198
|
+
checkedClose(handle);
|
|
199
|
+
throw error;
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
function verifyWindowsPath(path, ownerOnly) {
|
|
203
|
+
// Ancestors need attribute inspection, not access to their security descriptor.
|
|
204
|
+
const handle = pathHandle(path, ownerOnly ? 0x20000 | 0x80 : 0x80);
|
|
205
|
+
try {
|
|
206
|
+
if (ownerOnly)
|
|
207
|
+
verify(handle, 1);
|
|
183
208
|
}
|
|
184
209
|
finally {
|
|
185
|
-
|
|
210
|
+
checkedClose(handle);
|
|
186
211
|
}
|
|
187
|
-
});
|
|
188
|
-
}
|
|
189
|
-
function pathHandle(path, access = 0x20000 | 0x80) {
|
|
190
|
-
// OPEN_REPARSE_POINT inspects the lexical entry; BACKUP_SEMANTICS permits dirs.
|
|
191
|
-
const handle = open(path, access, 1 | 2, null, 3, 0x00200000 | 0x02000000, null);
|
|
192
|
-
if (!validHandle(handle))
|
|
193
|
-
fail();
|
|
194
|
-
try {
|
|
195
|
-
const info = Buffer.alloc(8);
|
|
196
|
-
if (!fileInfo(handle, 9, info, info.length) || info.readUInt32LE() & 0x400)
|
|
197
|
-
throw new ServiceUnavailableError();
|
|
198
|
-
return handle;
|
|
199
212
|
}
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
213
|
+
function createWindowsDirectory(path) {
|
|
214
|
+
withDescriptor((descriptor) => {
|
|
215
|
+
const bytes = Buffer.alloc(koffi.sizeof(attributes));
|
|
216
|
+
koffi.encode(bytes, attributes, {
|
|
217
|
+
length: bytes.length,
|
|
218
|
+
descriptor,
|
|
219
|
+
inherit: 0,
|
|
220
|
+
});
|
|
221
|
+
if (!createDirectory(path, bytes) && errorCode() !== 183)
|
|
222
|
+
fail();
|
|
223
|
+
});
|
|
224
|
+
verifyWindowsPath(path, true);
|
|
203
225
|
}
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
226
|
+
/** Only the caller's just-created exclusive unpublished metadata file. */
|
|
227
|
+
function restrictCreatedWindowsPath(path) {
|
|
228
|
+
const handle = pathHandle(path, 0x20000 | 0x40000 | 0x80000 | 0x80);
|
|
229
|
+
try {
|
|
230
|
+
withDescriptor((_descriptor, acl, owner) => {
|
|
231
|
+
if (setSecurity(handle, 1, 1 | 4 | 0x80000000, owner, null, acl, null) !==
|
|
232
|
+
0)
|
|
233
|
+
throw new ServiceUnavailableError();
|
|
234
|
+
});
|
|
210
235
|
verify(handle, 1);
|
|
236
|
+
}
|
|
237
|
+
finally {
|
|
238
|
+
checkedClose(handle);
|
|
239
|
+
}
|
|
211
240
|
}
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
inherit: 0,
|
|
241
|
+
function openWindowsStateLease(path, create = true) {
|
|
242
|
+
let handle;
|
|
243
|
+
withDescriptor((descriptor) => {
|
|
244
|
+
const bytes = Buffer.alloc(koffi.sizeof(attributes));
|
|
245
|
+
koffi.encode(bytes, attributes, {
|
|
246
|
+
length: bytes.length,
|
|
247
|
+
descriptor,
|
|
248
|
+
inherit: 0,
|
|
249
|
+
});
|
|
250
|
+
handle = open(path, 0x80000000 | 0x40000000 | 0x20000, 1 | 2, bytes, create ? 4 : 3, 0x00200000, null);
|
|
223
251
|
});
|
|
224
|
-
if (!
|
|
252
|
+
if (!validHandle(handle))
|
|
225
253
|
fail();
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
export function restrictCreatedWindowsPath(path) {
|
|
231
|
-
const handle = pathHandle(path, 0x20000 | 0x40000 | 0x80000 | 0x80);
|
|
232
|
-
try {
|
|
233
|
-
withDescriptor((_descriptor, acl, owner) => {
|
|
234
|
-
if (setSecurity(handle, 1, 1 | 4 | 0x80000000, owner, null, acl, null) !== 0)
|
|
254
|
+
try {
|
|
255
|
+
const info = Buffer.alloc(8);
|
|
256
|
+
if (!fileInfo(handle, 9, info, info.length) ||
|
|
257
|
+
info.readUInt32LE() & 0x400)
|
|
235
258
|
throw new ServiceUnavailableError();
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
259
|
+
const standard = Buffer.alloc(24);
|
|
260
|
+
if (!fileInfo(handle, 1, standard, standard.length) ||
|
|
261
|
+
standard.readBigInt64LE(8) !== 0n ||
|
|
262
|
+
standard.readUInt32LE(16) !== 1 ||
|
|
263
|
+
standard[20] !== 0 ||
|
|
264
|
+
standard[21] !== 0)
|
|
265
|
+
throw new ServiceUnavailableError();
|
|
266
|
+
verify(handle, 1);
|
|
267
|
+
const overlap = Buffer.alloc(koffi.sizeof(overlapped));
|
|
268
|
+
let closed = false, acquired = false;
|
|
269
|
+
return {
|
|
270
|
+
acquire() {
|
|
271
|
+
if (closed)
|
|
272
|
+
throw new ServiceUnavailableError();
|
|
273
|
+
if (acquired)
|
|
274
|
+
return true;
|
|
275
|
+
if (lockFile(handle, 1 | 2, 0, 1, 0, overlap)) {
|
|
276
|
+
acquired = true;
|
|
277
|
+
return true;
|
|
278
|
+
}
|
|
279
|
+
if (errorCode() === 33)
|
|
280
|
+
return false;
|
|
281
|
+
throw new ServiceUnavailableError();
|
|
282
|
+
},
|
|
283
|
+
close() {
|
|
284
|
+
if (!closed) {
|
|
285
|
+
checkedClose(handle);
|
|
286
|
+
closed = true;
|
|
287
|
+
}
|
|
288
|
+
},
|
|
289
|
+
};
|
|
290
|
+
}
|
|
291
|
+
catch (error) {
|
|
292
|
+
if (handle)
|
|
293
|
+
checkedClose(handle);
|
|
294
|
+
throw error;
|
|
295
|
+
}
|
|
241
296
|
}
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
withDescriptor((descriptor) => {
|
|
246
|
-
const bytes = Buffer.alloc(koffi.sizeof(attributes));
|
|
247
|
-
koffi.encode(bytes, attributes, {
|
|
248
|
-
length: bytes.length,
|
|
249
|
-
descriptor,
|
|
250
|
-
inherit: 0,
|
|
251
|
-
});
|
|
252
|
-
handle = open(path, 0x80000000 | 0x40000000 | 0x20000, 1 | 2, bytes, create ? 4 : 3, 0x00200000, null);
|
|
253
|
-
});
|
|
254
|
-
if (!validHandle(handle))
|
|
255
|
-
fail();
|
|
256
|
-
try {
|
|
257
|
-
const info = Buffer.alloc(8);
|
|
258
|
-
if (!fileInfo(handle, 9, info, info.length) || info.readUInt32LE() & 0x400)
|
|
259
|
-
throw new ServiceUnavailableError();
|
|
260
|
-
const standard = Buffer.alloc(24);
|
|
261
|
-
if (!fileInfo(handle, 1, standard, standard.length) ||
|
|
262
|
-
standard.readBigInt64LE(8) !== 0n ||
|
|
263
|
-
standard.readUInt32LE(16) !== 1 ||
|
|
264
|
-
standard[20] !== 0 ||
|
|
265
|
-
standard[21] !== 0)
|
|
297
|
+
/** No Node private handle fields: open only the controlled local pipe endpoint. */
|
|
298
|
+
function restrictWindowsPipe(endpoint) {
|
|
299
|
+
if (!/^\\\\\.\\pipe\\zedbee-[a-f0-9]{64}$/u.test(endpoint))
|
|
266
300
|
throw new ServiceUnavailableError();
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
if (
|
|
301
|
+
const handle = open(endpoint, 0x20000 | 0x40000 | 0x80000, 0, null, 3, 0, null);
|
|
302
|
+
if (!validHandle(handle))
|
|
303
|
+
fail();
|
|
304
|
+
try {
|
|
305
|
+
withDescriptor((_descriptor, acl, owner) => {
|
|
306
|
+
if (setSecurity(handle, 6, 1 | 4 | 0x80000000, owner, null, acl, null) !==
|
|
307
|
+
0)
|
|
273
308
|
throw new ServiceUnavailableError();
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
return true;
|
|
279
|
-
}
|
|
280
|
-
if (errorCode() === 33)
|
|
281
|
-
return false;
|
|
282
|
-
throw new ServiceUnavailableError();
|
|
283
|
-
},
|
|
284
|
-
close() {
|
|
285
|
-
if (!closed) {
|
|
286
|
-
checkedClose(handle);
|
|
287
|
-
closed = true;
|
|
288
|
-
}
|
|
289
|
-
},
|
|
290
|
-
};
|
|
291
|
-
}
|
|
292
|
-
catch (error) {
|
|
293
|
-
if (handle)
|
|
309
|
+
}, "pipe");
|
|
310
|
+
verify(handle, 6, true);
|
|
311
|
+
}
|
|
312
|
+
finally {
|
|
294
313
|
checkedClose(handle);
|
|
295
|
-
|
|
314
|
+
}
|
|
296
315
|
}
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
316
|
+
const createJob = kernel.func("void * __stdcall CreateJobObjectW(void *, const char16_t *)");
|
|
317
|
+
const openJob = kernel.func("void * __stdcall OpenJobObjectW(uint32, int, const char16_t *)");
|
|
318
|
+
const terminateJob = kernel.func("int __stdcall TerminateJobObject(void *, uint32)");
|
|
319
|
+
const accounting = koffi.struct({
|
|
320
|
+
totalUser: "int64",
|
|
321
|
+
totalKernel: "int64",
|
|
322
|
+
periodUser: "int64",
|
|
323
|
+
periodKernel: "int64",
|
|
324
|
+
pageFaults: "uint32",
|
|
325
|
+
totalProcesses: "uint32",
|
|
326
|
+
activeProcesses: "uint32",
|
|
327
|
+
terminated: "uint32",
|
|
328
|
+
});
|
|
329
|
+
const queryJob = kernel.func("int __stdcall QueryInformationJobObject(void *, int, void *, uint32, void *)");
|
|
330
|
+
function jobName(name) {
|
|
331
|
+
if (!/^Local\\zedbee-[a-f0-9]{64}$/u.test(name))
|
|
332
|
+
throw new ServiceUnavailableError();
|
|
311
333
|
}
|
|
312
|
-
|
|
313
|
-
|
|
334
|
+
function createOwnedWindowsJobHandle(name) {
|
|
335
|
+
jobName(name);
|
|
336
|
+
return withDescriptor((descriptor) => {
|
|
337
|
+
const bytes = Buffer.alloc(koffi.sizeof(attributes));
|
|
338
|
+
koffi.encode(bytes, attributes, {
|
|
339
|
+
length: bytes.length,
|
|
340
|
+
descriptor,
|
|
341
|
+
inherit: 0,
|
|
342
|
+
});
|
|
343
|
+
const handle = createJob(bytes, name);
|
|
344
|
+
if (!handle)
|
|
345
|
+
fail();
|
|
346
|
+
try {
|
|
347
|
+
if (errorCode() === 183)
|
|
348
|
+
throw new ServiceUnavailableError();
|
|
349
|
+
verify(handle, 6);
|
|
350
|
+
return handle;
|
|
351
|
+
}
|
|
352
|
+
catch (error) {
|
|
353
|
+
checkedClose(handle);
|
|
354
|
+
throw error;
|
|
355
|
+
}
|
|
356
|
+
}, "job");
|
|
314
357
|
}
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
const
|
|
318
|
-
const terminateJob = kernel.func("int __stdcall TerminateJobObject(void *, uint32)");
|
|
319
|
-
const accounting = koffi.struct({
|
|
320
|
-
totalUser: "int64",
|
|
321
|
-
totalKernel: "int64",
|
|
322
|
-
periodUser: "int64",
|
|
323
|
-
periodKernel: "int64",
|
|
324
|
-
pageFaults: "uint32",
|
|
325
|
-
totalProcesses: "uint32",
|
|
326
|
-
activeProcesses: "uint32",
|
|
327
|
-
terminated: "uint32",
|
|
328
|
-
});
|
|
329
|
-
const queryJob = kernel.func("int __stdcall QueryInformationJobObject(void *, int, void *, uint32, void *)");
|
|
330
|
-
function jobName(name) {
|
|
331
|
-
if (!/^Local\\zedbee-[a-f0-9]{64}$/u.test(name))
|
|
332
|
-
throw new ServiceUnavailableError();
|
|
333
|
-
}
|
|
334
|
-
export function createOwnedWindowsJobHandle(name) {
|
|
335
|
-
jobName(name);
|
|
336
|
-
return withDescriptor((descriptor) => {
|
|
337
|
-
const bytes = Buffer.alloc(koffi.sizeof(attributes));
|
|
338
|
-
koffi.encode(bytes, attributes, {
|
|
339
|
-
length: bytes.length,
|
|
340
|
-
descriptor,
|
|
341
|
-
inherit: 0,
|
|
342
|
-
});
|
|
343
|
-
const handle = createJob(bytes, name);
|
|
358
|
+
function openWindowsJobWitness(name) {
|
|
359
|
+
jobName(name);
|
|
360
|
+
const handle = openJob(0x20000 | 4 | 8, 0, name);
|
|
344
361
|
if (!handle)
|
|
345
362
|
fail();
|
|
346
363
|
try {
|
|
347
|
-
if (errorCode() === 183)
|
|
348
|
-
throw new ServiceUnavailableError();
|
|
349
364
|
verify(handle, 6);
|
|
350
|
-
return handle;
|
|
351
365
|
}
|
|
352
366
|
catch (error) {
|
|
353
367
|
checkedClose(handle);
|
|
354
368
|
throw error;
|
|
355
369
|
}
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
370
|
+
let closed = false;
|
|
371
|
+
const finish = () => {
|
|
372
|
+
if (!closed) {
|
|
373
|
+
checkedClose(handle);
|
|
374
|
+
closed = true;
|
|
375
|
+
}
|
|
376
|
+
};
|
|
377
|
+
return {
|
|
378
|
+
close: finish,
|
|
379
|
+
async stop() {
|
|
380
|
+
if (closed)
|
|
381
|
+
return;
|
|
382
|
+
if (!terminateJob(handle, 0x5a454442))
|
|
383
|
+
throw new ServiceUnavailableError();
|
|
384
|
+
const state = Buffer.alloc(koffi.sizeof(accounting));
|
|
385
|
+
while (true) {
|
|
386
|
+
if (!queryJob(handle, 1, state, state.length, null))
|
|
387
|
+
throw new ServiceUnavailableError();
|
|
388
|
+
if (state.readUInt32LE(koffi.offsetof(accounting, "activeProcesses")) === 0)
|
|
389
|
+
break;
|
|
390
|
+
await new Promise((resolve) => setTimeout(resolve, 20));
|
|
391
|
+
}
|
|
392
|
+
finish();
|
|
393
|
+
},
|
|
394
|
+
};
|
|
369
395
|
}
|
|
370
|
-
let closed = false;
|
|
371
|
-
const finish = () => {
|
|
372
|
-
if (!closed) {
|
|
373
|
-
checkedClose(handle);
|
|
374
|
-
closed = true;
|
|
375
|
-
}
|
|
376
|
-
};
|
|
377
396
|
return {
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
while (true) {
|
|
386
|
-
if (!queryJob(handle, 1, state, state.length, null))
|
|
387
|
-
throw new ServiceUnavailableError();
|
|
388
|
-
if (state.readUInt32LE(koffi.offsetof(accounting, "activeProcesses")) ===
|
|
389
|
-
0)
|
|
390
|
-
break;
|
|
391
|
-
await new Promise((resolve) => setTimeout(resolve, 20));
|
|
392
|
-
}
|
|
393
|
-
finish();
|
|
394
|
-
},
|
|
397
|
+
verifyWindowsPath,
|
|
398
|
+
createWindowsDirectory,
|
|
399
|
+
restrictCreatedWindowsPath,
|
|
400
|
+
openWindowsStateLease,
|
|
401
|
+
restrictWindowsPipe,
|
|
402
|
+
createOwnedWindowsJobHandle,
|
|
403
|
+
openWindowsJobWitness,
|
|
395
404
|
};
|
|
396
405
|
}
|
|
406
|
+
let cached;
|
|
407
|
+
function bindings() {
|
|
408
|
+
return (cached ??= loadBindings());
|
|
409
|
+
}
|
|
410
|
+
export function verifyWindowsPath(...args) {
|
|
411
|
+
return bindings().verifyWindowsPath(...args);
|
|
412
|
+
}
|
|
413
|
+
export function createWindowsDirectory(...args) {
|
|
414
|
+
return bindings().createWindowsDirectory(...args);
|
|
415
|
+
}
|
|
416
|
+
export function restrictCreatedWindowsPath(...args) {
|
|
417
|
+
return bindings().restrictCreatedWindowsPath(...args);
|
|
418
|
+
}
|
|
419
|
+
export function openWindowsStateLease(...args) {
|
|
420
|
+
return bindings().openWindowsStateLease(...args);
|
|
421
|
+
}
|
|
422
|
+
export function restrictWindowsPipe(...args) {
|
|
423
|
+
return bindings().restrictWindowsPipe(...args);
|
|
424
|
+
}
|
|
425
|
+
export function createOwnedWindowsJobHandle(...args) {
|
|
426
|
+
return bindings().createOwnedWindowsJobHandle(...args);
|
|
427
|
+
}
|
|
428
|
+
export function openWindowsJobWitness(...args) {
|
|
429
|
+
return bindings().openWindowsJobWitness(...args);
|
|
430
|
+
}
|
|
397
431
|
//# sourceMappingURL=windows-pipe.js.map
|