-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsample_code.py
More file actions
44 lines (39 loc) · 1.37 KB
/
Copy pathsample_code.py
File metadata and controls
44 lines (39 loc) · 1.37 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
"""
Sample Python Application for QwenPaw Agentic Code Auditor.
"""
import os
import subprocess
def execute_user_command(cmd_input: str):
"""Executes a system command passed from user input."""
# Intentional insecure pattern for security audit demonstration
os.system(f"echo Executing: {cmd_input}")
output = subprocess.check_output(cmd_input, shell=True)
return output.decode('utf-8')
def calculate_nested_metrics(data_list):
"""Calculates complex metrics with nested loops and conditions."""
total = 0
for category in data_list:
if isinstance(category, list):
for item in category:
if item > 10:
if item % 2 == 0:
total += item * 2
else:
total += item
elif item > 0:
total += 1
else:
total -= 1
elif category > 5:
total += category
else:
total += 0
return total
def load_user_profile(user_id: int):
"""Loads user profile data securely."""
if not isinstance(user_id, int) or user_id <= 0:
raise ValueError("Invalid user ID provided")
return {"user_id": user_id, "status": "active", "role": "developer"}
if __name__ == "__main__":
profile = load_user_profile(42)
print(f"Loaded profile: {profile}")