Skip to content

Commit

Permalink
Merge pull request #104 from dell/gosec-fix
Browse files Browse the repository at this point in the history
Update .golangci.yaml
  • Loading branch information
adarsh-dell authored Feb 27, 2024
2 parents c20e91b + cc388e9 commit daf5f9e
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 18 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/actions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout the code
uses: actions/checkout@v2
uses: actions/checkout@v4
- name: Run the formatter, linter, and vetter
uses: dell/common-github-actions/go-code-formatter-linter-vetter@main
with:
Expand All @@ -20,7 +20,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout the code
uses: actions/checkout@v2
uses: actions/checkout@v4
- name: Run Go Security
uses: securego/gosec@master
with:
Expand All @@ -30,7 +30,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout the code
uses: actions/checkout@v2
uses: actions/checkout@v4
- name: Run malware scan
uses: dell/common-github-actions/malware-scanner@main
with:
Expand Down
4 changes: 4 additions & 0 deletions .golangci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,7 @@ linters:
- govet
# Drop-in replacement of golint.
- revive
linters-settings:
gosec:
excludes:
- G402 # Look for bad TLS connection settings
8 changes: 4 additions & 4 deletions api/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -158,9 +158,9 @@ func New(

if opts.Insecure {
c.http.Transport = &http.Transport{
/* #nosec G402 */
TLSClientConfig: &tls.Config{
InsecureSkipVerify: true,
// #nosec G402
InsecureSkipVerify: true, // #nosec G402
},
}
}
Expand All @@ -172,10 +172,10 @@ func New(
}

c.http.Transport = &http.Transport{
/* #nosec G402 */
TLSClientConfig: &tls.Config{
RootCAs: pool,
InsecureSkipVerify: opts.Insecure,
// #nosec G402
InsecureSkipVerify: opts.Insecure,
},
}
}
Expand Down
22 changes: 11 additions & 11 deletions deploy.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,27 +54,27 @@ func NewGateway(host string, username, password string, insecure, useCerts bool)
username: username,
password: password,
}

if insecure {
gc.http.Transport = &http.Transport{
/* #nosec G402 */

if insecure {
gc.http.Transport = &http.Transport{
TLSClientConfig: &tls.Config{
InsecureSkipVerify: true,
// #nosec G402
InsecureSkipVerify: true,
},
}
}

if !insecure || useCerts {
if !insecure || useCerts {
pool, err := x509.SystemCertPool()
if err != nil {
return nil, errSysCerts
}

gc.http.Transport = &http.Transport{
/* #nosec G402 */
gc.http.Transport = &http.Transport{
TLSClientConfig: &tls.Config{
RootCAs: pool,
InsecureSkipVerify: insecure,
// #nosec G402
InsecureSkipVerify: insecure,
},
}
}
Expand Down Expand Up @@ -1264,7 +1264,7 @@ func writeConfig(config *CookieConfig) error {
if err != nil {
return err
}

// #nosec G306
err = ioutil.WriteFile(configFile, data, 0644)
if err != nil {
return err
Expand Down

0 comments on commit daf5f9e

Please sign in to comment.