Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
be4b875
fix: github actions permissions (#1059)
JeyJeyGao Oct 8, 2024
1b84cba
fix: fix debug log (#1061)
Oct 14, 2024
43219ae
build(deps): Bump github.com/onsi/gomega from 1.34.1 to 1.34.2 in /te…
dependabot[bot] Oct 15, 2024
4190c31
test: add unit tests (#1075)
Nov 1, 2024
88f39d2
fix: discard crl cache error (#1076)
Nov 5, 2024
cfc9ff6
build(deps): Bump codecov/codecov-action from 4.5.0 to 4.6.0 (#1054)
dependabot[bot] Nov 5, 2024
86c2a59
build(deps): Bump github.com/spf13/cobra from 1.7.0 to 1.8.1 in /test…
dependabot[bot] Nov 5, 2024
511841f
build(deps): Bump golang.org/x/term from 0.24.0 to 0.25.0 (#1055)
dependabot[bot] Nov 5, 2024
5e8ba7c
build(deps): Bump actions/cache from 4.0.2 to 4.1.2 (#1073)
dependabot[bot] Nov 11, 2024
6c94fc5
build(deps): Bump actions/upload-artifact from 4.4.0 to 4.4.3 (#1066)
dependabot[bot] Nov 11, 2024
986f8ae
build(deps): Bump actions/checkout from 4.1.7 to 4.2.2 (#1074)
dependabot[bot] Nov 11, 2024
faf439a
build(deps): Bump github.com/golang-jwt/jwt/v4 from 4.5.0 to 4.5.1 in…
dependabot[bot] Nov 11, 2024
f8c8112
feat: crl cache with log (#1078)
Nov 12, 2024
4dff08d
build(deps): Bump golang.org/x/term from 0.25.0 to 0.26.0 (#1081)
dependabot[bot] Nov 12, 2024
e279f4e
fix&test: discard error for NewFileCache & E2E test for CRL with cach…
JeyJeyGao Nov 13, 2024
5e5685d
build(deps): Bump github.com/golang-jwt/jwt/v4 from 4.5.0 to 4.5.1 (#…
dependabot[bot] Nov 14, 2024
be0bd93
build(deps): Bump github/codeql-action from 3.26.8 to 3.27.1 (#1085)
dependabot[bot] Nov 14, 2024
dfeaeeb
build(deps): Bump goreleaser/goreleaser-action from 6.0.0 to 6.1.0 (#…
dependabot[bot] Nov 14, 2024
afd5918
build(deps): Bump golang.org/x/net from 0.29.0 to 0.31.0 (#1082)
dependabot[bot] Nov 14, 2024
b14d9ab
build(deps): Bump github.com/onsi/gomega from 1.34.2 to 1.35.1 in /te…
dependabot[bot] Nov 27, 2024
9c60adc
build(deps): Bump actions/setup-go from 5.0.2 to 5.1.0 (#1090)
dependabot[bot] Nov 27, 2024
9d0a5a5
build(deps): Bump github/codeql-action from 3.27.1 to 3.27.5 (#1091)
dependabot[bot] Nov 27, 2024
701e906
build(deps): Bump codecov/codecov-action from 4.6.0 to 5.0.7 (#1092)
dependabot[bot] Nov 27, 2024
7eccb42
for v1.3.0-rc.2 release, backport from main
Dec 6, 2024
647447d
bump up
Dec 13, 2024
6168ce9
build(deps): Bump github.com/onsi/ginkgo/v2 from 2.21.0 to 2.22.0 in …
dependabot[bot] Dec 13, 2024
1beafc7
build(deps): Bump golang.org/x/term from 0.26.0 to 0.27.0 (#1098)
dependabot[bot] Dec 13, 2024
e108a7b
build(deps): Bump actions/cache from 4.1.2 to 4.2.0 (#1101)
dependabot[bot] Dec 13, 2024
0e76dd4
build(deps): Bump codecov/codecov-action from 5.0.7 to 5.1.1 (#1102)
dependabot[bot] Dec 13, 2024
3aa71ad
build(deps): Bump github/codeql-action from 3.27.5 to 3.27.6 (#1103)
dependabot[bot] Dec 13, 2024
c3a6d98
build(deps): Bump github.com/notaryproject/tspclient-go from 0.2.1-0.…
dependabot[bot] Dec 13, 2024
32a35a8
build(deps): Bump golang.org/x/net from 0.31.0 to 0.32.0 (#1099)
dependabot[bot] Dec 13, 2024
e51129f
build(deps): Bump github.com/onsi/gomega from 1.35.1 to 1.36.1 in /te…
dependabot[bot] Dec 13, 2024
bd5fd90
bump up
Dec 13, 2024
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
5 changes: 4 additions & 1 deletion .github/.codecov.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,7 @@ coverage:
status:
project:
default:
target: 70%
target: 70%
patch:
default:
target: 80%
8 changes: 4 additions & 4 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,14 @@ jobs:
fail-fast: true
steps:
- name: Set up Go ${{ matrix.go-version }}
uses: actions/setup-go@0a12ed9d6a96ab950c8f026ed9f722fe0da7ef32 # v5.0.2
uses: actions/setup-go@41dfa10bad2bb2ae585af6ee5bb4d7d973ad74ed # v5.1.0
with:
go-version: ${{ matrix.go-version }}
check-latest: true
- name: Check out code
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Cache Go modules
uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4.0.2
uses: actions/cache@1bd1e32a3bdc45362d1e726936510720a7c30a57 # v4.2.0
id: go-mod-cache
with:
path: ~/go/pkg/mod
Expand All @@ -59,6 +59,6 @@ jobs:
make e2e-covdata
fi
- name: Upload coverage to codecov.io
uses: codecov/codecov-action@e28ff129e5465c2c0dcc6f003fc735cb6ae0c673 # v4.5.0
uses: codecov/codecov-action@7f8b4b4bde536c465e797be725718b88c5d95e0e # v5.1.1
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
8 changes: 4 additions & 4 deletions .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,15 @@ jobs:
fail-fast: false
steps:
- name: Checkout repository
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Set up Go ${{ matrix.go-version }} environment
uses: actions/setup-go@0a12ed9d6a96ab950c8f026ed9f722fe0da7ef32 # v5.0.2
uses: actions/setup-go@41dfa10bad2bb2ae585af6ee5bb4d7d973ad74ed # v5.1.0
with:
go-version: ${{ matrix.go-version }}
check-latest: true
- name: Initialize CodeQL
uses: github/codeql-action/init@294a9d92911152fe08befb9ec03e240add280cb3 # v3.26.8
uses: github/codeql-action/init@aa578102511db1f4524ed59b8cc2bae4f6e88195 # v3.27.6
with:
languages: go
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@294a9d92911152fe08befb9ec03e240add280cb3 # v3.26.8
uses: github/codeql-action/analyze@aa578102511db1f4524ed59b8cc2bae4f6e88195 # v3.27.6
5 changes: 1 addition & 4 deletions .github/workflows/license-checker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,4 @@ permissions:

jobs:
check-license:
permissions:
contents: write
pull-requests: write
uses: notaryproject/notation-core-go/.github/workflows/reusable-license-checker.yml@main
uses: notaryproject/notation-core-go/.github/workflows/reusable-license-checker.yml@main
6 changes: 3 additions & 3 deletions .github/workflows/release-github.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,20 +33,20 @@ jobs:
fail-fast: true
steps:
- name: Set up Go ${{ matrix.go-version }}
uses: actions/setup-go@0a12ed9d6a96ab950c8f026ed9f722fe0da7ef32 # v5.0.2
uses: actions/setup-go@41dfa10bad2bb2ae585af6ee5bb4d7d973ad74ed # v5.1.0
with:
go-version: ${{ matrix.go-version }}
check-latest: true
- name: Checkout
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
fetch-depth: 0
- name: Set GoReleaser Previous Tag To Be Last Non Weekly Release
run: |
pre_tag=`git tag --sort=-creatordate --list 'v*' | grep -v dev | head -2 | tail -1`
echo "GORELEASER_PREVIOUS_TAG=$pre_tag" >> $GITHUB_ENV
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@286f3b13b1b49da4ac219696163fb8c1c93e1200 # v6.0.0
uses: goreleaser/goreleaser-action@9ed2f89a662bf1735a48bc8557fd212fa902bebf # v6.1.0
with:
distribution: goreleaser
version: latest
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/scorecard.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ jobs:

steps:
- name: "Checkout code"
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # tag=4.1.7
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # tag=4.2.2
with:
persist-credentials: false

Expand All @@ -54,13 +54,13 @@ jobs:
publish_results: true

- name: "Upload artifact"
uses: actions/upload-artifact@50769540e7f4bd5e21e526ee35c689e35e0d6874 # tag=v4.4.0
uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # tag=v4.4.3
with:
name: SARIF file
path: results.sarif
retention-days: 5

- name: "Upload to code-scanning"
uses: github/codeql-action/upload-sarif@294a9d92911152fe08befb9ec03e240add280cb3 # v3.26.8
uses: github/codeql-action/upload-sarif@aa578102511db1f4524ed59b8cc2bae4f6e88195 # v3.27.6
with:
sarif_file: results.sarif
9 changes: 7 additions & 2 deletions .github/workflows/stale.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,17 @@ on:
schedule:
- cron: "30 1 * * *"

permissions:
contents: read

jobs:
stale:
permissions:
issues: write
pull-requests: write
runs-on: ubuntu-latest
steps:
- uses: actions/stale@v9
- uses: actions/stale@28ca1036281a5e5922ead5184a1bbf96e5fc984e # v9.0.0
with:
stale-issue-message: "This issue is stale because it has been opened for 60 days with no activity. Remove stale label or comment. Otherwise, it will be closed in 30 days."
stale-pr-message: "This PR is stale because it has been opened for 45 days with no activity. Remove stale label or comment. Otherwise, it will be closed in 30 days."
Expand All @@ -31,4 +37,3 @@ jobs:
days-before-issue-close: 30
days-before-pr-close: 30
exempt-all-milestones: true

27 changes: 27 additions & 0 deletions cmd/notation/internal/truststore/testdata/NotationTestRoot.pem
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
-----BEGIN CERTIFICATE-----
MIIEizCCAvOgAwIBAgIBATANBgkqhkiG9w0BAQsFADBaMQswCQYDVQQGEwJ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ARVEZRVqTC5+ZSN2meGBXBXlT4n8FdEdmv+0
5iwVYdmDFp8FKeoOZZZF23u+r2OrazJo1ufWmoSI2P0lEfZQQFQElltWu3QH+OLO
WXJmB7KbLKyheelGK5XhtAYYapRdW4sKJ398ybpv5C1oALCcTwoSmvH8wW5J4/gj
mhKICYh2goMauf0lesdxj+0His7E8blOWrUmfOB5dp73XawLKcd/UxHN8zAPC08L
DL9NMcihn3ZHKi7/dtkiV2iSaDPD1ChSGdqfXIysYqOhYoktgAfBZ43CWnqQhgB8
NezRKdOStYC3P2AGJW18irxxTRp2CO+gnXEcyhyr+cvyf0j8MkRSaHLXzjIrECu8
BUitB6sKughdN13fs5t5SIiO6foeFdvIpZFFKO8s+4oTOSDCos2WFoC+8TZS6r58
3OtFLmywl1HRgQkobGgw
-----END CERTIFICATE-----
1 change: 1 addition & 0 deletions cmd/notation/internal/truststore/testdata/invalid.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
invalid test cert
20 changes: 20 additions & 0 deletions cmd/notation/internal/truststore/testdata/self-signed.crt
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
-----BEGIN CERTIFICATE-----
MIIDPjCCAiagAwIBAgIBeTANBgkqhkiG9w0BAQsFADBOMQswCQYDVQQGEwJVUzEL
MAkGA1UECBMCV0ExEDAOBgNVBAcTB1NlYXR0bGUxDzANBgNVBAoTBk5vdGFyeTEP
MA0GA1UEAxMGYWxwaW5lMB4XDTIzMDUwOTA0NTUxMloXDTMzMDUxMDA0NTUxMlow
TjELMAkGA1UEBhMCVVMxCzAJBgNVBAgTAldBMRAwDgYDVQQHEwdTZWF0dGxlMQ8w
DQYDVQQKEwZOb3RhcnkxDzANBgNVBAMTBmFscGluZTCCASIwDQYJKoZIhvcNAQEB
BQADggEPADCCAQoCggEBAK5hpq1229GGLjMK6i9KZhuUO+SV7rUFnWIDiIPO5yWx
YDkl+bGroeAvJYu6MVCMQ6FMRXD9jhnG6R+sAHwY7gVgcJ1OXak87PkLp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MTBmFscGluZTCCASIwDQYJKoZIhvcNAQEB
BQADggEPADCCAQoCggEBAK5hpq1229GGLjMK6i9KZhuUO+SV7rUFnWIDiIPO5yWx
YDkl+bGroeAvJYu6MVCMQ6FMRXD9jhnG6R+sAHwY7gVgcJ1OXak87PkLp/Ii1Cr7
XkkySZeD+Br1vSQzfxs3pFG+iBCeVVkeZdsg+xqwnAlqAILXwIbTGRyJP1Xiu9nw
OeuX1YmxPl2m29Pt1EtfVCL9COsVKt5LgOVyWP/9ISWevOBqSCU9bk35HFo9VTeU
f6+ffhSMjv0Y9uwkFFOKXpcV8Sa3ArqyBmgQlUfGg1iwYlqiDE0fTYxiB3gLgETA
lmTm50J+WB9LoDrnrQpbXFLoegm+JV+uSD8J8H7DL2sCAwEAAaMnMCUwDgYDVR0P
AQH/BAQDAgeAMBMGA1UdJQQMMAoGCCsGAQUFBwMDMA0GCSqGSIb3DQEBCwUAA4IB
AQAt0Nvna1c4pPn8kzoN5VvmFmeIgdO/BJpmdhdg0WIQ9aeN/xPXXaVjPp1Mk7ed
XHAvBwQr0Gyzqyy7g/h0gdnAFG7f6blrRNzbrRBCq6cNqX8iwgK/9+2OYKxk1QWj
8Gx0cvu1DN1aXjPPGgQ2j3tHjJvJv32J/zuZa8gU40RPPSLaBlc5ZjpFmyi29sKl
TeeZ+F/Ssic51qXXw2CsYGGWK5yQ3xSCxbw6bb2G/s/YI7/KlWg9BktBJHzRu04Z
NR77W7/dyJ3Lj17PlW1XKmMOFHsQivagXeRCbmYZ43fX4ugFRFKL7KE0EgmGOWpJ
0xv+6ig93sqHzQ/0uv1YgFov
-----END CERTIFICATE-----
2 changes: 1 addition & 1 deletion cmd/notation/internal/truststore/truststore.go
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ func DeleteCert(storeType, namedStore, cert string, confirmed bool) error {
return nil
}

// CheckNonErrNotExistError returns nil when no err or err is fs.ErrNotExist
// CheckNonErrNotExistError returns nil when err is nil or err is fs.ErrNotExist
func CheckNonErrNotExistError(err error) error {
if err != nil && !errors.Is(err, fs.ErrNotExist) {
return err
Expand Down
106 changes: 99 additions & 7 deletions cmd/notation/internal/truststore/truststore_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,107 @@ package truststore

import (
"errors"
"os"
"path/filepath"
"runtime"
"strings"
"testing"

"github.com/notaryproject/notation-go/dir"
)

func TestEmptyCertFile(t *testing.T) {
path := filepath.FromSlash("../../../../internal/testdata/Empty.txt")
expectedErr := errors.New("no valid certificate found in the empty file")
err := AddCert(path, "ca", "test", false)
if err == nil || err.Error() != "no valid certificate found in the file" {
t.Fatalf("expected err: %v, got: %v", expectedErr, err)
}
func TestAddCert(t *testing.T) {
defer func(oldDir string) {
dir.UserConfigDir = oldDir
}(dir.UserConfigDir)

t.Run("empty store type", func(t *testing.T) {
expectedErrMsg := "store type cannot be empty"
err := AddCert("", "", "test", false)
if err == nil || err.Error() != expectedErrMsg {
t.Fatalf("expected err: %v, but got: %v", expectedErrMsg, err)
}
})

t.Run("invalid store type", func(t *testing.T) {
expectedErrMsg := "unsupported store type: invalid"
err := AddCert("", "invalid", "test", false)
if err == nil || err.Error() != expectedErrMsg {
t.Fatalf("expected err: %v, but got: %v", expectedErrMsg, err)
}
})

t.Run("invalid store name", func(t *testing.T) {
expectedErrMsg := "named store name needs to follow [a-zA-Z0-9_.-]+ format"
err := AddCert("", "ca", "test%", false)
if err == nil || err.Error() != expectedErrMsg {
t.Fatalf("expected err: %v, but got: %v", expectedErrMsg, err)
}
})

t.Run("no valid certificate in file", func(t *testing.T) {
path := filepath.FromSlash("testdata/invalid.txt")
expectedErrMsg := "x509: malformed certificate"
err := AddCert(path, "ca", "test", false)
if err == nil || err.Error() != expectedErrMsg {
t.Fatalf("expected err: %v, but got: %v", expectedErrMsg, err)
}
})

t.Run("cert already exists", func(t *testing.T) {
dir.UserConfigDir = "testdata"
path := filepath.FromSlash("testdata/self-signed.crt")
expectedErrMsg := "certificate already exists in the Trust Store"
err := AddCert(path, "ca", "test", false)
if err == nil || err.Error() != expectedErrMsg {
t.Fatalf("expected err: %v, but got: %v", expectedErrMsg, err)
}
})

t.Run("empty file", func(t *testing.T) {
path := filepath.FromSlash("../../../../internal/testdata/Empty.txt")
expectedErr := errors.New("no valid certificate found in the empty file")
err := AddCert(path, "ca", "test", false)
if err == nil || err.Error() != "no valid certificate found in the file" {
t.Fatalf("expected err: %v, but got: %v", expectedErr, err)
}
})

t.Run("failed to add cert to store", func(t *testing.T) {
if runtime.GOOS == "windows" {
t.Skip("skipping test on Windows")
}

dir.UserConfigDir = t.TempDir()
if err := os.Chmod(dir.UserConfigDir, 0000); err != nil {
t.Fatal(err)
}
defer os.Chmod(dir.UserConfigDir, 0700)

path := filepath.FromSlash("testdata/NotationTestRoot.pem")
expectedErrMsg := "permission denied"
err := AddCert(path, "ca", "test", false)
if err == nil || !strings.Contains(err.Error(), expectedErrMsg) {
t.Fatalf("expected err: %v, but got: %v", expectedErrMsg, err)
}
})
}

func TestDeleteAllCerts(t *testing.T) {
defer func(oldDir string) {
dir.UserConfigDir = oldDir
}(dir.UserConfigDir)

t.Run("store does not exist", func(t *testing.T) {
if runtime.GOOS == "windows" {
t.Skip("skipping test on Windows")
}

dir.UserConfigDir = "testdata"
expectedErrMsg := `stat testdata/truststore/x509/tsa/test: no such file or directory`
err := DeleteAllCerts("tsa", "test", true)
if err == nil || err.Error() != expectedErrMsg {
t.Fatalf("expected err: %v, but got: %v", expectedErrMsg, err)
}
})
}
2 changes: 1 addition & 1 deletion cmd/notation/plugin/install.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ func install(command *cobra.Command, opts *pluginInstallOpts) error {
}
pluginURL, err := url.Parse(opts.pluginSource)
if err != nil {
return fmt.Errorf("failed to parse plugin download URL %s with error: %w", pluginURL, err)
return fmt.Errorf("failed to parse plugin download URL %s with error: %w", opts.pluginSource, err)
}
if pluginURL.Scheme != "https" {
return fmt.Errorf("failed to download plugin from URL: only the HTTPS scheme is supported, but got %s", pluginURL.Scheme)
Expand Down
Loading