mirror of
https://github.com/aljazceru/Auditor.git
synced 2025-12-17 03:24:18 +01:00
Fix: Handle null line/column values in ESLint and Bandit parsers
- Fix TypeError when linters return null instead of missing fields - Use 'or' operator to safely convert null to 0 - Affects only JSON-based parsers (ESLint, Bandit) - Line 0 indicates file-level or configuration issues Fixes GitHub issue: "TypeError: '<' not supported between instances of 'str' and 'NoneType'"
This commit is contained in:
@@ -67,8 +67,8 @@ def parse_eslint_output(output: str, workset_files: set[str]) -> tuple[list[dict
|
|||||||
translated = {
|
translated = {
|
||||||
"tool": "eslint",
|
"tool": "eslint",
|
||||||
"file": file_str,
|
"file": file_str,
|
||||||
"line": int(message.get("line", 0)),
|
"line": int(message.get("line") or 0),
|
||||||
"column": int(message.get("column", 0)),
|
"column": int(message.get("column") or 0),
|
||||||
"rule": message.get("ruleId", ""), # Empty not "unknown"
|
"rule": message.get("ruleId", ""), # Empty not "unknown"
|
||||||
"message": message.get("message", ""),
|
"message": message.get("message", ""),
|
||||||
"severity": standard_severity, # Use standardized severity
|
"severity": standard_severity, # Use standardized severity
|
||||||
@@ -489,8 +489,8 @@ def parse_bandit_output(output: str, workset_files: set[str]) -> list[dict[str,
|
|||||||
translated = {
|
translated = {
|
||||||
"tool": "bandit",
|
"tool": "bandit",
|
||||||
"file": matched_file, # Use the matched relative path from workset
|
"file": matched_file, # Use the matched relative path from workset
|
||||||
"line": int(result.get("line_number", 0)),
|
"line": int(result.get("line_number") or 0),
|
||||||
"column": int(result.get("col_offset", 0)),
|
"column": int(result.get("col_offset") or 0),
|
||||||
"rule": result.get("test_id", ""),
|
"rule": result.get("test_id", ""),
|
||||||
"message": result.get("issue_text", ""),
|
"message": result.get("issue_text", ""),
|
||||||
"severity": severity_map.get(result.get("issue_severity", "MEDIUM"), "warning"),
|
"severity": severity_map.get(result.get("issue_severity", "MEDIUM"), "warning"),
|
||||||
|
|||||||
Reference in New Issue
Block a user