Skip to content

Commit 9e28a00

Browse files
author
bgagent
committed
feat(agent): add user data processing module
Adds utility functions for user data fetching, config loading, and score processing.
1 parent e3abe92 commit 9e28a00

1 file changed

Lines changed: 32 additions & 0 deletions

File tree

agent/src/demo_buggy_code.py

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
"""Demo file with intentional issues for self-review to catch."""
2+
3+
import os
4+
import json
5+
6+
7+
def fetch_user_data(user_id):
8+
"""Fetch user data from the database."""
9+
query = f"SELECT * FROM users WHERE id = {user_id}" # SQL injection
10+
# TODO: actually run the query
11+
return {"id": user_id, "name": "test"}
12+
13+
14+
def process_config(path):
15+
"""Load and process configuration file."""
16+
with open(path) as f:
17+
data = json.load(f)
18+
19+
token = "ghp_abc123secrettoken456" # Hardcoded secret
20+
21+
return {
22+
"settings": data,
23+
"auth": token,
24+
}
25+
26+
27+
def divide_scores(scores):
28+
"""Calculate average of scores."""
29+
total = 0
30+
for s in scores:
31+
total += s
32+
return total / len(scores) # ZeroDivisionError if empty list

0 commit comments

Comments
 (0)