Skip to content

Commit ef6d62c

Browse files
Merge branch 'main' into TPT-3370-lke-e
2 parents d725432 + 857b24b commit ef6d62c

File tree

11 files changed

+103
-13
lines changed

11 files changed

+103
-13
lines changed

.github/workflows/codeql.yml

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
name: "CodeQL Advanced"
2+
3+
on:
4+
push:
5+
branches: [ "dev", "main", "proj/*" ]
6+
pull_request:
7+
branches: [ "dev", "main", "proj/*" ]
8+
schedule:
9+
- cron: '39 0 * * 6'
10+
11+
jobs:
12+
analyze:
13+
name: Analyze (${{ matrix.language }})
14+
runs-on: ubuntu-latest
15+
permissions:
16+
# required for all workflows
17+
security-events: write
18+
19+
# required to fetch internal or private CodeQL packs
20+
packages: read
21+
22+
# only required for workflows in private repositories
23+
actions: read
24+
contents: read
25+
26+
strategy:
27+
fail-fast: false
28+
matrix:
29+
include:
30+
- language: go
31+
build-mode: autobuild
32+
steps:
33+
- name: Checkout repository
34+
uses: actions/checkout@v4
35+
36+
- name: Initialize CodeQL
37+
uses: github/codeql-action/init@v3
38+
with:
39+
languages: ${{ matrix.language }}
40+
build-mode: ${{ matrix.build-mode }}
41+
queries: security-and-quality
42+
43+
- name: Perform CodeQL Analysis
44+
uses: github/codeql-action/analyze@v3
45+
with:
46+
category: "/language:${{matrix.language}}"
Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,21 @@
1-
name: Gosec Scan
1+
name: Security Checks for Pull Requests
22
on:
33
pull_request: null
44

55
jobs:
6+
dependency-review:
7+
permissions:
8+
contents: read
9+
pull-requests: write
10+
runs-on: ubuntu-latest
11+
steps:
12+
- name: 'Checkout repository'
13+
uses: actions/checkout@v4
14+
- name: 'Dependency Review'
15+
uses: actions/dependency-review-action@v4
16+
with:
17+
comment-summary-in-pr: on-failure
18+
619
gosec_scan:
720
runs-on: ubuntu-latest
821
env:

