Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remove gosec exampt #1616

Merged
merged 7 commits into from
Feb 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/dependency-review.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
with:
go-version: '1.21.6'
- run: go install github.com/securego/gosec/v2/cmd/gosec@latest
- run: gosec -exclude=G101,G103,G204 ./...
- run: gosec -exclude-generated ./...
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice!

working-directory: nodeadm
govulncheck:
runs-on: ubuntu-latest
Expand Down
16 changes: 13 additions & 3 deletions nodeadm/internal/kubelet/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ import (
"encoding/json"
"fmt"
"io"
"net"
"net/url"
"os"
"os/exec"
"path"
"strings"
"time"
Expand Down Expand Up @@ -171,7 +171,17 @@ func (ksc *kubeletConfig) withOutpostSetup(cfg *api.NodeConfig) error {
}

// TODO: cleanup
output, err := exec.Command("getent", "hosts", apiUrl.Host).Output()
ipAddresses, err := net.LookupHost(apiUrl.Host)
if err != nil {
return err
}
var ipHostMappings []string
for _, ip := range ipAddresses {
ipHostMappings = append(ipHostMappings, fmt.Sprintf("%s\t%s", ip, apiUrl.Host))
}
output := strings.Join(ipHostMappings, "\n") + "\n"
zap.L().Info(fmt.Sprintf("Log returned ipAddress: %v", output))

if err != nil {
return err
}
Expand All @@ -182,7 +192,7 @@ func (ksc *kubeletConfig) withOutpostSetup(cfg *api.NodeConfig) error {
return err
}
defer f.Close()
if _, err := f.Write(output); err != nil {
if _, err := f.WriteString(output); err != nil {
return err
}
}
Expand Down
2 changes: 2 additions & 0 deletions nodeadm/internal/kubelet/image-credential-provider.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// #nosec G101

package kubelet

import (
Expand Down
11 changes: 11 additions & 0 deletions nodeadm/test/e2e/cases/kubeconfig-outpost/config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
apiVersion: node.eks.aws/v1alpha1
kind: NodeConfig
spec:
cluster:
id: my-cluster-id
name: my-cluster
apiServerEndpoint: http://localhost
certificateAuthority: Y2VydGlmaWNhdGVBdXRob3JpdHk=
cidr: 10.100.0.0/16
enableOutpost: true
15 changes: 15 additions & 0 deletions nodeadm/test/e2e/cases/kubeconfig-outpost/run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/usr/bin/env bash

set -o errexit
set -o nounset
set -o pipefail

source /helpers.sh

mock::imds
wait::dbus-ready

mock::kubelet 1.28.0
nodeadm init --skip run --config-source file://config.yaml
assert::file-contains /etc/hosts $'127.0.0.1\tlocalhost'
assert::file-contains /etc/hosts $'::1\tlocalhost'
Loading