diff --git a/Containerfile b/Containerfile new file mode 100644 index 00000000..135eff00 --- /dev/null +++ b/Containerfile @@ -0,0 +1,55 @@ +# Debian Koji Container +# Koji build system environment with database connections and caching + +FROM debian:trixie-slim + +# Install system dependencies for koji +RUN apt-get update && apt-get install -y \ + python3 \ + python3-pip \ + python3-setuptools \ + python3-wheel \ + python3-dev \ + python3-psycopg2 \ + python3-ldap \ + python3-kerberos \ + python3-gssapi \ + ca-certificates \ + curl \ + postgresql-client \ + && rm -rf /var/lib/apt/lists/* + +# Install koji from the local source +COPY . /tmp/koji +RUN cd /tmp/koji && \ + python3 -m pip install --no-cache-dir -e . && \ + rm -rf /tmp/koji + +# Create non-root user for security +RUN useradd -r -s /bin/bash -u 1000 koji + +# Set up koji directories +RUN mkdir -p /var/lib/koji /var/log/koji /etc/koji && \ + chown -R koji:koji /var/lib/koji /var/log/koji /etc/koji + +# Set working directory +WORKDIR /var/lib/koji + +# Switch to non-root user +USER koji + +# Expose koji hub port +EXPOSE 80 + +# Health check +HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \ + CMD python3 -c "import koji; print('Koji available')" || exit 1 + +# Default command - koji hub +CMD ["python3", "-m", "koji", "hub", "--config", "/etc/koji/koji.conf"] + +# Labels for container management +LABEL org.opencontainers.image.title="Debian Koji" +LABEL org.opencontainers.image.description="Debian Koji - Build system coordination" +LABEL org.opencontainers.image.vendor="Debian Forge Team" +LABEL org.opencontainers.image.source="https://git.raines.xyz/particle-os/debian-koji" diff --git a/security_hardening.py b/security_hardening.py new file mode 100644 index 00000000..cffdcf60 --- /dev/null +++ b/security_hardening.py @@ -0,0 +1,681 @@ +#!/usr/bin/env python3 +""" +Debian Forge Security Hardening Module + +This module provides security testing, hardening, and monitoring capabilities +for the Debian Forge system. +""" + +import hashlib +import json +import os +import re +import sqlite3 +import time +from typing import Dict, List, Optional, Any, Tuple +from dataclasses import dataclass +from pathlib import Path +import secrets + +@dataclass +class SecurityVulnerability: + """Security vulnerability information""" + severity: str # "critical", "high", "medium", "low" + category: str # "authentication", "authorization", "input_validation", "data_protection" + description: str + cve_id: Optional[str] = None + affected_component: str = "unknown" + remediation: str = "" + +@dataclass +class SecurityTestResult: + """Result of a security test""" + test_name: str + passed: bool + details: str + vulnerabilities: List[SecurityVulnerability] = None + recommendations: List[str] = None + +class SecurityHardening: + """Security hardening and testing for Debian Forge""" + + def __init__(self, config_file: str = "security_config.json"): + self.config_file = config_file + self.security_config = self._load_security_config() + self.vulnerabilities_db = "security_vulnerabilities.db" + self._init_vulnerability_db() + + def _load_security_config(self) -> Dict[str, Any]: + """Load security configuration""" + default_config = { + "password_policy": { + "min_length": 12, + "require_uppercase": True, + "require_lowercase": True, + "require_numbers": True, + "require_special": True, + "max_age_days": 90 + }, + "session_policy": { + "timeout_minutes": 30, + "max_failed_attempts": 5, + "lockout_duration_minutes": 15 + }, + "input_validation": { + "max_input_length": 1000, + "allowed_file_types": [".json", ".yaml", ".yml", ".txt"], + "blocked_patterns": ["