@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.
Files changed (33) hide show
  1. package/dist/index.cjs +1 -1
  2. package/dist/index.cjs.map +1 -1
  3. package/dist/index.d.ts +7 -3
  4. package/dist/index.d.ts.map +1 -1
  5. package/dist/index.mjs +631 -213
  6. package/dist/index.mjs.map +1 -1
  7. package/dist/src/args/parse-argv.types.d.ts +6 -0
  8. package/dist/src/args/parse-argv.types.d.ts.map +1 -1
  9. package/dist/src/config/config-allow-list.d.ts +28 -0
  10. package/dist/src/config/config-allow-list.d.ts.map +1 -0
  11. package/dist/src/config/config.types.d.ts +1 -0
  12. package/dist/src/config/config.types.d.ts.map +1 -1
  13. package/dist/src/config/detect-config-action.d.ts +3 -1
  14. package/dist/src/config/detect-config-action.d.ts.map +1 -1
  15. package/dist/src/env/parse-env.d.ts +13 -1
  16. package/dist/src/env/parse-env.d.ts.map +1 -1
  17. package/dist/src/flags/parse-task-flags.d.ts.map +1 -1
  18. package/dist/src/template/ref-name.d.ts +11 -0
  19. package/dist/src/template/ref-name.d.ts.map +1 -0
  20. package/dist/src/template/remote-url.d.ts +27 -0
  21. package/dist/src/template/remote-url.d.ts.map +1 -0
  22. package/dist/src/template/template-argv.d.ts +25 -0
  23. package/dist/src/template/template-argv.d.ts.map +1 -0
  24. package/dist/src/template/template-values.d.ts +11 -0
  25. package/dist/src/template/template-values.d.ts.map +1 -0
  26. package/dist/src/tokens/flag-specs.d.ts.map +1 -1
  27. package/dist/src/vulnerabilities/detect-vulnerable-config-writes.d.ts.map +1 -1
  28. package/dist/src/vulnerabilities/detect-vulnerable-flags.d.ts.map +1 -1
  29. package/dist/src/vulnerabilities/vulnerability.types.d.ts +120 -2
  30. package/dist/src/vulnerabilities/vulnerability.types.d.ts.map +1 -1
  31. package/package.json +1 -1
  32. package/dist/src/vulnerabilities/vulnerability-check.d.ts +0 -6
  33. package/dist/src/vulnerabilities/vulnerability-check.d.ts.map +0 -1
@@ -1,20 +1,50 @@
1
1
  export type VulnerabilityCategory = keyof VulnerabilityCategoryFlags;
2
+ /**
3
+ * - `default` vulnerabilities are explicitly identified risks, blocked unless permitted.
4
+ * - `recommended` vulnerabilities are caught by broader catch-all rules (for example any configuration key
5
+ * ending in `.cmd` or `command`), blocked only when the consumer has opted in to the recommended checks.
6
+ */
7
+ export type VulnerabilityLevel = 'default' | 'recommended';
2
8
  export interface Vulnerability {
3
9
  category: VulnerabilityCategory;
4
10
  message: string;
11
+ /**
12
+ * Whether this vulnerability was explicitly identified (`default`) or caught by a broader
13
+ * catch-all rule (`recommended`).
14
+ */
15
+ level: VulnerabilityLevel;
16
+ /**
17
+ * Lower-cased configuration key that triggered this vulnerability, when it was found
18
+ * in a configuration write (`-c`, `--config-env`, `git config ...` or `GIT_CONFIG_KEY_<n>`).
19
+ */
20
+ configKey?: string;
21
+ /**
22
+ * Lower-cased environment variable name that triggered this vulnerability, when it was
23
+ * found in the environment supplied to the child process.
24
+ */
25
+ envKey?: string;
5
26
  }
