From 3e4e0fa5aa488ec94d385bf26edf5703e7af292e Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 8 Aug 2023 18:52:08 -0700 Subject: [PATCH] Bump github.com/rs/xid from 1.4.0 to 1.5.0 (#173) Bumps [github.com/rs/xid](https://github.com/rs/xid) from 1.4.0 to 1.5.0. - [Release notes](https://github.com/rs/xid/releases) - [Commits](https://github.com/rs/xid/compare/v1.4.0...v1.5.0) --- updated-dependencies: - dependency-name: github.com/rs/xid dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- go.mod | 2 +- go.sum | 4 +-- vendor/github.com/rs/xid/.golangci.yml | 5 ++++ vendor/github.com/rs/xid/README.md | 3 ++ vendor/github.com/rs/xid/id.go | 41 +++++++++++++------------- vendor/modules.txt | 2 +- 6 files changed, 32 insertions(+), 25 deletions(-) create mode 100644 vendor/github.com/rs/xid/.golangci.yml diff --git a/go.mod b/go.mod index 54c1794a4..3fbf55748 100644 --- a/go.mod +++ b/go.mod @@ -36,7 +36,7 @@ require ( github.com/olekukonko/tablewriter v0.0.5 github.com/pborman/ansi v1.0.0 github.com/prometheus/client_golang v1.14.0 - github.com/rs/xid v1.4.0 + github.com/rs/xid v1.5.0 github.com/sirupsen/logrus v1.9.0 github.com/spf13/cobra v1.7.0 github.com/tj/go v1.8.7 diff --git a/go.sum b/go.sum index 8f8a2b87c..eced3d8a9 100644 --- a/go.sum +++ b/go.sum @@ -315,8 +315,8 @@ github.com/rogpeppe/fastuuid v1.1.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6L github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= github.com/rollbar/rollbar-go v1.0.2 h1:uA3+z0jq6ka9WUUt9VX/xuiQZXZyWRoeKvkhVvLO9Jc= github.com/rollbar/rollbar-go v1.0.2/go.mod h1:AcFs5f0I+c71bpHlXNNDbOWJiKwjFDtISeXco0L5PKQ= -github.com/rs/xid v1.4.0 h1:qd7wPTDkN6KQx2VmMBLrpHkiyQwgFXRnkOLacUiaSNY= -github.com/rs/xid v1.4.0/go.mod h1:trrq9SKmegXys3aeAKXMUTdJsYXVwGY3RLcfgqegfbg= +github.com/rs/xid v1.5.0 h1:mKX4bl4iPYJtEIxp6CYiUuLQ/8DYMoz0PUdtGgMFRVc= +github.com/rs/xid v1.5.0/go.mod h1:trrq9SKmegXys3aeAKXMUTdJsYXVwGY3RLcfgqegfbg= github.com/russross/blackfriday/v2 v2.1.0 h1:JIOH55/0cWyOuilr9/qlrm0BSXldqnqwMsf35Ld67mk= github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= github.com/sergi/go-diff v1.0.0/go.mod h1:0CfEIISq7TuYL3j771MWULgwwjU+GofnZX9QAmXWZgo= diff --git a/vendor/github.com/rs/xid/.golangci.yml b/vendor/github.com/rs/xid/.golangci.yml new file mode 100644 index 000000000..7929600a9 --- /dev/null +++ b/vendor/github.com/rs/xid/.golangci.yml @@ -0,0 +1,5 @@ +run: + tests: false + +output: + sort-results: true diff --git a/vendor/github.com/rs/xid/README.md b/vendor/github.com/rs/xid/README.md index 5bf462e83..974e67d29 100644 --- a/vendor/github.com/rs/xid/README.md +++ b/vendor/github.com/rs/xid/README.md @@ -70,6 +70,9 @@ References: - Ruby port by [Valar](https://github.com/valarpirai/): https://github.com/valarpirai/ruby_xid - Java port by [0xShamil](https://github.com/0xShamil/): https://github.com/0xShamil/java-xid - Dart port by [Peter Bwire](https://github.com/pitabwire): https://pub.dev/packages/xid +- PostgreSQL port by [Rasmus Holm](https://github.com/crholm): https://github.com/modfin/pg-xid +- Swift port by [Uditha Atukorala](https://github.com/uditha-atukorala): https://github.com/uditha-atukorala/swift-xid +- C++ port by [Uditha Atukorala](https://github.com/uditha-atukorala): https://github.com/uditha-atukorala/libxid ## Install diff --git a/vendor/github.com/rs/xid/id.go b/vendor/github.com/rs/xid/id.go index 1f536b415..fcd7a0413 100644 --- a/vendor/github.com/rs/xid/id.go +++ b/vendor/github.com/rs/xid/id.go @@ -43,7 +43,7 @@ package xid import ( "bytes" - "crypto/md5" + "crypto/sha256" "crypto/rand" "database/sql/driver" "encoding/binary" @@ -72,13 +72,11 @@ const ( ) var ( - // objectIDCounter is atomically incremented when generating a new ObjectId - // using NewObjectId() function. It's used as a counter part of an id. - // This id is initialized with a random value. + // objectIDCounter is atomically incremented when generating a new ObjectId. It's + // used as the counter part of an id. This id is initialized with a random value. objectIDCounter = randInt() - // machineId stores machine id generated once and used in subsequent calls - // to NewObjectId function. + // machineID is generated once and used in subsequent calls to the New* functions. machineID = readMachineID() // pid stores the current process id @@ -107,9 +105,9 @@ func init() { } } -// readMachineId generates machine id and puts it into the machineId global -// variable. If this function fails to get the hostname, it will cause -// a runtime error. +// readMachineID generates a machine ID, derived from a platform-specific machine ID +// value, or else the machine's hostname, or else a randomly-generated number. +// It panics if all of these methods fail. func readMachineID() []byte { id := make([]byte, 3) hid, err := readPlatformMachineID() @@ -117,7 +115,7 @@ func readMachineID() []byte { hid, err = os.Hostname() } if err == nil && len(hid) != 0 { - hw := md5.New() + hw := sha256.New() hw.Write([]byte(hid)) copy(id, hw.Sum(nil)) } else { @@ -148,7 +146,7 @@ func NewWithTime(t time.Time) ID { var id ID // Timestamp, 4 bytes, big endian binary.BigEndian.PutUint32(id[:], uint32(t.Unix())) - // Machine, first 3 bytes of md5(hostname) + // Machine ID, 3 bytes id[4] = machineID[0] id[5] = machineID[1] id[6] = machineID[2] @@ -239,6 +237,7 @@ func (id *ID) UnmarshalText(text []byte) error { } } if !decode(id, text) { + *id = nilID return ErrInvalidID } return nil @@ -264,6 +263,10 @@ func decode(id *ID, src []byte) bool { _ = id[11] id[11] = dec[src[17]]<<6 | dec[src[18]]<<1 | dec[src[19]]>>4 + // check the last byte + if encoding[(id[11]<<4)&0x1F] != src[19] { + return false + } id[10] = dec[src[16]]<<3 | dec[src[17]]>>2 id[9] = dec[src[14]]<<5 | dec[src[15]] id[8] = dec[src[12]]<<7 | dec[src[13]]<<2 | dec[src[14]]>>3 @@ -275,16 +278,7 @@ func decode(id *ID, src []byte) bool { id[2] = dec[src[3]]<<4 | dec[src[4]]>>1 id[1] = dec[src[1]]<<6 | dec[src[2]]<<1 | dec[src[3]]>>4 id[0] = dec[src[0]]<<3 | dec[src[1]]>>2 - - // Validate that there are no discarer bits (padding) in src that would - // cause the string-encoded id not to equal src. - var check [4]byte - - check[3] = encoding[(id[11]<<4)&0x1F] - check[2] = encoding[(id[11]>>1)&0x1F] - check[1] = encoding[(id[11]>>6)&0x1F|(id[10]<<2)&0x1F] - check[0] = encoding[id[10]>>3] - return bytes.Equal([]byte(src[16:20]), check[:]) + return true } // Time returns the timestamp part of the id. @@ -344,6 +338,11 @@ func (id ID) IsNil() bool { return id == nilID } +// Alias of IsNil +func (id ID) IsZero() bool { + return id.IsNil() +} + // NilID returns a zero value for `xid.ID`. func NilID() ID { return nilID diff --git a/vendor/modules.txt b/vendor/modules.txt index 3eff0ce23..76a5f1fa4 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -191,7 +191,7 @@ github.com/prometheus/procfs/internal/util # github.com/rollbar/rollbar-go v1.0.2 ## explicit github.com/rollbar/rollbar-go -# github.com/rs/xid v1.4.0 +# github.com/rs/xid v1.5.0 ## explicit; go 1.12 github.com/rs/xid # github.com/russross/blackfriday/v2 v2.1.0