fix: 1.4.8 egress false positives (non-SYN replies, IMDS on host, Akamai/Telegram)
Release / Publish tags (push) Successful in 13s
Release / Plan (reuse the published image?) (push) Successful in 5s
Release / ci (push) Successful in 1m20s
Release / Build image (amd64) (push) Successful in 24s
Release / Build image (arm64) (push) Successful in 1m11s
Release / Gitea release (push) Skipped
CI / Format and vet (push) Successful in 51s
CI / Tests (Linux, race detector) (push) Successful in 50s
CI / Dependency audit (push) Successful in 29s
CI / Docker image (build and smoke test) (push) Skipped

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Lucas RayanandClaude Opus 5.5 committed 2026-11-15 08:51:42 -03:00
1 parent 873219416f
commit 3ae72e27d6
8 files changed
+175 -13

No files matched your search

+19 -1
View File
@@ -25,16 +25,28 @@ type Event struct {
SPort, DPort uint16
In, Out string
Host bool // IN= empty: output of the host itself
// SYN and ACK are the TCP flags present in the log line.
SYN, ACK bool
}
// ErrNotEgress marks a line that is not an egress log line.
var ErrNotEgress = errors.New("not an egress line")
// ErrNonSYN marks a TCP egress line that is not a connection attempt (no SYN,
// or SYN+ACK): replies of a flow whose conntrack entry was recreated in the
// middle (nf_conntrack_tcp_loose), logged by an old kit that did not filter
// on the SYN flag.
var ErrNonSYN = errors.New("tcp line without a pure SYN")
// ParseLine parses a kernel/rsyslog line. now is only used to infer the year
// of the "Nov 14 22:01:02" rsyslog format (and as the time of a line whose
// timestamp is unreadable).
func ParseLine(b []byte, now time.Time) (Event, error) {
return ParseKernel(b, marker, now)
ev, err := ParseKernel(b, marker, now)
if err == nil && ev.Proto == "tcp" && (!ev.SYN || ev.ACK) {
return ev, ErrNonSYN
}
return ev, err
}
// ParseKernel parses an nftables log line carrying the given prefix marker
@@ -51,6 +63,12 @@ func ParseKernel(b []byte, marker string, now time.Time) (Event, error) {
for _, f := range strings.Fields(line[i+len(marker):]) {
k, v, ok := strings.Cut(f, "=")
if !ok {
switch f {
case "SYN":
ev.SYN = true
case "ACK":
ev.ACK = true
}
continue
}
switch k {