Skip to content

Commit

Permalink
remove clipboard - pipeline failing and cannot be released
Browse files Browse the repository at this point in the history
  • Loading branch information
pete911 committed Jan 9, 2025
1 parent a6272c3 commit f872ed8
Show file tree
Hide file tree
Showing 128 changed files with 1 addition and 47,153 deletions.
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ certinfo [flags] [<file>|<host:port> ...]
| optional flags |
+---------------+---------------------------------------------------------------------------------------------------+
| -chains | whether to print verified chains as well |
| -clipboard | read input from clipboard (only if the clipboard is supported) |
| -expiry | print expiry of certificates |
| -extensions | whether to print extensions |
| -insecure | whether a client verifies the server's certificate chain and host name (only applicable for host) |
Expand Down
16 changes: 0 additions & 16 deletions flag.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ import (
"fmt"
"os"
"strconv"

"golang.design/x/clipboard"
)

type Flags struct {
Expand All @@ -25,7 +23,6 @@ type Flags struct {
PemOnly bool
Verbose bool
Version bool
Clipboard bool
Args []string
}

Expand Down Expand Up @@ -57,10 +54,6 @@ func ParseFlags() (Flags, error) {
"whether to print pem as well")
flagSet.BoolVar(&flags.PemOnly, "pem-only", getBoolEnv("CERTINFO_PEM_ONLY", false),
"whether to print only pem (useful for downloading certs from host)")
if isClipboardSupported() {
flagSet.BoolVar(&flags.Clipboard, "clipboard", false,
"read input from clipboard")
}
flagSet.BoolVar(&flags.Verbose, "verbose", getBoolEnv("CERTINFO_VERBOSE", false),
"verbose logging")
flagSet.BoolVar(&flags.Version, "version", getBoolEnv("CERTINFO_VERSION", false),
Expand Down Expand Up @@ -99,12 +92,3 @@ func getBoolEnv(envName string, defaultValue bool) bool {
}
return defaultValue
}

func isClipboardSupported() (ok bool) {
defer func() {
if err := recover(); err != nil {
ok = false
}
}()
return clipboard.Init() == nil
}
9 changes: 1 addition & 8 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,10 @@ module github.com/pete911/certinfo

go 1.23

require (
github.com/stretchr/testify v1.10.0
golang.design/x/clipboard v0.7.0
)
require github.com/stretchr/testify v1.10.0

require (
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
golang.org/x/exp/shiny v0.0.0-20241217172543-b2144cdd0a67 // indirect
golang.org/x/image v0.23.0 // indirect
golang.org/x/mobile v0.0.0-20241213221354-a87c1cf6cf46 // indirect
golang.org/x/sys v0.28.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)
10 changes: 0 additions & 10 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,6 @@ github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZb
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA=
github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
golang.design/x/clipboard v0.7.0 h1:4Je8M/ys9AJumVnl8m+rZnIvstSnYj1fvzqYrU3TXvo=
golang.design/x/clipboard v0.7.0/go.mod h1:PQIvqYO9GP29yINEfsEn5zSQKAz3UgXmZKzDA6dnq2E=
golang.org/x/exp/shiny v0.0.0-20241217172543-b2144cdd0a67 h1:bTeFnqCwBClQX8uFRPj1F2t9xnCyUdtJWPxCBG9KUXw=
golang.org/x/exp/shiny v0.0.0-20241217172543-b2144cdd0a67/go.mod h1:3F+MieQB7dRYLTmnncoFbb1crS5lfQoTfDgQy6K4N0o=
golang.org/x/image v0.23.0 h1:HseQ7c2OpPKTPVzNjG5fwJsOTCiiwS4QdsYi5XU6H68=
golang.org/x/image v0.23.0/go.mod h1:wJJBTdLfCCf3tiHa1fNxpZmUI4mmoZvwMCPP0ddoNKY=
golang.org/x/mobile v0.0.0-20241213221354-a87c1cf6cf46 h1:E+R1qmJL8cmWTyWXBHVtmqRxr7FdiTwntffsba1F1Tg=
golang.org/x/mobile v0.0.0-20241213221354-a87c1cf6cf46/go.mod h1:Sf9LBimL0mWKEdgAjRmJ6iu7Z34osHQTK/devqFbM2I=
golang.org/x/sys v0.28.0 h1:Fksou7UEQUWlKvIdsqzJmUmCX3cZuD2+P3XyyzwMhlA=
golang.org/x/sys v0.28.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
Expand Down
4 changes: 0 additions & 4 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,6 @@ func setLogger(verbose bool) {
func LoadCertificatesLocations(flags Flags) cert.CertificateLocations {

var certificateLocations cert.CertificateLocations
if flags.Clipboard {
certificateLocations = append(certificateLocations, cert.LoadCertificateFromClipboard())
}

if len(flags.Args) > 0 {
certificateLocations = append(certificateLocations, loadFromArgs(flags.Args, flags.ServerName, flags.Insecure)...)
}
Expand Down
16 changes: 0 additions & 16 deletions pkg/cert/location.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@ import (
"bytes"
"crypto/tls"
"crypto/x509"
"errors"
"fmt"
"golang.design/x/clipboard"
"io"
"log/slog"
"net"
Expand Down Expand Up @@ -186,20 +184,6 @@ func LoadCertificateFromStdin() CertificateLocation {
return loadCertificate("stdin", content)
}

func LoadCertificateFromClipboard() CertificateLocation {

if err := clipboard.Init(); err != nil {
slog.Error(fmt.Sprintf("load certificate from clipboard: %v", err.Error()))
return CertificateLocation{Path: "clipboard", Error: err}
}

content := clipboard.Read(clipboard.FmtText)
if content == nil {
return CertificateLocation{Path: "clipboard", Error: errors.New("clipboard is empty")}
}
return loadCertificate("clipboard", content)
}

func loadCertificate(fileName string, data []byte) CertificateLocation {

certificates, err := FromBytes(bytes.TrimSpace(data))
Expand Down
16 changes: 0 additions & 16 deletions pkg/cert/location_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import (

"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"golang.design/x/clipboard"
)

func Test_nameFormat(t *testing.T) {
Expand Down Expand Up @@ -46,21 +45,6 @@ func Test_loadCertificate(t *testing.T) {
})
}

func Test_loadCertificateFromClipboard(t *testing.T) {
if err := clipboard.Init(); err != nil {
t.Skip("clipboard not supported in this environment")
}

t.Run("given valid certificate in clipboard then cert is loaded", func(t *testing.T) {
certificate := loadTestFile(t, "cert.pem")
clipboard.Write(clipboard.FmtText, certificate)

cert := LoadCertificateFromClipboard()
require.Equal(t, 1, len(cert.Certificates))
assert.Equal(t, "CN=DigiCert Global Root G2,OU=www.digicert.com,O=DigiCert Inc,C=US", cert.Certificates[0].SubjectString())
})
}

func TestCertificateLocation_SortByExpiry(t *testing.T) {
t.Run("given valid certificate in clipboard then cert is loaded", func(t *testing.T) {
locations := CertificateLocations{
Expand Down
15 changes: 0 additions & 15 deletions vendor/golang.design/x/clipboard/.gitignore

This file was deleted.

13 changes: 0 additions & 13 deletions vendor/golang.design/x/clipboard/Dockerfile

This file was deleted.

21 changes: 0 additions & 21 deletions vendor/golang.design/x/clipboard/LICENSE

This file was deleted.

160 changes: 0 additions & 160 deletions vendor/golang.design/x/clipboard/README.md

This file was deleted.

Loading

0 comments on commit f872ed8

Please sign in to comment.