From 34e1e3380a06abc8263637e2fc2ddf08404dc966 Mon Sep 17 00:00:00 2001 From: Mariano Cano Date: Mon, 5 Aug 2019 16:14:25 -0700 Subject: [PATCH] Fix lint errors. --- Gopkg.lock | 8 +++++- authority/provisioner/jwk_test.go | 2 ++ authority/provisioner/sign_ssh_options.go | 30 ----------------------- authority/provisioner/ssh_test.go | 3 +++ 4 files changed, 12 insertions(+), 31 deletions(-) diff --git a/Gopkg.lock b/Gopkg.lock index b629b1f1..f27646a9 100644 --- a/Gopkg.lock +++ b/Gopkg.lock @@ -344,15 +344,20 @@ [[projects]] branch = "master" - digest = "1:5dd7da6df07f42194cb25d162b4b89664ed7b08d7d4334f6a288393d54b095ce" + digest = "1:afc49fe39c8c591fc2c8ddc73adc4c69e67125dde6c58e24c91b3b0cf78602be" name = "golang.org/x/crypto" packages = [ "cryptobyte", "cryptobyte/asn1", + "curve25519", "ed25519", "ed25519/internal/edwards25519", + "internal/chacha20", + "internal/subtle", "ocsp", "pbkdf2", + "poly1305", + "ssh", "ssh/terminal", ] pruneopts = "UT" @@ -494,6 +499,7 @@ "github.com/tsenart/deadcode", "github.com/urfave/cli", "golang.org/x/crypto/ocsp", + "golang.org/x/crypto/ssh", "golang.org/x/net/http2", "gopkg.in/square/go-jose.v2", "gopkg.in/square/go-jose.v2/jwt", diff --git a/authority/provisioner/jwk_test.go b/authority/provisioner/jwk_test.go index 9952f7ff..f8f0ff88 100644 --- a/authority/provisioner/jwk_test.go +++ b/authority/provisioner/jwk_test.go @@ -15,6 +15,7 @@ import ( var ( defaultDisableRenewal = false + defaultEnableSSHCA = true globalProvisionerClaims = Claims{ MinTLSDur: &Duration{5 * time.Minute}, MaxTLSDur: &Duration{24 * time.Hour}, @@ -26,6 +27,7 @@ var ( MinHostSSHDur: &Duration{Duration: 5 * time.Minute}, // Host SSH certs MaxHostSSHDur: &Duration{Duration: 30 * 24 * time.Hour}, DefaultHostSSHDur: &Duration{Duration: 30 * 24 * time.Hour}, + EnableSSHCA: &defaultEnableSSHCA, } ) diff --git a/authority/provisioner/sign_ssh_options.go b/authority/provisioner/sign_ssh_options.go index 83f4ee15..bcf0c798 100644 --- a/authority/provisioner/sign_ssh_options.go +++ b/authority/provisioner/sign_ssh_options.go @@ -1,7 +1,6 @@ package provisioner import ( - "fmt" "time" "github.com/pkg/errors" @@ -14,9 +13,6 @@ const ( // SSHHostCert is the string used to represent ssh.HostCert. SSHHostCert = "host" - - // sshProvisionerCommand is the provisioner command - sshProvisionerCommand = "sudo adduser --quiet --disabled-password --gecos '' %s 2>/dev/null ; nc -q0 localhost 22" ) // SSHCertificateModifier is the interface used to change properties in an SSH @@ -191,18 +187,6 @@ func (m *sshDefaultExtensionModifier) Modify(cert *ssh.Certificate) error { } } -type sshProvisionerExtensionModifier string - -func (m sshProvisionerExtensionModifier) Modify(cert *ssh.Certificate) error { - if cert.CertType == ssh.UserCert { - if cert.CriticalOptions == nil { - cert.CriticalOptions = make(map[string]string) - } - cert.CriticalOptions["force-command"] = fmt.Sprintf(sshProvisionerCommand, m) - } - return nil -} - // sshCertificateValidityModifier is a SSHCertificateModifier checks the // validity bounds, setting them if they are not provided. It will fail if a // CertType has not been set or is not valid. @@ -291,20 +275,6 @@ func (v *sshCertificateDefaultValidator) Valid(crt *ssh.Certificate) error { } } -// sshCertTypeName returns the string representation of the given ssh.CertType. -func sshCertTypeString(ct uint32) string { - switch ct { - case 0: - return "" - case ssh.UserCert: - return SSHUserCert - case ssh.HostCert: - return SSHHostCert - default: - return fmt.Sprintf("unknown (%d)", ct) - } -} - // sshCertTypeUInt32 func sshCertTypeUInt32(ct string) uint32 { switch ct { diff --git a/authority/provisioner/ssh_test.go b/authority/provisioner/ssh_test.go index 003f4e9a..1b31f78b 100644 --- a/authority/provisioner/ssh_test.go +++ b/authority/provisioner/ssh_test.go @@ -98,6 +98,9 @@ func signSSHCertificate(key crypto.PublicKey, opts SSHOptions, signOpts []SignOp default: return nil, fmt.Errorf("unexpected ssh certificate type: %d", cert.CertType) } + if err != nil { + return nil, err + } cert.SignatureKey = signer.PublicKey() // Get bytes for signing trailing the signature length.