6
27
  export interface VulnerabilityCategoryFlags {
7
28
  /**
8
29
  * Use of the `alias.*` configuration settings in simple-git tasks
30
+ *
31
+ * @deprecated name the specific keys instead, for example `allowConfig: ['alias.*']`
9
32
  */
10
33
  allowUnsafeAlias: boolean;
11
34
  /**
12
35
  * Use of the `core.askPass` configuration setting and environment variables in simple-git tasks
36
+ *
37
+ * @deprecated name the specific keys instead, for example `allowConfig: ['core.askPass']` and / or `allowEnvironment: ['GIT_ASKPASS', 'SSH_ASKPASS']`
13
38
  */
14
39
  allowUnsafeAskPass: boolean;
15
40
  /**
16
41
  * Allows using overriding the internally configured Git command binaries - for example the `tar` command
17
42
  * can be replaced by configuring `tar.command=/other/tar`.
43
+ *
44
+ * Also covers the catch-all rule for any other configuration key ending in `.cmd` or `command`, reported
45
+ * with the `recommended` level.
46
+ *
47
+ * @deprecated name the specific keys instead, for example `allowConfig: ['tar.*.command', 'trailer.*.cmd', 'trailer.*.command']`
18
48
  */
19
49
  allowUnsafeCommandBinaries: boolean;
20
50
  /**
@@ -27,20 +57,36 @@ export interface VulnerabilityCategoryFlags {
27
57
  * may require other unsafe flags to be enabled for use.
28
58
  */
29
59
  allowUnsafeConfigEnvCount: boolean;
60
+ /**
61
+ * Allows renaming a whole configuration section with `git config --rename-section <old> <new>` or
62
+ * `git config rename-section <old> <new>`. The keys in the section were written before the rename,
63
+ * so their values can't be checked: renaming a section of harmless looking keys (eg: `foo.fsmonitor`)
64
+ * to `core` would set `core.fsmonitor` without it ever being written directly.
65
+ */
66
+ allowUnsafeConfigRename: boolean;
30
67
  /**
31
68
  * Allows setting credential helper in simple-git tasks
69
+ *
70
+ * @deprecated name the specific keys instead, for example `allowConfig: ['credential.helper', 'credential.*.helper']`
32
71
  */
33
72
  allowUnsafeCredentialHelper: boolean;
34
73
  /**
35
74
  * Allows setting path to the text editor utility in simple-git tasks
75
+ *
76
+ * @deprecated name the specific keys instead, for example `allowConfig: ['core.editor', 'sequence.editor']` and / or `allowEnvironment: ['GIT_EDITOR', 'VISUAL', 'EDITOR', 'GIT_SEQUENCE_EDITOR']`
36
77
  */
37
78
  allowUnsafeEditor: boolean;
38
79
  /**
39
80
  * Allows use of setting paths for merge tools in simple-git tasks
81
+ *
82
+ * @deprecated name the specific keys instead, for example `allowConfig: ['merge.*.driver', 'mergetool.*.path', 'mergetool.*.cmd']`
40
83
  */
41
84
  allowUnsafeMergeDriver: boolean;
42
85
  /**
43
- * Allows setting path to the pager utility in simple-git tasks
86
+ * Allows setting path to the pager utility in simple-git tasks, and the `interactive.diffFilter`
87
+ * command that the diff shown by `git add -p` (and other `--patch` commands) is piped through
88
+ *
89
+ * @deprecated name the specific keys instead, for example `allowConfig: ['core.pager', 'pager.*', 'interactive.diffFilter']` and / or `allowEnvironment: ['GIT_PAGER', 'PAGER']`
44
90
  */
45
91
  allowUnsafePager: boolean;
46
92
  /**
@@ -52,6 +98,8 @@ export interface VulnerabilityCategoryFlags {
52
98
  *
53
99
  * Enable this override to use the `ext::` protocol (see examples on
54
100
  * [git-scm.com](https://git-scm.com/docs/git-remote-ext#_examples)).
101
+ *
102
+ * @deprecated name the specific keys instead, for example `allowConfig: ['protocol.*.allow']`
55
103
  */
56
104
  allowUnsafeProtocolOverride: boolean;
57
105
  /**
@@ -65,48 +113,112 @@ export interface VulnerabilityCategoryFlags {
65
113
  /**
66
114
  * Using a `-c` switch to enable custom SSH commands opens up a potential
67
115
  * attack vector for running arbitrary commands.
116
+ *
117
+ * @deprecated name the specific keys instead, for example `allowConfig: ['core.sshCommand']` and / or `allowEnvironment: ['GIT_SSH_COMMAND', 'GIT_SSH']`
68
118
  */
69
119
  allowUnsafeSshCommand: boolean;
70
120
  /**
71
121
  * Using a `-c` switch to enable custom proxy command for the `git://` transport
72
122
  * exposes and attack vector for running arbitrary commands.
123
+ *
124
+ * @deprecated name the specific keys instead, for example `allowConfig: ['core.gitProxy']` and / or `allowEnvironment: ['GIT_PROXY_COMMAND']`
73
125
  */
74
126
  allowUnsafeGitProxy: boolean;
75
127
  /**
76
128
  * Use of the `--exec-path` and similar options can override the binaries executed during
77
- * `git` operations.
129
+ * `git` operations. Also covers options and configuration that run their value as a shell
130
+ * command: `rebase --exec`, the `filter-branch` filters, `send-email --to-cmd` (and `--cc-cmd`,
131
+ * `--header-cmd`, `--sendmail-cmd`), `difftool --extcmd` and `gc.recentObjectsHook`.
78
132
  */
79
133
  allowUnsafeExec: boolean;
134
+ /**
135
+ * Allows options that write their output to a path named in the command: `--output=<file>` on
136
+ * `diff`-family commands, `format-patch` and `archive`, `format-patch -o` / `--output-directory`
137
+ * and `archive -o`. Only enforced with the recommended checks (`unsafe.recommended` or `strict`).
138
+ */
139
+ allowUnsafeOutputPath: boolean;
80
140
  /**
81
141
  * Using a `-c` switch to enable custom hooks path commands to be run automatically
82
142
  * exposes and attack vector for running arbitrary commands.
143
+ *
144
+ * @deprecated name the specific keys instead, for example `allowConfig: ['core.hooksPath']`
83
145
  */
84
146
  allowUnsafeHooksPath: boolean;
85
147
  /**
86
148
  * Using a `-c` switch to enable setting binary for processing diffs
87
149
  * exposes and attack vector for running arbitrary commands.
150
+ *
151
+ * @deprecated name the specific keys instead, for example `allowConfig: ['diff.external', 'diff.*.command', 'difftool.*.cmd', 'difftool.*.path']` and / or `allowEnvironment: ['GIT_EXTERNAL_DIFF']`
88
152
  */
89
153
  allowUnsafeDiffExternal: boolean;
90
154
  /**
91
155
  * Using a `-c` switch to enable setting binary for retrieving text content of a file
156
+ *
157
+ * @deprecated name the specific keys instead, for example `allowConfig: ['diff.*.textconv']`
92
158
  */
93
159
  allowUnsafeDiffTextConv: boolean;
94
160
  /**
95
161
  * Using a `-c` switch to enable setting binary for `smudge` and `clean` operations
96
162
  * which can add and remove content to a file during checkout and commit.
163
+ *
164
+ * @deprecated name the specific keys instead, for example `allowConfig: ['filter.*']`
97
165
  */
98
166
  allowUnsafeFilter: boolean;
99
167
  /**
100
168
  * Using a `-c` switch to enable setting the binary to which `git` will delegate
101
169
  * file content change detection.
170
+ *
171
+ * @deprecated name the specific keys instead, for example `allowConfig: ['core.fsmonitor']`
102
172
  */
103
173
  allowUnsafeFsMonitor: boolean;
104
174
  /**
105
175
  * Using a `-c` switch to configure the GPG signing program (`gpg.program`) or a
106
176
  * per-format variant (`gpg.ssh.program`, `gpg.x509.program`). Controlling the signing
107
177
  * binary allows an attacker to run arbitrary code whenever a commit or tag is signed.
178
+ *
179
+ * @deprecated name the specific keys instead, for example `allowConfig: ['gpg.program', 'gpg.*.program']`
108
180
  */
109
181
  allowUnsafeGpgProgram: boolean;
182
+ /**
183
+ * Allows setting the keys that decide which signatures are trusted when verifying commits and tags:
184
+ * `gpg.ssh.allowedSignersFile` (the keys trusted to sign), `gpg.ssh.revocationFile` (the keys that
185
+ * have been revoked) and `gpg.minTrustLevel` (the trust an OpenPGP key needs). Controlling these
186
+ * allows forged or revoked signatures to pass verification.
187
+ *
188
+ * @deprecated name the specific keys instead, for example `allowConfig: ['gpg.ssh.allowedSignersFile']`
189
+ */
190
+ allowUnsafeSignatureTrust: boolean;
191
+ /**
192
+ * Allows setting the `sendemail.*` (or per-identity `sendemail.<identity>.*`) keys that `git send-email`
193
+ * runs as commands (`sendmailCmd`, `toCmd`, `ccCmd`, `headerCmd`, an absolute path in `smtpServer` and
194
+ * the `smtpServerOption` arguments passed to it), uses to read files (`smtpSSLClientCert`,
195
+ * `smtpSSLClientKey`, `aliasesFile`, `mailmap.file`) or that turn off certificate verification
196
+ * (`smtpSSLCertPath`).
197
+ *
198
+ * Also covers the `imap.*` keys used by `git imap-send` (which `git send-email` can hand patches to)
199
+ * that run a command (`imap.tunnel`), choose the server patches and credentials are sent to
200
+ * (`imap.host`) or turn off certificate verification (`imap.sslVerify`).
201
+ *
202
+ * @deprecated name the specific keys instead, for example `allowConfig: ['sendemail.smtpServer', 'sendemail.*.toCmd']`
203
+ */
204
+ allowUnsafeSendEmailConfig: boolean;
205
+ /**
206
+ * Allows setting the `instaweb.*` keys that `git instaweb` uses to choose the web server it starts
207
+ * (`instaweb.httpd`) and the directories it loads server modules (`instaweb.modulePath`) or the gitweb
208
+ * CGI script (`instaweb.gitwebDir`) from.
209
+ *
210
+ * @deprecated name the specific keys instead, for example `allowConfig: ['instaweb.httpd']`
211
+ */
212
+ allowUnsafeWebServerConfig: boolean;
213
+ /**
214
+ * Allows setting the `browser.<tool>.path` / `browser.<tool>.cmd` keys used to open a web browser
215
+ * (`git help --web`, `git instaweb`) and the `man.<tool>.path` / `man.<tool>.cmd` keys used to open a
216
+ * man page viewer (`git help --man`). Each either replaces the program run for a known tool name, or
217
+ * sets the shell command run for a custom tool name.
218
+ *
219
+ * @deprecated name the specific keys instead, for example `allowConfig: ['browser.firefox.path', 'man.*.cmd']`
220
+ */
221
+ allowUnsafeBrowser: boolean;
110
222
  /**
111
223
  * Allows overriding template directory either by environment variable or configuration in simple-git tasks
112
224
  */
@@ -115,18 +227,24 @@ export interface VulnerabilityCategoryFlags {
115
227
  * Allows using `include.path` to load an external git configuration file in simple-git tasks.
116
228
  * An attacker-controlled path could direct git to load a malicious configuration, overriding any
117
229
  * setting — including those that enable further command-execution vectors.
230
+ *
231
+ * @deprecated name the specific keys instead, for example `allowConfig: ['include.path', 'includeIf.*.path']`
118
232
  */
119
233
  allowUnsafeInclude: boolean;
120
234
  /**
121
235
  * Allows setting `submodule.<name>.update` in simple-git tasks. When the update strategy begins
122
236
  * with `!`, git executes the remainder as a shell command on every `git submodule update`
123
237
  * invocation, providing an arbitrary code-execution path.
238
+ *
239
+ * @deprecated name the specific keys instead, for example `allowConfig: ['submodule.*.update']`
124
240
  */
125
241
  allowUnsafeSubmodule: boolean;
126
242
  /**
127
243
  * Allows using `url.<base>.insteadOf` configuration in simple-git tasks. URL rewriting can
128
244
  * silently redirect git operations to attacker-controlled hosts, potentially intercepting
129
245
  * credentials or substituting malicious repository content.
246
+ *
247
+ * @deprecated name the specific keys instead, for example `allowConfig: ['url.*.insteadOf']`
130
248
  */
131
249
  allowUnsafeUrlRewrite: boolean;
132
250
  }
@@ -1 +1 @@
1
- {"version":3,"file":"vulnerability.types.d.ts","sourceRoot":"","sources":["../../../src/vulnerabilities/vulnerability.types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,qBAAqB,GAAG,MAAM,0BAA0B,CAAC;AAErE,MAAM,WAAW,aAAa;IAC3B,QAAQ,EAAE,qBAAqB,CAAC;IAChC,OAAO,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,0BAA0B;IACxC;;OAEG;IACH,gBAAgB,EAAE,OAAO,CAAC;IAE1B;;OAEG;IACH,kBAAkB,EAAE,OAAO,CAAC;IAE5B;;;OAGG;IACH,0BAA0B,EAAE,OAAO,CAAC;IAEpC;;OAEG;IACH,sBAAsB,EAAE,OAAO,CAAC;IAEhC;;;;OAIG;IACH,yBAAyB,EAAE,OAAO,CAAC;IAEnC;;OAEG;IACH,2BAA2B,EAAE,OAAO,CAAC;IAErC;;OAEG;IACH,iBAAiB,EAAE,OAAO,CAAC;IAE3B;;OAEG;IACH,sBAAsB,EAAE,OAAO,CAAC;IAEhC;;OAEG;IACH,gBAAgB,EAAE,OAAO,CAAC;IAE1B;;;;;;;;;OASG;IACH,2BAA2B,EAAE,OAAO,CAAC;IAErC;;;;;;OAMG;IACH,eAAe,EAAE,OAAO,CAAC;IAEzB;;;OAGG;IACH,qBAAqB,EAAE,OAAO,CAAC;IAE/B;;;OAGG;IACH,mBAAmB,EAAE,OAAO,CAAC;IAE7B;;;OAGG;IACH,eAAe,EAAE,OAAO,CAAC;IAEzB;;;OAGG;IACH,oBAAoB,EAAE,OAAO,CAAC;IAE9B;;;OAGG;IACH,uBAAuB,EAAE,OAAO,CAAC;IAEjC;;OAEG;IACH,uBAAuB,EAAE,OAAO,CAAC;IAEjC;;;OAGG;IACH,iBAAiB,EAAE,OAAO,CAAC;IAE3B;;;OAGG;IACH,oBAAoB,EAAE,OAAO,CAAC;IAE9B;;;;OAIG;IACH,qBAAqB,EAAE,OAAO,CAAC;IAE/B;;OAEG;IACH,sBAAsB,EAAE,OAAO,CAAC;IAEhC;;;;OAIG;IACH,kBAAkB,EAAE,OAAO,CAAC;IAE5B;;;;OAIG;IACH,oBAAoB,EAAE,OAAO,CAAC;IAE9B;;;;OAIG;IACH,qBAAqB,EAAE,OAAO,CAAC;CACjC"}
1
+ {"version":3,"file":"vulnerability.types.d.ts","sourceRoot":"","sources":["../../../src/vulnerabilities/vulnerability.types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,qBAAqB,GAAG,MAAM,0BAA0B,CAAC;AAErE;;;;GAIG;AACH,MAAM,MAAM,kBAAkB,GAAG,SAAS,GAAG,aAAa,CAAC;AAE3D,MAAM,WAAW,aAAa;IAC3B,QAAQ,EAAE,qBAAqB,CAAC;IAChC,OAAO,EAAE,MAAM,CAAC;IAEhB;;;OAGG;IACH,KAAK,EAAE,kBAAkB,CAAC;IAE1B;;;OAGG;IACH,SAAS,CAA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AEnC;;;;;;;;;;;;OAYG;IACH,0BAA0B,EAAE,OAAO,CAAC;IAEpC;;;;;;OAMG;IACH,0BAA0B,EAAE,OAAO,CAAC;IAEpC;;;;;;;OAOG;IACH,kBAAkB,EAAE,OAAO,CAAC;IAE5B;;OAEG;IACH,sBAAsB,EAAE,OAAO,CAAC;IAEhC;;;;;;OAMG;IACH,kBAAkB,EAAE,OAAO,CAAC;IAE5B;;;;;;OAMG;IACH,oBAAoB,EAAE,OAAO,CAAC;IAE9B;;;;;;OAMG;IACH,qBAAqB,EAAE,OAAO,CAAC;CACjC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@simple-git/argv-parser",
3
- "version": "2.0.1",
3
+ "version": "3.1.0",
4
4
  "main": "dist/index.cjs",
5
5
  "files": [
6
6
  "dist"
@@ -1,6 +0,0 @@
1
- /**
2
- * Retrieves just the vulnerabilities identified in the supplied varargs tokens
3
- * and environment variables.
4
- */
5
- export declare function vulnerabilityCheck(tokens: readonly string[], env: Record<string, unknown>): import("./vulnerability.types").Vulnerability[];
6
- //# sourceMappingURL=vulnerability-check.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"vulnerability-check.d.ts","sourceRoot":"","sources":["../../../src/vulnerabilities/vulnerability-check.ts"],"names":[],"mappings":"AAGA;;;GAGG;AACH,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,SAAS,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,mDAEzF"}