Skip to content

Commit

Permalink
[service] Fix go linter errors
Browse files Browse the repository at this point in the history
  • Loading branch information
vlabo committed Nov 25, 2024
1 parent 7f2b8fc commit 1b4f5f1
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 5 deletions.
23 changes: 18 additions & 5 deletions service/firewall/packet_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -593,18 +593,31 @@ func inspectDNSPacket(conn *network.Connection, pkt packet.Packet) {
}

dnsPacket := new(dns.Msg)
pkt.LoadPacketData()
err := pkt.LoadPacketData()
if err != nil {
_ = pkt.Block()
log.Errorf("filter: failed to load packet payload: %s", err)
return
}

// Parse and block invalid packets.
err := dnsPacket.Unpack(pkt.Payload())
err = dnsPacket.Unpack(pkt.Payload())
if err != nil {
pkt.PermanentBlock()
conn.SetVerdict(network.VerdictBlock, "none DNS data on DNS port", "", nil)
err = pkt.PermanentBlock()
if err != nil {
log.Errorf("filter: failed to block packet: %s", err)
}
_ = conn.SetVerdict(network.VerdictBlock, "none DNS data on DNS port", "", nil)
conn.VerdictPermanent = true
conn.Save()
return
}
pkt.Accept()

// Packet was parsed, accept the connection and continue.
err = pkt.Accept()
if err != nil {
log.Errorf("filter: failed to accept dns packet: %s", err)
}

conn.Type = network.DNSRequest

Expand Down
1 change: 1 addition & 0 deletions service/integration/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ type OSIntegration struct {
m *mgr.Manager
states *mgr.StateMgr

//nolint:unused
os OSSpecific

instance instance
Expand Down
8 changes: 8 additions & 0 deletions service/network/packet/parse.go
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,14 @@ func ParseLayer4(packetData []byte, pktBase *Base) (err error) {
layer = layers.LayerTypeUDP
case ICMPv6:
layer = layers.LayerTypeICMPv6
case UDPLite:
return fmt.Errorf("UDPLite not supported")
case RAW:
return fmt.Errorf("RAW protocol not supported")
case AnyHostInternalProtocol61:
return fmt.Errorf("AnyHostInternalProtocol61 protocol not supported")
default:
return fmt.Errorf("protocol not supported")
}

packet := gopacket.NewPacket(packetData, layer, gopacket.DecodeOptions{
Expand Down

0 comments on commit 1b4f5f1

Please sign in to comment.