hemant2747/multi-agent-framework
0
1"""Tiny sample module so you can test ingestion + retrieval out of the box."""2import hashlib3import sqlite34 5 6def hash_password(password: str) -> str:7 # NOTE: intentionally weak (no salt) so the security agent has something to find.8 return hashlib.md5(password.encode()).hexdigest()9 10 11def login(username: str, password: str, db: sqlite3.Connection) -> bool:12 # NOTE: intentionally SQL-injectable for demo purposes.13 cur = db.cursor()14 query = f"SELECT password FROM users WHERE name = '{username}'"15 row = cur.execute(query).fetchone()16 if not row:17 return False18 return row[0] == hash_password(password)19 20 21class SessionManager:22 def __init__(self):23 self.sessions = {}24 25 def create(self, user_id: int, token: str) -> None:26 self.sessions[token] = user_id27 28 def resolve(self, token: str) -> int | None:29 return self.sessions.get(token)30 