@simple-git/argv-parser 2.0.1 → 3.1.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/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +7 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.mjs +631 -213
- package/dist/index.mjs.map +1 -1
- package/dist/src/args/parse-argv.types.d.ts +6 -0
- package/dist/src/args/parse-argv.types.d.ts.map +1 -1
- package/dist/src/config/config-allow-list.d.ts +28 -0
- package/dist/src/config/config-allow-list.d.ts.map +1 -0
- package/dist/src/config/config.types.d.ts +1 -0
- package/dist/src/config/config.types.d.ts.map +1 -1
- package/dist/src/config/detect-config-action.d.ts +3 -1
- package/dist/src/config/detect-config-action.d.ts.map +1 -1
- package/dist/src/env/parse-env.d.ts +13 -1
- package/dist/src/env/parse-env.d.ts.map +1 -1
- package/dist/src/flags/parse-task-flags.d.ts.map +1 -1
- package/dist/src/template/ref-name.d.ts +11 -0
- package/dist/src/template/ref-name.d.ts.map +1 -0
- package/dist/src/template/remote-url.d.ts +27 -0
- package/dist/src/template/remote-url.d.ts.map +1 -0
- package/dist/src/template/template-argv.d.ts +25 -0
- package/dist/src/template/template-argv.d.ts.map +1 -0
- package/dist/src/template/template-values.d.ts +11 -0
- package/dist/src/template/template-values.d.ts.map +1 -0
- package/dist/src/tokens/flag-specs.d.ts.map +1 -1
- package/dist/src/vulnerabilities/detect-vulnerable-config-writes.d.ts.map +1 -1
- package/dist/src/vulnerabilities/detect-vulnerable-flags.d.ts.map +1 -1
- package/dist/src/vulnerabilities/vulnerability.types.d.ts +120 -2
- package/dist/src/vulnerabilities/vulnerability.types.d.ts.map +1 -1
- package/package.json +1 -1
- package/dist/src/vulnerabilities/vulnerability-check.d.ts +0 -6
- package/dist/src/vulnerabilities/vulnerability-check.d.ts.map +0 -1
package/dist/index.mjs
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { isPathSpec as
|
|
2
|
-
function*
|
|
3
|
-
const
|
|
1
|
+
import { isPathSpec as b, toPaths as _ } from "@simple-git/args-pathspec";
|
|
2
|
+
function* F(e, t) {
|
|
3
|
+
const n = t === "global";
|
|
4
4
|
for (const o of e)
|
|
5
|
-
o.isGlobal ===
|
|
5
|
+
o.isGlobal === n && (yield o);
|
|
6
6
|
}
|
|
7
|
-
const
|
|
7
|
+
const W = /* @__PURE__ */ new Set([
|
|
8
8
|
"--add",
|
|
9
9
|
"--edit",
|
|
10
10
|
"--remove-section",
|
|
@@ -13,7 +13,7 @@ const P = /* @__PURE__ */ new Set([
|
|
|
13
13
|
"--unset",
|
|
14
14
|
"--unset-all",
|
|
15
15
|
"-e"
|
|
16
|
-
]),
|
|
16
|
+
]), K = /* @__PURE__ */ new Set([
|
|
17
17
|
"--get",
|
|
18
18
|
"--get-all",
|
|
19
19
|
"--get-color",
|
|
@@ -22,45 +22,51 @@ const P = /* @__PURE__ */ new Set([
|
|
|
22
22
|
"--get-urlmatch",
|
|
23
23
|
"--list",
|
|
24
24
|
"-l"
|
|
25
|
-
]),
|
|
25
|
+
]), j = /* @__PURE__ */ new Set([
|
|
26
26
|
"edit",
|
|
27
27
|
"remove-section",
|
|
28
28
|
"rename-section",
|
|
29
29
|
"set",
|
|
30
30
|
"unset"
|
|
31
|
-
]),
|
|
32
|
-
function
|
|
33
|
-
for (const { name: o } of
|
|
34
|
-
if (
|
|
35
|
-
return
|
|
36
|
-
if (
|
|
37
|
-
return
|
|
31
|
+
]), D = /* @__PURE__ */ new Set(["get", "get-color", "get-colorbool", "list"]);
|
|
32
|
+
function I(e, t) {
|
|
33
|
+
for (const { name: o } of F(e, "task")) {
|
|
34
|
+
if (W.has(o))
|
|
35
|
+
return v(!0, t, o === "--rename-section");
|
|
36
|
+
if (K.has(o))
|
|
37
|
+
return v(!1, t);
|
|
38
38
|
}
|
|
39
|
-
const
|
|
40
|
-
return
|
|
39
|
+
const n = t.at(0)?.toLowerCase();
|
|
40
|
+
return n === void 0 ? null : j.has(n) ? v(!0, t.slice(1), n === "rename-section") : D.has(n) ? v(!1, t.slice(1)) : t.length === 1 ? v(!1, t) : v(!0, t);
|
|
41
41
|
}
|
|
42
|
-
function
|
|
43
|
-
const
|
|
44
|
-
return
|
|
42
|
+
function v(e = !1, t = [], n = !1) {
|
|
43
|
+
const o = t.at(0)?.toLowerCase();
|
|
44
|
+
return o === void 0 ? null : {
|
|
45
45
|
isWrite: e,
|
|
46
46
|
isRead: !e,
|
|
47
|
-
key:
|
|
48
|
-
value:
|
|
47
|
+
key: o,
|
|
48
|
+
value: t.at(1),
|
|
49
|
+
rename: n
|
|
49
50
|
};
|
|
50
51
|
}
|
|
51
|
-
function
|
|
52
|
-
return
|
|
52
|
+
function B(e, t) {
|
|
53
|
+
return t.isWrite && t.value !== void 0 ? {
|
|
54
|
+
scope: e,
|
|
55
|
+
key: t.key,
|
|
56
|
+
value: t.value,
|
|
57
|
+
rename: t.rename
|
|
58
|
+
} : { key: t.key, scope: e };
|
|
53
59
|
}
|
|
54
|
-
function
|
|
55
|
-
const
|
|
56
|
-
return !e ||
|
|
57
|
-
key: e.slice(0,
|
|
58
|
-
value: e.slice(
|
|
60
|
+
function V(e) {
|
|
61
|
+
const t = e?.indexOf("=") || -1;
|
|
62
|
+
return !e || t < 0 ? null : {
|
|
63
|
+
key: e.slice(0, t).trim().toLowerCase(),
|
|
64
|
+
value: e.slice(t + 1)
|
|
59
65
|
};
|
|
60
66
|
}
|
|
61
|
-
function
|
|
62
|
-
for (const { name:
|
|
63
|
-
switch (
|
|
67
|
+
function q(e) {
|
|
68
|
+
for (const { name: t } of F(e, "task"))
|
|
69
|
+
switch (t) {
|
|
64
70
|
case "--global":
|
|
65
71
|
return "global";
|
|
66
72
|
case "--system":
|
|
@@ -75,45 +81,40 @@ function M(e) {
|
|
|
75
81
|
}
|
|
76
82
|
return "local";
|
|
77
83
|
}
|
|
78
|
-
function
|
|
84
|
+
function z({ name: e }) {
|
|
79
85
|
if (e === "-c" || e === "--config")
|
|
80
86
|
return "inline";
|
|
81
87
|
if (e === "--config-env")
|
|
82
88
|
return "env";
|
|
83
89
|
}
|
|
84
|
-
function*
|
|
85
|
-
for (const
|
|
86
|
-
const
|
|
90
|
+
function* H(e) {
|
|
91
|
+
for (const t of e) {
|
|
92
|
+
const n = z(t), o = n && V(t.value);
|
|
87
93
|
o && (yield {
|
|
88
94
|
...o,
|
|
89
|
-
scope:
|
|
95
|
+
scope: n
|
|
90
96
|
});
|
|
91
97
|
}
|
|
92
98
|
}
|
|
93
|
-
function
|
|
99
|
+
function Y(e, t, n) {
|
|
94
100
|
const o = {
|
|
95
101
|
read: [],
|
|
96
|
-
write: [
|
|
102
|
+
write: [...H(t)]
|
|
97
103
|
};
|
|
98
|
-
return e === "config" &&
|
|
104
|
+
return e === "config" && J(
|
|
99
105
|
o,
|
|
100
|
-
|
|
101
|
-
|
|
106
|
+
q(t),
|
|
107
|
+
I(t, n)
|
|
102
108
|
), o;
|
|
103
109
|
}
|
|
104
|
-
function
|
|
105
|
-
if (
|
|
110
|
+
function J(e, t, n) {
|
|
111
|
+
if (n === null)
|
|
106
112
|
return;
|
|
107
|
-
const o =
|
|
108
|
-
|
|
113
|
+
const o = B(t, n);
|
|
114
|
+
n.isWrite ? e.write.push(o) : e.read.push(o);
|
|
109
115
|
}
|
|
110
|
-
const
|
|
116
|
+
const S = {
|
|
111
117
|
short: /* @__PURE__ */ new Map([
|
|
112
|
-
["c", !0]
|
|
113
|
-
// -c <k=v> set config key for this invocation
|
|
114
|
-
])
|
|
115
|
-
}, I = {
|
|
116
|
-
short: new Map([
|
|
117
118
|
["C", !0],
|
|
118
119
|
// -C <path> change working directory
|
|
119
120
|
["P", !1],
|
|
@@ -124,7 +125,8 @@ const C = {
|
|
|
124
125
|
// -p paginate
|
|
125
126
|
["v", !1],
|
|
126
127
|
// -v version
|
|
127
|
-
|
|
128
|
+
["c", !0]
|
|
129
|
+
// -c <k=v> set config key for this invocation
|
|
128
130
|
]),
|
|
129
131
|
long: /* @__PURE__ */ new Set([
|
|
130
132
|
"attr-source",
|
|
@@ -136,11 +138,20 @@ const C = {
|
|
|
136
138
|
"super-prefix",
|
|
137
139
|
"work-tree"
|
|
138
140
|
])
|
|
139
|
-
},
|
|
141
|
+
}, X = {
|
|
142
|
+
archive: {
|
|
143
|
+
short: /* @__PURE__ */ new Map([
|
|
144
|
+
["c", !1]
|
|
145
|
+
// no `-c` of its own, with `--remote` unknown options are sent to the remote
|
|
146
|
+
]),
|
|
147
|
+
long: /* @__PURE__ */ new Set()
|
|
148
|
+
},
|
|
140
149
|
clone: {
|
|
141
150
|
short: /* @__PURE__ */ new Map([
|
|
142
151
|
["b", !0],
|
|
143
152
|
// -b <branch>
|
|
153
|
+
["c", !0],
|
|
154
|
+
// -c <k=v> set config key in the new repository
|
|
144
155
|
["j", !0],
|
|
145
156
|
// -j <n> parallel jobs
|
|
146
157
|
["l", !1],
|
|
@@ -184,14 +195,51 @@ const C = {
|
|
|
184
195
|
]),
|
|
185
196
|
long: /* @__PURE__ */ new Set(["blob", "comment", "default", "file", "type", "value"])
|
|
186
197
|
},
|
|
198
|
+
difftool: {
|
|
199
|
+
short: /* @__PURE__ */ new Map([
|
|
200
|
+
["d", !1],
|
|
201
|
+
// -d dir-diff
|
|
202
|
+
["g", !1],
|
|
203
|
+
// -g gui
|
|
204
|
+
["h", !1],
|
|
205
|
+
// -h help
|
|
206
|
+
["t", !0],
|
|
207
|
+
// -t <tool>
|
|
208
|
+
["x", !0],
|
|
209
|
+
// -x <command>
|
|
210
|
+
["y", !1]
|
|
211
|
+
// -y no-prompt
|
|
212
|
+
]),
|
|
213
|
+
long: /* @__PURE__ */ new Set(["extcmd", "tool"])
|
|
214
|
+
},
|
|
187
215
|
fetch: {
|
|
188
216
|
short: /* @__PURE__ */ new Map(),
|
|
189
217
|
long: /* @__PURE__ */ new Set(["upload-pack"])
|
|
190
218
|
},
|
|
219
|
+
grep: {
|
|
220
|
+
short: /* @__PURE__ */ new Map([
|
|
221
|
+
["c", !1]
|
|
222
|
+
// -c count
|
|
223
|
+
]),
|
|
224
|
+
long: /* @__PURE__ */ new Set()
|
|
225
|
+
},
|
|
191
226
|
init: {
|
|
192
227
|
short: /* @__PURE__ */ new Map(),
|
|
193
228
|
long: /* @__PURE__ */ new Set(["template"])
|
|
194
229
|
},
|
|
230
|
+
notes: {
|
|
231
|
+
short: /* @__PURE__ */ new Map([
|
|
232
|
+
["C", !0],
|
|
233
|
+
// -C <object> reuse message
|
|
234
|
+
["F", !0],
|
|
235
|
+
// -F <file> read message from file
|
|
236
|
+
["c", !0],
|
|
237
|
+
// -c <object> reedit message
|
|
238
|
+
["m", !0]
|
|
239
|
+
// -m <msg>
|
|
240
|
+
]),
|
|
241
|
+
long: /* @__PURE__ */ new Set(["file", "message", "reedit-message", "reuse-message"])
|
|
242
|
+
},
|
|
195
243
|
pull: {
|
|
196
244
|
short: /* @__PURE__ */ new Map(),
|
|
197
245
|
long: /* @__PURE__ */ new Set(["upload-pack"])
|
|
@@ -226,78 +274,91 @@ const C = {
|
|
|
226
274
|
// -x <cmd> exec
|
|
227
275
|
]),
|
|
228
276
|
long: /* @__PURE__ */ new Set(["exec", "onto", "strategy", "strategy-option"])
|
|
277
|
+
},
|
|
278
|
+
"send-email": {
|
|
279
|
+
short: /* @__PURE__ */ new Map(),
|
|
280
|
+
long: /* @__PURE__ */ new Set(["cc-cmd", "header-cmd", "sendmail-cmd", "to-cmd"])
|
|
281
|
+
},
|
|
282
|
+
switch: {
|
|
283
|
+
short: /* @__PURE__ */ new Map([
|
|
284
|
+
["C", !0],
|
|
285
|
+
// -C <branch> force create
|
|
286
|
+
["c", !0]
|
|
287
|
+
// -c <branch> create
|
|
288
|
+
]),
|
|
289
|
+
long: /* @__PURE__ */ new Set(["create", "force-create", "orphan"])
|
|
229
290
|
}
|
|
230
|
-
},
|
|
231
|
-
function
|
|
232
|
-
const
|
|
291
|
+
}, Q = { short: /* @__PURE__ */ new Map(), long: /* @__PURE__ */ new Set() };
|
|
292
|
+
function Z(e) {
|
|
293
|
+
const t = X[e ?? ""] ?? Q;
|
|
233
294
|
return {
|
|
234
|
-
short: new Map([
|
|
235
|
-
long:
|
|
295
|
+
short: new Map([["c", !1], ...t.short.entries()]),
|
|
296
|
+
long: t.long
|
|
236
297
|
};
|
|
237
298
|
}
|
|
238
|
-
function
|
|
299
|
+
function L(e, t = S) {
|
|
239
300
|
if (e.startsWith("--")) {
|
|
240
|
-
const
|
|
241
|
-
if (
|
|
242
|
-
return [{ name: e.slice(0,
|
|
301
|
+
const n = e.indexOf("=");
|
|
302
|
+
if (n > 2)
|
|
303
|
+
return [{ name: e.slice(0, n), value: e.slice(n + 1), needsNext: !1 }];
|
|
243
304
|
const o = e.slice(2);
|
|
244
|
-
return [{ name: e, needsNext:
|
|
305
|
+
return [{ name: e, needsNext: t.long.has(o) }];
|
|
245
306
|
}
|
|
246
307
|
if (e.length === 2) {
|
|
247
|
-
const
|
|
308
|
+
const n = e.charAt(1), o = t.short.get(n);
|
|
248
309
|
return [{ name: e, needsNext: o === !0 }];
|
|
249
310
|
}
|
|
250
|
-
return
|
|
311
|
+
return ee(e, t.short);
|
|
251
312
|
}
|
|
252
|
-
function
|
|
253
|
-
const
|
|
254
|
-
for (let a = 0; a <
|
|
255
|
-
const s =
|
|
313
|
+
function ee(e, t) {
|
|
314
|
+
const n = e.slice(1).split(""), o = [];
|
|
315
|
+
for (let a = 0; a < n.length; a++) {
|
|
316
|
+
const s = n[a], r = t.get(s);
|
|
256
317
|
if (r === void 0)
|
|
257
318
|
return [{ name: e, needsNext: !1 }];
|
|
258
319
|
if (r) {
|
|
259
|
-
const
|
|
260
|
-
if (
|
|
261
|
-
return o.push({ name: `-${s}`, value:
|
|
320
|
+
const u = n.slice(a + 1).join("");
|
|
321
|
+
if (u && ![...u].every((w) => t.has(w)))
|
|
322
|
+
return o.push({ name: `-${s}`, value: u, needsNext: !1 }), o;
|
|
262
323
|
}
|
|
263
324
|
o.push({ name: `-${s}`, needsNext: r });
|
|
264
325
|
}
|
|
265
326
|
return o;
|
|
266
327
|
}
|
|
267
|
-
function
|
|
268
|
-
let
|
|
269
|
-
for (;
|
|
270
|
-
const o = String(e[
|
|
328
|
+
function te(e, t = []) {
|
|
329
|
+
let n = 0;
|
|
330
|
+
for (; n < e.length; ) {
|
|
331
|
+
const o = String(e[n]);
|
|
271
332
|
if (!o.startsWith("-") || o.length < 2) break;
|
|
272
|
-
const a =
|
|
273
|
-
let s =
|
|
333
|
+
const a = L(o);
|
|
334
|
+
let s = n + 1;
|
|
274
335
|
for (const r of a) {
|
|
275
|
-
const
|
|
336
|
+
const u = {
|
|
276
337
|
name: r.name,
|
|
277
338
|
value: r.value,
|
|
278
339
|
absorbedNext: !1,
|
|
279
340
|
isGlobal: !0
|
|
280
341
|
};
|
|
281
|
-
r.needsNext &&
|
|
342
|
+
r.needsNext && u.value === void 0 && s < e.length && (u.value = String(e[s]), u.absorbedNext = !0, s++), t.push(u);
|
|
282
343
|
}
|
|
283
|
-
|
|
344
|
+
n = s;
|
|
284
345
|
}
|
|
285
|
-
return { flags:
|
|
346
|
+
return { flags: t, taskIndex: n };
|
|
286
347
|
}
|
|
287
|
-
function
|
|
288
|
-
const o =
|
|
348
|
+
function ne(e, t, n = []) {
|
|
349
|
+
const o = Z(t), a = [], s = [];
|
|
289
350
|
let r = 0;
|
|
290
351
|
for (; r < e.length; ) {
|
|
291
|
-
const
|
|
292
|
-
if (
|
|
293
|
-
s.push(...
|
|
352
|
+
const u = e[r];
|
|
353
|
+
if (b(u)) {
|
|
354
|
+
s.push(..._(u)), r++;
|
|
294
355
|
continue;
|
|
295
356
|
}
|
|
296
|
-
const p = String(
|
|
357
|
+
const p = String(u);
|
|
297
358
|
if (p === "--") {
|
|
298
|
-
for (let
|
|
299
|
-
const
|
|
300
|
-
|
|
359
|
+
for (let c = r + 1; c < e.length; c++) {
|
|
360
|
+
const d = e[c];
|
|
361
|
+
b(d) ? s.push(..._(d)) : s.push(String(d));
|
|
301
362
|
}
|
|
302
363
|
break;
|
|
303
364
|
}
|
|
@@ -305,136 +366,328 @@ function V(e, n, t = []) {
|
|
|
305
366
|
a.push(p), r++;
|
|
306
367
|
continue;
|
|
307
368
|
}
|
|
308
|
-
const
|
|
309
|
-
let
|
|
310
|
-
for (const
|
|
311
|
-
const
|
|
312
|
-
name:
|
|
313
|
-
value:
|
|
369
|
+
const w = L(p, o);
|
|
370
|
+
let h = r + 1;
|
|
371
|
+
for (const c of w) {
|
|
372
|
+
const d = {
|
|
373
|
+
name: c.name,
|
|
374
|
+
value: c.value,
|
|
314
375
|
absorbedNext: !1,
|
|
315
376
|
isGlobal: !1
|
|
316
377
|
};
|
|
317
|
-
|
|
378
|
+
c.needsNext && d.value === void 0 && h < e.length && !b(e[h]) ? (d.value = String(e[h]), d.absorbedNext = !0, h++) : oe(c, d, e[h]) && (d.value = String(e[h])), n.push(d);
|
|
318
379
|
}
|
|
319
|
-
r =
|
|
380
|
+
r = h;
|
|
320
381
|
}
|
|
321
|
-
return { flags:
|
|
382
|
+
return { flags: n, positionals: a, pathspecs: s };
|
|
322
383
|
}
|
|
323
|
-
function
|
|
384
|
+
function oe(e, t, n) {
|
|
385
|
+
return e.name === "-c" && !e.needsNext && t.value === void 0 && typeof n == "string" && !n.startsWith("-") && n.includes("=");
|
|
386
|
+
}
|
|
387
|
+
function* ae({
|
|
324
388
|
write: e
|
|
325
389
|
}) {
|
|
326
|
-
for (const
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
390
|
+
for (const t of e) {
|
|
391
|
+
if (t.rename) {
|
|
392
|
+
yield {
|
|
393
|
+
category: "allowUnsafeConfigRename",
|
|
394
|
+
level: "default",
|
|
395
|
+
message: `Renaming config section ${t.key} is not permitted without enabling allowUnsafeConfigRename`
|
|
396
|
+
};
|
|
397
|
+
continue;
|
|
330
398
|
}
|
|
399
|
+
for (const n of fe) {
|
|
400
|
+
const o = n(t.key);
|
|
401
|
+
if (o) {
|
|
402
|
+
yield o;
|
|
403
|
+
break;
|
|
404
|
+
}
|
|
405
|
+
}
|
|
406
|
+
}
|
|
331
407
|
}
|
|
332
|
-
function
|
|
333
|
-
const
|
|
334
|
-
return function(
|
|
335
|
-
if (
|
|
408
|
+
function i(e, t, n = String(e), o = "default") {
|
|
409
|
+
const a = typeof e == "string" ? new RegExp(`\\s*${e.toLowerCase()}`) : e;
|
|
410
|
+
return function(r) {
|
|
411
|
+
if (a.test(r))
|
|
336
412
|
return {
|
|
337
|
-
category:
|
|
338
|
-
|
|
413
|
+
category: t,
|
|
414
|
+
level: o,
|
|
415
|
+
message: `Configuring ${n} is not permitted without enabling ${t}`,
|
|
416
|
+
configKey: r
|
|
339
417
|
};
|
|
340
418
|
};
|
|
341
419
|
}
|
|
342
|
-
function
|
|
343
|
-
const
|
|
344
|
-
return
|
|
345
|
-
}
|
|
346
|
-
const
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
f("
|
|
365
|
-
|
|
366
|
-
f("
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
420
|
+
function f(e, t) {
|
|
421
|
+
const n = new RegExp(`\\s*${e.toLowerCase().replace(/\./g, "(..+)?.")}`);
|
|
422
|
+
return i(n, t, e);
|
|
423
|
+
}
|
|
424
|
+
const se = /^sendemail\.(.+\.)?(sendmailcmd|tocmd|cccmd|headercmd|smtpserver|smtpserveroption|smtpsslcertpath|smtpsslclientcert|smtpsslclientkey|aliasesfile|mailmap\.file)$/, re = /^imap\.(tunnel|host|sslverify)$/, le = /^instaweb\.(httpd|modulepath|gitwebdir)$/, ie = /^(browser|man)\..+\.(path|cmd)$/, ce = /^gpg\.(ssh\.(allowedsignersfile|revocationfile)|mintrustlevel)$/, fe = [
|
|
425
|
+
i(se, "allowUnsafeSendEmailConfig", "sendemail.*"),
|
|
426
|
+
i(re, "allowUnsafeSendEmailConfig", "imap.*"),
|
|
427
|
+
i(le, "allowUnsafeWebServerConfig", "instaweb.*"),
|
|
428
|
+
i(ie, "allowUnsafeBrowser", "browser.* / man.*"),
|
|
429
|
+
i(ce, "allowUnsafeSignatureTrust", "gpg.* signature trust"),
|
|
430
|
+
i("alias", "allowUnsafeAlias"),
|
|
431
|
+
i("core.askPass", "allowUnsafeAskPass"),
|
|
432
|
+
i("core.editor", "allowUnsafeEditor"),
|
|
433
|
+
i("core.fsmonitor", "allowUnsafeFsMonitor"),
|
|
434
|
+
i("core.gitProxy", "allowUnsafeGitProxy"),
|
|
435
|
+
i("core.hooksPath", "allowUnsafeHooksPath"),
|
|
436
|
+
i("core.pager", "allowUnsafePager"),
|
|
437
|
+
i("core.sshCommand", "allowUnsafeSshCommand"),
|
|
438
|
+
f("credential.helper", "allowUnsafeCredentialHelper"),
|
|
439
|
+
f("diff.command", "allowUnsafeDiffExternal"),
|
|
440
|
+
i("diff.external", "allowUnsafeDiffExternal"),
|
|
441
|
+
f("difftool.cmd", "allowUnsafeDiffExternal"),
|
|
442
|
+
f("difftool.path", "allowUnsafeDiffExternal"),
|
|
443
|
+
f("diff.textconv", "allowUnsafeDiffTextConv"),
|
|
444
|
+
f("filter.clean", "allowUnsafeFilter"),
|
|
445
|
+
f("filter.process", "allowUnsafeFilter"),
|
|
446
|
+
f("filter.smudge", "allowUnsafeFilter"),
|
|
447
|
+
f("gpg.program", "allowUnsafeGpgProgram"),
|
|
448
|
+
f("gpg.defaultKeyCommand", "allowUnsafeGpgProgram"),
|
|
449
|
+
i("gc.recentObjectsHook", "allowUnsafeExec"),
|
|
450
|
+
i("include.path", "allowUnsafeInclude"),
|
|
451
|
+
f("includeIf", "allowUnsafeInclude"),
|
|
452
|
+
i("init.templateDir", "allowUnsafeTemplateDir"),
|
|
453
|
+
i("interactive.diffFilter", "allowUnsafePager"),
|
|
454
|
+
f("pager.", "allowUnsafePager"),
|
|
455
|
+
f("merge.driver", "allowUnsafeMergeDriver"),
|
|
456
|
+
f("mergetool.path", "allowUnsafeMergeDriver"),
|
|
457
|
+
f("mergetool.cmd", "allowUnsafeMergeDriver"),
|
|
458
|
+
f("protocol.allow", "allowUnsafeProtocolOverride"),
|
|
459
|
+
f("remote.receivepack", "allowUnsafePack"),
|
|
460
|
+
f("remote.uploadpack", "allowUnsafePack"),
|
|
461
|
+
i("uploadpack.packObjectsHook", "allowUnsafePack"),
|
|
462
|
+
i("sequence.editor", "allowUnsafeEditor"),
|
|
463
|
+
f("submodule.update", "allowUnsafeSubmodule"),
|
|
464
|
+
f("tar.command", "allowUnsafeCommandBinaries"),
|
|
465
|
+
f("trailer.cmd", "allowUnsafeCommandBinaries"),
|
|
466
|
+
f("trailer.command", "allowUnsafeCommandBinaries"),
|
|
467
|
+
f("url.insteadOf", "allowUnsafeUrlRewrite"),
|
|
468
|
+
// catch-all configuration using the "foo.command", "bar.cmd" or "baz.someHook" naming conventions,
|
|
469
|
+
// only blocked when the `recommended` checks are enabled
|
|
470
|
+
i(/command$/, "allowUnsafeCommandBinaries", "/command$/", "recommended"),
|
|
471
|
+
i(/\.cmd$/, "allowUnsafeCommandBinaries", "/\\.cmd$/", "recommended"),
|
|
472
|
+
i(/hook$/, "allowUnsafeCommandBinaries", "/hook$/", "recommended")
|
|
381
473
|
];
|
|
382
|
-
function*
|
|
383
|
-
for (const
|
|
384
|
-
for (const o of
|
|
385
|
-
const a = o(e,
|
|
474
|
+
function* ue(e, t) {
|
|
475
|
+
for (const n of t)
|
|
476
|
+
for (const o of de) {
|
|
477
|
+
const a = o(e, n);
|
|
386
478
|
a && (yield a);
|
|
387
479
|
}
|
|
388
480
|
}
|
|
389
|
-
function
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
481
|
+
function m(e, t, n, {
|
|
482
|
+
name: o = String(t),
|
|
483
|
+
exceptTask: a,
|
|
484
|
+
globalOnly: s = !1,
|
|
485
|
+
withValue: r = !1,
|
|
486
|
+
level: u = "default"
|
|
487
|
+
} = {}) {
|
|
488
|
+
const p = typeof t == "string" ? new RegExp(`\\s*${t.toLowerCase()}`) : t, w = `Use of ${e ? `${e} with option ` : ""}${o} is not permitted without enabling ${n}`;
|
|
489
|
+
return function(c, d) {
|
|
490
|
+
if (!(e && c !== e) && !(a && c === a) && !(s && !d.isGlobal) && !(r && d.value === void 0) && p.test(d.name))
|
|
393
491
|
return {
|
|
394
|
-
category:
|
|
395
|
-
|
|
492
|
+
category: n,
|
|
493
|
+
level: u,
|
|
494
|
+
message: w
|
|
396
495
|
};
|
|
397
496
|
};
|
|
398
497
|
}
|
|
399
|
-
const
|
|
400
|
-
|
|
498
|
+
const y = { globalOnly: !0, withValue: !0 }, de = [
|
|
499
|
+
m(null, /--(upload|receive)-pack/, "allowUnsafePack", {
|
|
401
500
|
name: "--upload-pack or --receive-pack"
|
|
402
501
|
}),
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
502
|
+
m("clone", /^-\w*u/, "allowUnsafePack"),
|
|
503
|
+
m("clone", "--u", "allowUnsafePack"),
|
|
504
|
+
// `--exec` names the program run on the remote end of `push`, `send-pack`, `fetch-pack`, `archive` and
|
|
505
|
+
// (undocumented) `ls-remote`, `rebase` uses it for a command run after each commit
|
|
506
|
+
m(null, /^--exec$/, "allowUnsafePack", {
|
|
507
|
+
name: "--exec",
|
|
508
|
+
exceptTask: "rebase"
|
|
509
|
+
}),
|
|
406
510
|
// `git` accepts unambiguous abbreviations of long options, so `--ex` and `--exe` are `--exec`
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
511
|
+
m("rebase", /^(-x|--ex(ec?)?)$/, "allowUnsafeExec", { name: "-x or --exec" }),
|
|
512
|
+
// `git filter-branch` runs the value of each of these through `eval`
|
|
513
|
+
m(
|
|
514
|
+
"filter-branch",
|
|
515
|
+
/^--(setup|(env|tree|index|parent|msg|commit|tag-name)-filter)$/,
|
|
516
|
+
"allowUnsafeExec",
|
|
517
|
+
{ name: "--setup or --<type>-filter" }
|
|
518
|
+
),
|
|
519
|
+
// `git send-email` runs the value of each of these as a shell command. It reads its options with Perl's
|
|
520
|
+
// Getopt::Long, which accepts unambiguous abbreviations (`--to-cm`, `--sendm`) and a single leading dash.
|
|
521
|
+
m("send-email", /^--?(to-cm|cc-cm|hea|sendm)[a-z-]*(=|$)/, "allowUnsafeExec", {
|
|
522
|
+
name: "--to-cmd, --cc-cmd, --header-cmd or --sendmail-cmd"
|
|
523
|
+
}),
|
|
524
|
+
// `git difftool` runs the value of `-x` / `--extcmd` as the diff command. It passes options it doesn't
|
|
525
|
+
// know on to `git diff`, so an abbreviation such as `--extc` is never read as `--extcmd`, and in a short
|
|
526
|
+
// cluster `x` is only `-x` when it follows difftool's own switches (`-d`, `-g`, `-h`, `-y`): in `-tlinux`
|
|
527
|
+
// it is part of the tool name, and a cluster such as `-px` is handed to `git diff` as a whole.
|
|
528
|
+
m("difftool", /^(-[dghy]*x|--extcmd$)/, "allowUnsafeExec", {
|
|
529
|
+
name: "-x or --extcmd"
|
|
530
|
+
}),
|
|
531
|
+
// `git grep` configures a pager with `-O<cmd>` (potentially clustered as `-iO<cmd>`), or through the long-form
|
|
532
|
+
// `--open-files-in-pager`. Without a value both use the configured pager, so are permitted.
|
|
533
|
+
m("grep", /^-\w*O./, "allowUnsafePager", { name: "-O" }),
|
|
534
|
+
m("grep", "--open-files-in-pager", "allowUnsafePager", { withValue: !0 }),
|
|
535
|
+
// options that write their output to a path named in the command, enforced with the recommended checks:
|
|
536
|
+
// `--output=<file>` is a diff option (`diff`, `log`, `show`, `format-patch`, ...) and an `archive` option,
|
|
537
|
+
// `format-patch -o <dir>` / `--output-directory` and `archive -o <file>` are their short / directory forms.
|
|
538
|
+
// `--output-indicator-*` are unrelated diff options and remain permitted.
|
|
539
|
+
m(null, /^--output$/, "allowUnsafeOutputPath", {
|
|
540
|
+
name: "--output",
|
|
541
|
+
level: "recommended"
|
|
542
|
+
}),
|
|
543
|
+
m("format-patch", /^(-\w*o|--output-directory$)/, "allowUnsafeOutputPath", {
|
|
544
|
+
name: "-o or --output-directory",
|
|
545
|
+
level: "recommended"
|
|
546
|
+
}),
|
|
547
|
+
m("archive", /^-\w*o/, "allowUnsafeOutputPath", {
|
|
548
|
+
name: "-o",
|
|
549
|
+
level: "recommended"
|
|
550
|
+
}),
|
|
551
|
+
m(null, "--template", "allowUnsafeTemplateDir"),
|
|
552
|
+
m(null, "--exec-path", "allowUnsafeExec", y),
|
|
410
553
|
// `git` reads the configuration of whichever repository these name, so the
|
|
411
554
|
// directory alone is enough to deliver config the argv guards never see
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
555
|
+
m(null, "--git-dir", "allowUnsafeConfigPaths", y),
|
|
556
|
+
m(null, "--work-tree", "allowUnsafeConfigPaths", y),
|
|
557
|
+
m(null, /^-C$/, "allowUnsafeConfigPaths", { ...y, name: "-C" })
|
|
415
558
|
];
|
|
416
|
-
function
|
|
417
|
-
return [...
|
|
559
|
+
function R(e, t, n) {
|
|
560
|
+
return [...ue(e, t), ...ae(n)];
|
|
418
561
|
}
|
|
419
|
-
function
|
|
420
|
-
const { flags:
|
|
562
|
+
function Ae(...e) {
|
|
563
|
+
const { flags: t, taskIndex: n } = te(e), o = n < e.length ? String(e[n]).toLowerCase() : null, a = o !== null ? e.slice(n + 1) : [], { positionals: s, pathspecs: r } = ne(a, o, t), u = Y(o, t, s);
|
|
421
564
|
return {
|
|
422
565
|
task: o,
|
|
423
|
-
flags:
|
|
566
|
+
flags: t.map(ge),
|
|
424
567
|
paths: r,
|
|
425
|
-
config:
|
|
426
|
-
vulnerabilities:
|
|
568
|
+
config: u,
|
|
569
|
+
vulnerabilities: me(R(o, t, u))
|
|
427
570
|
};
|
|
428
571
|
}
|
|
429
|
-
function
|
|
572
|
+
function me(e) {
|
|
430
573
|
return Object.defineProperty(e, "vulnerabilities", {
|
|
431
574
|
value: e
|
|
432
575
|
});
|
|
433
576
|
}
|
|
434
|
-
function
|
|
435
|
-
return e !== void 0 ? { name:
|
|
577
|
+
function ge({ value: e, name: t }) {
|
|
578
|
+
return e !== void 0 ? { name: t, value: e } : { name: t };
|
|
436
579
|
}
|
|
437
|
-
const
|
|
580
|
+
const pe = Object.freeze([
|
|
581
|
+
// identity
|
|
582
|
+
"user.name",
|
|
583
|
+
"user.email",
|
|
584
|
+
"user.useconfigonly",
|
|
585
|
+
"author.name",
|
|
586
|
+
"author.email",
|
|
587
|
+
"committer.name",
|
|
588
|
+
"committer.email",
|
|
589
|
+
// line endings, file system and display behaviour
|
|
590
|
+
"core.abbrev",
|
|
591
|
+
"core.autocrlf",
|
|
592
|
+
"core.bigfilethreshold",
|
|
593
|
+
"core.commentchar",
|
|
594
|
+
"core.commentstring",
|
|
595
|
+
"core.compression",
|
|
596
|
+
"core.eol",
|
|
597
|
+
"core.filemode",
|
|
598
|
+
"core.ignorecase",
|
|
599
|
+
"core.logallrefupdates",
|
|
600
|
+
"core.longpaths",
|
|
601
|
+
"core.precomposeunicode",
|
|
602
|
+
"core.preloadindex",
|
|
603
|
+
"core.quotepath",
|
|
604
|
+
"core.safecrlf",
|
|
605
|
+
"core.untrackedcache",
|
|
606
|
+
"core.whitespace",
|
|
607
|
+
"advice.*",
|
|
608
|
+
"color.*",
|
|
609
|
+
"column.ui",
|
|
610
|
+
"i18n.commitencoding",
|
|
611
|
+
"i18n.logoutputencoding",
|
|
612
|
+
"init.defaultbranch",
|
|
613
|
+
// branch / merge / rebase / pull / push defaults
|
|
614
|
+
"branch.autosetupmerge",
|
|
615
|
+
"branch.autosetuprebase",
|
|
616
|
+
"branch.sort",
|
|
617
|
+
"checkout.defaultremote",
|
|
618
|
+
"clone.defaultremotename",
|
|
619
|
+
"fetch.prune",
|
|
620
|
+
"fetch.prunetags",
|
|
621
|
+
"merge.conflictstyle",
|
|
622
|
+
"merge.ff",
|
|
623
|
+
"merge.renamelimit",
|
|
624
|
+
"pull.ff",
|
|
625
|
+
"pull.rebase",
|
|
626
|
+
"push.autosetupremote",
|
|
627
|
+
"push.default",
|
|
628
|
+
"push.followtags",
|
|
629
|
+
"rebase.autosquash",
|
|
630
|
+
"rebase.autostash",
|
|
631
|
+
"rerere.enabled",
|
|
632
|
+
"tag.sort",
|
|
633
|
+
"versionsort.suffix",
|
|
634
|
+
// output formatting of diff / log / status / grep
|
|
635
|
+
"diff.algorithm",
|
|
636
|
+
"diff.colormoved",
|
|
637
|
+
"diff.context",
|
|
638
|
+
"diff.interhunkcontext",
|
|
639
|
+
"diff.mnemonicprefix",
|
|
640
|
+
"diff.noprefix",
|
|
641
|
+
"diff.relative",
|
|
642
|
+
"diff.renamelimit",
|
|
643
|
+
"diff.renames",
|
|
644
|
+
"grep.extendedregexp",
|
|
645
|
+
"grep.linenumber",
|
|
646
|
+
"grep.patterntype",
|
|
647
|
+
"log.abbrevcommit",
|
|
648
|
+
"log.date",
|
|
649
|
+
"log.decorate",
|
|
650
|
+
"log.follow",
|
|
651
|
+
"status.branch",
|
|
652
|
+
"status.renames",
|
|
653
|
+
"status.short",
|
|
654
|
+
"status.showuntrackedfiles",
|
|
655
|
+
// performance and transfer tuning
|
|
656
|
+
"feature.manyfiles",
|
|
657
|
+
"gc.auto",
|
|
658
|
+
"gc.autodetach",
|
|
659
|
+
"http.lowspeedlimit",
|
|
660
|
+
"http.lowspeedtime",
|
|
661
|
+
"http.postbuffer",
|
|
662
|
+
"http.version",
|
|
663
|
+
"index.version",
|
|
664
|
+
"pack.threads",
|
|
665
|
+
"pack.windowmemory",
|
|
666
|
+
"protocol.version",
|
|
667
|
+
// extra request headers, commonly used for CI authentication tokens
|
|
668
|
+
"http.extraheader",
|
|
669
|
+
"http.*.extraheader",
|
|
670
|
+
// integrity checks - these only ever make git stricter
|
|
671
|
+
"fetch.fsckobjects",
|
|
672
|
+
"receive.fsckobjects",
|
|
673
|
+
"transfer.fsckobjects"
|
|
674
|
+
]);
|
|
675
|
+
function he(e) {
|
|
676
|
+
const t = /* @__PURE__ */ new Set(), n = [];
|
|
677
|
+
for (const o of e) {
|
|
678
|
+
const a = String(o).trim().toLowerCase();
|
|
679
|
+
a && (a.includes("*") ? n.push(
|
|
680
|
+
new RegExp(
|
|
681
|
+
`^${a.split("*").map((s) => s.replace(/[.+?^${}()|[\]\\]/g, "\\$&")).join(".*")}$`
|
|
682
|
+
)
|
|
683
|
+
) : t.add(a));
|
|
684
|
+
}
|
|
685
|
+
return (o) => {
|
|
686
|
+
const a = o.trim().toLowerCase();
|
|
687
|
+
return t.has(a) || n.some((s) => s.test(a));
|
|
688
|
+
};
|
|
689
|
+
}
|
|
690
|
+
const Fe = he(pe), M = {
|
|
438
691
|
editor: "allowUnsafeEditor",
|
|
439
692
|
git_askpass: "allowUnsafeAskPass",
|
|
440
693
|
git_config_global: "allowUnsafeConfigPaths",
|
|
@@ -455,55 +708,220 @@ const y = {
|
|
|
455
708
|
prefix: "allowUnsafeConfigPaths",
|
|
456
709
|
ssh_askpass: "allowUnsafeAskPass",
|
|
457
710
|
visual: "allowUnsafeEditor"
|
|
711
|
+
}, G = {
|
|
712
|
+
home: "allowUnsafeConfigPaths",
|
|
713
|
+
xdg_config_home: "allowUnsafeConfigPaths"
|
|
458
714
|
};
|
|
459
|
-
function
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
715
|
+
function N(e) {
|
|
716
|
+
return Object.hasOwn(G, e);
|
|
717
|
+
}
|
|
718
|
+
function* we(e) {
|
|
719
|
+
const t = parseInt(e.git_config_count ?? "0", 10);
|
|
720
|
+
for (let n = 0; n < t; n++) {
|
|
721
|
+
const o = e[`git_config_key_${n}`], a = e[`git_config_value_${n}`];
|
|
463
722
|
o !== void 0 && (yield { key: o.toLowerCase().trim(), value: a, scope: "env" });
|
|
464
723
|
}
|
|
465
724
|
}
|
|
466
|
-
function*
|
|
725
|
+
function* ve(e, t) {
|
|
467
726
|
for (const n of Object.keys(e))
|
|
468
|
-
if (
|
|
469
|
-
const
|
|
727
|
+
if (N(n) && e[n] !== t[n]) {
|
|
728
|
+
const o = G[n];
|
|
470
729
|
yield {
|
|
471
|
-
category:
|
|
472
|
-
|
|
730
|
+
category: o,
|
|
731
|
+
level: "recommended",
|
|
732
|
+
message: `Use of "${n.toUpperCase()}" with a value other than the inherited one is not permitted without enabling ${o}`,
|
|
733
|
+
envKey: n
|
|
734
|
+
};
|
|
735
|
+
}
|
|
736
|
+
}
|
|
737
|
+
function* be(e) {
|
|
738
|
+
for (const t of Object.keys(e))
|
|
739
|
+
if (T(t)) {
|
|
740
|
+
const n = M[t];
|
|
741
|
+
yield {
|
|
742
|
+
category: n,
|
|
743
|
+
level: "default",
|
|
744
|
+
message: `Use of "${t.toUpperCase()}" is not permitted without enabling ${n}`,
|
|
745
|
+
envKey: t
|
|
473
746
|
};
|
|
474
747
|
}
|
|
475
748
|
}
|
|
476
|
-
function
|
|
477
|
-
return Object.hasOwn(
|
|
749
|
+
function T(e) {
|
|
750
|
+
return Object.hasOwn(M, e);
|
|
751
|
+
}
|
|
752
|
+
function Ue(e) {
|
|
753
|
+
const t = String(e).toLowerCase().trim();
|
|
754
|
+
return t.startsWith("git_") || T(t);
|
|
478
755
|
}
|
|
479
|
-
function
|
|
480
|
-
const
|
|
481
|
-
for (const [
|
|
482
|
-
const a =
|
|
483
|
-
(
|
|
756
|
+
function $(e) {
|
|
757
|
+
const t = {};
|
|
758
|
+
for (const [n, o] of Object.entries(e)) {
|
|
759
|
+
const a = n.toLowerCase().trim();
|
|
760
|
+
(Ue(a) || N(a)) && (t[a] = String(o));
|
|
484
761
|
}
|
|
485
|
-
return
|
|
762
|
+
return t;
|
|
486
763
|
}
|
|
487
|
-
function
|
|
488
|
-
const n =
|
|
764
|
+
function Le(e, t = {}) {
|
|
765
|
+
const n = $(e), o = {
|
|
489
766
|
read: [],
|
|
490
|
-
write: [...
|
|
491
|
-
},
|
|
492
|
-
...
|
|
493
|
-
...
|
|
767
|
+
write: [...we(n)]
|
|
768
|
+
}, a = [
|
|
769
|
+
...be(n),
|
|
770
|
+
...ve(n, $(t)),
|
|
771
|
+
...R(null, [], o)
|
|
494
772
|
];
|
|
495
773
|
return {
|
|
496
|
-
config:
|
|
497
|
-
vulnerabilities:
|
|
774
|
+
config: o,
|
|
775
|
+
vulnerabilities: a
|
|
776
|
+
};
|
|
777
|
+
}
|
|
778
|
+
class E {
|
|
779
|
+
constructor(t, n) {
|
|
780
|
+
this.value = t, this.validate = n;
|
|
781
|
+
}
|
|
782
|
+
}
|
|
783
|
+
function Re(e) {
|
|
784
|
+
return new E(String(e), (t) => {
|
|
785
|
+
if (!t || t === "@" || t.includes("..") || t.includes("@{") || t.includes("//") || /[\s~^:?*[\\]/.test(t) || t.endsWith("/") || t.endsWith(".") || t.split("/").some((n) => n.startsWith(".") || n.endsWith(".lock")))
|
|
786
|
+
return "not a valid ref name";
|
|
787
|
+
});
|
|
788
|
+
}
|
|
789
|
+
const ye = [
|
|
790
|
+
"https",
|
|
791
|
+
"http",
|
|
792
|
+
"ssh",
|
|
793
|
+
"git+ssh",
|
|
794
|
+
"ssh+git",
|
|
795
|
+
"git",
|
|
796
|
+
"file",
|
|
797
|
+
"scp",
|
|
798
|
+
"local"
|
|
799
|
+
], xe = new Set(ye), Ce = /^([a-z][a-z0-9+.-]*):\/\//i, Se = /^(?:([^@/]+)@)?([^/:]+):(?!\/\/)/;
|
|
800
|
+
function Me(e, { protocols: t } = {}) {
|
|
801
|
+
const n = t ? new Set(t) : xe;
|
|
802
|
+
return new E(String(e), (o) => {
|
|
803
|
+
const a = Ce.exec(o)?.[1]?.toLowerCase();
|
|
804
|
+
if (a !== void 0) {
|
|
805
|
+
if (!n.has(a))
|
|
806
|
+
return `protocol "${a}" is not permitted`;
|
|
807
|
+
let r;
|
|
808
|
+
try {
|
|
809
|
+
r = new URL(o);
|
|
810
|
+
} catch {
|
|
811
|
+
return "not a valid url";
|
|
812
|
+
}
|
|
813
|
+
return r.hostname.startsWith("-") || decodeURIComponent(r.username).startsWith("-") ? 'host and user names must not start with "-"' : void 0;
|
|
814
|
+
}
|
|
815
|
+
const s = Se.exec(o);
|
|
816
|
+
return s && !/^[a-z]:[\\/]/i.test(o) ? n.has("scp") ? s[1]?.startsWith("-") || s[2].startsWith("-") ? 'host and user names must not start with "-"' : void 0 : "scp-like urls are not permitted" : n.has("local") ? void 0 : "local paths are not permitted";
|
|
817
|
+
});
|
|
818
|
+
}
|
|
819
|
+
class Ee extends Error {
|
|
820
|
+
}
|
|
821
|
+
const ke = /[\u0000-\u001f\u007f]/, _e = /^[a-z][a-z0-9+.-]*::/i, P = /* @__PURE__ */ new Set(["-c", "--config", "--config-env"]), O = /* @__PURE__ */ new Set([
|
|
822
|
+
...[...S.short].filter(([, e]) => e).map(([e]) => `-${e}`),
|
|
823
|
+
...[...S.long].map((e) => `--${e}`)
|
|
824
|
+
]);
|
|
825
|
+
function g(e) {
|
|
826
|
+
throw new Ee(e);
|
|
827
|
+
}
|
|
828
|
+
function $e(e) {
|
|
829
|
+
return Array.isArray(e) && Array.isArray(e.raw) && Object.isFrozen(e);
|
|
830
|
+
}
|
|
831
|
+
function U(e) {
|
|
832
|
+
return JSON.stringify(String(e));
|
|
833
|
+
}
|
|
834
|
+
function A(e) {
|
|
835
|
+
let t;
|
|
836
|
+
if (e instanceof E) {
|
|
837
|
+
t = e.value;
|
|
838
|
+
const n = e.validate(t);
|
|
839
|
+
n && g(`interpolated value ${U(t)} is rejected: ${n}`);
|
|
840
|
+
} else typeof e == "string" ? t = e : typeof e == "number" && Number.isFinite(e) ? t = String(e) : g(
|
|
841
|
+
`interpolated values must be strings, finite numbers or arrays of them, received ${typeof e}`
|
|
842
|
+
);
|
|
843
|
+
return ke.test(t) && g(`interpolated value ${U(t)} contains control characters`), _e.test(t) && g(`interpolated value ${U(t)} would select a git remote helper transport`), t;
|
|
844
|
+
}
|
|
845
|
+
function Pe(e, t) {
|
|
846
|
+
const n = [];
|
|
847
|
+
let o = [];
|
|
848
|
+
const a = () => {
|
|
849
|
+
o.length && (n.push(o), o = []);
|
|
498
850
|
};
|
|
851
|
+
return e.forEach((s, r) => {
|
|
852
|
+
for (const u of s.split(/(\s+)/))
|
|
853
|
+
/^\s+$/.test(u) ? a() : u && o.push({ text: u });
|
|
854
|
+
r < t.length && o.push({ text: "", value: t[r] });
|
|
855
|
+
}), a(), n;
|
|
499
856
|
}
|
|
500
|
-
function
|
|
501
|
-
|
|
857
|
+
function Ge(e, t) {
|
|
858
|
+
$e(e) || g("must be used as a tagged template literal");
|
|
859
|
+
const n = [];
|
|
860
|
+
let o, a = !1, s;
|
|
861
|
+
for (const r of Pe(e, t)) {
|
|
862
|
+
if (r.every((l) => !("value" in l))) {
|
|
863
|
+
const l = r.map((x) => x.text).join("");
|
|
864
|
+
n.push(l), s = l, a || (a = o !== void 0 && l === "--"), o === void 0 && !l.startsWith("-") && !O.has(n.at(-2) ?? "") && (o = l);
|
|
865
|
+
continue;
|
|
866
|
+
}
|
|
867
|
+
const p = !("value" in r[0]);
|
|
868
|
+
s !== void 0 && P.has(s) && !p && g(
|
|
869
|
+
'configuration keys must be written literally, use "-c some.key=${value}" rather than "-c ${value}"'
|
|
870
|
+
);
|
|
871
|
+
const h = p && (r[0].text.startsWith("-") || s !== void 0 && O.has(s));
|
|
872
|
+
if (o === void 0 && !h && g(
|
|
873
|
+
'the git sub-command must be written literally, interpolated values before it can only be used as option values, for example "-c user.name=${name}"'
|
|
874
|
+
), r.length === 1) {
|
|
875
|
+
const { value: l } = r[0];
|
|
876
|
+
if (b(l))
|
|
877
|
+
n.push(l);
|
|
878
|
+
else
|
|
879
|
+
for (const x of Array.isArray(l) ? l : [l]) {
|
|
880
|
+
const C = A(x);
|
|
881
|
+
C.startsWith("-") && !a && g(
|
|
882
|
+
`interpolated value ${U(C)} would be read as an option, values that may start with "-" must follow "--" or be wrapped with pathspec()`
|
|
883
|
+
), n.push(C);
|
|
884
|
+
}
|
|
885
|
+
s = void 0;
|
|
886
|
+
continue;
|
|
887
|
+
}
|
|
888
|
+
let c = "", d = -1;
|
|
889
|
+
for (const l of r)
|
|
890
|
+
"value" in l ? ((Array.isArray(l.value) || b(l.value)) && g("arrays and pathspecs must be interpolated as a standalone argument"), d < 0 && (d = c.length), c += A(l.value)) : c += l.text;
|
|
891
|
+
if (d === 0 && c.startsWith("-") && !a && g(`interpolated value ${U(c)} would be read as an option`), d > 0 && c.startsWith("-") && !a) {
|
|
892
|
+
const l = c.indexOf("=");
|
|
893
|
+
(l < 0 || l >= d) && g(
|
|
894
|
+
'interpolated values in options must follow "=", for example "--message=${value}"'
|
|
895
|
+
);
|
|
896
|
+
}
|
|
897
|
+
if (s !== void 0 && P.has(s)) {
|
|
898
|
+
const l = c.indexOf("=");
|
|
899
|
+
(l < 0 || l >= d) && g(
|
|
900
|
+
'configuration keys must be written literally, use "-c some.key=${value}" rather than "-c ${value}"'
|
|
901
|
+
);
|
|
902
|
+
}
|
|
903
|
+
const k = /^(?:--config(?:-env)?=|-c(?=.))/.exec(c)?.[0];
|
|
904
|
+
if (k && !a) {
|
|
905
|
+
const l = c.indexOf("=", k.length);
|
|
906
|
+
(l < 0 || l >= d) && g('configuration keys must be written literally, use "--config=some.key=${value}"');
|
|
907
|
+
}
|
|
908
|
+
n.push(c), s = void 0;
|
|
909
|
+
}
|
|
910
|
+
return o === void 0 && g("no git sub-command supplied"), n;
|
|
502
911
|
}
|
|
503
912
|
export {
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
913
|
+
Ee as GitTemplateError,
|
|
914
|
+
pe as SAFE_CONFIG_KEYS,
|
|
915
|
+
E as TemplateValue,
|
|
916
|
+
he as configKeyMatcher,
|
|
917
|
+
T as isGitEnvKey,
|
|
918
|
+
Ue as isGuardedEnvKey,
|
|
919
|
+
Fe as isSafeConfigKey,
|
|
920
|
+
$e as isTemplateStringsArray,
|
|
921
|
+
Ae as parseArgv,
|
|
922
|
+
Le as parseEnv,
|
|
923
|
+
Re as refName,
|
|
924
|
+
Me as remoteUrl,
|
|
925
|
+
Ge as templateArgv
|
|
508
926
|
};
|
|
509
927
|
//# sourceMappingURL=index.mjs.map
|