Buckets:

download
raw
1.61 kB
"""
Comprehensive test file for engineer's test cases.
NOTE: This file contains intentional use of dangerous patterns (os.system, subprocess with shell=True, etc.)
for the purpose of testing, demonstration, and validation of security scanners. These are NOT used in production code.
"""
import os
import hashlib
import random
from flask import request
# Case 1: Hardcoded API key (Secret Detection) - WORKING
API_KEY = "sk-proj-1234567890abcdef" # hardcoded secret
SECRET_TOKEN = "ghp_1234567890abcdefghijklmnop"
# Case 2: SQL Injection - NOW FIXED
def get_user():
uid = request.args.get("id")
query = "SELECT * FROM users WHERE id = %s" % uid # vulnerable
# Should be: query = "SELECT * FROM users WHERE id = ?", (uid,)
return query
# Case 3: Command Injection via os.system - NOW FIXED
def run_ping(host):
os.system("ping -c 1 " + host) # vulnerable
# Should use: subprocess.run(['ping', '-c', '1', host], check=True)
# Case 4: Auto-Fix validation patterns
def weak_crypto_example():
# Weak cryptography - MD5
password = "secret123"
hashed = hashlib.md5(password.encode()).hexdigest() # vulnerable
# Should use: hashlib.sha256()
return hashed
def insecure_random_example():
# Insecure random for token generation
token = str(random.random()) # vulnerable
# Should use: secrets.token_hex(16)
return token
def another_sql_injection():
user_input = "malicious"
query = "DELETE FROM users WHERE name = '%s'" % user_input # vulnerable
return query
if __name__ == "__main__":
print("Test file with multiple vulnerabilities")

Xet Storage Details

Size:
1.61 kB
·
Xet hash:
5b5548cfd7514dd4b77114fdbc89b66198b23e5bc5f047003aaa3d6f3523fe3d

Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.