Skip to content

Commit ec2dab4

Browse files
smagnani96pchaigno
authored andcommitted
check-encryption-leaks: fix indentation in leak report printfs
When printing leak reports, indent the lines related to general packet information (ips, iface, etc.) and protocol-specific information (e.g., TCP flags, DNS query) to improve readability. Example of an ICMP packet via VXLAN: ``` [10:48:26:599698] [0xffff8909322c0d00] 172.18.0.3:36366 -> 172.18.0.4:8472 (proto: 17, encap: 1, skb: 0) [10:48:26:599698] [0xffff8909322c0d00] ↳ 10.244.2.11:0 -> 10.244.0.43:0 (len: 84, proto: 1, ifindex: 7, netns: f0000000, srcPod: 1 (internal: 0), dstPod: 1 (internal: 0), proxy: 0 (masqueraded: 0)) [10:48:26:599698] [0xffff8909322c0d00] ↳ Detected ICMP message, IPFlags: .D., Type: 8, Code: 0, FragOff: 0, FragID: 28977 ``` Signed-off-by: Simone Magnani <simone.magnani@isovalent.com>
1 parent 94fcd7c commit ec2dab4

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

.github/actions/bpftrace/scripts/check-encryption-leaks.bt

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ kprobe:br_forward
160160
$encap, $skb->encapsulation);
161161
}
162162

163-
printf("[%s] [%p] %s:%d -> %s:%d (len: %d, proto: %d, ifindex: %d, netns: %x, srcPod: %d (internal: %d), dstPod: %d (internal: %d), proxy: %d (masqueraded: %d))\n",
163+
printf("[%s] [%p] %s:%d -> %s:%d (len: %d, proto: %d, ifindex: %d, netns: %x, srcPod: %d (internal: %d), dstPod: %d (internal: %d), proxy: %d (masqueraded: %d))\n",
164164
$time, $skb,
165165
ntop($ip4h->saddr),
166166
($ip4h->protocol == PROTO_UDP || $ip4h->protocol == PROTO_TCP) ? bswap($udph->source) : 0,
@@ -176,7 +176,7 @@ kprobe:br_forward
176176
$pod_to_pod_via_proxy == PROXY_TRACED_AND_MASQUERADED);
177177

178178
if ($ip4h->protocol == PROTO_TCP) {
179-
printf("[%s] [%p] ↳ Detected TCP message, TCPFlags: %c%c%c%c%c%c%c%c, Seq: %u, Ack: %u\n",
179+
printf("[%s] [%p] ↳ Detected TCP message, TCPFlags: %c%c%c%c%c%c%c%c, Seq: %u, Ack: %u\n",
180180
$time, $skb,
181181
$tcph->cwr ? CH_C : CH_DOT, $tcph->ece ? CH_E : CH_DOT,
182182
$tcph->urg ? CH_U : CH_DOT, $tcph->ack ? CH_A : CH_DOT,
@@ -188,7 +188,7 @@ kprobe:br_forward
188188
if ($ip4h->protocol == PROTO_UDP && (bswap($udph->source) == PORT_DNS || bswap($udph->dest) == PORT_DNS)) {
189189
$dns = (struct dnshdr*)($udph + 1);
190190
$query = (uint8 *)($dns + 1);
191-
printf("[%s] [%p] ↳ Detected DNS message, ID: %04x, flags %04x, QD: %d, AN: %d, NS: %d, AR: %d, query %s\n",
191+
printf("[%s] [%p] ↳ Detected DNS message, ID: %04x, flags %04x, QD: %d, AN: %d, NS: %d, AR: %d, query %s\n",
192192
$time, $skb,
193193
bswap($dns->id), bswap($dns->flags), bswap($dns->qdcount),
194194
bswap($dns->ancount), bswap($dns->nscount), bswap($dns->arcount),
@@ -198,7 +198,7 @@ kprobe:br_forward
198198
if ($ip4h->protocol == PROTO_ICMP_IPV4) {
199199
$frag_off = bswap($ip4h->frag_off);
200200

201-
printf("[%s] [%p] ↳ Detected ICMP message, IPFlags: .%c%c, Type: %u, Code: %u, FragOff: %d, FragID: %d\n",
201+
printf("[%s] [%p] ↳ Detected ICMP message, IPFlags: .%c%c, Type: %u, Code: %u, FragOff: %d, FragID: %d\n",
202202
$time, $skb,
203203
($frag_off & 0x4000) >> 14 ? CH_D : CH_DOT,
204204
($frag_off & 0x2000) >> 13 ? CH_M : CH_DOT,
@@ -253,7 +253,7 @@ kprobe:br_forward
253253
$encap, $skb->encapsulation);
254254
}
255255

256-
printf("[%s] [%p] %s:%d -> %s:%d (len: %d, proto: %d, ifindex: %d, netns: %x, srcPod: %d (internal: %d), dstPod: %d (internal: %d), proxy: %d (masqueraded: %d))\n",
256+
printf("[%s] [%p] %s:%d -> %s:%d (len: %d, proto: %d, ifindex: %d, netns: %x, srcPod: %d (internal: %d), dstPod: %d (internal: %d), proxy: %d (masqueraded: %d))\n",
257257
$time, $skb,
258258
ntop($ip6h->saddr.in6_u.u6_addr8),
259259
($ip6h->nexthdr == PROTO_UDP || $ip6h->nexthdr == PROTO_TCP) ? bswap($udph->source) : 0,
@@ -269,7 +269,7 @@ kprobe:br_forward
269269
$pod_to_pod_via_proxy == PROXY_TRACED_AND_MASQUERADED);
270270

271271
if ($ip6h->nexthdr == PROTO_TCP) {
272-
printf("[%s] [%p] ↳ Detected TCP message, TCPFlags: %c%c%c%c%c%c%c%c, Seq: %u, Ack: %u\n",
272+
printf("[%s] [%p] ↳ Detected TCP message, TCPFlags: %c%c%c%c%c%c%c%c, Seq: %u, Ack: %u\n",
273273
$time, $skb,
274274
$tcph->cwr ? CH_C : CH_DOT, $tcph->ece ? CH_E : CH_DOT,
275275
$tcph->urg ? CH_U : CH_DOT, $tcph->ack ? CH_A : CH_DOT,
@@ -281,7 +281,7 @@ kprobe:br_forward
281281
if ($ip6h->nexthdr == PROTO_UDP && (bswap($udph->source) == PORT_DNS || bswap($udph->dest) == PORT_DNS)) {
282282
$dns = (struct dnshdr*)($udph + 1);
283283
$query = (uint8 *)($dns + 1);
284-
printf("[%s] [%p] ↳ Detected DNS message, ID: %04x, flags %04x, QD: %d, AN: %d, NS: %d, AR: %d, query %s\n",
284+
printf("[%s] [%p] ↳ Detected DNS message, ID: %04x, flags %04x, QD: %d, AN: %d, NS: %d, AR: %d, query %s\n",
285285
$time, $skb,
286286
bswap($dns->id), bswap($dns->flags), bswap($dns->qdcount),
287287
bswap($dns->ancount), bswap($dns->nscount), bswap($dns->arcount),
@@ -298,7 +298,7 @@ kprobe:br_forward
298298
$frag_off_res_m = bswap($frag_hdr->frag_off);
299299
}
300300

301-
printf("[%s] [%p] ↳ Detected ICMP message, IPFlags: ..%c, Type: %u, Code: %u, FragOff: %d, FragID: %d\n",
301+
printf("[%s] [%p] ↳ Detected ICMP message, IPFlags: ..%c, Type: %u, Code: %u, FragOff: %d, FragID: %d\n",
302302
$time, $skb,
303303
$frag_off_res_m & 0x0001 ? CH_M : CH_DOT,
304304
$icmph->type,

0 commit comments

Comments
 (0)