UNPKG

mcp-server-semgrep

Version:

MCP Server for Semgrep Integration - static code analysis with AI

80 lines (79 loc) 2.35 kB
rules: - id: tempfile-without-flush languages: - python message: Using '$F.name' without '.flush()' or '.close()' may cause an error because the file may not exist when '$F.name' is used. Use '.flush()' or close the file before using '$F.name'. pattern-either: - patterns: - pattern-not-inside: | $F = tempfile.NamedTemporaryFile(...) ... $F.write(...) ... $F.flush() ... $F.name - pattern-not-inside: | $F = tempfile.NamedTemporaryFile(...) ... $F.write(...) ... $F.close() ... $F.name - pattern-not-inside: | $F = tempfile.NamedTemporaryFile(..., delete=False, ...) ... $F.close() ... $F.name - pattern-inside: | $F = tempfile.NamedTemporaryFile(...) ... - pattern: | $F.name - patterns: - pattern-not-inside: | with tempfile.NamedTemporaryFile(...) as $F: ... $F.write(...) ... $F.flush() ... $F.name - pattern-not-inside: | with tempfile.NamedTemporaryFile(...) as $F: ... $F.write(...) ... $F.close() ... $F.name - pattern-not-inside: | with tempfile.NamedTemporaryFile(...) as $F: ... $MODULE.dump(..., $F, ...) ... $F.flush() ... $F.name - pattern-not-inside: | with tempfile.NamedTemporaryFile(...) as $F: ... $MODULE.dump(..., $F, ...) ... $F.close() ... $F.name - pattern-inside: | with tempfile.NamedTemporaryFile(...) as $F: ... - pattern: | $F.name severity: ERROR metadata: category: correctness technology: - python