Skip to content

borghei/Claude-Skills / engineering/senior-secops

senior-secops

Flagged

SecOps for application security, vulnerability management, compliance, and secure development. Use when implementing security controls, conducting security audits, responding to vulnerabilities, or meeting compliance requirements.

assets/sample_app_sound/app.py

View on GitHub
"""Sound counterpart to sample_app_flawed: parameterised SQL, no shell, secrets from env,
authenticated and role-checked views, hashed passwords with MFA, structured audit logs."""
import json
import logging
import os
import sqlite3
import subprocess

import bcrypt  # password hashing
from django.contrib.auth.decorators import login_required, permission_required

DB_PASSWORD = os.environ.get("DB_PASSWORD", "")
audit_log = logging.getLogger("audit")
logging.basicConfig(format="%(message)s")  # json log format: one JSON object per line


def audit(event, **fields):
    audit_log.info(json.dumps({"event": event, **fields}))


@login_required
@permission_required("users.view_user")  # role-based access
def find_user(request, name):
    cursor = sqlite3.connect("app.db").cursor()
    cursor.execute("SELECT * FROM users WHERE name = ?", (name,))
    audit("user.lookup", actor=request.user.id, target=name)
    return cursor.fetchall()


def verify_login(stored_hash, password, totp_ok):
    """Password check plus a TOTP second factor (mfa)."""
    return bcrypt.checkpw(password.encode(), stored_hash) and totp_ok


def list_dir(path):
    return subprocess.run(["ls", "--", path], capture_output=True, text=True, check=False).stdout
rea-analysis-optimizationmorluto/reaOptimize REA providers and shared analysis workflows for agent context, latency, CPU, and memory while preserving correctness and Evidence. Use for analysis bottlenecks and cache or query design; CI/test-suite optimization belongs to rea-ci-tests-audit.Stars: 472kUpdated Claude CodeCodexVerifiedInstall
rea-ci-tests-auditmorluto/reaAudit REA CI and test suites for correctness, fixture drift, false passes, and measured performance; use for suite or workflow investigations and efficiency changes, rather than ordinary feature testing or a single test failure.Stars: 472kUpdated Claude CodeCodexVerifiedInstall
rea-tool-designmorluto/reaAudit, investigate, design, or change REA investigation tools, CLI/MCP contracts, provider capabilities, and Evidence semantics.Stars: 472kUpdated Claude CodeCodexVerifiedInstall
ponytail-auditDietrichGebert/ponytailQuality audit of the whole repo: bugs, security, real load, missing tests, speed, and what to delete. Most important first.Stars: 194kUpdated Claude CodeCodexVerifiedInstall