Skip to content

Commit

Permalink
suppress false positive gosec warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
wollomatic committed Dec 14, 2023
1 parent 9d0b367 commit f672742
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions hostsfile.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ func refreshHostsfile(cli *client.Client) error {

if len(containers) > 0 {
for _, container := range containers {
if conf.onlyLabeledContainers && !(strings.ToLower(container.Labels[DOCKER_LABEL+".enabled"]) == "true") {
if conf.onlyLabeledContainers && (strings.ToLower(container.Labels[DOCKER_LABEL+".enabled"]) != "true") {
// log.Println("Skipping container", container.Names[len(container.Names)-1], "because it is not labeled with", DOCKER_LABEL+".enabled=true")
continue
}
Expand Down Expand Up @@ -60,7 +60,7 @@ func writeHostsfile(bs []byte) error {
hfnew := bytes.Split(hf, []byte(HOSTLIST_PREFIX))[0]
hfnew = append(hfnew, bs...)

return os.WriteFile(conf.hostsfile, hfnew, 0644)
return os.WriteFile(conf.hostsfile, hfnew, 0644) // #nosec G306 -- hostsfile has to be writable
}

// getContainerHostList returns the list of hostnames for a given container
Expand Down
2 changes: 1 addition & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ func main() {
// check if hostsfile is writable
if _, err := os.OpenFile(conf.hostsfile, os.O_WRONLY, 0644); err != nil {
log.Fatalf("Error: Hostsfile %s ist not writable: %s", conf.hostsfile, err)
}
} // #nosec G302 -- hostsfile has to be writable

// stop signal listener
done := make(chan os.Signal, 1)
Expand Down

0 comments on commit f672742

Please sign in to comment.