Implement complete database schema and Flask application structure for SneakyScan web interface. This establishes the foundation for web-based scan management, scheduling, and visualization. Database & ORM: - Add 11 SQLAlchemy models for comprehensive scan data storage (Scan, ScanSite, ScanIP, ScanPort, ScanService, ScanCertificate, ScanTLSVersion, Schedule, Alert, AlertRule, Setting) - Configure Alembic migrations system with initial schema migration - Add init_db.py script for database initialization and password setup - Support both migration-based and direct table creation Settings System: - Implement SettingsManager with automatic encryption for sensitive values - Add Fernet encryption for SMTP passwords and API tokens - Implement PasswordManager with bcrypt password hashing (work factor 12) - Initialize default settings for SMTP, authentication, and retention Flask Application: - Create Flask app factory pattern with scoped session management - Add 4 API blueprints: scans, schedules, alerts, settings - Implement functional Settings API (GET/PUT/DELETE endpoints) - Add CORS support, error handlers, and request/response logging - Configure development and production logging to file and console Docker & Deployment: - Update Dockerfile to install Flask dependencies - Add docker-compose-web.yml for web application deployment - Configure volume mounts for database, output, and logs persistence - Expose port 5000 for Flask web server Testing & Validation: - Add validate_phase1.py script to verify all deliverables - Validate directory structure, Python syntax, models, and endpoints - All validation checks passing Documentation: - Add PHASE1_COMPLETE.md with comprehensive Phase 1 summary - Update ROADMAP.md with Phase 1 completion status - Update .gitignore to exclude database files and documentation Files changed: 21 files - New: web/ directory with complete Flask app structure - New: migrations/ with Alembic configuration - New: requirements-web.txt with Flask dependencies - Modified: Dockerfile, ROADMAP.md, .gitignore
60 lines
1.6 KiB
Docker
60 lines
1.6 KiB
Docker
FROM python:3.11-slim
|
|
|
|
# Install system dependencies and masscan
|
|
RUN apt-get update && \
|
|
apt-get install -y --no-install-recommends \
|
|
git \
|
|
build-essential \
|
|
libpcap-dev \
|
|
nmap \
|
|
chromium \
|
|
chromium-driver \
|
|
&& rm -rf /var/lib/apt/lists/*
|
|
|
|
# Build and install masscan from source
|
|
RUN git clone https://github.com/robertdavidgraham/masscan /tmp/masscan && \
|
|
cd /tmp/masscan && \
|
|
make && \
|
|
make install && \
|
|
cd / && \
|
|
rm -rf /tmp/masscan
|
|
|
|
# Set working directory
|
|
WORKDIR /app
|
|
|
|
# Copy requirements and install Python dependencies
|
|
COPY requirements.txt .
|
|
COPY requirements-web.txt .
|
|
RUN pip install --no-cache-dir -r requirements.txt && \
|
|
pip install --no-cache-dir -r requirements-web.txt
|
|
|
|
# Install Playwright browsers (Chromium only)
|
|
# Note: We skip --with-deps since we already installed system chromium and dependencies above
|
|
RUN playwright install chromium
|
|
|
|
# Copy application code
|
|
COPY src/ ./src/
|
|
COPY templates/ ./templates/
|
|
COPY web/ ./web/
|
|
COPY migrations/ ./migrations/
|
|
COPY alembic.ini .
|
|
COPY init_db.py .
|
|
|
|
# Create required directories
|
|
RUN mkdir -p /app/output /app/logs
|
|
|
|
# Make scripts executable
|
|
RUN chmod +x /app/src/scanner.py /app/init_db.py
|
|
|
|
# Force Python unbuffered output
|
|
ENV PYTHONUNBUFFERED=1
|
|
|
|
# Expose Flask web app port
|
|
EXPOSE 5000
|
|
|
|
# Default entry point is the scanner (backward compatibility)
|
|
# To run the Flask web app, override with: docker run --entrypoint python3 sneakyscanner -m web.app
|
|
# To initialize the database, use: docker run --entrypoint python3 sneakyscanner init_db.py
|
|
ENTRYPOINT ["python3", "-u", "/app/src/scanner.py"]
|
|
CMD ["--help"]
|