Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(deps): update module github.com/oklog/ulid/v2 to v2.1.0 #232

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -5,7 +5,7 @@ go 1.20
require (
github.com/cenkalti/backoff/v4 v4.2.1
github.com/gorilla/websocket v1.4.2
github.com/oklog/ulid/v2 v2.0.2
github.com/oklog/ulid/v2 v2.1.0
github.com/stretchr/testify v1.7.0
google.golang.org/protobuf v1.27.1
)
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
@@ -9,8 +9,8 @@ github.com/google/go-cmp v0.5.6 h1:BKbKCqvP6I+rmFHt06ZmyQtvB8xAkWdhFyr0ZUNZcxQ=
github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/gorilla/websocket v1.4.2 h1:+/TMaTYc4QFitKJxsQ7Yye35DkWvkdLcvGKqM+x0Ufc=
github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
github.com/oklog/ulid/v2 v2.0.2 h1:r4fFzBm+bv0wNKNh5eXTwU7i85y5x+uwkxCUTNVQqLc=
github.com/oklog/ulid/v2 v2.0.2/go.mod h1:mtBL0Qe/0HAx6/a4Z30qxVIAL1eQDweXq5lxOEiwQ68=
github.com/oklog/ulid/v2 v2.1.0 h1:+9lhoxAP56we25tyYETBBY1YLA2SaoLvUFgrP2miPJU=
github.com/oklog/ulid/v2 v2.1.0/go.mod h1:rcEKHmBBKfef9DhnvX7y1HZBYxjXb0cP5ExxNsTT1QQ=
github.com/pborman/getopt v0.0.0-20170112200414-7148bc3a4c30/go.mod h1:85jBQOZwpVEaDAr341tbn15RS4fCAsIst0qp7i8ex1o=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
2 changes: 1 addition & 1 deletion internal/examples/go.mod
Original file line number Diff line number Diff line change
@@ -5,7 +5,7 @@ go 1.20
require (
github.com/cenkalti/backoff/v4 v4.2.1
github.com/knadh/koanf v1.3.3
github.com/oklog/ulid/v2 v2.0.2
github.com/oklog/ulid/v2 v2.1.0
github.com/open-telemetry/opamp-go v0.1.0
github.com/shirou/gopsutil v3.21.11+incompatible
github.com/stretchr/testify v1.7.0
4 changes: 2 additions & 2 deletions internal/examples/go.sum
Original file line number Diff line number Diff line change
@@ -130,8 +130,8 @@ github.com/mitchellh/reflectwalk v1.0.2 h1:G2LzWKi524PWgd3mLHV8Y5k7s6XUvT0Gef6zx
github.com/mitchellh/reflectwalk v1.0.2/go.mod h1:mSTlrgnPZtwu0c4WaC2kGObEpuNDbx0jmZXqmk4esnw=
github.com/npillmayer/nestext v0.1.3/go.mod h1:h2lrijH8jpicr25dFY+oAJLyzlya6jhnuG+zWp9L0Uk=
github.com/oklog/run v1.0.0/go.mod h1:dlhp/R75TPv97u0XWUtDeV/lRKWPKSdTuV0TZvrmrQA=
github.com/oklog/ulid/v2 v2.0.2 h1:r4fFzBm+bv0wNKNh5eXTwU7i85y5x+uwkxCUTNVQqLc=
github.com/oklog/ulid/v2 v2.0.2/go.mod h1:mtBL0Qe/0HAx6/a4Z30qxVIAL1eQDweXq5lxOEiwQ68=
github.com/oklog/ulid/v2 v2.1.0 h1:+9lhoxAP56we25tyYETBBY1YLA2SaoLvUFgrP2miPJU=
github.com/oklog/ulid/v2 v2.1.0/go.mod h1:rcEKHmBBKfef9DhnvX7y1HZBYxjXb0cP5ExxNsTT1QQ=
github.com/pascaldekloe/goe v0.1.0/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc=
github.com/pborman/getopt v0.0.0-20170112200414-7148bc3a4c30/go.mod h1:85jBQOZwpVEaDAr341tbn15RS4fCAsIst0qp7i8ex1o=
github.com/pelletier/go-toml v1.7.0 h1:7utD74fnzVc/cpcyy8sjrlFr5vYpypUixARcHIMIGuI=

Unchanged files with check annotations Beta

}
if c.Capabilities&protobufs.AgentCapabilities_AgentCapabilities_ReportsHealth != 0 && c.ClientSyncedState.Health() == nil {
return ErrHealthMissing

Check warning on line 87 in client/internal/clientcommon.go

Codecov / codecov/patch

client/internal/clientcommon.go#L87

Added line #L87 was not covered by tests
}
// Prepare remote config status.
r, err := http.NewRequestWithContext(ctx, OpAMPPlainHTTPMethod, h.url, nil)
if err != nil {
return nil, err
}

