Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01DmXxNULoSNPvjF7buKipsB
58 lines
2.0 KiB
Python
58 lines
2.0 KiB
Python
import os
|
|
import subprocess
|
|
import requests
|
|
|
|
# ruleid: cra-ai-20-python-shell-command
|
|
os.system("ping -c 1 " + host)
|
|
# ok: cra-ai-20-python-shell-command
|
|
os.system("uptime")
|
|
# ruleid: cra-ai-20-python-shell-command
|
|
subprocess.call("rotate-key --id " + key_id, shell=True)
|
|
# ok: cra-ai-20-python-shell-command
|
|
subprocess.call("rotate-key --all", shell=True)
|
|
# ok: cra-ai-20-python-shell-command
|
|
subprocess.call(["rotate-key", "--id", key_id])
|
|
|
|
# ruleid: cra-ai-20-python-sql-string
|
|
cur.execute("SELECT * FROM users WHERE id = " + user_id)
|
|
# ruleid: cra-ai-20-python-sql-string
|
|
cur.execute(f"SELECT * FROM users WHERE id = {user_id}")
|
|
# ruleid: cra-ai-20-python-sql-string
|
|
cur.execute("SELECT * FROM users WHERE id = %s" % user_id)
|
|
# ok: cra-ai-20-python-sql-string
|
|
cur.execute("SELECT * FROM users WHERE id = %s", (user_id,))
|
|
# ok: cra-ai-20-python-sql-string
|
|
cur.execute("SELECT 1")
|
|
|
|
# ruleid: cra-ai-8-python-hardcoded-credential
|
|
ADMIN_PASSWORD = "admin123"
|
|
# ruleid: cra-ai-8-python-hardcoded-credential
|
|
API_KEY = "sk_live_51HxYzABCDEFghijklmnopqrstuvwxyz0123456789"
|
|
# ok: cra-ai-8-python-hardcoded-credential
|
|
ADMIN_PASSWORD = os.environ["ADMIN_PASSWORD"]
|
|
# ok: cra-ai-8-python-hardcoded-credential
|
|
PASSWORD_FIELD = "password"
|
|
# ok: cra-ai-8-python-hardcoded-credential
|
|
password = ""
|
|
# ok: cra-ai-8-python-hardcoded-credential
|
|
password = "changeme"
|
|
|
|
# ruleid: cra-ai-15-python-cleartext-http
|
|
requests.get("http://api.internal.example/" + path)
|
|
# ok: cra-ai-15-python-cleartext-http
|
|
requests.get("https://api.internal.example/" + path)
|
|
# ok: cra-ai-15-python-cleartext-http
|
|
requests.get("http://localhost:8080/health")
|
|
|
|
import pickle
|
|
import yaml
|
|
|
|
# ruleid: cra-ai-20-python-unsafe-deserialization
|
|
config = yaml.load(request.data)
|
|
# ok: cra-ai-20-python-unsafe-deserialization
|
|
config = yaml.load(request.data, Loader=yaml.SafeLoader)
|
|
# ok: cra-ai-20-python-unsafe-deserialization
|
|
config = yaml.safe_load(request.data)
|
|
# ruleid: cra-ai-20-python-unsafe-deserialization
|
|
session = pickle.loads(request.cookies["session"])
|