These were purposefully ignored before but this goes ahead and "fixes"
most of them.
Note that none of the things gosec flagged are problematic, just
quieting the linter here.
Signed-off-by: Brian Goff <cpuguy83@gmail.com>
| ... | ... |
@@ -117,7 +117,7 @@ func fetchNodePeers(ip string, port int, network string) map[string]string {
|
| 117 | 117 |
path = fmt.Sprintf(clusterPeers, ip, port) |
| 118 | 118 |
} |
| 119 | 119 |
|
| 120 |
- resp, err := http.Get(path) // nolint:gosec |
|
| 120 |
+ resp, err := http.Get(path) //nolint:gosec // G107: Potential HTTP request made with variable url |
|
| 121 | 121 |
if err != nil {
|
| 122 | 122 |
logrus.WithError(err).Fatalf("Failed fetching path")
|
| 123 | 123 |
} |
| ... | ... |
@@ -39,8 +39,9 @@ func setupVerifyAndReconcile(config *networkConfiguration, i *bridgeInterface) e |
| 39 | 39 |
|
| 40 | 40 |
// Release any residual IPv6 address that might be there because of older daemon instances |
| 41 | 41 |
for _, addrv6 := range addrsv6 {
|
| 42 |
+ addrv6 := addrv6 |
|
| 42 | 43 |
if addrv6.IP.IsGlobalUnicast() && !types.CompareIPNet(addrv6.IPNet, i.bridgeIPv6) {
|
| 43 |
- if err := i.nlh.AddrDel(i.Link, &addrv6); err != nil { // nolint:gosec
|
|
| 44 |
+ if err := i.nlh.AddrDel(i.Link, &addrv6); err != nil {
|
|
| 44 | 45 |
logrus.Warnf("Failed to remove residual IPv6 address %s from bridge: %v", addrv6.IPNet, err)
|
| 45 | 46 |
} |
| 46 | 47 |
} |
| ... | ... |
@@ -628,8 +628,9 @@ func clearEncryptionStates() {
|
| 628 | 628 |
logrus.Warnf("Failed to retrieve SA list for cleanup: %v", err)
|
| 629 | 629 |
} |
| 630 | 630 |
for _, sp := range spList {
|
| 631 |
+ sp := sp |
|
| 631 | 632 |
if sp.Mark != nil && sp.Mark.Value == spMark.Value {
|
| 632 |
- if err := nlh.XfrmPolicyDel(&sp); err != nil { // nolint:gosec
|
|
| 633 |
+ if err := nlh.XfrmPolicyDel(&sp); err != nil {
|
|
| 633 | 634 |
logrus.Warnf("Failed to delete stale SP %s: %v", sp, err)
|
| 634 | 635 |
continue |
| 635 | 636 |
} |
| ... | ... |
@@ -637,8 +638,9 @@ func clearEncryptionStates() {
|
| 637 | 637 |
} |
| 638 | 638 |
} |
| 639 | 639 |
for _, sa := range saList {
|
| 640 |
+ sa := sa |
|
| 640 | 641 |
if sa.Reqid == r {
|
| 641 |
- if err := nlh.XfrmStateDel(&sa); err != nil { // nolint:gosec
|
|
| 642 |
+ if err := nlh.XfrmStateDel(&sa); err != nil {
|
|
| 642 | 643 |
logrus.Warnf("Failed to delete stale SA %s: %v", sa, err)
|
| 643 | 644 |
continue |
| 644 | 645 |
} |
| ... | ... |
@@ -131,10 +131,11 @@ func (d *driver) peerDbNetworkWalk(nid string, f func(*peerKey, *peerEntry) bool |
| 131 | 131 |
|
| 132 | 132 |
for pKeyStr, pEntry := range mp {
|
| 133 | 133 |
var pKey peerKey |
| 134 |
+ pEntry := pEntry |
|
| 134 | 135 |
if _, err := fmt.Sscan(pKeyStr, &pKey); err != nil {
|
| 135 | 136 |
logrus.Warnf("Peer key scan on network %s failed: %v", nid, err)
|
| 136 | 137 |
} |
| 137 |
- if f(&pKey, &pEntry) { // nolint:gosec
|
|
| 138 |
+ if f(&pKey, &pEntry) {
|
|
| 138 | 139 |
return nil |
| 139 | 140 |
} |
| 140 | 141 |
} |
| ... | ... |
@@ -448,7 +448,8 @@ func (epj *endpointJoinInfo) UnmarshalJSON(b []byte) error {
|
| 448 | 448 |
} |
| 449 | 449 |
var StaticRoutes []*types.StaticRoute |
| 450 | 450 |
for _, r := range tStaticRoute {
|
| 451 |
- StaticRoutes = append(StaticRoutes, &r) // nolint:gosec |
|
| 451 |
+ r := r |
|
| 452 |
+ StaticRoutes = append(StaticRoutes, &r) |
|
| 452 | 453 |
} |
| 453 | 454 |
epj.StaticRoutes = StaticRoutes |
| 454 | 455 |
|
| ... | ... |
@@ -244,7 +244,7 @@ func (nDB *NetworkDB) clusterLeave() error {
|
| 244 | 244 |
|
| 245 | 245 |
func (nDB *NetworkDB) triggerFunc(stagger time.Duration, C <-chan time.Time, f func()) {
|
| 246 | 246 |
// Use a random stagger to avoid synchronizing |
| 247 |
- randStagger := time.Duration(uint64(rnd.Int63()) % uint64(stagger)) // nolint:gosec |
|
| 247 |
+ randStagger := time.Duration(uint64(rnd.Int63()) % uint64(stagger)) //nolint:gosec // gosec complains about the use of rand here. It should be fine. |
|
| 248 | 248 |
select {
|
| 249 | 249 |
case <-time.After(randStagger): |
| 250 | 250 |
case <-nDB.ctx.Done(): |
| ... | ... |
@@ -214,7 +214,7 @@ func setCommonFlags(msg *dns.Msg) {
|
| 214 | 214 |
|
| 215 | 215 |
func shuffleAddr(addr []net.IP) []net.IP {
|
| 216 | 216 |
for i := len(addr) - 1; i > 0; i-- {
|
| 217 |
- r := rand.Intn(i + 1) // nolint:gosec |
|
| 217 |
+ r := rand.Intn(i + 1) // nolint:gosec // gosec complains about the use of rand here. It should be fine. |
|
| 218 | 218 |
addr[i], addr[r] = addr[r], addr[i] |
| 219 | 219 |
} |
| 220 | 220 |
return addr |
| ... | ... |
@@ -49,7 +49,7 @@ func reexecSetupResolver() {
|
| 49 | 49 |
logrus.Errorf("failed get network namespace %q: %v", os.Args[1], err)
|
| 50 | 50 |
os.Exit(2) |
| 51 | 51 |
} |
| 52 |
- defer f.Close() // nolint:gosec |
|
| 52 |
+ defer f.Close() //nolint:gosec |
|
| 53 | 53 |
|
| 54 | 54 |
nsFD := f.Fd() |
| 55 | 55 |
if err = netns.Set(netns.NsHandle(nsFD)); err != nil {
|
| ... | ... |
@@ -322,7 +322,7 @@ func (sb *sandbox) updateDNS(ipv6Enabled bool) error {
|
| 322 | 322 |
if err != nil {
|
| 323 | 323 |
return err |
| 324 | 324 |
} |
| 325 |
- err = ioutil.WriteFile(sb.config.resolvConfPath, newRC.Content, 0644) // nolint:gosec |
|
| 325 |
+ err = ioutil.WriteFile(sb.config.resolvConfPath, newRC.Content, 0644) //nolint:gosec // gosec complains about perms here, which must be 0644 in this case |
|
| 326 | 326 |
if err != nil {
|
| 327 | 327 |
return err |
| 328 | 328 |
} |
| ... | ... |
@@ -378,7 +378,7 @@ func programIngress(gwIP net.IP, ingressPorts []*PortConfig, isDelete bool) erro |
| 378 | 378 |
} |
| 379 | 379 |
|
| 380 | 380 |
path := filepath.Join("/proc/sys/net/ipv4/conf", oifName, "route_localnet")
|
| 381 |
- if err := ioutil.WriteFile(path, []byte{'1', '\n'}, 0644); err != nil { // nolint:gosec
|
|
| 381 |
+ if err := ioutil.WriteFile(path, []byte{'1', '\n'}, 0644); err != nil { //nolint:gosec // gosec complains about perms here, which must be 0644 in this case
|
|
| 382 | 382 |
return fmt.Errorf("could not write to %s: %v", path, err)
|
| 383 | 383 |
} |
| 384 | 384 |
|
| ... | ... |
@@ -542,7 +542,7 @@ func writePortsToFile(ports []*PortConfig) (string, error) {
|
| 542 | 542 |
if err != nil {
|
| 543 | 543 |
return "", err |
| 544 | 544 |
} |
| 545 |
- defer f.Close() // nolint:gosec |
|
| 545 |
+ defer f.Close() //nolint:gosec |
|
| 546 | 546 |
|
| 547 | 547 |
buf, _ := proto.Marshal(&EndpointRecord{
|
| 548 | 548 |
IngressPorts: ports, |