Skip to content

Commit 23b070f

Browse files
authored
Fix regex for CLONE_OPTIONS constant (#1122)
* Fix regex for CLONE_OPTIONS constant Unbounded regexp would catch clone options that should be permitted. Closes #1121 * changeset * Adjust timeout for clone command injection test Increase timeout for clone command injection test. * Update block-unsafe-operations-plugin.ts
1 parent c050c1e commit 23b070f

File tree

3 files changed

+9
-2
lines changed

3 files changed

+9
-2
lines changed
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
"simple-git": patch
3+
---
4+
5+
Fix regex for detecting unsafe clone options
6+
7+
Thanks to @stevenwdv for reporting this issue.

simple-git/src/lib/plugins/block-unsafe-operations-plugin.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import type { SimpleGitPlugin } from './simple-git-plugin';
33
import { GitPluginError } from '../errors/git-plugin-error';
44
import type { SimpleGitPluginConfig } from '../types';
55

6-
const CLONE_OPTIONS = /^\0*(-|--|--no-)[\0\dlsqvnobucj]+/;
6+
const CLONE_OPTIONS = /^\0*(-|--|--no-)[\0\dlsqvnobucj]+\b/;
77

88
function isConfigSwitch(arg: string | unknown) {
99
return typeof arg === 'string' && arg.trim().toLowerCase() === '-c';

simple-git/test/integration/plugin.unsafe.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ describe('plugin.unsafe', () => {
7070
),
7171
);
7272
}
73-
});
73+
}, 20000);
7474

7575
it('allows clone command injection: `-u...` pattern', async () => {
7676
await promiseResult(

0 commit comments

Comments
 (0)