-
-
Notifications
You must be signed in to change notification settings - Fork 59
Description
📋 Unified Requirements Management & Setup Instructions
🎯 Overview
The repository currently lacks a single, authoritative dependency management and setup flow. That causes onboarding friction and inconsistent runtime behaviour across contributors and users. This document centralizes dependency definitions, setup instructions, dev tooling, and CI checks so the project is reproducible and easy to contribute to.
🔍 Current State
- Individual scripts in
python-scripts/(and other directories) use third-party libraries without documented requirements. - Only one
requirements.txtexists atsql-injection-lab/requirements.txt(containsFlaskandpytest). - No repository root-level
requirements.txtorrequirements-dev.txt. - No setup instructions for Python environment configuration or platform notes.
- Dependencies are not version-pinned, increasing the risk of breakage.
📚 Dependencies Identified
Core Dependencies (used across scripts)
scapy— Network packet manipulationrequests— HTTP requestsbeautifulsoup4— HTML parsingcryptography— SSL/TLS analysisgeoip2— IP geolocationurllib3— HTTP client utilitiesparamiko— SSH connections (implied)
Optional / Development Dependencies
pytest>=7.0— Testing frameworkFlask>=2.0— Web framework (sql injection lab)
Note: exact minimum versions should be derived from static analysis & running the test matrix (Phase 1).
🎯 Proposed Solution (High-level)
- Add a repository root
requirements.txtwith pinned (minimum) versions for core runtime dependencies. - Add
requirements-dev.txtfor developer tools and testing libraries. - Add comprehensive setup docs:
README.mdadditions +SETUP.mdwith platform-specific notes. - Optionally add
pyproject.tomlorsetup.pyfor packaging/distribution, and aDockerfilefor reproducible environments. - Add CI checks to validate dependency installation and run smoke tests.
📋 Tasks & Phases
Phase 1: Core Requirements
- Analyze every Python file to enumerate
importstatements and map them to PyPI package names. - Determine minimum versions by running scripts on a clean environment and noting any version-specific features/errors.
- Create
requirements.txtat repository root with pinned minimum versions (usepackage>=min_version,<next_majorwhere appropriate). - Test the
requirements.txtby creating a fresh virtual environment and installing. - Update
sql-injection-lab/requirements.txtto reference or include the root file (see examples).
Deliverables: requirements.txt (root), verification notes, updated sql-injection-lab/requirements.txt.
Phase 2: Documentation & Setup
- README.md / SETUP.md: Add step-by-step environment setup (venv, pip, Windows/Linux/macOS specifics).
- Platform Notes: Npcap installation (Windows),
sudo/capabilities for Scapy (Linux), macOS permissions. - Troubleshooting: Common permission errors, binary dependency issues, SSL issues,
pipwheels vs. source builds. - Activation scripts: Provide shell and PowerShell snippets for activating venvs.
Deliverables: SETUP.md, patches to README.md.
Phase 3: Development Environment
- Create
requirements-dev.txt— containspytest, linters, pre-commit hooks,black,isort,mypy(optional) - Pre-commit: Add
.pre-commit-config.yamland example hooks. - CI Workflow: Add GitHub Actions workflow to validate installs and run unit tests on PRs.
- Virtualenv helper scripts:
scripts/activate_venv.shandscripts/activate_venv.ps1.
Deliverables: requirements-dev.txt, .pre-commit-config.yaml, .github/workflows/ci.yml, helper scripts.
Phase 4: Advanced (Optional)
pyproject.tomlwithbuild-systemmetadata and dependency groups.Dockerfileanddocker-compose.ymlfor development.- One-command install script:
scripts/bootstrap.sh/scripts/bootstrap.ps1.
🎁 Benefits
Contributors
- Consistent environments and faster onboarding.
Users
- Clear, tested setup steps and platform guidance.
Maintainers
- Easier dependency tracking, versioning, and security scanning.
🔧 Technical Considerations
- Python support: Target Python 3.8+ unless older syntax mandates otherwise.
- Pinning policy: Use minimum pinned versions with a compatibility upper bound (e.g.,
requests>=2.28.0,<3.0.0). - Platform-specific notes: Document packet-capture privileges (Linux capabilities or running as root) for
scapy, and Npcap installer for Windows. - Security: Prefer well-maintained packages; add
pip-auditorsafetyinrequirements-dev.txt.
⚙️ Example Files & Snippets
Save these as examples in the repo (e.g.,
examples/requirements_samples/).
Example: requirements.txt (root)
# Core runtime dependencies (minimum pinned versions)
scapy>=2.4.5,<3.0
requests>=2.28.0,<3.0
beautifulsoup4>=4.11.1,<5.0
cryptography>=39.0.0,<40.0
geoip2>=4.6.0,<5.0
urllib3>=1.26.14,<2.0
paramiko>=2.11.0,<3.0
Example: requirements-dev.txt
-r requirements.txt
pytest>=7.0
black
isort
mypy
pre-commit
pip-audit
Example: sql-injection-lab/requirements.txt (wrapper)
# include core requirements from root
-r ../requirements.txt
# lab-specific additions
Flask>=2.0
pytest>=7.0
🧭 README / SETUP.md — Key Sections to Add
- Quickstart (30 seconds): create venv, install deps, run a sample script.
- Full Setup (detailed): platform-specific steps and troubleshooting.
- Running tests and lints.
- Contributing guide with dev workflow and commit hooks.
- How to add new dependencies (policy for pinning and PR process).
🛠️ Example SETUP.md Outline (detailed)
-
Prerequisites
- Python 3.8+ installed
pipup-to-date:python -m pip install --upgrade pip
-
Linux / macOS
python -m venv .venv source .venv/bin/activate pip install -r requirements-dev.txt-
For
scapyraw sockets: either run scripts as root or set capabilities (Linux):sudo setcap cap_net_raw,cap_net_admin=eip $(which python3)
-
-
Windows (PowerShell)
python -m venv .venv .\.venv\Scripts\Activate.ps1 pip install -r requirements-dev.txt
- Install Npcap (WinPcap-compatible) for packet capture.
-
Virtual Environment Activation Shortcuts
scripts/activate_venv.shandscripts/activate_venv.ps1provided.
-
Troubleshooting
- Permission errors with Scapy: use
sudoor capabilities. - Binary wheel build failures: install system-level build tools (
build-essential/python3-dev). pipcache issues:pip cache purgethen reinstall.
- Permission errors with Scapy: use