-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
21 changed files
with
300 additions
and
91 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -61,3 +61,11 @@ the `/etc/machine-id` file), comin won't deploy the configuration. | |
So, to migrate to another machine, you have to update this | ||
option in the `testing-<hostname>` branch in order to only deploy this | ||
configuration to the new machine. | ||
|
||
## Check Git commit signatures | ||
|
||
The option `services.comin.gpgPublicKeyPaths` allows to declare a list | ||
a GPG public keys. If `services.comin.gpgPublicKeyPaths != []`, comin **only** evaluates commits signed | ||
by one of these GPG public keys. Note only the last commit needs to be signed. | ||
|
||
The file containing a GPG public key has to be created with `gpg --armor --export [email protected]`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
-----BEGIN PGP PUBLIC KEY BLOCK----- | ||
|
||
mDMEZ4oDaRYJKwYBBAHaRw8BAQdA91zbRSdMphKMs7wP+3/mOpDkxEfeWrfblS5t | ||
uf5xw1O0F2ZhaWwgPGZhaWxAY29taW4uc3BhY2U+iJQEExYKADwWIQSNo3AzK05c | ||
jADI4rwfTCYbHTKLkgUCZ4oDaQIbAwUJBaOagAQLCQgHBBUKCQgFFgIDAQACHgUC | ||
F4AACgkQH0wmGx0yi5IEyAD/ck8A4aPUK8+g7EzMLRnl+twUccwmS7wIthLsA7Sm | ||
s0sA/2RMyImXOK82hesQi8VqV/XNsu/n5Lg6bAfkTHQR1CwLuDgEZ4oDaRIKKwYB | ||
BAGXVQEFAQEHQLr2P/jpdMyluCmFv1mmtHxNy4rOAstT61B+Zsq+8/wtAwEIB4h+ | ||
BBgWCgAmFiEEjaNwMytOXIwAyOK8H0wmGx0yi5IFAmeKA2kCGwwFCQWjmoAACgkQ | ||
H0wmGx0yi5IXxwD6AwMQTzw4uXuMJiNC3lsaX5+L9vJDy4tSu/bufc4EKPoA/iiu | ||
kbksGGr4c6gTHOovFhEklvJhjPcEcwdvdEnioWgL | ||
=zjq4 | ||
-----END PGP PUBLIC KEY BLOCK----- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,23 @@ | ||
package repository | ||
|
||
import ( | ||
"os" | ||
"path/filepath" | ||
"testing" | ||
"time" | ||
|
||
"github.com/ProtonMail/go-crypto/openpgp" | ||
"github.com/go-git/go-git/v5" | ||
"github.com/go-git/go-git/v5/plumbing" | ||
"github.com/go-git/go-git/v5/plumbing/object" | ||
"github.com/stretchr/testify/assert" | ||
"io/ioutil" | ||
"path/filepath" | ||
"testing" | ||
"time" | ||
) | ||
|
||
func commitFile(remoteRepository *git.Repository, dir, branch, content string) (commitId string, err error) { | ||
return commitFileAndSign(remoteRepository, dir, branch, content, nil) | ||
} | ||
|
||
func commitFileAndSign(remoteRepository *git.Repository, dir, branch, content string, signKey *openpgp.Entity) (commitId string, err error) { | ||
w, err := remoteRepository.Worktree() | ||
if err != nil { | ||
return | ||
|
@@ -22,7 +28,7 @@ func commitFile(remoteRepository *git.Repository, dir, branch, content string) ( | |
}) | ||
|
||
filename := filepath.Join(dir, content) | ||
err = ioutil.WriteFile(filename, []byte(content), 0644) | ||
err = os.WriteFile(filename, []byte(content), 0644) | ||
if err != nil { | ||
return | ||
} | ||
|
@@ -36,6 +42,7 @@ func commitFile(remoteRepository *git.Repository, dir, branch, content string) ( | |
Email: "[email protected]", | ||
When: time.Unix(0, 0), | ||
}, | ||
SignKey: signKey, | ||
}) | ||
if err != nil { | ||
return | ||
|
@@ -119,3 +126,28 @@ func TestIsAncestor(t *testing.T) { | |
|
||
//time.Sleep(100*time.Second) | ||
} | ||
|
||
func TestHeadSignedBy(t *testing.T) { | ||
dir := t.TempDir() | ||
remoteRepository, _ := git.PlainInit(dir, false) | ||
|
||
r, err := os.Open("./test.private") | ||
entityList, _ := openpgp.ReadArmoredKeyRing(r) | ||
commitFileAndSign(remoteRepository, dir, "main", "file-1", entityList[0]) | ||
|
||
failPublic, _ := os.ReadFile("./fail.public") | ||
testPublic, _ := os.ReadFile("./test.public") | ||
signedBy, err := headSignedBy(remoteRepository, []string{string(failPublic), string(testPublic)}) | ||
assert.Nil(t, err) | ||
assert.Equal(t, "test <[email protected]>", signedBy.PrimaryIdentity().Name) | ||
|
||
signedBy, err = headSignedBy(remoteRepository, []string{string(failPublic)}) | ||
assert.ErrorContains(t, err, "is not signed") | ||
assert.Nil(t, signedBy) | ||
|
||
commitFileAndSign(remoteRepository, dir, "main", "file-2", nil) | ||
signedBy, err = headSignedBy(remoteRepository, []string{string(failPublic), string(testPublic)}) | ||
assert.ErrorContains(t, err, "is not signed") | ||
assert.Nil(t, signedBy) | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Not a valid armored GPG pub key |
Oops, something went wrong.