Skip to content

Commit ee708e7

Browse files
authored
Merge branch 'master' into at_specific_time
2 parents 6ca3d15 + 2f6f9f4 commit ee708e7

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+148
-148
lines changed

.github/dependabot.yml

+4
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ updates:
44
directory: /
55
schedule:
66
interval: weekly
7+
groups:
8+
all:
9+
patterns:
10+
- "*" # Group all updates into a single larger pull request.
711

812
- package-ecosystem: gomod
913
directory: /

.github/workflows/codeql.yml

+4-9
Original file line numberDiff line numberDiff line change
@@ -40,17 +40,12 @@ jobs:
4040
# Learn more about CodeQL language support at https://aka.ms/codeql-docs/language-support
4141

4242
steps:
43-
- name: Harden Runner
44-
uses: step-security/harden-runner@a4aa98b93cab29d9b1101a6143fb8bce00e2eac4 # v2.7.1
45-
with:
46-
egress-policy: audit
47-
4843
- name: Checkout repository
49-
uses: actions/checkout@44c2b7a8a4ea60a981eaca3cf939b5f4305c123b # v4.1.5
44+
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
5045

5146
# Initializes the CodeQL tools for scanning.
5247
- name: Initialize CodeQL
53-
uses: github/codeql-action/init@4f0ceda83afa9bc55df7b6c611b81435fa53d987 # v2.25.4
48+
uses: github/codeql-action/init@4fa2a7953630fd2f3fb380f21be14ede0169dd4f # v3.25.12
5449
with:
5550
languages: ${{ matrix.language }}
5651
# If you wish to specify custom queries, you can do so here or in a config file.
@@ -60,7 +55,7 @@ jobs:
6055
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
6156
# If this step fails, then you should remove it and run the build manually (see below)
6257
- name: Autobuild
63-
uses: github/codeql-action/autobuild@4f0ceda83afa9bc55df7b6c611b81435fa53d987 # v2.25.4
58+
uses: github/codeql-action/autobuild@4fa2a7953630fd2f3fb380f21be14ede0169dd4f # v3.25.12
6459

6560
# ℹ️ Command-line programs to run using the OS shell.
6661
# 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun
@@ -73,6 +68,6 @@ jobs:
7368
# ./location_of_script_within_repo/buildscript.sh
7469

7570
- name: Perform CodeQL Analysis
76-
uses: github/codeql-action/analyze@4f0ceda83afa9bc55df7b6c611b81435fa53d987 # v2.25.4
71+
uses: github/codeql-action/analyze@4fa2a7953630fd2f3fb380f21be14ede0169dd4f # v3.25.12
7772
with:
7873
category: "/language:${{matrix.language}}"

.github/workflows/dependency-review.yml

+2-7
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,7 @@ jobs:
1616
dependency-review:
1717
runs-on: ubuntu-latest
1818
steps:
19-
- name: Harden Runner
20-
uses: step-security/harden-runner@a4aa98b93cab29d9b1101a6143fb8bce00e2eac4 # v2.7.1
21-
with:
22-
egress-policy: audit
23-
2419
- name: 'Checkout Repository'
25-
uses: actions/checkout@44c2b7a8a4ea60a981eaca3cf939b5f4305c123b # v4.1.5
20+
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
2621
- name: 'Dependency Review'
27-
uses: actions/dependency-review-action@0c155c5e8556a497adf53f2c18edabf945ed8e70 # v4.3.2
22+
uses: actions/dependency-review-action@5a2ce3f5b92ee19cbb1541a4984c76d921601d7c # v4.3.4

.github/workflows/go.yml

+9-19
Original file line numberDiff line numberDiff line change
@@ -17,19 +17,13 @@ jobs:
1717
env:
1818
GO111MODULE: auto
1919
steps:
20-
21-
- name: Harden Runner
22-
uses: step-security/harden-runner@a4aa98b93cab29d9b1101a6143fb8bce00e2eac4 # v2.7.1
23-
with:
24-
egress-policy: audit
25-
2620
- name: Build
27-
uses: actions/setup-go@bfdd3570ce990073878bf10f6b2d79082de49492 # v2.2.0
21+
uses: actions/setup-go@0a12ed9d6a96ab950c8f026ed9f722fe0da7ef32 # v5.0.2
2822
with:
29-
go-version: '1.19.x'
23+
go-version: '1.22.x'
3024

3125
- name: Check out code into the Go module directory
32-
uses: actions/checkout@44c2b7a8a4ea60a981eaca3cf939b5f4305c123b # v4.1.5
26+
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
3327

