ability to encrypt the .drone.sec file
This commit is contained in:
parent
dc96183f2f
commit
5f802056e0
3 changed files with 13 additions and 2 deletions
|
@ -80,7 +80,7 @@
|
||||||
* @param {string} Plaintext to encrypt.
|
* @param {string} Plaintext to encrypt.
|
||||||
*/
|
*/
|
||||||
this.encrypt = function (repoName, plaintext) {
|
this.encrypt = function (repoName, plaintext) {
|
||||||
return $http.post('/api/repos/' + repoName + '/encrypt', plaintext);
|
return $http.post('/api/repos/' + repoName + '/encrypt', btoa(plaintext));
|
||||||
};
|
};
|
||||||
|
|
||||||
var callback,
|
var callback,
|
||||||
|
|
|
@ -255,6 +255,7 @@ func (r *Runner) Logs(job *types.Job) (io.ReadCloser, error) {
|
||||||
// make sure this container actually exists
|
// make sure this container actually exists
|
||||||
info, err := client.InspectContainer(cname(job))
|
info, err := client.InspectContainer(cname(job))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
||||||
// add a small exponential backoff since there
|
// add a small exponential backoff since there
|
||||||
// is a small window when the container hasn't
|
// is a small window when the container hasn't
|
||||||
// been created yet, but the build is about to start
|
// been created yet, but the build is about to start
|
||||||
|
@ -264,7 +265,9 @@ func (r *Runner) Logs(job *types.Job) (io.ReadCloser, error) {
|
||||||
if err != nil && i == 5 {
|
if err != nil && i == 5 {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
break
|
if err == nil {
|
||||||
|
break
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
package server
|
package server
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"bytes"
|
||||||
|
"encoding/base64"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
|
|
||||||
|
@ -254,6 +256,12 @@ func Encrypt(c *gin.Context) {
|
||||||
c.Fail(500, err)
|
c.Fail(500, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
in, err = base64.StdEncoding.DecodeString(string(in))
|
||||||
|
if err != nil {
|
||||||
|
c.Fail(500, err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
in = bytes.Replace(in, []byte{'\xA0'}, []byte{' '}, -1)
|
||||||
out, err := secure.Encrypt(string(in), repo.Keys.Private)
|
out, err := secure.Encrypt(string(in), repo.Keys.Private)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
c.Fail(500, err)
|
c.Fail(500, err)
|
||||||
|
|
Loading…
Reference in a new issue