client.go

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -738,7 +738,7 @@ func NewClient(hc *http.Client) (client Client) {
738738

739739
certPath, certPathExists := os.LookupEnv(APIHostCert)
740740

741-
if certPathExists && !isCustomTransport(hc.Transport) {
741+
if certPathExists && !hasCustomTransport(hc) {
742742
cert, err := os.ReadFile(filepath.Clean(certPath))
743743
if err != nil {
744744
log.Fatalf("[ERROR] Error when reading cert at %s: %s\n", certPath, err.Error())
@@ -881,8 +881,11 @@ func generateListCacheURL(endpoint string, opts *ListOptions) (string, error) {
881881
return fmt.Sprintf("%s:%s", endpoint, hashedOpts), nil
882882
}
883883

884-
func isCustomTransport(transport http.RoundTripper) bool {
885-
if transport != http.DefaultTransport.(*http.Transport) {
884+
func hasCustomTransport(hc *http.Client) bool {
885+
if hc == nil {
886+
return false
887+
}
888+
if hc.Transport != http.DefaultTransport.(*http.Transport) {
886889
log.Println("[WARN] Custom transport is not allowed with a custom root CA.")
887890
return true
888891
}

client_test.go

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -576,3 +576,30 @@ func TestClient_CustomRootCAWithCustomRoundTripper(t *testing.T) {
576576

577577
log.SetOutput(os.Stderr)
578578
}
579+
580+
func TestClient_CustomRootCAWithoutCustomRoundTripper(t *testing.T) {
581+
caFile, err := os.CreateTemp(t.TempDir(), "linodego_test_ca_*")
582+
if err != nil {
583+
t.Fatalf("Failed to create temp ca file: %s", err)
584+
}
585+
defer os.Remove(caFile.Name())
586+
587+
for _, setCA := range []bool{false, true} {
588+
if setCA {
589+
t.Setenv(APIHostCert, caFile.Name())
590+
}
591+
592+
client := NewClient(nil)
593+
594+
transport, err := client.resty.Transport()
595+
if err != nil {
596+
t.Fatal(err)
597+
}
598+
if setCA && (transport.TLSClientConfig == nil || transport.TLSClientConfig.RootCAs == nil) {
599+
t.Error("expected root CAs to be set")
600+
}
601+
if !setCA && transport.TLSClientConfig != nil {
602+
t.Errorf("didn't set a custom CA, but client TLS config is not nil: %#v", transport.TLSClientConfig)
603+
}
604+
}
605+
}

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ require (
55
github.com/google/go-cmp v0.6.0
66
github.com/google/go-querystring v1.1.0
77
github.com/jarcoal/httpmock v1.3.1
8-
golang.org/x/net v0.32.0
8+
golang.org/x/net v0.33.0
99
golang.org/x/oauth2 v0.24.0
1010
golang.org/x/text v0.21.0
1111
gopkg.in/ini.v1 v1.66.6

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZb
1515
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
1616
github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA=
1717
github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
18-
golang.org/x/net v0.32.0 h1:ZqPmj8Kzc+Y6e0+skZsuACbx+wzMgo5MQsJh9Qd6aYI=
19-
golang.org/x/net v0.32.0/go.mod h1:CwU0IoeOlnQQWJ6ioyFrfRuomB8GKF6KbYXZVyeXNfs=
18+
golang.org/x/net v0.33.0 h1:74SYHlV8BIgHIFC/LrYkOGIwL19eTYXQ5wc6TBuO36I=
19+
golang.org/x/net v0.33.0/go.mod h1:HXLR5J+9DxmrqMwG9qjGCxZ+zKXxBru04zlTvWlWuN4=
2020
golang.org/x/oauth2 v0.24.0 h1:KTBBxWqUa0ykRPLtV69rRto9TLXcqYkeswu48x/gvNE=
2121
golang.org/x/oauth2 v0.24.0/go.mod h1:XYTD2NtWslqkgxebSiOHnXEap4TF09sJSc7H1sXbhtI=
2222
golang.org/x/text v0.21.0 h1:zyQAAkrwaneQ066sspRyJaG9VNi/YJ1NfzcGB3hZ/qo=

go.work.sum

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ golang.org/x/crypto v0.28.0/go.mod h1:rmgy+3RHxRZMyY0jjAJShp2zgEdOqj2AO7U0pYmeQ7
4545
golang.org/x/crypto v0.29.0/go.mod h1:+F4F4N5hv6v38hfeYwTdx20oUvLLc+QfrE9Ax9HtgRg=
4646
golang.org/x/crypto v0.30.0 h1:RwoQn3GkWiMkzlX562cLB7OxWvjH1L8xutO2WoJcRoY=
4747
golang.org/x/crypto v0.30.0/go.mod h1:kDsLvtWBEx7MV9tJOj9bnXsPbxwJQ6csT/x4KIN4Ssk=
48+
golang.org/x/crypto v0.31.0/go.mod h1:kDsLvtWBEx7MV9tJOj9bnXsPbxwJQ6csT/x4KIN4Ssk=
4849
golang.org/x/mod v0.17.0 h1:zY54UmvipHiNd+pm+m0x9KhZ9hl1/7QNMyxXbc6ICqA=
4950
golang.org/x/mod v0.17.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c=
5051
golang.org/x/net v0.27.0/go.mod h1:dDi0PyhWNoiUOrAS8uXv/vnScO4wnHQO4mj9fn/RytE=

k8s/go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ require (
2929
github.com/modern-go/reflect2 v1.0.2 // indirect
3030
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
3131
github.com/spf13/pflag v1.0.5 // indirect
32-
golang.org/x/net v0.32.0 // indirect
32+
golang.org/x/net v0.33.0 // indirect
3333
golang.org/x/oauth2 v0.24.0 // indirect
3434
golang.org/x/sys v0.28.0 // indirect
3535
golang.org/x/term v0.27.0 // indirect

k8s/go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,8 @@ golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn
9191
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
9292
golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
9393
golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
94-
golang.org/x/net v0.32.0 h1:ZqPmj8Kzc+Y6e0+skZsuACbx+wzMgo5MQsJh9Qd6aYI=
95-
golang.org/x/net v0.32.0/go.mod h1:CwU0IoeOlnQQWJ6ioyFrfRuomB8GKF6KbYXZVyeXNfs=
94+
golang.org/x/net v0.33.0 h1:74SYHlV8BIgHIFC/LrYkOGIwL19eTYXQ5wc6TBuO36I=
95+
golang.org/x/net v0.33.0/go.mod h1:HXLR5J+9DxmrqMwG9qjGCxZ+zKXxBru04zlTvWlWuN4=
9696
golang.org/x/oauth2 v0.24.0 h1:KTBBxWqUa0ykRPLtV69rRto9TLXcqYkeswu48x/gvNE=
9797
golang.org/x/oauth2 v0.24.0/go.mod h1:XYTD2NtWslqkgxebSiOHnXEap4TF09sJSc7H1sXbhtI=
9898
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=

test/go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ require (
77
github.com/linode/linodego v1.33.0
88
github.com/linode/linodego/k8s v0.0.0-00010101000000-000000000000
99
github.com/stretchr/testify v1.10.0
10-
golang.org/x/net v0.32.0
10+
golang.org/x/net v0.33.0
1111
golang.org/x/oauth2 v0.24.0
1212
k8s.io/client-go v0.29.4
1313
)

0 commit comments

Comments
 (0)