mirror of
https://github.com/GoogleContainerTools/kaniko
synced 2026-10-07 20:10:50 +02:00
chore(deps): bump google.golang.org/api from 0.142.0 to 0.143.0 (#2769)
Bumps [google.golang.org/api](https://github.com/googleapis/google-api-go-client) from 0.142.0 to 0.143.0. - [Release notes](https://github.com/googleapis/google-api-go-client/releases) - [Changelog](https://github.com/googleapis/google-api-go-client/blob/main/CHANGES.md) - [Commits](https://github.com/googleapis/google-api-go-client/compare/v0.142.0...v0.143.0) --- updated-dependencies: - dependency-name: google.golang.org/api dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
This commit is contained in:
+38
-4
@@ -35,6 +35,8 @@ import (
|
||||
const signAPI = "EnterpriseCertSigner.Sign"
|
||||
const certificateChainAPI = "EnterpriseCertSigner.CertificateChain"
|
||||
const publicKeyAPI = "EnterpriseCertSigner.Public"
|
||||
const encryptAPI = "EnterpriseCertSigner.Encrypt"
|
||||
const decryptAPI = "EnterpriseCertSigner.Decrypt"
|
||||
|
||||
// A Connection wraps a pair of unidirectional streams as an io.ReadWriteCloser.
|
||||
type Connection struct {
|
||||
@@ -54,13 +56,28 @@ func (c *Connection) Close() error {
|
||||
|
||||
func init() {
|
||||
gob.Register(crypto.SHA256)
|
||||
gob.Register(crypto.SHA384)
|
||||
gob.Register(crypto.SHA512)
|
||||
gob.Register(&rsa.PSSOptions{})
|
||||
gob.Register(&rsa.OAEPOptions{})
|
||||
}
|
||||
|
||||
// SignArgs contains arguments to a crypto Signer.Sign method.
|
||||
// SignArgs contains arguments for a Sign API call.
|
||||
type SignArgs struct {
|
||||
Digest []byte // The content to sign.
|
||||
Opts crypto.SignerOpts // Options for signing, such as Hash identifier.
|
||||
Opts crypto.SignerOpts // Options for signing. Must implement HashFunc().
|
||||
}
|
||||
|
||||
// EncryptArgs contains arguments for an Encrypt API call.
|
||||
type EncryptArgs struct {
|
||||
Plaintext []byte // The plaintext to encrypt.
|
||||
Opts any // Options for encryption. Ex: an instance of crypto.Hash.
|
||||
}
|
||||
|
||||
// DecryptArgs contains arguments to for a Decrypt API call.
|
||||
type DecryptArgs struct {
|
||||
Ciphertext []byte // The ciphertext to decrypt.
|
||||
Opts crypto.DecrypterOpts // Options for decryption. Ex: an instance of *rsa.OAEPOptions.
|
||||
}
|
||||
|
||||
// Key implements credential.Credential by holding the executed signer subprocess.
|
||||
@@ -98,7 +115,7 @@ func (k *Key) Public() crypto.PublicKey {
|
||||
return k.publicKey
|
||||
}
|
||||
|
||||
// Sign signs a message digest, using the specified signer options.
|
||||
// Sign signs a message digest, using the specified signer opts. Implements crypto.Signer interface.
|
||||
func (k *Key) Sign(_ io.Reader, digest []byte, opts crypto.SignerOpts) (signed []byte, err error) {
|
||||
if opts != nil && opts.HashFunc() != 0 && len(digest) != opts.HashFunc().Size() {
|
||||
return nil, fmt.Errorf("Digest length of %v bytes does not match Hash function size of %v bytes", len(digest), opts.HashFunc().Size())
|
||||
@@ -107,6 +124,18 @@ func (k *Key) Sign(_ io.Reader, digest []byte, opts crypto.SignerOpts) (signed [
|
||||
return
|
||||
}
|
||||
|
||||
// Encrypt encrypts a plaintext msg into ciphertext, using the specified encrypt opts.
|
||||
func (k *Key) Encrypt(_ io.Reader, msg []byte, opts any) (ciphertext []byte, err error) {
|
||||
err = k.client.Call(encryptAPI, EncryptArgs{Plaintext: msg, Opts: opts}, &ciphertext)
|
||||
return
|
||||
}
|
||||
|
||||
// Decrypt decrypts a ciphertext msg into plaintext, using the specified decrypter opts. Implements crypto.Decrypter interface.
|
||||
func (k *Key) Decrypt(_ io.Reader, msg []byte, opts crypto.DecrypterOpts) (plaintext []byte, err error) {
|
||||
err = k.client.Call(decryptAPI, DecryptArgs{Ciphertext: msg, Opts: opts}, &plaintext)
|
||||
return
|
||||
}
|
||||
|
||||
// ErrCredUnavailable is a sentinel error that indicates ECP Cred is unavailable,
|
||||
// possibly due to missing config or missing binary path.
|
||||
var ErrCredUnavailable = errors.New("Cred is unavailable")
|
||||
@@ -120,7 +149,12 @@ var ErrCredUnavailable = errors.New("Cred is unavailable")
|
||||
// The config file also specifies which certificate the signer should use.
|
||||
func Cred(configFilePath string) (*Key, error) {
|
||||
if configFilePath == "" {
|
||||
configFilePath = util.GetDefaultConfigFilePath()
|
||||
envFilePath := util.GetConfigFilePathFromEnv()
|
||||
if envFilePath != "" {
|
||||
configFilePath = envFilePath
|
||||
} else {
|
||||
configFilePath = util.GetDefaultConfigFilePath()
|
||||
}
|
||||
}
|
||||
enterpriseCertSignerPath, err := util.LoadSignerBinaryPath(configFilePath)
|
||||
if err != nil {
|
||||
|
||||
+9
@@ -22,6 +22,7 @@ import (
|
||||
"os/user"
|
||||
"path/filepath"
|
||||
"runtime"
|
||||
"strings"
|
||||
)
|
||||
|
||||
const configFileName = "certificate_config.json"
|
||||
@@ -63,6 +64,9 @@ func LoadSignerBinaryPath(configFilePath string) (path string, err error) {
|
||||
if signerBinaryPath == "" {
|
||||
return "", ErrConfigUnavailable
|
||||
}
|
||||
|
||||
signerBinaryPath = strings.ReplaceAll(signerBinaryPath, "~", guessHomeDir())
|
||||
signerBinaryPath = strings.ReplaceAll(signerBinaryPath, "$HOME", guessHomeDir())
|
||||
return signerBinaryPath, nil
|
||||
}
|
||||
|
||||
@@ -89,3 +93,8 @@ func getDefaultConfigFileDirectory() (directory string) {
|
||||
func GetDefaultConfigFilePath() (path string) {
|
||||
return filepath.Join(getDefaultConfigFileDirectory(), configFileName)
|
||||
}
|
||||
|
||||
// GetConfigFilePathFromEnv returns the path associated with environment variable GOOGLE_API_CERTIFICATE_CONFIG
|
||||
func GetConfigFilePathFromEnv() (path string) {
|
||||
return os.Getenv("GOOGLE_API_CERTIFICATE_CONFIG")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user