1212
1313CEF_DEFAULT_PRODUCT_NAME = "Advanced Exfiltration Detection"
1414CEF_DEFAULT_SEVERITY_LEVEL = "5"
15+ OUTPUT_VIA_PAGER_THRESHOLD = 10
1516
1617
1718class JsonOutputFormat :
@@ -66,12 +67,15 @@ def get_formatted_output(self, output):
6667 for item in output :
6768 yield self ._format_output (item )
6869
69- def echo_formatted_list (self , output_list ):
70+ def echo_formatted_list (self , output_list , force_pager = False ):
7071 formatted_output = self .get_formatted_output (output_list )
71- for output in formatted_output :
72- click .echo (output , nl = False )
73- if self .output_format in [OutputFormat .TABLE ]:
74- click .echo ()
72+ if len (output_list ) > OUTPUT_VIA_PAGER_THRESHOLD or force_pager :
73+ click .echo_via_pager (formatted_output )
74+ else :
75+ for output in formatted_output :
76+ click .echo (output , nl = False )
77+ if self .output_format in [OutputFormat .TABLE ]:
78+ click .echo ()
7579
7680 @property
7781 def _requires_list_output (self ):
@@ -124,7 +128,7 @@ def get_formatted_output(self, df, **kwargs):
124128
125129 def echo_formatted_dataframe (self , df , ** kwargs ):
126130 str_output = self .get_formatted_output (df , ** kwargs )
127- if len (df ) <= 10 :
131+ if len (df ) <= OUTPUT_VIA_PAGER_THRESHOLD :
128132 click .echo (str_output )
129133 else :
130134 click .echo_via_pager (str_output )
@@ -135,7 +139,7 @@ def to_csv(output):
135139
136140 if not output :
137141 return
138- string_io = io .StringIO ()
142+ string_io = io .StringIO (newline = None )
139143 fieldnames = list ({k for d in output for k in d .keys ()})
140144 writer = csv .DictWriter (string_io , fieldnames = fieldnames )
141145 writer .writeheader ()
0 commit comments