From 4f6729d64cebf5676893153d4ec93cbf8b9f111f Mon Sep 17 00:00:00 2001 From: TheAuditorTool Date: Tue, 9 Sep 2025 17:46:15 +0700 Subject: [PATCH] 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'" --- theauditor/linters/parsers.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/theauditor/linters/parsers.py b/theauditor/linters/parsers.py index 9f187a9..507f2d4 100644 --- a/theauditor/linters/parsers.py +++ b/theauditor/linters/parsers.py @@ -67,8 +67,8 @@ def parse_eslint_output(output: str, workset_files: set[str]) -> tuple[list[dict translated = { "tool": "eslint", "file": file_str, - "line": int(message.get("line", 0)), - "column": int(message.get("column", 0)), + "line": int(message.get("line") or 0), + "column": int(message.get("column") or 0), "rule": message.get("ruleId", ""), # Empty not "unknown" "message": message.get("message", ""), "severity": standard_severity, # Use standardized severity @@ -489,8 +489,8 @@ def parse_bandit_output(output: str, workset_files: set[str]) -> list[dict[str, translated = { "tool": "bandit", "file": matched_file, # Use the matched relative path from workset - "line": int(result.get("line_number", 0)), - "column": int(result.get("col_offset", 0)), + "line": int(result.get("line_number") or 0), + "column": int(result.get("col_offset") or 0), "rule": result.get("test_id", ""), "message": result.get("issue_text", ""), "severity": severity_map.get(result.get("issue_severity", "MEDIUM"), "warning"),