-
Notifications
You must be signed in to change notification settings - Fork 35
[WIP] Add support for annotated and signed tags #88
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -358,4 +358,81 @@ public function testPostRunHook() | |
| // Verify the postRun hook was executed | ||
| $this->assertTrue($called); | ||
| } | ||
|
|
||
| /** @test */ | ||
| public function testAnnotateTagConfiguration() | ||
| { | ||
| $config = new Configuration(['annotateTag' => true]); | ||
| $this->assertTrue($config->isAnnotateTag()); | ||
|
|
||
| $config = new Configuration(['annotateTag' => false]); | ||
| $this->assertFalse($config->isAnnotateTag()); | ||
| } | ||
|
|
||
| /** @test */ | ||
| public function testSignTagConfiguration() | ||
| { | ||
| $config = new Configuration(['signTag' => true]); | ||
| $this->assertTrue($config->isSignTag()); | ||
|
|
||
| $config = new Configuration(['signTag' => false]); | ||
| $this->assertFalse($config->isSignTag()); | ||
| } | ||
|
|
||
| /** @test */ | ||
| public function testAnnotateTagDefault() | ||
| { | ||
| $config = new Configuration(); | ||
| // By default, annotateTag should be false | ||
| $this->assertFalse($config->isAnnotateTag()); | ||
| } | ||
|
|
||
| /** @test */ | ||
| public function testSignTagDefault() | ||
| { | ||
| $config = new Configuration(); | ||
| // By default, signTag should be false | ||
| $this->assertFalse($config->isSignTag()); | ||
| } | ||
|
|
||
| /** @test */ | ||
| public function testTagCommandLightweight() | ||
| { | ||
| // Test that lightweight tags don't have flags | ||
| $class = new \ReflectionClass(\ConventionalChangelog\Git\Repository::class); | ||
| $method = $class->getMethod('tag'); | ||
|
|
||
| // For lightweight tags, the command should be: git tag <name> | ||
| // We can't easily test exec output, but we can verify the method exists and is callable | ||
| $this->assertTrue($method->isStatic()); | ||
| $this->assertTrue($method->isPublic()); | ||
| } | ||
|
|
||
| /** @test */ | ||
| public function testTagCommandAnnotated() | ||
| { | ||
| // Test that annotated tags work with both boolean and string | ||
| $config = new Configuration(['annotateTag' => true]); | ||
| $this->assertTrue($config->isAnnotateTag()); | ||
| } | ||
|
|
||
| /** @test */ | ||
| public function testTagCommandSigned() | ||
| { | ||
| // Test that signed tags can be configured | ||
| $config = new Configuration(['signTag' => true]); | ||
| $this->assertTrue($config->isSignTag()); | ||
| } | ||
|
|
||
| /** @test */ | ||
| public function testBothAnnotateAndSignTag() | ||
| { | ||
| // Test that both can be enabled together | ||
| $config = new Configuration([ | ||
| 'annotateTag' => true, | ||
| 'signTag' => true, | ||
| ]); | ||
| $this->assertTrue($config->isAnnotateTag()); | ||
| $this->assertTrue($config->isSignTag()); | ||
| } | ||
|
Comment on lines
+398
to
+437
|
||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
Repository::tagmethod builds agit tagcommand by interpolating unescaped variables ($flagsand$name, which include the tag name and optional annotation message) directly into a string passed toexec, which allows shell command injection if an attacker controls the tag message or name. An attacker who can influence--annotate-tagor configuration values could inject shell metacharacters or break out of the quotes around"{$message}"to execute arbitrary commands with the privileges of the process. To mitigate this, construct the command using a safe API (e.g., passing arguments as an array or using a process builder) or at least escape each argument with a proper shell-escaping function instead of concatenating raw strings.