3428
- name: Build
3529
run: go build -v ./...
@@ -38,27 +32,23 @@ jobs:
3832
run: go test ./... -race -coverprofile=coverage.txt -covermode=atomic
3933

4034
- name: Coverage
41-
uses: codecov/codecov-action@5ecb98a3c6b747ed38dc09f787459979aebb39be # v4.3.1
35+
uses: codecov/codecov-action@e28ff129e5465c2c0dcc6f003fc735cb6ae0c673 # v4.5.0
36+
env:
37+
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
4238

4339
build-legacy:
4440
name: Build + Test Previous Stable
4541
runs-on: ubuntu-latest
4642
env:
4743
GO111MODULE: auto
4844
steps:
49-
50-
- name: Harden Runner
51-
uses: step-security/harden-runner@a4aa98b93cab29d9b1101a6143fb8bce00e2eac4 # v2.7.1
52-
with:
53-
egress-policy: audit
54-
5545
- name: Build
56-
uses: actions/setup-go@bfdd3570ce990073878bf10f6b2d79082de49492 # v2.2.0
46+
uses: actions/setup-go@0a12ed9d6a96ab950c8f026ed9f722fe0da7ef32 # v5.0.2
5747
with:
58-
go-version: '1.18.x'
48+
go-version: '1.21.x'
5949

6050
- name: Check out code into the Go module directory
61-
uses: actions/checkout@44c2b7a8a4ea60a981eaca3cf939b5f4305c123b # v4.1.5
51+
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
6252

6353
- name: Build
6454
run: go build -v ./...

.github/workflows/scorecards.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ jobs:
3131

3232
steps:
3333
- name: "Checkout code"
34-
uses: actions/checkout@44c2b7a8a4ea60a981eaca3cf939b5f4305c123b # v4.1.5
34+
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
3535
with:
3636
persist-credentials: false
3737

@@ -58,14 +58,14 @@ jobs:
5858
# Upload the results as artifacts (optional). Commenting out will disable uploads of run results in SARIF
5959
# format to the repository Actions tab.
6060
- name: "Upload artifact"
61-
uses: actions/upload-artifact@65462800fd760344b1a7b4382951275a0abb4808 # v4.3.3
61+
uses: actions/upload-artifact@0b2256b8c012f0828dc542b3febcab082c67f72b # v4.3.4
6262
with:
6363
name: SARIF file
6464
path: results.sarif
6565
retention-days: 5
6666

6767
# Upload the results to GitHub's code scanning dashboard.
6868
- name: "Upload to code-scanning"
69-
uses: github/codeql-action/upload-sarif@4f0ceda83afa9bc55df7b6c611b81435fa53d987 # v2.25.4
69+
uses: github/codeql-action/upload-sarif@4fa2a7953630fd2f3fb380f21be14ede0169dd4f # v3.25.12
7070
with:
7171
sarif_file: results.sarif

README.md

