diff --git a/example/commitpr/main.go b/example/commitpr/main.go index 328afda5469..7e73d7ffdef 100644 --- a/example/commitpr/main.go +++ b/example/commitpr/main.go @@ -21,15 +21,18 @@ package main import ( + "bytes" "context" "errors" "flag" "fmt" + "io" "log" "os" "strings" "time" + "github.com/ProtonMail/go-crypto/openpgp" "github.com/google/go-github/v55/github" ) @@ -51,6 +54,7 @@ If the file should be in the same location with the same name, you can just put Example: README.md,main.go:github/examples/commitpr/main.go`) authorName = flag.String("author-name", "", "Name of the author of the commit.") authorEmail = flag.String("author-email", "", "Email of the author of the commit.") + privateKey = flag.String("private-key", "", "Path to the private key to use to sign the commit.") ) var client *github.Client @@ -135,7 +139,25 @@ func pushCommit(ref *github.Reference, tree *github.Tree) (err error) { date := time.Now() author := &github.CommitAuthor{Date: &github.Timestamp{Time: date}, Name: authorName, Email: authorEmail} commit := &github.Commit{Author: author, Message: commitMessage, Tree: tree, Parents: []*github.Commit{parent.Commit}} - newCommit, _, err := client.Git.CreateCommit(ctx, *sourceOwner, *sourceRepo, commit) + opts := github.CreateCommitOptions{} + if *privateKey != "" { + armoredBlock, e := os.ReadFile(*privateKey) + if e != nil { + return e + } + keyring, e := openpgp.ReadArmoredKeyRing(bytes.NewReader(armoredBlock)) + if e != nil { + return e + } + if len(keyring) != 1 { + return errors.New("expected exactly one key in the keyring") + } + key := keyring[0] + opts.Signer = github.MessageSignerFunc(func(w io.Writer, r io.Reader) error { + return openpgp.ArmoredDetachSign(w, key, r, nil) + }) + } + newCommit, _, err := client.Git.CreateCommit(ctx, *sourceOwner, *sourceRepo, commit, &opts) if err != nil { return err } diff --git a/example/go.mod b/example/go.mod index eaf9f5b6926..7f7c9ededaa 100644 --- a/example/go.mod +++ b/example/go.mod @@ -3,6 +3,7 @@ module github.com/google/go-github/v55/example go 1.17 require ( + github.com/ProtonMail/go-crypto v0.0.0-20230828082145-3c4c8a2d2371 github.com/bradleyfalzon/ghinstallation/v2 v2.0.4 github.com/gofri/go-github-ratelimit v1.0.3 github.com/google/go-github/v55 v55.0.0 @@ -12,7 +13,6 @@ require ( ) require ( - github.com/ProtonMail/go-crypto v0.0.0-20230217124315-7d5c6f04bbb8 // indirect github.com/cloudflare/circl v1.3.3 // indirect github.com/golang-jwt/jwt/v4 v4.0.0 // indirect github.com/golang/protobuf v1.5.2 // indirect diff --git a/example/go.sum b/example/go.sum index 513022c3565..7b1a57e73c8 100644 --- a/example/go.sum +++ b/example/go.sum @@ -1,9 +1,8 @@ -github.com/ProtonMail/go-crypto v0.0.0-20230217124315-7d5c6f04bbb8 h1:wPbRQzjjwFc0ih8puEVAOFGELsn1zoIIYdxvML7mDxA= -github.com/ProtonMail/go-crypto v0.0.0-20230217124315-7d5c6f04bbb8/go.mod h1:I0gYDMZ6Z5GRU7l58bNFSkPTFN6Yl12dsUlAZ8xy98g= +github.com/ProtonMail/go-crypto v0.0.0-20230828082145-3c4c8a2d2371 h1:kkhsdkhsCvIsutKu5zLMgWtgh9YxGCNAw8Ad8hjwfYg= +github.com/ProtonMail/go-crypto v0.0.0-20230828082145-3c4c8a2d2371/go.mod h1:EjAoLdwvbIOoOQr3ihjnSoLZRtE8azugULFRteWMNc0= github.com/bradleyfalzon/ghinstallation/v2 v2.0.4 h1:tXKVfhE7FcSkhkv0UwkLvPDeZ4kz6OXd0PKPlFqf81M= github.com/bradleyfalzon/ghinstallation/v2 v2.0.4/go.mod h1:B40qPqJxWE0jDZgOR1JmaMy+4AY1eBP+IByOvqyAKp0= -github.com/bwesterb/go-ristretto v1.2.0/go.mod h1:fUIoIZaG73pV5biE2Blr2xEzDoMj7NFEuV9ekS419A0= -github.com/cloudflare/circl v1.1.0/go.mod h1:prBCrKB9DV4poKZY1l9zBXg2QJY7mvgRvtMxxK7fi4I= +github.com/bwesterb/go-ristretto v1.2.3/go.mod h1:fUIoIZaG73pV5biE2Blr2xEzDoMj7NFEuV9ekS419A0= github.com/cloudflare/circl v1.3.3 h1:fE/Qz0QdIGqeWfnwq0RE0R7MI51s0M2E4Ga9kq5AEMs= github.com/cloudflare/circl v1.3.3/go.mod h1:5XYMA4rFBvNIrhs50XuiBJ15vF2pZn4nnUKZrLbUZFA= github.com/gofri/go-github-ratelimit v1.0.3 h1:Ocs2jaYokZDzgvqaajX+g04dqFyVqL0JQzoO7d2wmlk= @@ -23,29 +22,59 @@ github.com/google/go-github/v41 v41.0.0 h1:HseJrM2JFf2vfiZJ8anY2hqBjdfY1Vlj/K27u github.com/google/go-github/v41 v41.0.0/go.mod h1:XgmCA5H323A9rtgExdTcnDkcqp6S30AVACCBDOonIxg= github.com/google/go-querystring v1.1.0 h1:AnCroh3fv4ZBgVIf1Iwtovgjaw/GiKJo8M8yD/fhyJ8= github.com/google/go-querystring v1.1.0/go.mod h1:Kcdr2DB4koayq7X8pmAG4sNG59So17icRSOU623lUBU= +github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20210817164053-32db794688a5/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= +golang.org/x/crypto v0.3.1-0.20221117191849-2c476679df9a/go.mod h1:hebNnKkNXi2UzZN1eVRvBB7co0a+JxK6XbPiWVs/3J4= +golang.org/x/crypto v0.7.0/go.mod h1:pYwdfH91IfpZVANVyUOhSIPZaFoJGxTFbZhFTx+dXZU= golang.org/x/crypto v0.12.0 h1:tFM/ta59kqch6LlvYnPa0yx5a83cL2nHflFhYKvv9Yk= golang.org/x/crypto v0.12.0/go.mod h1:NF0Gs7EO5K4qLn+Ylc+fih8BSTeIjAP05siRnAh98yw= +golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= +golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= golang.org/x/net v0.0.0-20190603091049-60506f45cf65/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks= +golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= +golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= +golang.org/x/net v0.2.0/go.mod h1:KqCZLdyyvdV855qA2rE3GC2aiw5xGR5TEjj8smXukLY= +golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= +golang.org/x/net v0.8.0/go.mod h1:QVkue5JL9kW//ek3r6jTKnTFis1tRmNAW2P1shuFdJc= golang.org/x/net v0.10.0 h1:X2//UzNDwYmtCLn7To6G58Wr6f5ahEAQgKNzv9Y951M= golang.org/x/net v0.10.0/go.mod h1:0qNGK6F8kojg2nk9dLZ2mShWaEBan6FAoqfSigmmuDg= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= +golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20211007075335-d3039528d8ac/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.2.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.3.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.11.0 h1:eG7RXZHdqOJ1i+0lgLgCpSXAp6M3LYlAo6osgSi0xOM= golang.org/x/sys v0.11.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= +golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= +golang.org/x/term v0.2.0/go.mod h1:TVmDHMZPmdnySmBfhjOoOdhjzdE1h4u1VwSiw2l1Nuc= +golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k= +golang.org/x/term v0.6.0/go.mod h1:m6U89DPEgQRMq3DNkDClhWw02AUbt2daBVO4cn4Hv9U= golang.org/x/term v0.11.0 h1:F9tnn/DA/Im8nCwm+fX+1/eBwi4qFjRT++MhtVC4ZX0= golang.org/x/term v0.11.0/go.mod h1:zC9APTIj3jG3FdV/Ons+XE1riIZXG4aZ4GTHiPZJPIU= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= +golang.org/x/text v0.4.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= +golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= +golang.org/x/text v0.8.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= +golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU= +golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= google.golang.org/appengine v1.6.7 h1:FZR1q0exgwxzPzp/aF+VccGrSfxfPpkBqjIIEq3ru6c= google.golang.org/appengine v1.6.7/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc= diff --git a/example/newreposecretwithlibsodium/go.sum b/example/newreposecretwithlibsodium/go.sum index 236b1e435bd..dd58884a049 100644 --- a/example/newreposecretwithlibsodium/go.sum +++ b/example/newreposecretwithlibsodium/go.sum @@ -1,62 +1,8 @@ github.com/GoKillers/libsodium-go v0.0.0-20171022220152-dd733721c3cb h1:ilqSFSbR1fq6x88heeHrvAqlg+ES+tZk2ZcaCmiH1gI= github.com/GoKillers/libsodium-go v0.0.0-20171022220152-dd733721c3cb/go.mod h1:72TQeEkiDH9QMXZa5nJJvZre0UjqqO67X2QEIoOwCRU= -github.com/ProtonMail/go-crypto v0.0.0-20230217124315-7d5c6f04bbb8 h1:wPbRQzjjwFc0ih8puEVAOFGELsn1zoIIYdxvML7mDxA= -github.com/ProtonMail/go-crypto v0.0.0-20230217124315-7d5c6f04bbb8/go.mod h1:I0gYDMZ6Z5GRU7l58bNFSkPTFN6Yl12dsUlAZ8xy98g= -github.com/bwesterb/go-ristretto v1.2.0/go.mod h1:fUIoIZaG73pV5biE2Blr2xEzDoMj7NFEuV9ekS419A0= -github.com/bwesterb/go-ristretto v1.2.3/go.mod h1:fUIoIZaG73pV5biE2Blr2xEzDoMj7NFEuV9ekS419A0= -github.com/cloudflare/circl v1.1.0/go.mod h1:prBCrKB9DV4poKZY1l9zBXg2QJY7mvgRvtMxxK7fi4I= -github.com/cloudflare/circl v1.3.3 h1:fE/Qz0QdIGqeWfnwq0RE0R7MI51s0M2E4Ga9kq5AEMs= -github.com/cloudflare/circl v1.3.3/go.mod h1:5XYMA4rFBvNIrhs50XuiBJ15vF2pZn4nnUKZrLbUZFA= github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38= github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/google/go-querystring v1.1.0 h1:AnCroh3fv4ZBgVIf1Iwtovgjaw/GiKJo8M8yD/fhyJ8= github.com/google/go-querystring v1.1.0/go.mod h1:Kcdr2DB4koayq7X8pmAG4sNG59So17icRSOU623lUBU= -github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= -golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= -golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= -golang.org/x/crypto v0.3.1-0.20221117191849-2c476679df9a/go.mod h1:hebNnKkNXi2UzZN1eVRvBB7co0a+JxK6XbPiWVs/3J4= -golang.org/x/crypto v0.12.0 h1:tFM/ta59kqch6LlvYnPa0yx5a83cL2nHflFhYKvv9Yk= -golang.org/x/crypto v0.12.0/go.mod h1:NF0Gs7EO5K4qLn+Ylc+fih8BSTeIjAP05siRnAh98yw= -golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= -golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= -golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= -golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= -golang.org/x/net v0.2.0/go.mod h1:KqCZLdyyvdV855qA2rE3GC2aiw5xGR5TEjj8smXukLY= -golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= -golang.org/x/net v0.10.0/go.mod h1:0qNGK6F8kojg2nk9dLZ2mShWaEBan6FAoqfSigmmuDg= -golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20211007075335-d3039528d8ac/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.2.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.3.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.11.0 h1:eG7RXZHdqOJ1i+0lgLgCpSXAp6M3LYlAo6osgSi0xOM= -golang.org/x/sys v0.11.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= -golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= -golang.org/x/term v0.2.0/go.mod h1:TVmDHMZPmdnySmBfhjOoOdhjzdE1h4u1VwSiw2l1Nuc= -golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k= -golang.org/x/term v0.8.0/go.mod h1:xPskH00ivmX89bAKVGSKKtLOWNx2+17Eiy94tnKShWo= -golang.org/x/term v0.11.0/go.mod h1:zC9APTIj3jG3FdV/Ons+XE1riIZXG4aZ4GTHiPZJPIU= -golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= -golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= -golang.org/x/text v0.4.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= -golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= -golang.org/x/text v0.9.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8= -golang.org/x/text v0.12.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE= -golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= -golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= -golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU= -golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= diff --git a/github/git_commits.go b/github/git_commits.go index 862837c0d59..1a683bc34c9 100644 --- a/github/git_commits.go +++ b/github/git_commits.go @@ -10,9 +10,8 @@ import ( "context" "errors" "fmt" + "io" "strings" - - "github.com/ProtonMail/go-crypto/openpgp" ) // SignatureVerification represents GPG signature verification. @@ -23,6 +22,25 @@ type SignatureVerification struct { Payload *string `json:"payload,omitempty"` } +// MessageSigner is used by GitService.CreateCommit to sign a commit. +// +// To create a MessageSigner that signs a commit with a [golang.org/x/crypto/openpgp.Entity], +// or [github.com/ProtonMail/go-crypto/openpgp.Entity], use: +// +// commit.Signer = github.MessageSignerFunc(func(w io.Writer, r io.Reader) error { +// return openpgp.ArmoredDetachSign(w, openpgpEntity, r, nil) +// }) +type MessageSigner interface { + Sign(w io.Writer, r io.Reader) error +} + +// MessageSignerFunc is a single function implementation of MessageSigner. +type MessageSignerFunc func(w io.Writer, r io.Reader) error + +func (f MessageSignerFunc) Sign(w io.Writer, r io.Reader) error { + return f(w, r) +} + // Commit represents a GitHub commit. type Commit struct { SHA *string `json:"sha,omitempty"` @@ -41,11 +59,6 @@ type Commit struct { // is only populated for requests that fetch GitHub data like // Pulls.ListCommits, Repositories.ListCommits, etc. CommentCount *int `json:"comment_count,omitempty"` - - // SigningKey denotes a key to sign the commit with. If not nil this key will - // be used to sign the commit. The private key must be present and already - // decrypted. Ignored if Verification.Signature is defined. - SigningKey *openpgp.Entity `json:"-"` } func (c Commit) String() string { @@ -96,6 +109,12 @@ type createCommit struct { Signature *string `json:"signature,omitempty"` } +type CreateCommitOptions struct { + // CreateCommit will sign the commit with this signer. See MessageSigner doc for more details. + // Ignored on commits where Verification.Signature is defined. + Signer MessageSigner +} + // CreateCommit creates a new commit in a repository. // commit must not be nil. // @@ -104,10 +123,13 @@ type createCommit struct { // the authenticated user’s information and the current date. // // GitHub API docs: https://docs.github.com/en/rest/git/commits#create-a-commit -func (s *GitService) CreateCommit(ctx context.Context, owner string, repo string, commit *Commit) (*Commit, *Response, error) { +func (s *GitService) CreateCommit(ctx context.Context, owner string, repo string, commit *Commit, opts *CreateCommitOptions) (*Commit, *Response, error) { if commit == nil { return nil, nil, fmt.Errorf("commit must be provided") } + if opts == nil { + opts = &CreateCommitOptions{} + } u := fmt.Sprintf("repos/%v/%v/git/commits", owner, repo) @@ -125,16 +147,16 @@ func (s *GitService) CreateCommit(ctx context.Context, owner string, repo string if commit.Tree != nil { body.Tree = commit.Tree.SHA } - if commit.SigningKey != nil { - signature, err := createSignature(commit.SigningKey, body) + switch { + case commit.Verification != nil: + body.Signature = commit.Verification.Signature + case opts.Signer != nil: + signature, err := createSignature(opts.Signer, body) if err != nil { return nil, nil, err } body.Signature = &signature } - if commit.Verification != nil { - body.Signature = commit.Verification.Signature - } req, err := s.client.NewRequest("POST", u, body) if err != nil { @@ -150,8 +172,8 @@ func (s *GitService) CreateCommit(ctx context.Context, owner string, repo string return c, resp, nil } -func createSignature(signingKey *openpgp.Entity, commit *createCommit) (string, error) { - if signingKey == nil || commit == nil { +func createSignature(signer MessageSigner, commit *createCommit) (string, error) { + if signer == nil { return "", errors.New("createSignature: invalid parameters") } @@ -160,9 +182,9 @@ func createSignature(signingKey *openpgp.Entity, commit *createCommit) (string, return "", err } - writer := new(bytes.Buffer) - reader := bytes.NewReader([]byte(message)) - if err := openpgp.ArmoredDetachSign(writer, signingKey, reader, nil); err != nil { + var writer bytes.Buffer + err = signer.Sign(&writer, strings.NewReader(message)) + if err != nil { return "", err } diff --git a/github/git_commits_test.go b/github/git_commits_test.go index ddb1672ea72..bc25206b495 100644 --- a/github/git_commits_test.go +++ b/github/git_commits_test.go @@ -9,15 +9,34 @@ import ( "context" "encoding/json" "fmt" + "io" "net/http" - "strings" "testing" "time" - "github.com/ProtonMail/go-crypto/openpgp" "github.com/google/go-cmp/cmp" ) +func mockSigner(t *testing.T, signature string, emitErr error, wantMessage string) MessageSignerFunc { + return func(w io.Writer, r io.Reader) error { + t.Helper() + message, err := io.ReadAll(r) + assertNilError(t, err) + if wantMessage != "" && string(message) != wantMessage { + t.Errorf("MessageSignerFunc got %q, want %q", string(message), wantMessage) + } + assertWrite(t, w, []byte(signature)) + return emitErr + } +} + +func uncalledSigner(t *testing.T) MessageSignerFunc { + return func(w io.Writer, r io.Reader) error { + t.Error("MessageSignerFunc should not be called") + return nil + } +} + func TestCommit_Marshal(t *testing.T) { testJSONMarshal(t, &Commit{}, "{}") @@ -65,7 +84,6 @@ func TestCommit_Marshal(t *testing.T) { }, NodeID: String("n"), CommentCount: Int(1), - SigningKey: &openpgp.Entity{}, } want := `{ @@ -190,7 +208,7 @@ func TestGitService_CreateCommit(t *testing.T) { }) ctx := context.Background() - commit, _, err := client.Git.CreateCommit(ctx, "o", "r", input) + commit, _, err := client.Git.CreateCommit(ctx, "o", "r", input, nil) if err != nil { t.Errorf("Git.CreateCommit returned error: %v", err) } @@ -202,12 +220,12 @@ func TestGitService_CreateCommit(t *testing.T) { const methodName = "CreateCommit" testBadOptions(t, methodName, func() (err error) { - _, _, err = client.Git.CreateCommit(ctx, "\n", "\n", input) + _, _, err = client.Git.CreateCommit(ctx, "\n", "\n", input, nil) return err }) testNewRequestAndDoFailure(t, methodName, client, func() (*Response, error) { - got, resp, err := client.Git.CreateCommit(ctx, "o", "r", input) + got, resp, err := client.Git.CreateCommit(ctx, "o", "r", input, nil) if got != nil { t.Errorf("testNewRequestAndDoFailure %v = %#v, want nil", methodName, got) } @@ -249,7 +267,7 @@ func TestGitService_CreateSignedCommit(t *testing.T) { }) ctx := context.Background() - commit, _, err := client.Git.CreateCommit(ctx, "o", "r", input) + commit, _, err := client.Git.CreateCommit(ctx, "o", "r", input, nil) if err != nil { t.Errorf("Git.CreateCommit returned error: %v", err) } @@ -261,12 +279,12 @@ func TestGitService_CreateSignedCommit(t *testing.T) { const methodName = "CreateCommit" testBadOptions(t, methodName, func() (err error) { - _, _, err = client.Git.CreateCommit(ctx, "\n", "\n", input) + _, _, err = client.Git.CreateCommit(ctx, "\n", "\n", input, nil) return err }) testNewRequestAndDoFailure(t, methodName, client, func() (*Response, error) { - got, resp, err := client.Git.CreateCommit(ctx, "o", "r", input) + got, resp, err := client.Git.CreateCommit(ctx, "o", "r", input, nil) if got != nil { t.Errorf("testNewRequestAndDoFailure %v = %#v, want nil", methodName, got) } @@ -278,103 +296,78 @@ func TestGitService_CreateSignedCommitWithInvalidParams(t *testing.T) { client, _, _, teardown := setup() defer teardown() - input := &Commit{ - SigningKey: &openpgp.Entity{}, - } + input := &Commit{} ctx := context.Background() - _, _, err := client.Git.CreateCommit(ctx, "o", "r", input) + opts := CreateCommitOptions{Signer: uncalledSigner(t)} + _, _, err := client.Git.CreateCommit(ctx, "o", "r", input, &opts) if err == nil { t.Errorf("Expected error to be returned because invalid params were passed") } } -func TestGitService_CreateSignedCommitWithNilCommit(t *testing.T) { +func TestGitService_CreateCommitWithNilCommit(t *testing.T) { client, _, _, teardown := setup() defer teardown() ctx := context.Background() - _, _, err := client.Git.CreateCommit(ctx, "o", "r", nil) + _, _, err := client.Git.CreateCommit(ctx, "o", "r", nil, nil) if err == nil { t.Errorf("Expected error to be returned because commit=nil") } } -func TestGitService_CreateSignedCommitWithKey(t *testing.T) { +func TestGitService_CreateCommit_WithSigner(t *testing.T) { client, mux, _, teardown := setup() defer teardown() - s := strings.NewReader(testGPGKey) - keyring, err := openpgp.ReadArmoredKeyRing(s) - if err != nil { - t.Errorf("Error reading keyring: %+v", err) - } - - // Set the key lifetime to nil so we don't care about the example key expiring and making tests fail - keyring[0].Identities["go-github "].SelfSignature.KeyLifetimeSecs = nil - - date, _ := time.Parse("Mon Jan 02 15:04:05 2006 -0700", "Thu May 04 00:03:43 2017 +0200") + signature := "my voice is my password" + date := time.Date(2017, time.May, 4, 0, 3, 43, 0, time.FixedZone("CEST", 2*3600)) author := CommitAuthor{ Name: String("go-github"), Email: String("go-github@github.com"), Date: &Timestamp{date}, } - input := &Commit{ - Message: String("Commit Message."), - Tree: &Tree{SHA: String("t")}, - Parents: []*Commit{{SHA: String("p")}}, - SigningKey: keyring[0], - Author: &author, - } - - messageReader := strings.NewReader(`tree t + wantMessage := `tree t parent p author go-github 1493849023 +0200 committer go-github 1493849023 +0200 -Commit Message.`) - +Commit Message.` + sha := "commitSha" + input := &Commit{ + SHA: &sha, + Message: String("Commit Message."), + Tree: &Tree{SHA: String("t")}, + Parents: []*Commit{{SHA: String("p")}}, + Author: &author, + } + wantBody := createCommit{ + Message: input.Message, + Tree: String("t"), + Parents: []string{"p"}, + Author: &author, + Signature: &signature, + } + var gotBody createCommit mux.HandleFunc("/repos/o/r/git/commits", func(w http.ResponseWriter, r *http.Request) { - v := new(createCommit) - assertNilError(t, json.NewDecoder(r.Body).Decode(v)) - + assertNilError(t, json.NewDecoder(r.Body).Decode(&gotBody)) testMethod(t, r, "POST") - - want := &createCommit{ - Message: input.Message, - Tree: String("t"), - Parents: []string{"p"}, - Author: &author, - } - - sigReader := strings.NewReader(*v.Signature) - signer, err := openpgp.CheckArmoredDetachedSignature(keyring, messageReader, sigReader, nil) - if err != nil { - t.Errorf("Error verifying signature: %+v", err) - } - if signer.Identities["go-github "].Name != "go-github " { - t.Errorf("Signer is incorrect. got: %+v, want %+v", signer.Identities["go-github "].Name, "go-github ") - } - // Nullify Signature since we checked it above - v.Signature = nil - if !cmp.Equal(v, want) { - t.Errorf("Request body = %+v, want %+v", v, want) - } - fmt.Fprint(w, `{"sha":"commitSha"}`) + fmt.Fprintf(w, `{"sha":"%s"}`, sha) }) - ctx := context.Background() - commit, _, err := client.Git.CreateCommit(ctx, "o", "r", input) - if err != nil { - t.Errorf("Git.CreateCommit returned error: %v", err) + wantCommit := &Commit{SHA: String(sha)} + opts := CreateCommitOptions{Signer: mockSigner(t, signature, nil, wantMessage)} + commit, _, err := client.Git.CreateCommit(ctx, "o", "r", input, &opts) + assertNilError(t, err) + if cmp.Diff(gotBody, wantBody) != "" { + t.Errorf("Request body = %+v, want %+v\n%s", gotBody, wantBody, cmp.Diff(gotBody, wantBody)) } - - want := &Commit{SHA: String("commitSha")} - if !cmp.Equal(commit, want) { - t.Errorf("Git.CreateCommit returned %+v, want %+v", commit, want) + if cmp.Diff(commit, wantCommit) != "" { + t.Errorf("Git.CreateCommit returned %+v, want %+v\n%s", commit, wantCommit, cmp.Diff(commit, wantCommit)) } } -func TestGitService_createSignature_nilSigningKey(t *testing.T) { +func TestGitService_createSignature_nilSigner(t *testing.T) { a := &createCommit{ Message: String("Commit Message."), Tree: String("t"), @@ -389,48 +382,26 @@ func TestGitService_createSignature_nilSigningKey(t *testing.T) { } func TestGitService_createSignature_nilCommit(t *testing.T) { - _, err := createSignature(&openpgp.Entity{}, nil) + _, err := createSignature(uncalledSigner(t), nil) if err == nil { t.Errorf("Expected error to be returned because no author was passed") } } -func TestGitService_createSignature_noAuthor(t *testing.T) { +func TestGitService_createSignature_signerError(t *testing.T) { a := &createCommit{ Message: String("Commit Message."), Tree: String("t"), Parents: []string{"p"}, + Author: &CommitAuthor{Name: String("go-github")}, } - _, err := createSignature(&openpgp.Entity{}, a) - - if err == nil { - t.Errorf("Expected error to be returned because no author was passed") - } -} - -func TestGitService_createSignature_invalidKey(t *testing.T) { - date, _ := time.Parse("Mon Jan 02 15:04:05 2006 -0700", "Thu May 04 00:03:43 2017 +0200") - authorName := "go-github" - authorEmail := "go-github@github.com" - - signKey, _ := openpgp.NewEntity(authorName, "", authorEmail, nil) - _ = signKey.RevokeKey(0, "Invalidate key", nil) - - _, err := createSignature(signKey, &createCommit{ - Message: String("Commit Message."), - Tree: String("t"), - Parents: []string{"p"}, - Author: &CommitAuthor{ - Name: String("go-github"), - Email: String("go-github@github.com"), - Date: &Timestamp{date}, - }, - }) + signer := mockSigner(t, "", fmt.Errorf("signer error"), "") + _, err := createSignature(signer, a) if err == nil { - t.Errorf("Expected error to be returned due to invalid key") + t.Errorf("Expected error to be returned because signer returned an error") } } @@ -540,69 +511,10 @@ func TestGitService_CreateCommit_invalidOwner(t *testing.T) { defer teardown() ctx := context.Background() - _, _, err := client.Git.CreateCommit(ctx, "%", "%", &Commit{}) + _, _, err := client.Git.CreateCommit(ctx, "%", "%", &Commit{}, nil) testURLParseError(t, err) } -const testGPGKey = ` ------BEGIN PGP PRIVATE KEY BLOCK----- - -lQOYBFyi1qYBCAD3EPfLJzIt4qkAceUKkhdvfaIvOsBwXbfr5sSu/lkMq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ZRcLiRKZk1up8SCngyolcjVuTuCXDKyAUX1jRqDu7tlN0qVH0CYDGch -BqTKXNkzAvV+CKOyaUILSBBWdef+cxVrDCJuuC3894x3G1FjJycOy0m9PArvGtSG -g7/0Bp9oLXwiHzFoUMDvx+WlPnPHQNcufmQXUNdZvg+Ad4/unEU81EGDBDz3Eg== -=VFSn ------END PGP PRIVATE KEY BLOCK-----` - func TestSignatureVerification_Marshal(t *testing.T) { testJSONMarshal(t, &SignatureVerification{}, "{}") diff --git a/github/repos_commits_test.go b/github/repos_commits_test.go index fb8b45d4439..8fa8eb9f401 100644 --- a/github/repos_commits_test.go +++ b/github/repos_commits_test.go @@ -14,7 +14,6 @@ import ( "testing" "time" - "github.com/ProtonMail/go-crypto/openpgp" "github.com/google/go-cmp/cmp" ) @@ -713,7 +712,6 @@ func TestBranchCommit_Marshal(t *testing.T) { }, NodeID: String("n"), CommentCount: Int(1), - SigningKey: &openpgp.Entity{}, }, Protected: Bool(false), } diff --git a/github/repos_contents_test.go b/github/repos_contents_test.go index f9613069209..91da567f4aa 100644 --- a/github/repos_contents_test.go +++ b/github/repos_contents_test.go @@ -14,7 +14,6 @@ import ( "net/url" "testing" - "github.com/ProtonMail/go-crypto/openpgp" "github.com/google/go-cmp/cmp" ) @@ -885,7 +884,6 @@ func TestRepositoryContentResponse_Marshal(t *testing.T) { }, NodeID: String("n"), CommentCount: Int(1), - SigningKey: &openpgp.Entity{}, }, } diff --git a/go.mod b/go.mod index c41237ead0e..05f97f6f1ff 100644 --- a/go.mod +++ b/go.mod @@ -1,15 +1,8 @@ module github.com/google/go-github/v55 require ( - github.com/ProtonMail/go-crypto v0.0.0-20230217124315-7d5c6f04bbb8 github.com/google/go-cmp v0.5.9 github.com/google/go-querystring v1.1.0 ) -require ( - github.com/cloudflare/circl v1.3.3 // indirect - golang.org/x/crypto v0.12.0 // indirect - golang.org/x/sys v0.11.0 // indirect -) - go 1.17 diff --git a/go.sum b/go.sum index 3317d0c67b7..a2c5fe4a12f 100644 --- a/go.sum +++ b/go.sum @@ -1,24 +1,6 @@ -github.com/ProtonMail/go-crypto v0.0.0-20230217124315-7d5c6f04bbb8 h1:wPbRQzjjwFc0ih8puEVAOFGELsn1zoIIYdxvML7mDxA= -github.com/ProtonMail/go-crypto v0.0.0-20230217124315-7d5c6f04bbb8/go.mod h1:I0gYDMZ6Z5GRU7l58bNFSkPTFN6Yl12dsUlAZ8xy98g= -github.com/bwesterb/go-ristretto v1.2.0/go.mod h1:fUIoIZaG73pV5biE2Blr2xEzDoMj7NFEuV9ekS419A0= -github.com/cloudflare/circl v1.1.0/go.mod h1:prBCrKB9DV4poKZY1l9zBXg2QJY7mvgRvtMxxK7fi4I= -github.com/cloudflare/circl v1.3.3 h1:fE/Qz0QdIGqeWfnwq0RE0R7MI51s0M2E4Ga9kq5AEMs= -github.com/cloudflare/circl v1.3.3/go.mod h1:5XYMA4rFBvNIrhs50XuiBJ15vF2pZn4nnUKZrLbUZFA= github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38= github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/google/go-querystring v1.1.0 h1:AnCroh3fv4ZBgVIf1Iwtovgjaw/GiKJo8M8yD/fhyJ8= github.com/google/go-querystring v1.1.0/go.mod h1:Kcdr2DB4koayq7X8pmAG4sNG59So17icRSOU623lUBU= -golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= -golang.org/x/crypto v0.12.0 h1:tFM/ta59kqch6LlvYnPa0yx5a83cL2nHflFhYKvv9Yk= -golang.org/x/crypto v0.12.0/go.mod h1:NF0Gs7EO5K4qLn+Ylc+fih8BSTeIjAP05siRnAh98yw= -golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= -golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20211007075335-d3039528d8ac/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.11.0 h1:eG7RXZHdqOJ1i+0lgLgCpSXAp6M3LYlAo6osgSi0xOM= -golang.org/x/sys v0.11.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= -golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=