@wzwjustdoit/dsh-plugin-git-bash 0.0.0-stage → 0.4.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.
- package/LICENSE +21 -0
- package/README.md +154 -2
- package/client.js +736 -0
- package/cordis.patch.yml +27 -0
- package/lib/agents.d.ts +5 -0
- package/lib/agents.d.ts.map +1 -0
- package/lib/agents.js +56 -0
- package/lib/agents.js.map +1 -0
- package/lib/discovery.d.ts +21 -0
- package/lib/discovery.d.ts.map +1 -0
- package/lib/discovery.js +122 -0
- package/lib/discovery.js.map +1 -0
- package/lib/index.d.ts +55 -0
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +369 -0
- package/lib/index.js.map +1 -0
- package/native/CMakeLists.txt +58 -0
- package/native/bin/win32-x64/msys-token-guard-hook.dll +0 -0
- package/native/bin/win32-x64/msys-token-guard.exe +0 -0
- package/native/msys-token-guard-hook.cpp +470 -0
- package/native/msys-token-guard.cpp +671 -0
- package/native/vendor/detours/LICENSE.md +23 -0
- package/native/vendor/detours/README.dsh.md +13 -0
- package/native/vendor/detours/creatwth.cpp +1577 -0
- package/native/vendor/detours/detours.cpp +2364 -0
- package/native/vendor/detours/detours.h +1059 -0
- package/native/vendor/detours/detver.h +27 -0
- package/native/vendor/detours/disasm.cpp +4236 -0
- package/native/vendor/detours/image.cpp +2251 -0
- package/native/vendor/detours/modules.cpp +929 -0
- package/native/vendor/detours/uimports.cpp +269 -0
- package/package.json +120 -4
- package/scripts/build-native.mjs +35 -0
- package/scripts/dsh.desktop.startup/README.md +27 -0
- package/scripts/dsh.desktop.startup/dsh.desktop.startup.gitbash.bat +28 -0
- package/scripts/dsh.desktop.startup/dsh.desktop.startup.gitbash.sh +46 -0
- package/scripts/dsh.desktop.startup/dsh.desktop.startup.gitbash.vbs +0 -0
- package/scripts/dsh.web.startup/README.md +33 -0
- package/scripts/dsh.web.startup/dsh.web.startup.gitbash.bat +28 -0
- package/scripts/dsh.web.startup/dsh.web.startup.gitbash.sh +48 -0
- package/scripts/dsh.web.startup/dsh.web.startup.gitbash.vbs +0 -0
package/lib/index.js
ADDED
|
@@ -0,0 +1,369 @@
|
|
|
1
|
+
import { LocalBashExecutor } from "@deepseek-ai/dsh-bash-local";
|
|
2
|
+
import { SandboxUnavailableError } from "@deepseek-ai/dsh-sandbox";
|
|
3
|
+
import z from "@deepseek-ai/schemastery";
|
|
4
|
+
import { spawnSync } from "node:child_process";
|
|
5
|
+
import { accessSync, constants, statSync } from "node:fs";
|
|
6
|
+
import { dirname, resolve } from "node:path";
|
|
7
|
+
import { fileURLToPath } from "node:url";
|
|
8
|
+
import { GIT_BASH_PATH_CONFINED_ENV, configuredGitBashPath, resolveGitBashPath } from "./discovery.js";
|
|
9
|
+
export { GIT_BASH_PATH_CONFINED_ENV, GIT_BASH_PATH_ENV, configuredGitBashPath, gitBashCandidates, resolveGitBashPath, } from "./discovery.js";
|
|
10
|
+
const PACKAGE_ROOT = resolve(dirname(fileURLToPath(import.meta.url)), "..");
|
|
11
|
+
const GUARD_EXECUTABLE = resolve(PACKAGE_ROOT, "native", "bin", "win32-x64", "msys-token-guard.exe");
|
|
12
|
+
const GUARD_HOOK = resolve(PACKAGE_ROOT, "native", "bin", "win32-x64", "msys-token-guard-hook.dll");
|
|
13
|
+
const EXECUTABLE_SPAWN_CODES = new Set(["EACCES", "ENOENT"]);
|
|
14
|
+
const GIT_BASH_EXECUTABLE_PATTERN = /^(?:[A-Z]:[\\/]|\\\\[^\\/]+[\\/][^\\/]+[\\/]|%[^%]+%[\\/])(?:.*[\\/])?bash\.exe$/i;
|
|
15
|
+
const GUARD_FAILURE_RULE = {
|
|
16
|
+
allowedExitCodes: [125],
|
|
17
|
+
fatalSignatures: ["msys-token-guard:"],
|
|
18
|
+
};
|
|
19
|
+
// The guard's child-token setup fails when the restricted DACL (inherited from
|
|
20
|
+
// the server token's default DACL) offers no usable ordinary SID to the guard.
|
|
21
|
+
const SERVER_DACL_FAILURE_SIGNATURE = "openprocesstoken(child default dacl)";
|
|
22
|
+
// DSH derives every restricted token from the server's own process token, and
|
|
23
|
+
// the restricted DACL starts as a copy of the server's default DACL. Servers
|
|
24
|
+
// started outside MSYS2 can carry a DACL without the user SID, which blocks
|
|
25
|
+
// the guard's workspace-write child-token setup (exit 125). Run the guard
|
|
26
|
+
// helper once per server process to stamp the standard DACL shape — the same
|
|
27
|
+
// normalization starting `dsh web` from Git Bash gets for free.
|
|
28
|
+
function normalizeServerDefaultDacl() {
|
|
29
|
+
if (process.platform !== "win32" || process.arch !== "x64")
|
|
30
|
+
return false;
|
|
31
|
+
let result;
|
|
32
|
+
try {
|
|
33
|
+
result = spawnSync(GUARD_EXECUTABLE, ["--normalize-server-dacl"], {
|
|
34
|
+
timeout: 10_000,
|
|
35
|
+
windowsHide: true,
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
catch {
|
|
39
|
+
return false;
|
|
40
|
+
}
|
|
41
|
+
return result.status === 0;
|
|
42
|
+
}
|
|
43
|
+
const LOCAL_BASH_CONFIG = LocalBashExecutor.Config;
|
|
44
|
+
// Keep the field schema permissive enough to render a recovery card for a
|
|
45
|
+
// legacy bad value; resolveConfiguredExecutable enforces it on new writes and use.
|
|
46
|
+
//
|
|
47
|
+
// Extend the base schema with `set` rather than `z.intersect`: intersect rebuilds
|
|
48
|
+
// the object and drops the inherited `volatile` metadata, which the host needs to
|
|
49
|
+
// parse a live config section (otherwise the first command fails with
|
|
50
|
+
// "config.timeoutMs.get is not a function").
|
|
51
|
+
export const Config = LOCAL_BASH_CONFIG
|
|
52
|
+
.set("executable", z.string()
|
|
53
|
+
.default("")
|
|
54
|
+
.role("path")
|
|
55
|
+
.description("Absolute path to Git for Windows bash.exe; blank uses automatic discovery."))
|
|
56
|
+
.set("confinedExecutable", z.string()
|
|
57
|
+
.default("")
|
|
58
|
+
.role("path")
|
|
59
|
+
.description("Absolute path to the bash.exe used by read-only / workspace-write; must be a"
|
|
60
|
+
+ " different Git installation than `executable`. Blank falls back to"
|
|
61
|
+
+ " DSH_GIT_BASH_PATH_CONFINED, then to `executable`."));
|
|
62
|
+
function checkExecutableShape(executable) {
|
|
63
|
+
if (!GIT_BASH_EXECUTABLE_PATTERN.test(executable)) {
|
|
64
|
+
throw new TypeError("git-bash: executable must be an absolute Windows path ending in bash.exe");
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
function resolveConfiguredExecutable(config) {
|
|
68
|
+
const executable = config.executable?.trim();
|
|
69
|
+
if (!executable)
|
|
70
|
+
return undefined;
|
|
71
|
+
checkExecutableShape(executable);
|
|
72
|
+
return resolveGitBashPath(executable);
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* The `bash.exe` for the confined modes, or `undefined` to fall back to
|
|
76
|
+
* {@link resolveConfiguredExecutable} / auto-discovery. Order: the
|
|
77
|
+
* `confinedExecutable` field, then {@link GIT_BASH_PATH_CONFINED_ENV}.
|
|
78
|
+
*/
|
|
79
|
+
function resolveConfinedExecutable(config) {
|
|
80
|
+
const configured = config.confinedExecutable?.trim();
|
|
81
|
+
if (configured) {
|
|
82
|
+
checkExecutableShape(configured);
|
|
83
|
+
return resolveGitBashPath(configured);
|
|
84
|
+
}
|
|
85
|
+
return configuredGitBashPath(GIT_BASH_PATH_CONFINED_ENV);
|
|
86
|
+
}
|
|
87
|
+
function checkedCompositionConfig(config) {
|
|
88
|
+
// Blank configuration intentionally defers auto-discovery so the host still
|
|
89
|
+
// composes when Git for Windows is not installed yet.
|
|
90
|
+
resolveConfiguredExecutable(config);
|
|
91
|
+
resolveConfinedExecutable(config);
|
|
92
|
+
return config;
|
|
93
|
+
}
|
|
94
|
+
function isUsableWorkdir(path) {
|
|
95
|
+
try {
|
|
96
|
+
if (!statSync(path).isDirectory())
|
|
97
|
+
return false;
|
|
98
|
+
accessSync(path, constants.X_OK);
|
|
99
|
+
return true;
|
|
100
|
+
}
|
|
101
|
+
catch {
|
|
102
|
+
return false;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
function isRunnerSpawnFailure(error, runnerProgram, workdir) {
|
|
106
|
+
if (runnerProgram === undefined || !isUsableWorkdir(workdir))
|
|
107
|
+
return false;
|
|
108
|
+
if (typeof error !== "object" || error === null)
|
|
109
|
+
return false;
|
|
110
|
+
const { code, path, syscall } = error;
|
|
111
|
+
if (typeof code !== "string" || !EXECUTABLE_SPAWN_CODES.has(code))
|
|
112
|
+
return false;
|
|
113
|
+
if (typeof syscall !== "string")
|
|
114
|
+
return false;
|
|
115
|
+
const exactSyscall = "spawn " + runnerProgram;
|
|
116
|
+
if (path === undefined)
|
|
117
|
+
return syscall === exactSyscall;
|
|
118
|
+
if (typeof path !== "string" || path.length === 0 || path !== runnerProgram)
|
|
119
|
+
return false;
|
|
120
|
+
return syscall === "spawn" || syscall === exactSyscall;
|
|
121
|
+
}
|
|
122
|
+
function matchesSignature(exitCode, stderr, signatures) {
|
|
123
|
+
if (exitCode === null || exitCode === 0)
|
|
124
|
+
return false;
|
|
125
|
+
const lowered = stderr.toLowerCase();
|
|
126
|
+
return signatures.some((signature) => lowered.includes(signature.toLowerCase()));
|
|
127
|
+
}
|
|
128
|
+
function classifyDenial(result, signatures) {
|
|
129
|
+
return matchesSignature(result.exitCode, result.stderr.text, signatures);
|
|
130
|
+
}
|
|
131
|
+
// Turn the guard's bare DACL failure line into an actionable message: the
|
|
132
|
+
// automatic normalization ran (or was skipped) and the server still serves
|
|
133
|
+
// restricted tokens without ordinary user coverage.
|
|
134
|
+
export function describeGuardFailure(detail) {
|
|
135
|
+
if (!detail.toLowerCase().includes(SERVER_DACL_FAILURE_SIGNATURE))
|
|
136
|
+
return detail;
|
|
137
|
+
return detail + " (git-bash: the DSH server process token's default DACL lacks the user SID,"
|
|
138
|
+
+ " so the guard cannot prepare the restricted child token. Start `dsh web` from Git Bash"
|
|
139
|
+
+ " so MSYS2 restores the standard DACL shape, and see"
|
|
140
|
+
+ " https://github.com/wzwjustdoit/dsh-git-bash/issues/4)";
|
|
141
|
+
}
|
|
142
|
+
function classifyRunnerFailure(exitCode, stderr, rules) {
|
|
143
|
+
if (exitCode === null || exitCode === 0)
|
|
144
|
+
return undefined;
|
|
145
|
+
const lines = stderr.split(/\r?\n/);
|
|
146
|
+
for (const rule of rules) {
|
|
147
|
+
if (rule.allowedExitCodes !== undefined && !rule.allowedExitCodes.includes(exitCode)) {
|
|
148
|
+
continue;
|
|
149
|
+
}
|
|
150
|
+
const informationalLines = new Set((rule.informationalLines ?? []).map((line) => line.toLowerCase()));
|
|
151
|
+
const fatalSignatures = rule.fatalSignatures
|
|
152
|
+
.filter((signature) => signature.trim().length > 0)
|
|
153
|
+
.map((signature) => signature.toLowerCase());
|
|
154
|
+
for (const line of lines) {
|
|
155
|
+
const lowered = line.toLowerCase();
|
|
156
|
+
if (informationalLines.has(lowered))
|
|
157
|
+
continue;
|
|
158
|
+
if (fatalSignatures.some((signature) => lowered.includes(signature))) {
|
|
159
|
+
return { detail: line };
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
return undefined;
|
|
164
|
+
}
|
|
165
|
+
function assertNativeGuard(mode) {
|
|
166
|
+
if (process.platform !== "win32" || process.arch !== "x64") {
|
|
167
|
+
throw new SandboxUnavailableError(mode, "Git Bash restricted mode requires win32-x64, received " +
|
|
168
|
+
process.platform + "-" + process.arch);
|
|
169
|
+
}
|
|
170
|
+
for (const artifact of [GUARD_EXECUTABLE, GUARD_HOOK]) {
|
|
171
|
+
try {
|
|
172
|
+
if (!statSync(artifact).isFile())
|
|
173
|
+
throw new Error("not a file");
|
|
174
|
+
accessSync(artifact, constants.R_OK);
|
|
175
|
+
}
|
|
176
|
+
catch (error) {
|
|
177
|
+
throw new SandboxUnavailableError(mode, "Git Bash native guard artifact is unavailable: " + artifact + " (" + String(error) + ")");
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
// DSH shell executor backed by Git for Windows Bash.
|
|
182
|
+
//
|
|
183
|
+
// The host interface is `execute(spec)`: a subclass replaces the public
|
|
184
|
+
// command's `bash -c` argv at the execution boundary through `executeArgv`,
|
|
185
|
+
// and stamps settlement facts in `onProcessDone`. There is no separate
|
|
186
|
+
// foreground/background entry point to override — "foreground" is decided by
|
|
187
|
+
// whether the caller awaits the returned handle's `result()`.
|
|
188
|
+
export class GitBashExecutor extends LocalBashExecutor {
|
|
189
|
+
static inject = ["subprocess", "sandbox", "sandboxPolicy"];
|
|
190
|
+
// The extended schema adds `executable`; the static-side cast keeps this
|
|
191
|
+
// subclass assignable to the host's base class, while the runtime schema the
|
|
192
|
+
// host actually parses stays the intersected one.
|
|
193
|
+
static Config = Config;
|
|
194
|
+
executableCache = new Map();
|
|
195
|
+
mode;
|
|
196
|
+
processFacts = new Map();
|
|
197
|
+
constructor(ctx, config) {
|
|
198
|
+
// The host owns shell settings; this executor only resolves and validates
|
|
199
|
+
// its composition config (including the executable-aware extension).
|
|
200
|
+
super(ctx, checkedCompositionConfig(config));
|
|
201
|
+
this.mode = ctx.sandboxPolicy.defaultMode;
|
|
202
|
+
}
|
|
203
|
+
/**
|
|
204
|
+
* The bash.exe for one file-effect mode. `danger-full-access` uses the
|
|
205
|
+
* unconfined installation (`executable` / {@link GIT_BASH_PATH_ENV}); the
|
|
206
|
+
* confined modes prefer their dedicated installation (`confinedExecutable` /
|
|
207
|
+
* {@link GIT_BASH_PATH_CONFINED_ENV}) so their MSYS shared object is created
|
|
208
|
+
* fresh by the Low-integrity child rather than inherited as a Medium object.
|
|
209
|
+
* @param mode - the resolved policy mode for this execution.
|
|
210
|
+
*/
|
|
211
|
+
executableFor(mode) {
|
|
212
|
+
const config = this.config;
|
|
213
|
+
const confined = mode !== "danger-full-access";
|
|
214
|
+
const configured = (confined ? config.confinedExecutable : config.executable)?.trim() ?? "";
|
|
215
|
+
const cached = this.executableCache.get(mode);
|
|
216
|
+
if (cached?.configured === configured)
|
|
217
|
+
return cached.resolved;
|
|
218
|
+
const resolved = (confined ? resolveConfinedExecutable(config) : resolveConfiguredExecutable(config))
|
|
219
|
+
?? resolveGitBashPath();
|
|
220
|
+
this.executableCache.set(mode, { configured, resolved });
|
|
221
|
+
return resolved;
|
|
222
|
+
}
|
|
223
|
+
/** The unconfined-mode bash.exe; kept as the public property existing tests and callers read. */
|
|
224
|
+
get executable() {
|
|
225
|
+
return this.executableFor("danger-full-access");
|
|
226
|
+
}
|
|
227
|
+
get sandboxMode() {
|
|
228
|
+
return this.mode;
|
|
229
|
+
}
|
|
230
|
+
resolve(request) {
|
|
231
|
+
const resolved = super.resolve(request);
|
|
232
|
+
return {
|
|
233
|
+
...resolved,
|
|
234
|
+
env: {
|
|
235
|
+
...(resolved.env ?? {}),
|
|
236
|
+
// Keep Git/MSYS2 Bash in the workspace directory instead of
|
|
237
|
+
// changing to $HOME on login-shell startup.
|
|
238
|
+
CHERE_INVOKING: "1",
|
|
239
|
+
},
|
|
240
|
+
sandboxPolicy: request.sandboxPolicy ?? this.ctx.sandboxPolicy.resolve(),
|
|
241
|
+
};
|
|
242
|
+
}
|
|
243
|
+
argv(mode, command) {
|
|
244
|
+
return [this.executableFor(mode), "--login", "-c", command];
|
|
245
|
+
}
|
|
246
|
+
guardedArgv(command, mode) {
|
|
247
|
+
assertNativeGuard(mode);
|
|
248
|
+
return [GUARD_EXECUTABLE, "--", ...this.argv(mode, command)];
|
|
249
|
+
}
|
|
250
|
+
policy(spec) {
|
|
251
|
+
if (!spec.sandboxPolicy) {
|
|
252
|
+
throw new Error("git-bash: resolved execution is missing sandbox policy");
|
|
253
|
+
}
|
|
254
|
+
return spec.sandboxPolicy;
|
|
255
|
+
}
|
|
256
|
+
async confine(command, policy, signal) {
|
|
257
|
+
this.ensureServerDaclNormalized();
|
|
258
|
+
// `ctx.sandbox.confine` is async; await it before spreading so the
|
|
259
|
+
// runner-failure rules extend the resolved wrap rather than a promise.
|
|
260
|
+
const confined = await this.ctx.sandbox.confine(this.guardedArgv(command, policy.mode), policy, signal);
|
|
261
|
+
return {
|
|
262
|
+
...confined,
|
|
263
|
+
runnerFailureRules: [...confined.runnerFailureRules, GUARD_FAILURE_RULE],
|
|
264
|
+
};
|
|
265
|
+
}
|
|
266
|
+
serverDaclNormalized = false;
|
|
267
|
+
ensureServerDaclNormalized() {
|
|
268
|
+
if (this.serverDaclNormalized)
|
|
269
|
+
return;
|
|
270
|
+
this.serverDaclNormalized = true;
|
|
271
|
+
normalizeServerDefaultDacl();
|
|
272
|
+
}
|
|
273
|
+
async execute(spec) {
|
|
274
|
+
const policy = this.policy(spec);
|
|
275
|
+
const { mode } = policy;
|
|
276
|
+
if (mode === "danger-full-access") {
|
|
277
|
+
// Unconfined, but still the configured Git Bash. The host base class
|
|
278
|
+
// hardcodes `["bash", "-c", …]` (a PATH lookup), which would silently
|
|
279
|
+
// ignore `executable` and DSH_GIT_BASH_PATH; route through the same
|
|
280
|
+
// argv the confined branch builds so all three modes share one
|
|
281
|
+
// resolution chain.
|
|
282
|
+
const execution = await this.executeArgv(spec, this.argv(mode, spec.command));
|
|
283
|
+
return GitBashExecutor.decorateResult(execution, (result) => ({
|
|
284
|
+
...result,
|
|
285
|
+
sandbox: { mode, denied: false },
|
|
286
|
+
}));
|
|
287
|
+
}
|
|
288
|
+
let confined;
|
|
289
|
+
const execution = await this.executeArgv(spec, async (signal) => {
|
|
290
|
+
const prepared = await this.confine(spec.command, { ...policy, mode }, signal);
|
|
291
|
+
signal.throwIfAborted();
|
|
292
|
+
confined = prepared;
|
|
293
|
+
return prepared.argv;
|
|
294
|
+
}, (process) => {
|
|
295
|
+
const facts = confined;
|
|
296
|
+
if (facts === undefined)
|
|
297
|
+
return;
|
|
298
|
+
this.processFacts.set(process, {
|
|
299
|
+
mode,
|
|
300
|
+
enforcement: facts.enforcement,
|
|
301
|
+
denialSignatures: facts.denialSignatures,
|
|
302
|
+
runnerFailureRules: facts.runnerFailureRules,
|
|
303
|
+
runnerProgram: facts.argv[0],
|
|
304
|
+
workdir: spec.workdir,
|
|
305
|
+
});
|
|
306
|
+
});
|
|
307
|
+
return GitBashExecutor.decorateResult(execution, (result) => {
|
|
308
|
+
if (confined === undefined) {
|
|
309
|
+
return { ...result, sandbox: { mode, denied: false } };
|
|
310
|
+
}
|
|
311
|
+
const runnerFailure = classifyRunnerFailure(result.exitCode, result.stderr.text, confined.runnerFailureRules);
|
|
312
|
+
if (runnerFailure !== undefined) {
|
|
313
|
+
throw new SandboxUnavailableError(mode, describeGuardFailure(runnerFailure.detail));
|
|
314
|
+
}
|
|
315
|
+
return {
|
|
316
|
+
...result,
|
|
317
|
+
sandbox: {
|
|
318
|
+
mode,
|
|
319
|
+
denied: classifyDenial(result, confined.denialSignatures),
|
|
320
|
+
enforcement: confined.enforcement,
|
|
321
|
+
},
|
|
322
|
+
};
|
|
323
|
+
}, (error) => {
|
|
324
|
+
if (spec.signal?.aborted === true)
|
|
325
|
+
spec.signal.throwIfAborted();
|
|
326
|
+
if (confined !== undefined && isRunnerSpawnFailure(error, confined.argv[0], spec.workdir)) {
|
|
327
|
+
throw new SandboxUnavailableError(mode, String(error));
|
|
328
|
+
}
|
|
329
|
+
throw error;
|
|
330
|
+
});
|
|
331
|
+
}
|
|
332
|
+
/**
|
|
333
|
+
* Decorate the handle's foreground projection in place, memoized once. The
|
|
334
|
+
* handle keeps its identity (never wrapped in a second object) because the
|
|
335
|
+
* per-process facts and `onProcessDone` key on the exact instance.
|
|
336
|
+
*/
|
|
337
|
+
static decorateResult(execution, map, mapError) {
|
|
338
|
+
const base = execution.result.bind(execution);
|
|
339
|
+
let decorated;
|
|
340
|
+
execution.result = () => {
|
|
341
|
+
decorated ??= mapError === undefined ? base().then(map) : base().then(map, mapError);
|
|
342
|
+
return decorated;
|
|
343
|
+
};
|
|
344
|
+
return execution;
|
|
345
|
+
}
|
|
346
|
+
/**
|
|
347
|
+
* Stamp per-process sandbox facts before `done` settles. Full-access
|
|
348
|
+
* processes carry no facts; provider rejections are classified as runner
|
|
349
|
+
* failures rather than denials.
|
|
350
|
+
*/
|
|
351
|
+
onProcessDone(proc, stderr, providerRejected, providerError) {
|
|
352
|
+
const facts = this.processFacts.get(proc);
|
|
353
|
+
if (facts !== undefined) {
|
|
354
|
+
this.processFacts.delete(proc);
|
|
355
|
+
const runnerFailed = providerRejected
|
|
356
|
+
? isRunnerSpawnFailure(providerError, facts.runnerProgram, facts.workdir)
|
|
357
|
+
: classifyRunnerFailure(proc.exitCode, stderr, facts.runnerFailureRules) !== undefined;
|
|
358
|
+
proc.sandbox = {
|
|
359
|
+
mode: facts.mode,
|
|
360
|
+
denied: !runnerFailed && matchesSignature(proc.exitCode, stderr, facts.denialSignatures),
|
|
361
|
+
enforcement: facts.enforcement,
|
|
362
|
+
...(runnerFailed ? { runnerFailed } : {}),
|
|
363
|
+
};
|
|
364
|
+
}
|
|
365
|
+
super.onProcessDone(proc, stderr, providerRejected, providerError);
|
|
366
|
+
}
|
|
367
|
+
}
|
|
368
|
+
export default GitBashExecutor;
|
|
369
|
+
//# sourceMappingURL=index.js.map
|
package/lib/index.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAC;AAEhE,OAAO,EAAE,uBAAuB,EAAE,MAAM,0BAA0B,CAAC;AAkBnE,OAAO,CAAC,MAAM,0BAA0B,CAAC;AACzC,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAC/C,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAC1D,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAC7C,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,0BAA0B,EAAE,qBAAqB,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AAEvG,OAAO,EACL,0BAA0B,EAC1B,iBA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,CAAC"}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
cmake_minimum_required(VERSION 3.25)
|
|
2
|
+
project(dsh_msys_token_guard LANGUAGES CXX)
|
|
3
|
+
|
|
4
|
+
set(DETOURS_DIR "${CMAKE_CURRENT_SOURCE_DIR}/vendor/detours")
|
|
5
|
+
add_library(detours STATIC
|
|
6
|
+
"${DETOURS_DIR}/detours.cpp"
|
|
7
|
+
"${DETOURS_DIR}/modules.cpp"
|
|
8
|
+
"${DETOURS_DIR}/disasm.cpp"
|
|
9
|
+
"${DETOURS_DIR}/image.cpp"
|
|
10
|
+
"${DETOURS_DIR}/creatwth.cpp"
|
|
11
|
+
)
|
|
12
|
+
target_include_directories(detours PUBLIC "${DETOURS_DIR}")
|
|
13
|
+
target_compile_definitions(detours PRIVATE WIN32_LEAN_AND_MEAN _WIN32_WINNT=0x0A00)
|
|
14
|
+
set_target_properties(detours PROPERTIES
|
|
15
|
+
MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>"
|
|
16
|
+
)
|
|
17
|
+
|
|
18
|
+
add_executable(msys-token-guard msys-token-guard.cpp)
|
|
19
|
+
add_library(msys-token-guard-hook SHARED msys-token-guard-hook.cpp)
|
|
20
|
+
|
|
21
|
+
foreach(target IN ITEMS msys-token-guard msys-token-guard-hook)
|
|
22
|
+
target_compile_features(${target} PRIVATE cxx_std_20)
|
|
23
|
+
target_compile_definitions(${target} PRIVATE UNICODE _UNICODE)
|
|
24
|
+
target_link_libraries(${target} PRIVATE detours advapi32)
|
|
25
|
+
set_target_properties(${target} PROPERTIES
|
|
26
|
+
MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>"
|
|
27
|
+
RUNTIME_OUTPUT_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/bin/win32-x64"
|
|
28
|
+
RUNTIME_OUTPUT_DIRECTORY_DEBUG "${CMAKE_CURRENT_SOURCE_DIR}/bin/win32-x64"
|
|
29
|
+
RUNTIME_OUTPUT_DIRECTORY_RELEASE "${CMAKE_CURRENT_SOURCE_DIR}/bin/win32-x64"
|
|
30
|
+
RUNTIME_OUTPUT_DIRECTORY_RELWITHDEBINFO "${CMAKE_CURRENT_SOURCE_DIR}/bin/win32-x64"
|
|
31
|
+
RUNTIME_OUTPUT_DIRECTORY_MINSIZEREL "${CMAKE_CURRENT_SOURCE_DIR}/bin/win32-x64"
|
|
32
|
+
)
|
|
33
|
+
endforeach()
|
|
34
|
+
|
|
35
|
+
if(MSVC)
|
|
36
|
+
target_compile_options(detours PRIVATE
|
|
37
|
+
/W4 /WX /GS /guard:cf /sdl /utf-8 /Zc:inline /Zc:preprocessor
|
|
38
|
+
)
|
|
39
|
+
foreach(target IN ITEMS msys-token-guard msys-token-guard-hook)
|
|
40
|
+
target_compile_options(${target} PRIVATE
|
|
41
|
+
/W4 /WX /permissive- /EHsc /GS /guard:cf /sdl /utf-8
|
|
42
|
+
/Zc:__cplusplus /Zc:inline /Zc:preprocessor
|
|
43
|
+
)
|
|
44
|
+
target_link_options(${target} PRIVATE
|
|
45
|
+
/DYNAMICBASE /NXCOMPAT /guard:cf /CETCOMPAT /OPT:REF /OPT:ICF /Brepro
|
|
46
|
+
)
|
|
47
|
+
endforeach()
|
|
48
|
+
target_link_options(msys-token-guard PRIVATE
|
|
49
|
+
"/MANIFESTUAC:level='asInvoker' uiAccess='false'"
|
|
50
|
+
)
|
|
51
|
+
target_link_options(msys-token-guard-hook PRIVATE
|
|
52
|
+
"/EXPORT:DetourFinishHelperProcess,@1,NONAME"
|
|
53
|
+
)
|
|
54
|
+
else()
|
|
55
|
+
foreach(target IN ITEMS detours msys-token-guard msys-token-guard-hook)
|
|
56
|
+
target_compile_options(${target} PRIVATE -Wall -Wextra -Wpedantic -Werror)
|
|
57
|
+
endforeach()
|
|
58
|
+
endif()
|
|
Binary file
|
|
Binary file
|