+3
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@
55
[![Go Reference](https://pkg.go.dev/badge/github.com/gofrs/uuid/v5.svg)](https://pkg.go.dev/github.com/gofrs/uuid/v5)
66
[![Coverage Status](https://codecov.io/gh/gofrs/uuid/branch/master/graphs/badge.svg?branch=master)](https://codecov.io/gh/gofrs/uuid/)
77
[![Go Report Card](https://goreportcard.com/badge/github.com/gofrs/uuid)](https://goreportcard.com/report/github.com/gofrs/uuid)
8+
[![CodeQL](https://github.com/gofrs/uuid/actions/workflows/codeql.yml/badge.svg)](https://github.com/gofrs/uuid/actions/workflows/codeql.yml)
9+
[![OpenSSF Best Practices](https://www.bestpractices.dev/projects/8929/badge)](https://www.bestpractices.dev/projects/8929)
10+
[![OpenSSF Scorecard](https://api.scorecard.dev/projects/github.com/gofrs/uuid/badge)](https://scorecard.dev/viewer/?uri=github.com/gofrs/uuid)
811

912
Package uuid provides a pure Go implementation of Universally Unique Identifiers
1013
(UUID) variant as defined in RFC-9562. This package supports both the creation

SECURITY.md

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# Security Policy
2+
3+
## Supported Versions
4+
5+
We support the latest version of this library. We do not guarantee support of previous versions. If a defect is reported, it will generally be fixed on the latest version
6+
(provided it exists) irrespective of whether it was introduced in a prior version.
7+
8+
## Reporting a Vulnerability
9+
10+
If you discover a vulnerability against this package, please report it in the issues tab with a `vulnerability` label. We will examine promptly.
11+
12+
If you would like to disclose the vulnerability privately, you may reach the maintainers in our [channel](https://gophers.slack.com/archives/CBP4N9BEU) on the gophers slack.
13+
14+
## Security Scorecard
15+
16+
This project submits security [results](https://scorecard.dev/viewer/?uri=github.com/gofrs/uuid) to the [OpenSSF Scorecard](https://securityscorecards.dev/).
17+
18+
### Actively Maintained
19+
20+
One heuristic these scorecards measure to gauge whether a package is safe for consumption is an "Actively Maintained" metric. Because this library implements UUIDs,
21+
it is very stable - there is not much maintenance required other than adding/updating newer UUID versions, keeping up to date with latest versions of Go, and responding
22+
to reported exploits. As a result, periods of low active maintenance are to be expected.

codec_test.go

+100-21
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,7 @@ package uuid
2323

2424
import (
2525
"bytes"
26-
"flag"
27-
"fmt"
28-
"os"
29-
"path/filepath"
26+
"regexp"
3027
"strings"
3128
"testing"
3229
)
@@ -403,28 +400,110 @@ func BenchmarkParseV4(b *testing.B) {
403400
}
404401
}
405402

406-
var seedFuzzCorpus = flag.Bool("seed_fuzz_corpus", false, "seed fuzz test corpus")
403+
const uuidPattern = "[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}"
407404

408-
func TestSeedFuzzCorpus(t *testing.T) {
409-
// flag.Parse() is called for us by the test binary.
410-
if !*seedFuzzCorpus {
411-
t.Skip("seeding fuzz test corpus only on demand")
405+
var fromBytesCorpus = [][]byte{
406+
{0x6b, 0xa7, 0xb8, 0x10, 0x9d, 0xad, 0x11, 0xd1, 0x80, 0xb4, 0x00, 0xc0, 0x4f, 0xd4, 0x30, 0xc8},
407+
{4, 8, 15, 16, 23, 42},
408+
}
409+
410+
// FuzzFromBytesFunc is a fuzz testing suite that exercises the FromBytes function
411+
func FuzzFromBytesFunc(f *testing.F) {
412+
for _, seed := range fromBytesCorpus {
413+
f.Add(seed)
412414
}
413-
corpusDir := filepath.Join(".", "testdata", "corpus")
414-
writeSeedFile := func(name, data string) error {
415-
path := filepath.Join(corpusDir, name)
416-
return os.WriteFile(path, []byte(data), os.ModePerm)
415+
uuidRegexp, err := regexp.Compile(uuidPattern)
416+
if err != nil {
417+
f.Fatal("uuid regexp failed to compile")
417418
}
418-
for _, fst := range fromStringTests {
419-
name := "seed_valid_" + fst.variant
420-
if err := writeSeedFile(name, fst.input); err != nil {
421-
t.Fatal(err)
419+
f.Fuzz(func(t *testing.T, payload []byte) {
420+
u, err := FromBytes(payload)
421+
if len(payload) != Size && err == nil {
422+
t.Errorf("%v did not result in an error", payload)
423+
}
424+
if len(payload) == Size && u == Nil {
425+
t.Errorf("%v resulted in Nil uuid", payload)
422426
}
427+
if len(payload) == Size && !uuidRegexp.MatchString(u.String()) {
428+
t.Errorf("%v resulted in invalid uuid %s", payload, u.String())
429+
}
430+
// otherwise, allow to pass if no panic
431+
})
432+
}
433+
434+
// FuzzFromBytesOrNilFunc is a fuzz testing suite that exercises the FromBytesOrNil function
435+
func FuzzFromBytesOrNilFunc(f *testing.F) {
436+
for _, seed := range fromBytesCorpus {
437+
f.Add(seed)
423438
}
424-
for i, s := range invalidFromStringInputs {
425-
name := fmt.Sprintf("seed_invalid_%d", i)
426-
if err := writeSeedFile(name, s); err != nil {
427-
t.Fatal(err)
439+
uuidRegexp, err := regexp.Compile(uuidPattern)
440+
if err != nil {
441+
f.Error("uuid regexp failed to compile")
442+
}
443+
f.Fuzz(func(t *testing.T, payload []byte) {
444+
u := FromBytesOrNil(payload)
445+
if len(payload) != Size && u != Nil {
446+
t.Errorf("%v resulted in non Nil uuid %s", payload, u.String())
447+
}
448+
if len(payload) == Size && u == Nil {
449+
t.Errorf("%v resulted Nil uuid", payload)
450+
}
451+
if len(payload) == Size && !uuidRegexp.MatchString(u.String()) {
452+
t.Errorf("%v resulted in invalid uuid %s", payload, u.String())
453+
}
454+
// otherwise, allow to pass if no panic
455+
})
456+
}
457+
458+
var fromStringCorpus = []string{
459+
"6ba7b810-9dad-11d1-80b4-00c04fd430c8",
460+
"6BA7B810-9DAD-11D1-80B4-00C04FD430C8",
461+
"{6BA7B810-9DAD-11D1-80B4-00C04FD430C8}",
462+
"urn:uuid:6BA7B810-9DAD-11D1-80B4-00C04FD430C8",
463+
"6BA7B8109DAD11D180B400C04FD430C8",
464+
"{6BA7B8109DAD11D180B400C04FD430C8}",
465+
"urn:uuid:6BA7B8109DAD11D180B400C04FD430C8",
466+
}
467+
468+
// FuzzFromStringFunc is a fuzz testing suite that exercises the FromString function
469+
func FuzzFromStringFunc(f *testing.F) {
470+
for _, seed := range fromStringCorpus {
471+
f.Add(seed)
472+
}
473+
uuidRegexp, err := regexp.Compile(uuidPattern)
474+
if err != nil {
475+
f.Fatal("uuid regexp failed to compile")
476+
}
477+
f.Fuzz(func(t *testing.T, payload string) {
478+
u, err := FromString(payload)
479+
if err != nil {
480+
if u == Nil {
481+
t.Errorf("%s resulted in Nil uuid", payload)
482+
}
483+
if !uuidRegexp.MatchString(u.String()) {
484+
t.Errorf("%s resulted in invalid uuid %s", payload, u.String())
485+
}
428486
}
487+
// otherwise, allow to pass if no panic
488+
})
489+
}
490+
491+
// FuzzFromStringOrNil is a fuzz testing suite that exercises the FromStringOrNil function
492+
func FuzzFromStringOrNilFunc(f *testing.F) {
493+
for _, seed := range fromStringCorpus {
494+
f.Add(seed)
495+
}
496+
uuidRegexp, err := regexp.Compile(uuidPattern)
497+
if err != nil {
498+
f.Error("uuid regexp failed to compile")
429499
}
500+
f.Fuzz(func(t *testing.T, payload string) {
501+
u := FromStringOrNil(payload)
502+
if u != Nil {
503+
if !uuidRegexp.MatchString(u.String()) {
504+
t.Errorf("%s resulted in invalid uuid %s", payload, u.String())
505+
}
506+
}
507+
// otherwise, allow to pass if no panic
508+
})
430509
}

fuzz.go

-48
This file was deleted.

generator_test.go

+1
Original file line numberDiff line numberDiff line change
@@ -611,6 +611,7 @@ func testNewV7(t *testing.T) {
611611
t.Run("FaultyRand", makeTestNewV7FaultyRand())
612612
t.Run("FaultyRandWithOptions", makeTestNewV7FaultyRandWithOptions())
613613
t.Run("ShortRandomRead", makeTestNewV7ShortRandomRead())
614+
t.Run("ShortRandomReadWithOptions", makeTestNewV7ShortRandomReadWithOptions())
614615
t.Run("KSortable", makeTestNewV7KSortable())
615616
t.Run("ClockSequence", makeTestNewV7ClockSequence())
616617
}

testdata/corpus/1416586f4a34d02bcb506f6107b40df512b9f2f9

-1
This file was deleted.

testdata/corpus/3b46a7e7b02ec193581e6c9fa2c8a72f50a64e08-1

-1
This file was deleted.

testdata/corpus/50c54bb75fcfdc488f162bf2f0c6dec6103bfa18-5

-1
This file was deleted.

testdata/corpus/69c581ab749cbd56be8684d3a58ac2cfab9af0f4-5

-1
This file was deleted.

testdata/corpus/752bf000e0bff06777dd0d6f0be6353844de678a-3

-1
This file was deleted.

testdata/corpus/a4483762d4ece8466d82cca5cacd35a0829c4e60-2

-1
This file was deleted.

testdata/corpus/d0952c45e0c823fc5cc12bcf7d9b877d150ab523-1

-1
This file was deleted.

testdata/corpus/da39a3ee5e6b4b0d3255bfef95601890afd80709

Whitespace-only changes.

testdata/corpus/e2b84d2065846891f18ae109b12e01d224e1c7c3-4

-1
This file was deleted.

0 commit comments

Comments
 (0)