Skip to content

Commit 94b1fe0

Browse files
committed
fix(analyzer): skip security checks for test files, remove 'bar' from placeholders
- Security checks now skip test files — they intentionally contain dangerous patterns (eval, exec, etc.) for testing purposes - Removed 'bar' from PLACEHOLDER_PATTERN — too common a word used in tqdm, matplotlib, and other libraries Final verification across 6 repos all showing accurate results.
1 parent c97a35b commit 94b1fe0

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

‎web/api/roast.py‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,8 +107,9 @@ def scan_repo(path: str, max_files: int = 50) -> List[FileResult]:
107107
# ============================================================
108108

109109
TODO_PATTERN = re.compile(r"#\s*(TODO|FIXME|HACK|XXX)\b", re.IGNORECASE)
110-
# Match placeholder names used as standalone identifiers (variable/function names)
111-
PLACEHOLDER_PATTERN = re.compile(r"\b(?:def|class|let|const|var)\s+(?:foo|bar|baz|temp|data2|result2|test123)\b|^\s*(?:foo|bar|baz|temp|data2|result2|test123)\s*=", re.MULTILINE)
110+
# Match placeholder names used as variable/function declarations
111+
# Removed 'bar' — too common a word (tqdm, matplotlib, etc.)
112+
PLACEHOLDER_PATTERN = re.compile(r"\b(?:def|class|let|const|var)\s+(?:foo|baz|temp|data2|result2|test123)\b|^\s*(?:foo|baz|temp|data2|result2|test123)\s*=", re.MULTILINE)
112113
FAKE_IMPORTS = {"magiclib", "utils2", "codemancer", "autocodekit", "aihelpers"}
113114
PASSWORD_PATTERN = re.compile(r"(password|passwd|secret|api_key)\s*=\s*['\"][^'\"]+['\"]", re.IGNORECASE)
114115
URL_PATTERN = re.compile(r"(https?://[^\s'\"]+)")
@@ -200,6 +201,9 @@ def _detect_medium_severity(content: str, path: str, language: str) -> List[Issu
200201
def _detect_security(content: str, path: str, language: str) -> List[Issue]:
201202
issues = []
202203
lines = content.split("\n")
204+
# Skip security checks for test files — they intentionally contain dangerous patterns
205+
if _is_test_file(path):
206+
return issues
203207

204208
# Hardcoded secrets (language-agnostic)
205209
for i, line in enumerate(lines, 1):

0 commit comments

Comments
 (0)