Skip to content

Add example utilities#9

Open
matej wants to merge 13 commits intomainfrom
matej/add-example-utilities
Open

Add example utilities#9
matej wants to merge 13 commits intomainfrom
matej/add-example-utilities

Conversation

@matej
Copy link
Member

@matej matej commented Feb 4, 2026

Summary

  • Adds example utility functions for demonstration purposes

Test plan

  • Review the example utilities code

🤖 Generated with Claude Code

Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Summary: 5 findings across 1 file (HIGH: 4, MEDIUM: 1, LOW: 0).
Assessment: High-severity issues were found that should be addressed before merge.

def load_user_data(serialized_data):
"""Load user data from serialized format."""
# Security issue: unsafe pickle deserialization
return pickle.loads(serialized_data)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤖 Code Review Finding: Unsafe pickle deserialization enables remote code execution

Severity: HIGH
Category: security

Impact: An attacker who can control the serialized_data input can achieve remote code execution by crafting a malicious pickle payload. This is a well-known exploitation technique that can lead to complete system compromise.

Recommendation: Use a safe serialization format like JSON for untrusted data. If pickle is absolutely required, implement cryptographic signing to verify data integrity and source authenticity.

Suggested change
return pickle.loads(serialized_data)
return json.loads(serialized_data)

def run_command(user_input):
"""Run a shell command based on user input."""
# Security issue: command injection
result = subprocess.run(f"echo {user_input}", shell=True, capture_output=True)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤖 Code Review Finding: Command injection via shell=True with unsanitized user input

Severity: HIGH
Category: security

Impact: An attacker can inject arbitrary shell commands. For example, input like ; rm -rf / or $(cat /etc/passwd) would execute additional commands. This leads to remote code execution and potential full system compromise.

Recommendation: Avoid shell=True with user input. Use a list of arguments instead, which prevents shell interpretation of metacharacters.

Suggested change
result = subprocess.run(f"echo {user_input}", shell=True, capture_output=True)
result = subprocess.run(["echo", user_input], capture_output=True)

Comment on lines +24 to +25
path = f"/data/{filename}"
with open(path, "r") as f:
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤖 Code Review Finding: Path traversal vulnerability allows reading arbitrary files

Severity: HIGH
Category: security

Impact: An attacker can read arbitrary files on the system by providing input like ../etc/passwd or ../../../../etc/shadow. This can expose sensitive configuration files, credentials, or application source code.

Recommendation: Validate and sanitize the filename. Use os.path.basename() to strip directory components, or resolve the full path and verify it remains within the intended directory.

Suggested change
path = f"/data/{filename}"
with open(path, "r") as f:
safe_filename = os.path.basename(filename)
path = f"/data/{safe_filename}"
with open(path, "r") as f:

Comment on lines +49 to +50
query = f"SELECT * FROM users WHERE id = {user_id}"
return connection.execute(query)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤖 Code Review Finding: SQL injection via string interpolation in query construction

Severity: HIGH
Category: security

Impact: An attacker can manipulate the query by providing malicious input like 1 OR 1=1 to bypass authentication, 1; DROP TABLE users-- to destroy data, or UNION SELECT attacks to exfiltrate data from other tables.

Recommendation: Use parameterized queries with placeholders. Pass user input as parameters rather than interpolating into the query string.

Suggested change
query = f"SELECT * FROM users WHERE id = {user_id}"
return connection.execute(query)
query = "SELECT * FROM users WHERE id = ?"
return connection.execute(query, (user_id,))

def process_items(items):
"""Process a list of items."""
results = []
for i in range(len(items)):
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤖 Code Review Finding: O(n²) algorithm with redundant self-comparisons

Severity: MEDIUM
Category: performance

Impact: For large lists, this will cause significant performance degradation. A list of 10,000 items requires 100 million comparisons. Additionally, the logic appears broken - it always matches items to themselves, resulting in duplicates.

Recommendation: If the goal is to find duplicate items, use a Counter or set-based approach. If finding unique items, use list(set(items)). The current implementation's intent is unclear.

@matej matej force-pushed the matej/add-example-utilities branch from 7585ebe to 8a26559 Compare February 13, 2026 12:29
@matej matej force-pushed the matej/add-example-utilities branch from 06be829 to 303714d Compare February 13, 2026 13:02
Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Found 5 compliance, correctness, and reliability issues. Please address the high-severity issues before merging.

@@ -0,0 +1,44 @@
"""Unit tests for review_orchestrator."""

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤖 Code Review Finding: New functionality added without required tests

Severity: HIGH
Category: compliance

Impact: Insufficient test coverage for critical review orchestration logic increases risk of regressions and bugs in production. The orchestrator handles triage, context discovery, compliance, quality, security, and validation phases - only 2 tests is inadequate.

Recommendation: Add comprehensive test coverage for ReviewOrchestrator including: successful multi-phase flow, individual phase failures, finding merging, filtering integration, exclusion logic, and edge cases


except AuditError as e:
print(json.dumps({'error': f'Code review failed: {str(e)}'}))
success, review_results, review_error = orchestrator.run(

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤖 Code Review Finding: review_context (prior review feedback) silently dropped in multi-phase flow

Severity: HIGH
Category: correctness

Impact: On re-reviews (trigger-on-commit or PR synchronize), Claude will never see previous review comments, user replies, or reaction feedback. This causes the reviewer to re-flag issues the developer already addressed or dismissed, defeating the purpose of the iterative review thread.

Recommendation: Add a review_context parameter to ReviewOrchestrator.run() and forward it into the relevant phase prompts (at minimum quality and security). Pass review_context from main() into orchestrator.run().

custom_security_instructions=custom_security_instructions,
)

ok_c, compliance_result, err_c = self._run_phase(repo_dir, compliance_prompt, self.model_config.compliance, "compliance")

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤖 Code Review Finding: All three specialist phases run sequentially; single phase failure aborts entire review

Severity: MEDIUM
Category: reliability

Impact: A transient failure in one specialist phase (e.g., a timeout in the compliance phase) will discard all findings from the other successful phases, causing a complete review failure where a partial result would be more useful.

Recommendation: Collect errors from failed phases but continue with successful ones. Only fail the entire orchestration if all specialist phases fail or if a critical phase (like quality or security) fails.

return True, "", parsed_result

# Parse failed
if attempt == 0:

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤖 Code Review Finding: Parse failure only retried once regardless of NUM_RETRIES setting

Severity: MEDIUM
Category: correctness

Impact: Transient parse failures (e.g., partial stdout due to timing) are retried less aggressively than other failure modes. With NUM_RETRIES=3, a parse failure gets 1 retry while other errors get 2.

Recommendation: Change if attempt == 0 to if attempt < NUM_RETRIES - 1 for consistency with the other retry conditions.

}
kept_findings = validated
original_count = len(all_candidates)
filter_response = self.findings_filter.filter_findings(validated, pr_context)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤖 Code Review Finding: Filter failure silently keeps all findings without logging

Severity: MEDIUM
Category: correctness

Impact: If the filter returns an unexpected format (e.g., a 2-tuple or raises), the orchestrator silently skips filtering. Without logging, operators cannot tell that filtering was bypassed during a review run.

Recommendation: Add a logger.warning() when the filter response doesn't match the expected 3-tuple shape, so operators can detect filter bypass in production.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant