Complete Phase 1: Foundation - Flask web application infrastructure

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
This commit is contained in:
2025-11-13 23:59:23 -06:00
parent e29c839d80
commit 986c0d3d17
22 changed files with 3138 additions and 42 deletions

View File

@@ -1,5 +1,19 @@
# SneakyScanner Roadmap
**Status:** Phase 1 Complete ✅ | Phase 2 Ready to Start
## Progress Overview
-**Phase 1: Foundation** - Complete (2025-11-13)
- Database schema & SQLAlchemy models
- Settings system with encryption
- Flask app structure with API blueprints
- Docker deployment support
-**Phase 2: Flask Web App Core** - Next up (Weeks 3-4)
- 📋 **Phase 3: Dashboard & Scheduling** - Planned (Weeks 5-6)
- 📋 **Phase 4: Email & Comparisons** - Planned (Weeks 7-8)
- 📋 **Phase 5: CLI as API Client** - Planned (Week 9)
- 📋 **Phase 6: Advanced Features** - Planned (Weeks 10+)
## Vision & Goals
SneakyScanner is evolving from a CLI-based network scanning tool into a comprehensive **Flask web application** for infrastructure monitoring and security auditing. The web application will provide:
@@ -336,58 +350,83 @@ All API endpoints return JSON and follow RESTful conventions.
## Phased Roadmap
### Phase 1: Foundation (Weeks 1-2)
### Phase 1: Foundation ✅ COMPLETE
**Completed:** 2025-11-13
**Priority: CRITICAL** - Database and settings infrastructure
**Goals:**
- Establish database schema
- Create settings system
- Set up Flask project structure
- Establish database schema
- Create settings system
- Set up Flask project structure
**Tasks:**
1. Create SQLite database schema (use Alembic for migrations)
2. Implement SQLAlchemy models for all tables
3. Create database initialization script (`init_db.py`)
4. Implement settings system:
- Settings model with get/set methods
- Default settings initialization
- Encrypted storage for passwords (cryptography library)
5. Set up Flask project structure:
1. Create SQLite database schema (use Alembic for migrations)
2. Implement SQLAlchemy models for all tables (11 models)
3. Create database initialization script (`init_db.py`)
4. Implement settings system:
- Settings model with get/set methods
- Default settings initialization
- Encrypted storage for passwords (cryptography library + bcrypt)
- ✅ PasswordManager for bcrypt password hashing
5. ✅ Set up Flask project structure:
```
SneakyScanner/
├── src/
│ ├── scanner.py (existing)
│ ├── screenshot_capture.py (existing)
│ └── report_generator.py (existing)
├── web/
│ ├── app.py (Flask app factory)
│ ├── models.py (SQLAlchemy models)
│ ├── api/ (API blueprints)
│ ├── scans.py
│ │ ├── schedules.py
│ │ ├── alerts.py
│ │ ── settings.py
├── templates/ (Jinja2 templates)
├── static/ (CSS, JS, images)
── utils/ (helpers, decorators)
├── migrations/ (Alembic migrations)
├── web/ ✅ CREATED
│ ├── __init__.py ✅
│ ├── app.py (Flask app factory) ✅
│ ├── models.py (SQLAlchemy models) ✅
├── api/ (API blueprints) ✅
│ │ ├── __init__.py ✅
│ │ ├── scans.py ✅
│ │ ── schedules.py ✅
│ ├── alerts.py ✅
│ └── settings.py ✅ (Fully functional!)
── templates/ (Jinja2 templates) ✅
│ ├── static/ (CSS, JS, images) ✅
│ │ ├── css/ ✅
│ │ ├── js/ ✅
│ │ └── images/ ✅
│ └── utils/ (helpers, decorators) ✅
│ ├── __init__.py ✅
│ └── settings.py ✅
├── migrations/ (Alembic migrations) ✅
│ ├── env.py ✅
│ ├── script.py.mako ✅
│ └── versions/ ✅
│ └── 001_initial_schema.py ✅
├── alembic.ini ✅
├── configs/ (existing)
├── output/ (existing)
└── templates/ (existing - for reports)
```
6. Create `requirements-web.txt` for Flask dependencies
7. Update Dockerfile to support Flask app
6. Create `requirements-web.txt` for Flask dependencies
7. Update Dockerfile to support Flask app
8. ✅ Create `docker-compose-web.yml` for web deployment
9. ✅ Create `validate_phase1.py` for verification
**Deliverables:**
- Working database with schema
- Settings CRUD functionality
- Flask app skeleton (no UI yet)
- Database migration system
- Working database with schema (SQLite3 + Alembic migrations)
- Settings CRUD functionality (with encryption for sensitive values)
- Flask app skeleton with functional Settings API
- Database migration system (Alembic)
- ✅ API blueprint stubs (scans, schedules, alerts, settings)
- ✅ Docker support (Dockerfile updated, docker-compose-web.yml created)
**Testing:**
- Database creates successfully
- Settings can be stored/retrieved
- Flask app starts without errors
- Database creates successfully (`init_db.py` works)
- Settings can be stored/retrieved (encryption working)
- Flask app starts without errors (`python3 -m web.app` works)
- ✅ All validation checks pass (`validate_phase1.py` ✓)
- ✅ All 11 database models defined correctly
- ✅ Settings API endpoints functional and tested
**Documentation:**
- ✅ `PHASE1_COMPLETE.md` - Complete Phase 1 summary with API reference and deployment guide
- ✅ `validate_phase1.py` - Automated validation script
---
@@ -785,7 +824,15 @@ All API endpoints return JSON and follow RESTful conventions.
## Success Metrics
### Phase 1-3 Success
### Phase 1 Success ✅ ACHIEVED
- [x] Database creates successfully with all 11 tables
- [x] Settings can be stored/retrieved with encryption
- [x] Flask app starts without errors
- [x] API blueprints load correctly
- [x] All Python modules have valid syntax
- [x] Docker deployment configured
### Phase 2-3 Success (In Progress)
- [ ] Database stores scan results correctly
- [ ] Dashboard displays scans and trends
- [ ] Scheduled scans execute automatically
@@ -844,8 +891,9 @@ All API endpoints return JSON and follow RESTful conventions.
| Date | Version | Changes |
|------|---------|---------|
| 2025-11-14 | 1.0 | Initial roadmap created based on user requirements |
| 2025-11-13 | 1.1 | **Phase 1 COMPLETE** - Database schema, SQLAlchemy models, Flask app structure, settings system with encryption, Alembic migrations, API blueprints, Docker support, validation script |
---
**Last Updated:** 2025-11-14
**Next Review:** After Phase 1 completion
**Last Updated:** 2025-11-13
**Next Review:** Before Phase 2 kickoff (REST API for scans implementation)