@@ -41203,26 +41203,6 @@ var init_git_response_error = __esm({
4120341203 }
4120441204});
4120541205
41206- // src/lib/args/pathspec.ts
41207- function pathspec(...paths) {
41208- const key = new String(paths);
41209- cache.set(key, paths);
41210- return key;
41211- }
41212- function isPathSpec(path) {
41213- return path instanceof String && cache.has(path);
41214- }
41215- function toPaths(pathSpec) {
41216- return cache.get(pathSpec) || [];
41217- }
41218- var cache;
41219- var init_pathspec = __esm({
41220- "src/lib/args/pathspec.ts"() {
41221- "use strict";
41222- cache = /* @__PURE__ */ new WeakMap();
41223- }
41224- });
41225-
4122641206// src/lib/errors/git-construct-error.ts
4122741207var GitConstructError;
4122841208var init_git_construct_error = __esm({
@@ -41367,7 +41347,7 @@ function prefixedArray(input, prefix) {
4136741347 return output;
4136841348}
4136941349function bufferToString(input) {
41370- return (Array.isArray(input) ? import_node_buffer. Buffer.concat(input) : input).toString("utf-8");
41350+ return (Array.isArray(input) ? Buffer.concat(input) : input).toString("utf-8");
4137141351}
4137241352function pick(source, properties) {
4137341353 const out = {};
@@ -41387,11 +41367,10 @@ function orVoid(input) {
4138741367 }
4138841368 return input;
4138941369}
41390- var import_node_buffer, import_file_exists, NULL, NOOP, objectToString;
41370+ var import_file_exists, NULL, NOOP, objectToString;
4139141371var init_util = __esm({
4139241372 "src/lib/utils/util.ts"() {
4139341373 "use strict";
41394- import_node_buffer = __nccwpck_require__(4573);
4139541374 import_file_exists = __nccwpck_require__(7117);
4139641375 init_argument_filters();
4139741376 NULL = "\0";
@@ -41409,7 +41388,7 @@ function filterType(input, filter, def) {
4140941388 return arguments.length > 2 ? def : void 0;
4141041389}
4141141390function filterPrimitives(input, omit) {
41412- const type = isPathSpec(input) ? "string" : typeof input;
41391+ const type = (0, import_args_pathspec. isPathSpec) (input) ? "string" : typeof input;
4141341392 return /number|string|boolean/.test(type) && (!omit || !omit.includes(type));
4141441393}
4141541394function filterPlainObject(input) {
@@ -41418,11 +41397,11 @@ function filterPlainObject(input) {
4141841397function filterFunction(input) {
4141941398 return typeof input === "function";
4142041399}
41421- var filterArray, filterNumber, filterString, filterStringOrStringArray, filterHasLength;
41400+ var import_args_pathspec, filterArray, filterNumber, filterString, filterStringOrStringArray, filterHasLength;
4142241401var init_argument_filters = __esm({
4142341402 "src/lib/utils/argument-filters.ts"() {
4142441403 "use strict";
41425- init_pathspec( );
41404+ import_args_pathspec = __nccwpck_require__(6632 );
4142641405 init_util();
4142741406 filterArray = (input) => {
4142841407 return Array.isArray(input);
@@ -41431,7 +41410,7 @@ var init_argument_filters = __esm({
4143141410 return typeof input === "number";
4143241411 };
4143341412 filterString = (input) => {
41434- return typeof input === "string" || isPathSpec(input);
41413+ return typeof input === "string" || (0, import_args_pathspec. isPathSpec) (input);
4143541414 };
4143641415 filterStringOrStringArray = (input) => {
4143741416 return filterString(input) || Array.isArray(input) && input.every(filterString);
@@ -41562,7 +41541,7 @@ function appendTaskOptions(options, commands = []) {
4156241541 }
4156341542 return Object.keys(options).reduce((commands2, key) => {
4156441543 const value = options[key];
41565- if (isPathSpec(value)) {
41544+ if ((0, import_args_pathspec2. isPathSpec) (value)) {
4156641545 commands2.push(value);
4156741546 } else if (filterPrimitives(value, ["boolean"])) {
4156841547 commands2.push(key + "=" + value);
@@ -41603,12 +41582,13 @@ function trailingFunctionArgument(args, includeNoop = true) {
4160341582 const callback = asFunction(last(args));
4160441583 return includeNoop || isUserFunction(callback) ? callback : void 0;
4160541584}
41585+ var import_args_pathspec2;
4160641586var init_task_options = __esm({
4160741587 "src/lib/utils/task-options.ts"() {
4160841588 "use strict";
4160941589 init_argument_filters();
4161041590 init_util();
41611- init_pathspec( );
41591+ import_args_pathspec2 = __nccwpck_require__(6632 );
4161241592 }
4161341593});
4161441594
@@ -42295,12 +42275,13 @@ __export(api_exports, {
4229542275 ResetMode: () => ResetMode,
4229642276 TaskConfigurationError: () => TaskConfigurationError,
4229742277 grepQueryBuilder: () => grepQueryBuilder,
42298- pathspec: () => pathspec
42278+ pathspec: () => import_args_pathspec3. pathspec
4229942279});
42280+ var import_args_pathspec3;
4230042281var init_api = __esm({
4230142282 "src/lib/api.ts"() {
4230242283 "use strict";
42303- init_pathspec( );
42284+ import_args_pathspec3 = __nccwpck_require__(6632 );
4230442285 init_git_construct_error();
4230542286 init_git_error();
4230642287 init_git_plugin_error();
@@ -42348,83 +42329,25 @@ var init_abort_plugin = __esm({
4234842329});
4234942330
4235042331// src/lib/plugins/block-unsafe-operations-plugin.ts
42351- function isConfigSwitch(arg) {
42352- return typeof arg === "string" && arg.trim().toLowerCase() === "-c";
42353- }
42354- function isCloneUploadPackSwitch(char, arg) {
42355- if (typeof arg !== "string" || !arg.includes(char)) {
42356- return false;
42357- }
42358- const cleaned = arg.trim().replace(/\0/g, "");
42359- return /^(--no)?-{1,2}[\dlsqvnobucj]+(\s|$)/.test(cleaned);
42360- }
42361- function preventConfigBuilder(config, setting, message = String(config)) {
42362- const regex = typeof config === "string" ? new RegExp(`\\s*${config}`, "i") : config;
42363- return function preventCommand(options, arg, next) {
42364- if (options[setting] !== true && isConfigSwitch(arg) && regex.test(next)) {
42365- throw new GitPluginError(
42366- void 0,
42367- "unsafe",
42368- `Configuring ${message} is not permitted without enabling ${setting}`
42369- );
42370- }
42371- };
42372- }
42373- function preventUploadPack(arg, method) {
42374- if (/^\s*--(upload|receive)-pack/.test(arg)) {
42375- throw new GitPluginError(
42376- void 0,
42377- "unsafe",
42378- `Use of --upload-pack or --receive-pack is not permitted without enabling allowUnsafePack`
42379- );
42380- }
42381- if (method === "clone" && isCloneUploadPackSwitch("u", arg)) {
42382- throw new GitPluginError(
42383- void 0,
42384- "unsafe",
42385- `Use of clone with option -u is not permitted without enabling allowUnsafePack`
42386- );
42387- }
42388- if (method === "push" && /^\s*--exec\b/.test(arg)) {
42389- throw new GitPluginError(
42390- void 0,
42391- "unsafe",
42392- `Use of push with option --exec is not permitted without enabling allowUnsafePack`
42393- );
42394- }
42395- }
42396- function blockUnsafeOperationsPlugin({
42397- allowUnsafePack = false,
42398- ...options
42399- } = {}) {
42332+ function blockUnsafeOperationsPlugin(options = {}) {
4240042333 return {
4240142334 type: "spawn.args",
42402- action(args, context ) {
42403- args.forEach((current, index) => {
42404- const next = index < args.length ? args[index + 1] : "";
42405- allowUnsafePack || preventUploadPack(current, context.method );
42406- preventUnsafeConfig.forEach((helper) => helper(options, current, next));
42407- });
42335+ action(args, { env } ) {
42336+ for (const vulnerability of (0, import_argv_parser.vulnerabilityCheck)(args, env)) {
42337+ if (options[vulnerability.category] !== true) {
42338+ throw new GitPluginError(void 0, "unsafe", vulnerability.message );
42339+ }
42340+ }
4240842341 return args;
4240942342 }
4241042343 };
4241142344}
42412- var preventUnsafeConfig ;
42345+ var import_argv_parser ;
4241342346var init_block_unsafe_operations_plugin = __esm({
4241442347 "src/lib/plugins/block-unsafe-operations-plugin.ts"() {
4241542348 "use strict";
42349+ import_argv_parser = __nccwpck_require__(7202);
4241642350 init_git_plugin_error();
42417- preventUnsafeConfig = [
42418- preventConfigBuilder(
42419- /^\s*protocol(.[a-z]+)?.allow/i,
42420- "allowUnsafeProtocolOverride",
42421- "protocol.allow"
42422- ),
42423- preventConfigBuilder("core.sshCommand", "allowUnsafeSshCommand"),
42424- preventConfigBuilder("core.gitProxy", "allowUnsafeGitProxy"),
42425- preventConfigBuilder("core.hooksPath", "allowUnsafeHooksPath"),
42426- preventConfigBuilder("diff.external", "allowUnsafeDiffExternal")
42427- ];
4242842351 }
4242942352});
4243042353
@@ -42788,13 +42711,13 @@ function suffixPathsPlugin() {
4278842711 }
4278942712 for (let i = 0; i < data.length; i++) {
4279042713 const param = data[i];
42791- if (isPathSpec(param)) {
42792- append2(toPaths(param));
42714+ if ((0, import_args_pathspec4. isPathSpec) (param)) {
42715+ append2((0, import_args_pathspec4. toPaths) (param));
4279342716 continue;
4279442717 }
4279542718 if (param === "--") {
4279642719 append2(
42797- data.slice(i + 1).flatMap((item) => isPathSpec(item) && toPaths(item) || item)
42720+ data.slice(i + 1).flatMap((item) => (0, import_args_pathspec4. isPathSpec) (item) && (0, import_args_pathspec4. toPaths) (item) || item)
4279842721 );
4279942722 break;
4280042723 }
@@ -42804,10 +42727,11 @@ function suffixPathsPlugin() {
4280442727 }
4280542728 };
4280642729}
42730+ var import_args_pathspec4;
4280742731var init_suffix_paths_plugin = __esm({
4280842732 "src/lib/plugins/suffix-paths.plugin.ts"() {
4280942733 "use strict";
42810- init_pathspec( );
42734+ import_args_pathspec4 = __nccwpck_require__(6632 );
4281142735 }
4281242736});
4281342737
@@ -43029,11 +42953,10 @@ var init_git_executor_chain = __esm({
4302942953 }
4303042954 async attemptRemoteTask(task, logger) {
4303142955 const binary = this._plugins.exec("spawn.binary", "", pluginContext(task, task.commands));
43032- const args = this._plugins.exec(
43033- "spawn.args",
43034- [...task.commands],
43035- pluginContext(task, task.commands)
43036- );
42956+ const args = this._plugins.exec("spawn.args", [...task.commands], {
42957+ ...pluginContext(task, task.commands),
42958+ env: { ...this.env }
42959+ });
4303742960 const raw = await this.gitResponse(
4303842961 task,
4303942962 binary,
@@ -43836,7 +43759,7 @@ function parseLogOptions(opt = {}, customArgs = []) {
4383643759 suffix.push(`${opt.from || ""}${rangeOperator}${opt.to || ""}`);
4383743760 }
4383843761 if (filterString(opt.file)) {
43839- command.push("--follow", pathspec(opt.file));
43762+ command.push("--follow", (0, import_args_pathspec5. pathspec) (opt.file));
4384043763 }
4384143764 appendTaskOptions(userOptions(opt), command);
4384243765 return {
@@ -43874,12 +43797,12 @@ function log_default() {
4387443797 );
4387543798 }
4387643799}
43877- var excludeOptions;
43800+ var import_args_pathspec5, excludeOptions;
4387843801var init_log = __esm({
4387943802 "src/lib/tasks/log.ts"() {
4388043803 "use strict";
4388143804 init_log_format();
43882- init_pathspec( );
43805+ import_args_pathspec5 = __nccwpck_require__(6632 );
4388343806 init_parse_list_log_summary();
4388443807 init_utils();
4388543808 init_task();
@@ -44657,17 +44580,17 @@ function clone_default() {
4465744580 }
4465844581 };
4465944582}
44660- var cloneTask, cloneMirrorTask;
44583+ var import_args_pathspec6, cloneTask, cloneMirrorTask;
4466144584var init_clone = __esm({
4466244585 "src/lib/tasks/clone.ts"() {
4466344586 "use strict";
4466444587 init_task();
4466544588 init_utils();
44666- init_pathspec( );
44589+ import_args_pathspec6 = __nccwpck_require__(6632 );
4466744590 cloneTask = (repo, directory, customArgs) => {
4466844591 const commands = ["clone", ...customArgs];
44669- filterString(repo) && commands.push(pathspec(repo));
44670- filterString(directory) && commands.push(pathspec(directory));
44592+ filterString(repo) && commands.push((0, import_args_pathspec6. pathspec) (repo));
44593+ filterString(directory) && commands.push((0, import_args_pathspec6. pathspec) (directory));
4467144594 return straightThroughStringTask(commands);
4467244595 };
4467344596 cloneMirrorTask = (repo, directory, customArgs) => {
@@ -55908,6 +55831,26 @@ module.exports = function getPolyfill() {
5590855831};
5590955832
5591055833
55834+ /***/ }),
55835+
55836+ /***/ 6632:
55837+ /***/ ((__unused_webpack_module, exports) => {
55838+
55839+ "use strict";
55840+ Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=new WeakMap;function c(...t){const n=new String(t);return e.set(n,t),n}function o(t){return t instanceof String&&e.has(t)}function r(t){return e.get(t)??[]}exports.isPathSpec=o;exports.pathspec=c;exports.toPaths=r;
55841+ //# sourceMappingURL=index.cjs.map
55842+
55843+
55844+ /***/ }),
55845+
55846+ /***/ 7202:
55847+ /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
55848+
55849+ "use strict";
55850+ Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const h=__nccwpck_require__(6632);function*v(e,t){const n=t==="global";for(const o of e)o.isGlobal===n&&(yield o)}const S=new Set(["--add","--edit","--remove-section","--rename-section","--replace-all","--unset","--unset-all","-e"]),P=new Set(["--get","--get-all","--get-color","--get-colorbool","--get-regexp","--get-urlmatch","--list","-l"]),E=new Set(["edit","remove-section","rename-section","set","unset"]),A=new Set(["get","get-color","get-colorbool","list"]);function F(e,t){for(const{name:o}of v(e,"task")){if(S.has(o))return p(!0,t);if(P.has(o))return p(!1,t)}const n=t.at(0)?.toLowerCase();return n===void 0?null:E.has(n)?p(!0,t.slice(1)):A.has(n)?p(!1,t.slice(1)):t.length===1?p(!1,t):p(!0,t)}function p(e=!1,t=[]){const n=t.at(0)?.toLowerCase();return n===void 0?null:{isWrite:e,isRead:!e,key:n,value:t.at(1)}}function M(e,t){return t.isWrite&&t.value!==void 0?{key:t.key,value:t.value,scope:e}:{key:t.key,scope:e}}function N(e){const t=e?.indexOf("=")||-1;return!e||t<0?null:{key:e.slice(0,t).trim().toLowerCase(),value:e.slice(t+1)}}function O(e){for(const{name:t}of v(e,"task"))switch(t){case"--global":return"global";case"--system":return"system";case"--worktree":return"worktree";case"--local":return"local";case"--file":case"-f":return"file"}return"local"}function G({name:e}){if(e==="-c"||e==="--config")return"inline";if(e==="--config-env")return"env"}function*L(e){for(const t of e){const n=G(t),o=n&&N(t.value);o&&(yield{...o,scope:n})}}function $(e,t,n){const o={read:[],write:[...L(t)]};return e==="config"&&D(o,O(t),F(t,n)),o}function D(e,t,n){if(n===null)return;const o=M(t,n);n.isWrite?e.write.push(o):e.read.push(o)}const U={short:new Map([["c",!0]])},T={short:new Map([["C",!0],["P",!1],["h",!1],["p",!1],["v",!1],...U.short.entries()]),long:new Set(["attr-source","config-env","exec-path","git-dir","list-cmds","namespace","super-prefix","work-tree"])},R={clone:{short:new Map([["b",!0],["j",!0],["l",!1],["n",!1],["o",!0],["q",!1],["s",!1],["u",!0]]),long:new Set(["branch","config","jobs","origin","upload-pack","u","template"])},commit:{short:new Map([["C",!0],["F",!0],["c",!0],["m",!0],["t",!0]]),long:new Set(["file","message","reedit-message","reuse-message","template"])},config:{short:new Map([["e",!1],["f",!0],["l",!1]]),long:new Set(["blob","comment","default","file","type","value"])},fetch:{short:new Map,long:new Set(["upload-pack"])},init:{short:new Map,long:new Set(["template"])},pull:{short:new Map,long:new Set(["upload-pack"])},push:{short:new Map,long:new Set(["exec","receive-pack"])}},I={short:new Map,long:new Set};function j(e){const t=R[e??""]??I;return{short:new Map([...U.short.entries(),...t.short.entries()]),long:t.long}}function b(e,t=T){if(e.startsWith("--")){const n=e.indexOf("=");if(n>2)return[{name:e.slice(0,n),value:e.slice(n+1),needsNext:!1}];const o=e.slice(2);return[{name:e,needsNext:t.long.has(o)}]}if(e.length===2){const n=e.charAt(1),o=t.short.get(n);return[{name:e,needsNext:o===!0}]}return W(e,t.short)}function W(e,t){const n=e.slice(1).split(""),o=[];for(let s=0;s<n.length;s++){const r=n[s],a=t.get(r);if(a===void 0)return[{name:e,needsNext:!1}];if(a){const l=n.slice(s+1).join("");if(l&&![...l].every(m=>t.has(m)))return o.push({name:`-${r}`,value:l,needsNext:!1}),o}o.push({name:`-${r}`,needsNext:a})}return o}function B(e,t=[]){let n=0;for(;n<e.length;){const o=String(e[n]);if(!o.startsWith("-")||o.length<2)break;const s=b(o);let r=n+1;for(const a of s){const l={name:a.name,value:a.value,absorbedNext:!1,isGlobal:!0};a.needsNext&&l.value===void 0&&r<e.length&&(l.value=String(e[r]),l.absorbedNext=!0,r++),t.push(l)}n=r}return{flags:t,taskIndex:n}}function q(e,t,n=[]){const o=j(t),s=[],r=[];let a=0;for(;a<e.length;){const l=e[a];if(h.isPathSpec(l)){r.push(...h.toPaths(l)),a++;continue}const f=String(l);if(f==="--"){for(let g=a+1;g<e.length;g++){const u=e[g];h.isPathSpec(u)?r.push(...h.toPaths(u)):r.push(String(u))}break}if(!f.startsWith("-")||f.length<2){s.push(f),a++;continue}const m=b(f,o);let d=a+1;for(const g of m){const u={name:g.name,value:g.value,absorbedNext:!1,isGlobal:!1};g.needsNext&&u.value===void 0&&d<e.length&&!h.isPathSpec(e[d])&&(u.value=String(e[d]),u.absorbedNext=!0,d++),n.push(u)}a=d}return{flags:n,positionals:s,pathspecs:r}}function*V({write:e}){for(const t of e)for(const n of K){const o=n(t.key);o&&(yield o)}}function c(e,t,n=String(e)){const o=typeof e=="string"?new RegExp(`\\s*${e.toLowerCase()}`):e;return function(r){if(o.test(r))return{category:t,message:`Configuring ${n} is not permitted without enabling ${t}`}}}function i(e,t){const n=new RegExp(`\\s*${e.toLowerCase().replace(/\./g,"(..+)?.")}`);return c(n,t,e)}const K=[c("alias","allowUnsafeAlias"),c("core.askPass","allowUnsafeAskPass"),c("core.editor","allowUnsafeEditor"),c("core.fsmonitor","allowUnsafeFsMonitor"),c("core.gitProxy","allowUnsafeGitProxy"),c("core.hooksPath","allowUnsafeHooksPath"),c("core.pager","allowUnsafePager"),c("core.sshCommand","allowUnsafeSshCommand"),i("credential.helper","allowUnsafeCredentialHelper"),i("diff.command","allowUnsafeDiffExternal"),c("diff.external","allowUnsafeDiffExternal"),i("diff.textconv","allowUnsafeDiffTextConv"),i("filter.clean","allowUnsafeFilter"),i("filter.smudge","allowUnsafeFilter"),i("gpg.program","allowUnsafeGpgProgram"),c("init.templateDir","allowUnsafeTemplateDir"),i("merge.driver","allowUnsafeMergeDriver"),i("mergetool.path","allowUnsafeMergeDriver"),i("mergetool.cmd","allowUnsafeMergeDriver"),i("protocol.allow","allowUnsafeProtocolOverride"),i("remote.receivepack","allowUnsafePack"),i("remote.uploadpack","allowUnsafePack"),c("sequence.editor","allowUnsafeEditor")];function*H(e,t){for(const n of t)for(const o of Y){const s=o(e,n.name);s&&(yield s)}}function w(e,t,n,o=String(t)){const s=typeof t=="string"?new RegExp(`\\s*${t.toLowerCase()}`):t,r=`Use of ${e?`${e} with option `:""}${o} is not permitted without enabling ${n}`;return function(l,f){if((!e||l===e)&&s.test(f))return{category:n,message:r}}}const Y=[w(null,/--(upload|receive)-pack/,"allowUnsafePack","--upload-pack or --receive-pack"),w("clone",/^-\w*u/,"allowUnsafePack"),w("clone","--u","allowUnsafePack"),w("push","--exec","allowUnsafePack"),w(null,"--template","allowUnsafeTemplateDir")];function C(e,t,n){return[...H(e,t),...V(n)]}function x(...e){const{flags:t,taskIndex:n}=B(e),o=n<e.length?String(e[n]).toLowerCase():null,s=o!==null?e.slice(n+1):[],{positionals:r,pathspecs:a}=q(s,o,t),l=$(o,t,r);return{task:o,flags:t.map(J),paths:a,config:l,vulnerabilities:z(C(o,t,l))}}function z(e){return Object.defineProperty(e,"vulnerabilities",{value:e})}function J({value:e,name:t}){return e!==void 0?{name:t,value:e}:{name:t}}const y={editor:"allowUnsafeEditor",git_askpass:"allowUnsafeAskPass",git_config_global:"allowUnsafeConfigPaths",git_config_system:"allowUnsafeConfigPaths",git_config_count:"allowUnsafeConfigEnvCount",git_config:"allowUnsafeConfigPaths",git_editor:"allowUnsafeEditor",git_exec_path:"allowUnsafeConfigPaths",git_external_diff:"allowUnsafeDiffExternal",git_pager:"allowUnsafePager",git_proxy_command:"allowUnsafeGitProxy",git_template_dir:"allowUnsafeTemplateDir",git_sequence_editor:"allowUnsafeEditor",git_ssh:"allowUnsafeSshCommand",git_ssh_command:"allowUnsafeSshCommand",pager:"allowUnsafePager",prefix:"allowUnsafeConfigPaths",ssh_askpass:"allowUnsafeAskPass"};function*Q(e){const t=parseInt(e.git_config_count??"0",10);for(let n=0;n<t;n++){const o=e[`git_config_key_${n}`],s=e[`git_config_value_${n}`];o!==void 0&&(yield{key:o.toLowerCase().trim(),value:s,scope:"env"})}}function*X(e){for(const t of Object.keys(e))if(k(t)){const n=y[t];yield{category:n,message:`Use of "${t.toUpperCase()}" is not permitted without enabling ${n}`}}}function k(e){return Object.hasOwn(y,e)}function Z(e){const t={};for(const[n,o]of Object.entries(e)){const s=n.toLowerCase().trim();(k(s)||s.startsWith("git"))&&(t[s]=String(o))}return t}function _(e){const t=Z(e),n={read:[],write:[...Q(t)]},o=[...X(t),...C(null,[],n)];return{config:n,vulnerabilities:o}}function ee(e,t){return[...x(...e).vulnerabilities,..._(t).vulnerabilities]}exports.parseArgv=x;exports.parseEnv=_;exports.vulnerabilityCheck=ee;
55851+ //# sourceMappingURL=index.cjs.map
55852+
55853+
5591155854/***/ }),
5591255855
5591355856/***/ 7942:
0 commit comments