Skip to content

Commit

Permalink
Merge branch 'main' into feature-session-update-finetune-probe-calls
Browse files Browse the repository at this point in the history
  • Loading branch information
KshitijaKakde authored Aug 9, 2024
2 parents 476b7e5 + 2cc3b38 commit 557af8b
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 6 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/linters.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@ jobs:
go-version: "1.22"
cache: false
- name: Checkout the code
uses: actions/checkout@v3.2.0
uses: actions/checkout@v4
- name: Vendor packages
run: |
go mod vendor
- name: golangci-lint
uses: golangci/golangci-lint-action@v3
uses: golangci/golangci-lint-action@v5
with:
version: v1.55
version: latest
skip-cache: true
4 changes: 3 additions & 1 deletion api/restclient.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright © 2019 Dell Inc. or its subsidiaries. All Rights Reserved.
Copyright © 2019-2024 Dell Inc. or its subsidiaries. All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -147,6 +147,7 @@ func New(ctx context.Context, host string, opts ClientOptions, debug bool) (Clie
c.http.Transport = &http.Transport{
TLSClientConfig: &tls.Config{
InsecureSkipVerify: true,
CipherSuites: util.GetSecuredCipherSuites(),
},
}
} else {
Expand All @@ -158,6 +159,7 @@ func New(ctx context.Context, host string, opts ClientOptions, debug bool) (Clie
TLSClientConfig: &tls.Config{
RootCAs: pool,
InsecureSkipVerify: false,
CipherSuites: util.GetSecuredCipherSuites(),
},
}
}
Expand Down
14 changes: 13 additions & 1 deletion util/util.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright © 2019 Dell Inc. or its subsidiaries. All Rights Reserved.
Copyright © 2019-2024 Dell Inc. or its subsidiaries. All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand All @@ -16,6 +16,7 @@ package util

import (
"context"
"crypto/tls"
"errors"
"fmt"
"os"
Expand Down Expand Up @@ -176,3 +177,14 @@ func ValidateDuration(durationStr string) (uint64, error) {

return 0, nil
}

// GetSecuredCipherSuites returns a slice of secured cipher suites.
// It iterates over the tls.CipherSuites() and appends the ID of each cipher suite to the suites slice.
// The function returns the suites slice.
func GetSecuredCipherSuites() (suites []uint16) {
securedSuite := tls.CipherSuites()
for _, v := range securedSuite {
suites = append(suites, v.ID)
}
return suites
}
29 changes: 28 additions & 1 deletion util/util_test.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright © 2019 Dell Inc. or its subsidiaries. All Rights Reserved.
Copyright © 2019-2024 Dell Inc. or its subsidiaries. All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand All @@ -16,6 +16,7 @@ package util

import (
"context"
"crypto/tls"
"fmt"
"testing"
)
Expand All @@ -29,6 +30,7 @@ func TestUtils(t *testing.T) {
getLoggetTest(t)
validateResourceNameTest(t)
validateDurationTest(t)
getSecuredCipherSuitesTest(t)
}

func getRunIDLoggerTest(_ *testing.T) {
Expand Down Expand Up @@ -145,3 +147,28 @@ func validateDurationTest(t *testing.T) {
fmt.Println("Error: ", err)
fmt.Println("Validate Duration Test Successful")
}

func getSecuredCipherSuitesTest(t *testing.T) {
fmt.Println("Begin - Get Secured Cipher Suites Test")

suites := GetSecuredCipherSuites()
if len(suites) == 0 {
t.Fatalf("No secured cipher suites found")
}

// Check if all returned suites are valid TLS cipher suites
for _, suite := range suites {
found := false
for _, v := range tls.CipherSuites() {
if suite == v.ID {
found = true
break
}
}
if !found {
t.Fatalf("Invalid cipher suite ID found: %d", suite)
}
}

fmt.Println("Get Secured Cipher Suites Test Successful")
}

0 comments on commit 557af8b

Please sign in to comment.