gosec fixes and added #nosec where necassary
This commit is contained in:
@@ -264,11 +264,11 @@ func (ai *AutoInterface) Stop() error {
|
||||
defer ai.mutex.Unlock()
|
||||
|
||||
for _, server := range ai.interfaceServers {
|
||||
server.Close()
|
||||
server.Close() // #nosec G104
|
||||
}
|
||||
|
||||
if ai.outboundConn != nil {
|
||||
ai.outboundConn.Close()
|
||||
ai.outboundConn.Close() // #nosec G104
|
||||
}
|
||||
|
||||
return nil
|
||||
|
||||
@@ -161,7 +161,7 @@ func (i *BaseInterface) SendLinkPacket(dest []byte, data []byte, timestamp time.
|
||||
frame = append(frame, dest...)
|
||||
|
||||
ts := make([]byte, 8)
|
||||
binary.BigEndian.PutUint64(ts, uint64(timestamp.Unix()))
|
||||
binary.BigEndian.PutUint64(ts, uint64(timestamp.Unix())) // #nosec G115
|
||||
frame = append(frame, ts...)
|
||||
frame = append(frame, data...)
|
||||
|
||||
|
||||
@@ -138,7 +138,7 @@ func (tc *TCPClientInterface) readLoop() {
|
||||
}
|
||||
|
||||
// Update RX bytes for raw received data
|
||||
tc.UpdateStats(uint64(n), true)
|
||||
tc.UpdateStats(uint64(n), true) // #nosec G115
|
||||
|
||||
for i := 0; i < n; i++ {
|
||||
b := buffer[i]
|
||||
@@ -267,7 +267,7 @@ func (tc *TCPClientInterface) teardown() {
|
||||
tc.IN = false
|
||||
tc.OUT = false
|
||||
if tc.conn != nil {
|
||||
tc.conn.Close()
|
||||
tc.conn.Close() // #nosec G104
|
||||
}
|
||||
}
|
||||
|
||||
@@ -418,9 +418,11 @@ func (tc *TCPClientInterface) GetRTT() time.Duration {
|
||||
var rtt time.Duration = 0
|
||||
if runtime.GOOS == "linux" {
|
||||
if info, err := tcpConn.SyscallConn(); err == nil {
|
||||
info.Control(func(fd uintptr) {
|
||||
if err := info.Control(func(fd uintptr) { // #nosec G104
|
||||
rtt = platformGetRTT(fd)
|
||||
})
|
||||
}); err != nil {
|
||||
log.Printf("[DEBUG-2] Error in SyscallConn Control: %v", err)
|
||||
}
|
||||
}
|
||||
}
|
||||
return rtt
|
||||
@@ -651,7 +653,7 @@ func (ts *TCPServerInterface) handleConnection(conn net.Conn) {
|
||||
ts.mutex.Lock()
|
||||
delete(ts.connections, addr)
|
||||
ts.mutex.Unlock()
|
||||
conn.Close()
|
||||
conn.Close() // #nosec G104
|
||||
}()
|
||||
|
||||
buffer := make([]byte, ts.MTU)
|
||||
@@ -662,7 +664,7 @@ func (ts *TCPServerInterface) handleConnection(conn net.Conn) {
|
||||
}
|
||||
|
||||
ts.mutex.Lock()
|
||||
ts.RxBytes += uint64(n)
|
||||
ts.RxBytes += uint64(n) // #nosec G115
|
||||
ts.mutex.Unlock()
|
||||
|
||||
if ts.packetCallback != nil {
|
||||
|
||||
@@ -18,8 +18,8 @@ func platformGetRTT(fd uintptr) time.Duration {
|
||||
fd,
|
||||
syscall.SOL_TCP,
|
||||
syscall.TCP_INFO,
|
||||
uintptr(unsafe.Pointer(&info)),
|
||||
uintptr(unsafe.Pointer(&size)),
|
||||
uintptr(unsafe.Pointer(&info)), // #nosec G103
|
||||
uintptr(unsafe.Pointer(&size)), // #nosec G103
|
||||
0,
|
||||
)
|
||||
|
||||
|
||||
@@ -70,7 +70,7 @@ func (ui *UDPInterface) Detach() {
|
||||
defer ui.mutex.Unlock()
|
||||
ui.Detached = true
|
||||
if ui.conn != nil {
|
||||
ui.conn.Close()
|
||||
ui.conn.Close() // #nosec G104
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user