Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions sast_test_file.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@

import sqlite3
import os
import pickle

# Hardcoded credentials (Issue: Sensitive Information Exposure)
USERNAME = "admin"
PASSWORD = "password123"

# SQL Injection vulnerability
user_input = input("Enter username: ")
connection = sqlite3.connect("example.db")
cursor = connection.cursor()
query = f"SELECT * FROM users WHERE username = '{user_input}'"
cursor.execute(query)
print(cursor.fetchall())

# Command Injection vulnerability
filename = input("Enter filename to list: ")
os.system(f"ls {filename}")

# Insecure deserialization
malicious_data = b"cos
system
(S'echo hacked'
tR."
pickle.loads(malicious_data)

# Weak cryptography
import hashlib
password = "mypassword"
hash_value = hashlib.md5(password.encode()).hexdigest()
print("MD5 hash:", hash_value)
Loading