Check warning on line 235 in client/internal/httpsender.go

Codecov / codecov/patch

client/internal/httpsender.go#L234-L235

Added lines #L234 - L235 were not covered by tests
req := requestWrapper{Request: r}
if h.compressionEnabled {
u, err := url.Parse(srv.srv.URL)
if err != nil {
t.Fatal(err)
}

Check warning on line 95 in client/internal/mockserver.go

Codecov / codecov/patch

client/internal/mockserver.go#L94-L95

Added lines #L94 - L95 were not covered by tests
srv.Endpoint = u.Host
testhelpers.WaitForEndpoint(srv.Endpoint)
err = s.localState.UpdateContent(ctx, pkgName, resp.Body, file.ContentHash)
if err != nil {
return fmt.Errorf("failed to install/update the package %s downloaded from %s: %v", pkgName, file.DownloadUrl, err)

Check warning on line 281 in client/internal/packagessyncer.go

Codecov / codecov/patch

client/internal/packagessyncer.go#L281

Added line #L281 was not covered by tests
}
return nil
}
err := r.sender.SetInstanceUid(agentId.NewInstanceUid)
if err != nil {
r.logger.Errorf("Error while setting instance uid: %v", err)

Check warning on line 220 in client/internal/receivedprocessor.go

Codecov / codecov/patch

client/internal/receivedprocessor.go#L220

Added line #L220 was not covered by tests
return err
}
"github.com/open-telemetry/opamp-go/protobufs"
)
func CreateClientTLSConfig(clientCert *tls.Certificate, caCertPath string) (*tls.Config, error) {
// Read the CA's public key. This is the CA that signs the server's certificate.
caCertBytes, err := os.ReadFile(caCertPath)
if err != nil {
return nil, err
}

Check warning on line 32 in internal/certs.go

Codecov / codecov/patch

internal/certs.go#L27-L32

Added lines #L27 - L32 were not covered by tests
// Create a certificate pool and make our CA trusted.
caCertPool := x509.NewCertPool()
if ok := caCertPool.AppendCertsFromPEM(caCertBytes); !ok {
return nil, errors.New("cannot append ca.cert.pem")
}

Check warning on line 38 in internal/certs.go

Codecov / codecov/patch

internal/certs.go#L35-L38

Added lines #L35 - L38 were not covered by tests
cfg := &tls.Config{
RootCAs: caCertPool,
}
if clientCert != nil {
// If there is a client-side certificate use it for connection too.
cfg.Certificates = []tls.Certificate{*clientCert}
}
return cfg, nil

Check warning on line 47 in internal/certs.go

Codecov / codecov/patch

internal/certs.go#L40-L47

Added lines #L40 - L47 were not covered by tests
}
func CreateServerTLSConfig(caCertPath, serverCertPath, serverKeyPath string) (*tls.Config, error) {
// Read the CA's public key. This is the CA that signs the server's certificate.
caCertBytes, err := os.ReadFile(caCertPath)
if err != nil {
return nil, err
}

Check warning on line 55 in internal/certs.go

Codecov / codecov/patch

internal/certs.go#L50-L55

Added lines #L50 - L55 were not covered by tests
// Create a certificate pool and make our CA trusted.
caCertPool := x509.NewCertPool()
if ok := caCertPool.AppendCertsFromPEM(caCertBytes); !ok {
return nil, errors.New("cannot append ca.cert.pem")
}

Check warning on line 61 in internal/certs.go

Codecov / codecov/patch

internal/certs.go#L58-L61

Added lines #L58 - L61 were not covered by tests
// Load server's certificate.
cert, err := tls.LoadX509KeyPair(
serverCertPath,
serverKeyPath,
)
if err != nil {
return nil, fmt.Errorf("tls.LoadX509KeyPair failed: %v", err)
}
tlsConfig := &tls.Config{
Certificates: []tls.Certificate{cert},
// TODO: verify client cert manually, and allow TOFU option. See manual
// verification example: https://dev.to/living_syn/validating-client-certificate-sans-in-go-i5p
// Instead, we use VerifyClientCertIfGiven which will automatically verify the provided certificate
// is signed by our CA (so TOFU with self-generated client certificate will not work).
ClientAuth: tls.VerifyClientCertIfGiven,
// Allow insecure connections for demo purposes.
InsecureSkipVerify: true,
ClientCAs: caCertPool,
}
tlsConfig.BuildNameToCertificate()
return tlsConfig, nil

Check warning on line 83 in internal/certs.go

Codecov / codecov/patch

internal/certs.go#L64-L83

Added lines #L64 - L83 were not covered by tests
}
func CreateTLSCert(caCertPath, caKeyPath string) (*protobufs.TLSCertificate, error) {
// Load CA Cert.
caCertBytes, err := ioutil.ReadFile(caCertPath)
if err != nil {
return nil, fmt.Errorf("cannot read CA cert: %v", err)
}

Check warning on line 92 in internal/certs.go

Codecov / codecov/patch

internal/certs.go#L86-L92

Added lines #L86 - L92 were not covered by tests
caKeyBytes, err := ioutil.ReadFile(caKeyPath)
if err != nil {
return nil, fmt.Errorf("cannot read CA key: %v", err)
}

Check warning on line 97 in internal/certs.go

Codecov / codecov/patch

internal/certs.go#L94-L97

Added lines #L94 - L97 were not covered by tests
caCertPB, _ := pem.Decode(caCertBytes)
caKeyPB, _ := pem.Decode(caKeyBytes)
caCert, err := x509.ParseCertificate(caCertPB.Bytes)
if err != nil {
return nil, fmt.Errorf("cannot parse CA cert: %v", err)
}

Check warning on line 104 in internal/certs.go

Codecov / codecov/patch

internal/certs.go#L99-L104

Added lines #L99 - L104 were not covered by tests
caPrivKey, err := x509.ParsePKCS1PrivateKey(caKeyPB.Bytes)
if err != nil {
return nil, fmt.Errorf("cannot parse CA key: %v", err)
}

Check warning on line 109 in internal/certs.go

Codecov / codecov/patch

internal/certs.go#L106-L109

Added lines #L106 - L109 were not covered by tests
// Generate a private key for new client cert.
certPrivKey, err := rsa.GenerateKey(rand.Reader, 4096)
if err != nil {
err := fmt.Errorf("cannot generate private key: %v", err)
return nil, err
}

Check warning on line 116 in internal/certs.go

Codecov / codecov/patch

internal/certs.go#L112-L116

Added lines #L112 - L116 were not covered by tests
// Prepare certificate template.
template := &x509.Certificate{
SerialNumber: big.NewInt(1),
Subject: pkix.Name{
CommonName: "OpAMP Example Client",
Organization: []string{"OpAMP Example"},
Country: []string{"CA"},
Province: []string{"ON"},
Locality: []string{"City"},
StreetAddress: []string{""},
PostalCode: []string{""},
},
IPAddresses: []net.IP{net.IPv4(127, 0, 0, 1)},
NotBefore: time.Now(),
NotAfter: time.Now().Add(time.Hour * 1000),
ExtKeyUsage: []x509.ExtKeyUsage{x509.ExtKeyUsageClientAuth, x509.ExtKeyUsageServerAuth},
KeyUsage: x509.KeyUsageDigitalSignature,
}
// Create the client cert. Sign it using CA cert.
certBytes, err := x509.CreateCertificate(rand.Reader, template, caCert, &certPrivKey.PublicKey, caPrivKey)
if err != nil {
err := fmt.Errorf("cannot create certificate: %v", err)
return nil, err
}

Check warning on line 142 in internal/certs.go

Codecov / codecov/patch

internal/certs.go#L119-L142

Added lines #L119 - L142 were not covered by tests
publicKeyPEM := new(bytes.Buffer)
pem.Encode(publicKeyPEM, &pem.Block{
Type: "CERTIFICATE",
Bytes: certBytes,
})
privateKeyPEM := new(bytes.Buffer)
pem.Encode(privateKeyPEM, &pem.Block{
Type: "RSA PRIVATE KEY",
Bytes: x509.MarshalPKCS1PrivateKey(certPrivKey),
})
// We have a client certificate with a public and private key.
certificate := &protobufs.TLSCertificate{
PublicKey: publicKeyPEM.Bytes(),
PrivateKey: privateKeyPEM.Bytes(),
CaPublicKey: caCertBytes,
}
return certificate, nil

Check warning on line 163 in internal/certs.go

Codecov / codecov/patch

internal/certs.go#L144-L163

Added lines #L144 - L163 were not covered by tests
}
conn net.Conn
}
func (c httpConnection) Connection() net.Conn {
return c.conn

Check warning on line 27 in server/httpconnection.go

Codecov / codecov/patch

server/httpconnection.go#L26-L27

Added lines #L26 - L27 were not covered by tests
}
var _ types.Connection = (*httpConnection)(nil)