test(rollback): verify shell metacharacter escaping in git commit parameter
This commit is contained in:
parent
e4fae68f0e
commit
02858c0892
1 changed files with 21 additions and 0 deletions
|
|
@ -87,6 +87,27 @@
|
||||||
expect($result)->toContain('def789abc012def789abc012def789abc012def7');
|
expect($result)->toContain('def789abc012def789abc012def789abc012def7');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('setGitImportSettings escapes shell metacharacters in commit parameter', function () {
|
||||||
|
ApplicationSetting::create([
|
||||||
|
'application_id' => $this->application->id,
|
||||||
|
'is_git_shallow_clone_enabled' => false,
|
||||||
|
]);
|
||||||
|
|
||||||
|
$maliciousCommit = 'abc123; rm -rf /';
|
||||||
|
|
||||||
|
$result = $this->application->setGitImportSettings(
|
||||||
|
deployment_uuid: 'test-uuid',
|
||||||
|
git_clone_command: 'git clone',
|
||||||
|
public: true,
|
||||||
|
commit: $maliciousCommit
|
||||||
|
);
|
||||||
|
|
||||||
|
// escapeshellarg wraps the value in single quotes, neutralizing metacharacters
|
||||||
|
expect($result)
|
||||||
|
->toContain("checkout 'abc123; rm -rf /'")
|
||||||
|
->not->toContain('checkout abc123; rm -rf /');
|
||||||
|
});
|
||||||
|
|
||||||
test('setGitImportSettings does not append checkout when commit is HEAD', function () {
|
test('setGitImportSettings does not append checkout when commit is HEAD', function () {
|
||||||
ApplicationSetting::create([
|
ApplicationSetting::create([
|
||||||
'application_id' => $this->application->id,
|
'application_id' => $this->application->id,
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue