Skip to content

Commit e6601ad

Browse files
authored
🐛 fix mql printer for RawIP (#5307)
Signed-off-by: Salim Afiune Maya <afiune@mondoo.com>
1 parent 07024f9 commit e6601ad

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

cli/printer/mql.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -787,6 +787,9 @@ func (print *Printer) Data(typ types.Type, data interface{}, codeID string, bund
787787
return print.Secondary(data.(string))
788788

789789
case types.IP:
790+
if data == nil {
791+
return print.Secondary("null")
792+
}
790793
return print.Secondary(data.(llx.RawIP).String())
791794

792795
case types.ArrayLike:

cli/printer/printer_test.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,20 @@ func TestPrinter(t *testing.T) {
176176
"]",
177177
},
178178
},
179+
{
180+
"ip(\"\")",
181+
"", // ignore
182+
[]string{
183+
"ip: null",
184+
},
185+
},
186+
{
187+
"ip(\"1.2.3.4\")",
188+
"", // ignore
189+
[]string{
190+
"ip: 1.2.3.4",
191+
},
192+
},
179193
})
180194
}
181195

0 commit comments

Comments
 (0)