Skip to content

Commit

Permalink
add github action to run gosec static analysis (#398)
Browse files Browse the repository at this point in the history
* add github action to run gosec static analysis

* install gosec
  • Loading branch information
sushrk authored Apr 3, 2024
1 parent 8b9cdb9 commit cf1e58b
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 0 deletions.
16 changes: 16 additions & 0 deletions .github/workflows/presubmit.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -53,3 +53,19 @@ jobs:
run: go install golang.org/x/vuln/cmd/govulncheck@latest
- name: Run `govulncheck`
run: ~/go/bin/govulncheck ./...
static-security-analysis:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Setup Go Version
run: echo "GO_VERSION=$(cat .go-version)" >> $GITHUB_ENV
- uses: actions/setup-go@v4
with:
go-version: ${{ env.GO_VERSION }}
cache-dependency-path: "**/go.sum"
- name: Install `gosec`
run: go install github.com/securego/gosec/v2/cmd/gosec@latest
- name: Run Gosec Security Scanner
run: ~/go/bin/gosec -exclude-dir test -exclude-generated -severity medium -exclude=G108,G114 ./...

1 change: 1 addition & 0 deletions pkg/k8s/pod/converter.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ func (c *PodConverter) ConvertList(originalList interface{}) (convertedList inte
},
}
for _, pod := range podList.Items {
pod := pod // Fix gosec G601, so we can use &node
strippedPod := c.StripDownPod(&pod)
strippedPodList.Items = append(strippedPodList.Items, *strippedPod)
}
Expand Down
1 change: 1 addition & 0 deletions pkg/provider/branch/trunk/trunk.go
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,7 @@ func (t *trunkENI) InitTrunk(instance ec2.EC2Instance, podList []v1.Pod) error {

// From the list of pods on the given node, and the branch ENIs from EC2 API call rebuild the internal cache
for _, pod := range podList {
pod := pod // Fix gosec G601, so we can use &node
eniListFromPod := t.getBranchInterfacesUsedByPod(&pod)
if len(eniListFromPod) == 0 {
continue
Expand Down
1 change: 1 addition & 0 deletions pkg/utils/events.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ func SendNodeEventWithNodeObject(client k8s.K8sWrapper, node *v1.Node, reason, m
func SendBroadcastNodeEvent(client k8s.K8sWrapper, reason, msg, eventType string, logger logr.Logger) {
if nodeList, err := client.ListNodes(); err == nil {
for _, node := range nodeList.Items {
node := node // Fix gosec G601, so we can use &node
client.BroadcastEvent(&node, reason, msg, eventType)
}
} else {
Expand Down

0 comments on commit cf1e58b

Please sign in to comment.