Skip to content
This repository was archived by the owner on Mar 15, 2024. It is now read-only.

Commit 2ce68f9

Browse files
author
Michael Weber
committed
Address gosec/code scan issues
1 parent 827a6cf commit 2ce68f9

File tree

7 files changed

+27
-8
lines changed

7 files changed

+27
-8
lines changed

.circleci/config.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,9 @@ jobs:
4141
- run:
4242
name: Test
4343
command: make test TESTREPORT=test-results/go/results.xml
44+
- run:
45+
name: Code Quality
46+
command: make lint
4447
- store_test_results:
4548
path: test-results/
4649
- store_artifacts:

Makefile

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ LD_FLAGS += -X "$(LD_FLAGS_PKG).commit=$(SHORT_COMMIT)"
1414
LD_FLAGS += -X "$(LD_FLAGS_PKG).goVersion=$(GO_VERSION)"
1515

1616
.PHONY: all
17-
all: dep build lint test
17+
all: build lint test
1818

1919
.PHONY: dep
2020
dep: prereq
@@ -46,11 +46,15 @@ test: build
4646
lint: dep
4747
go list ./... | grep -v vendor | xargs go vet
4848
go list ./... | grep -v vendor | xargs golint
49+
ineffassign .
50+
gosec -quiet -vendor ./...
4951

5052
.PHONY: prereq
5153
prereq:
5254
go get github.com/golang/dep/cmd/dep
5355
go get golang.org/x/lint/golint
56+
go get github.com/gordonklaus/ineffassign
57+
go get github.com/securego/gosec/cmd/gosec/...
5458
go get gotest.tools/gotestsum
5559

5660
.PHONY: clean

README.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,14 @@ vault-plugin-splunk
44
A Hashicorp Vault[1] plugin that aims to securely manage Splunk admin
55
accounts, including secrets rotation for compliance purposes.
66

7-
[![CircleCI](https://circleci.com/gh/splunk/vault-plugin-splunk.svg?style=svg)](https://circleci.com/gh/splunk/vault-plugin-splunk)
8-
97
[1] https://www.vaultproject.io/
108

9+
## Project status
10+
11+
[![Build Status](https://circleci.com/gh/splunk/vault-plugin-splunk.svg?style=shield)](https://circleci.com/gh/splunk/vault-plugin-splunk)
12+
[![GoReport](https://goreportcard.com/badge/github.com/splunk/vault-plugin-splunk)](https://goreportcard.com/report/github.com/splunk/vault-plugin-splunk)
13+
14+
1115
# Building from Source
1216

1317
```shell

clients/splunk/testing.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,8 @@ func TestGlobalSplunkClient(t *testing.T) *API {
9292
// See also: APIParams.NewAPI
9393
func TestDefaultContext() context.Context {
9494
tr := &http.Transport{
95-
TLSClientConfig: &tls.Config{InsecureSkipVerify: true}, // XXX
95+
// #nosec G402
96+
TLSClientConfig: &tls.Config{InsecureSkipVerify: true},
9697
}
9798
// client is the underlying transport for API calls, including Login (for obtaining session token)
9899
client := &http.Client{
@@ -202,6 +203,7 @@ func NewTestSplunkServiceWithTempAdmin() (cleanup func(), conn *API, err error)
202203
clConn := conn
203204
clCleanup := cleanup
204205
cleanup = func() {
206+
// #nosec G104
205207
clConn.AccessControl.Authentication.Users.Delete(testUser)
206208
clCleanup()
207209
}

clients/splunk/user_test.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ func TestUserService_Create(t *testing.T) {
3030
params := testUserParams("")
3131

3232
user, _, err := userSvc.Create(params)
33-
defer userSvc.Delete(user.Name)
3433
assert.NilError(t, err)
34+
defer userSvc.Delete(user.Name)
3535
assert.Equal(t, user.Name, params.Name)
3636
assert.Equal(t, user.Content.Email, params.Email)
3737
}
@@ -52,8 +52,8 @@ func TestUserService_Update_Email(t *testing.T) {
5252
params := testUserParams("")
5353

5454
user, _, err := userSvc.Create(params)
55-
defer userSvc.Delete(user.Name)
5655
assert.NilError(t, err)
56+
defer userSvc.Delete(user.Name)
5757
assert.Equal(t, user.Name, params.Name)
5858

5959
user, _, err = userSvc.Update(user.Name, &UpdateUserOptions{
@@ -68,6 +68,7 @@ func TestUserService_Update_Password(t *testing.T) {
6868
params := testUserParams("")
6969

7070
user, _, err := userSvc.Create(params)
71+
assert.NilError(t, err)
7172
defer userSvc.Delete(user.Name)
7273
assert.NilError(t, err)
7374
assert.Equal(t, user.Name, params.Name)
@@ -93,6 +94,7 @@ func TestUserService_Update_OwnPassword(t *testing.T) {
9394

9495
params := testUserParams("")
9596
user, _, err := userSvc.Create(params)
97+
assert.NilError(t, err)
9698
defer userSvc.Delete(user.Name)
9799

98100
_, _, err = userSvc.Update(user.Name, &UpdateUserOptions{

cmd/vault-plugin-splunk/main.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,17 @@ import (
44
"os"
55

66
"github.com/hashicorp/go-hclog"
7-
"github.com/splunk/vault-plugin-splunk"
87
"github.com/hashicorp/vault/helper/pluginutil"
98
"github.com/hashicorp/vault/logical/plugin"
9+
10+
splunk "github.com/splunk/vault-plugin-splunk"
1011
)
1112

1213
func main() {
1314
apiClientMeta := &pluginutil.APIClientMeta{}
1415
flags := apiClientMeta.FlagSet()
16+
// all plugins ignore Parse errors
17+
// #nosec G104
1518
flags.Parse(os.Args[1:])
1619

1720
tlsConfig := apiClientMeta.GetTLSConfig()
@@ -27,4 +30,4 @@ func main() {
2730
logger.Error("plugin shutting down", "error", err)
2831
os.Exit(1)
2932
}
30-
}
33+
}

conn.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ func (config *splunkConfig) store(ctx context.Context, s logical.Storage, name s
7777
defer func() {
7878
if err != nil {
7979
// config was not stored => cancel cleanup
80+
// #nosec G104
8081
framework.DeleteWAL(ctx, s, walID)
8182
}
8283
}()

0 commit comments

Comments
 (0)