@@ -133,7 +133,7 @@ def csv(findings: list[Finding], heading: str | None = None, colourMode: int = 0
133133 _ = colourMode # silence pylint
134134 findings = sorted (findings , key = lambda i : i ["severity" ], reverse = True )
135135 output = StringIO ()
136- csvString = writer (output , quoting = QUOTE_ALL )
136+ csvString = writer (output , quoting = QUOTE_ALL , lineterminator = " \n " , strict = True )
137137 csvString .writerow (
138138 [
139139 heading
@@ -224,7 +224,7 @@ def ansi(findings: list[Finding], heading: str | None = None, colourMode: int =
224224 strBuf .append ("│Severity │Finding │" )
225225 strBuf .append (f"├{ '─' * 10 } ┼{ '─' * 50 } ┤" )
226226 for finding in findings :
227- strBuf .append (f"│{ finding ['severity' ]: <10} │{ finding ['title' ][:50 ]: <50} │" )
227+ strBuf .append (f"│{ str ( finding ['severity' ]) : <10} │{ finding ['title' ][:50 ]: <50} │" )
228228 strBuf .append (f"└{ '─' * 10 } ┴{ '─' * 50 } ┘" )
229229 strBuf .append ("" )
230230
@@ -289,7 +289,7 @@ def sarif(findings: list[Finding], heading: str | None = None, colourMode: int =
289289 "physicalLocation" : {
290290 "artifactLocation" : {"uri" : finding ["file" ]},
291291 "region" : {
292- "startLine" : finding ["line" ],
292+ "startLine" : max ( finding ["line" ], 1 ) ,
293293 "snippet" : {
294294 "text" : "" .join (
295295 [
@@ -301,8 +301,8 @@ def sarif(findings: list[Finding], heading: str | None = None, colourMode: int =
301301 },
302302 },
303303 "contextRegion" : {
304- "startLine" : finding ["evidence" ][0 ]["line" ],
305- "endLine" : finding ["evidence" ][- 1 ]["line" ],
304+ "startLine" : max ( finding ["evidence" ][0 ]["line" ], 1 ) ,
305+ "endLine" : max ( finding ["evidence" ][- 1 ]["line" ], 1 ) ,
306306 "snippet" : {
307307 "text" : "\n " .join (
308308 [line ["content" ] for line in finding ["evidence" ]]
0 commit comments