Contributing to WiFi Jammer
Thank you for your interest in contributing to WiFi Jammer! This guide will help you get started with development and make your first contribution.
Development Setup
1. Clone the Repository
git clone https://github.com/oyi77/wifi-jammer.git
cd wifi-jammer
2. Create a Virtual Environment
python3 -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
3. Install Dependencies
# Install base dependencies
pip install -r requirements.txt
# Install development dependencies
pip install -r requirements-optional.txt
# Install in development mode
pip install -e .
4. Install Development Tools
pip install pytest pytest-cov flake8 black isort
bash install.sh or bash quick_install.sh to automatically set up Location Services permissions.
Code Style Guidelines
WiFi Jammer follows strict code quality standards to ensure maintainability and readability.
Python Best Practices
- PEP 8 Compliance: Follow Python style guide strictly
- Type Hints: Use type annotations for all function parameters and return values
- Docstrings: Google style docstrings for all public functions and classes
- Error Handling: Use specific exception types, not generic exceptions
Code Structure
- Functions: Keep functions under 20 lines, methods under 15 lines
- Classes: Keep classes focused and under 200 lines
- Modules: Keep modules under 500 lines
- Comments: Explain why, not what (code should be self-documenting)
Naming Conventions
- Variables and functions:
snake_case - Classes:
PascalCase - Constants:
UPPER_CASE - Boolean names: Use
is_*,has_*,can_*prefixes
Example: Adding a New Function
def scan_networks(interface: str, channel: int = None) -> List[Network]:
"""
Scan for available WiFi networks on the specified interface.
Args:
interface: The wireless interface name (e.g., 'en0', 'wlan0')
channel: Optional channel number to scan. If None, scans all channels.
Returns:
List of Network objects representing discovered networks.
Raises:
NetworkError: If scanning fails or interface is invalid.
Example:
>>> networks = scan_networks('en0', channel=6)
>>> print(f"Found {len(networks)} networks")
"""
# Implementation here
pass
Architecture Overview
WiFi Jammer follows SOLID principles and uses design patterns for clean, maintainable code.
SOLID Principles
- Single Responsibility: Each class has one clear purpose
- Open/Closed: Open for extension, closed for modification
- Liskov Substitution: Subtypes are substitutable for base types
- Interface Segregation: Clients depend only on interfaces they use
- Dependency Inversion: High-level modules don't depend on low-level modules
Design Patterns
- Factory Pattern: Attack strategy creation (
factory/attack_factory.py) - Strategy Pattern: Different attack implementations (
attacks/) - Observer Pattern: Progress monitoring and callbacks
- Template Method: Base attack class with customizable steps
- Adapter Pattern: Platform-specific interface abstraction
File Structure
wifi_jammer/
├── core/ # Core interfaces and data structures
│ ├── interfaces.py # Attack types, configs, network models
│ └── platform_interface.py # Platform abstraction
├── scanner/ # Network scanning functionality
│ └── network_scanner.py
├── attacks/ # Attack strategy implementations
│ ├── base_attack.py
│ ├── deauth_attack.py
│ └── flood_attacks.py
├── factory/ # Factory pattern for creating attacks
│ └── attack_factory.py
├── utils/ # Utility functions and logging
│ ├── logger.py
│ ├── validators.py
│ └── platform_utils.py
├── gui/ # Qt GUI components
├── cli.py # Command-line interface
└── tui.py # Text user interface
Adding New Attack Types
To add a new attack type, follow these steps:
1. Create Attack Class
Create a new file in wifi_jammer/attacks/:
from wifi_jammer.attacks.base_attack import BaseAttack
from scapy.all import Packet
class MyCustomAttack(BaseAttack):
"""Custom attack implementation."""
def _create_packet(self) -> Packet:
"""
Create the attack packet.
Returns:
Scapy packet for the attack.
"""
# Implement packet creation logic
pass
2. Register in AttackFactory
Add your attack to wifi_jammer/factory/attack_factory.py:
from wifi_jammer.attacks.my_custom_attack import MyCustomAttack
# In AttackFactory class
def _register_attacks(self):
self._attacks = {
AttackType.DEAUTH: DeauthAttack,
AttackType.MY_CUSTOM: MyCustomAttack, # Add your attack
# ... other attacks
}
3. Add Attack Type Enum
Add the new attack type to wifi_jammer/core/interfaces.py:
class AttackType(Enum):
DEAUTH = "deauth"
DISASSOC = "disassoc"
MY_CUSTOM = "my_custom" # Add your attack type
# ... other types
4. Write Tests
Create tests in tests/test_attacks.py:
def test_my_custom_attack():
"""Test custom attack creation and execution."""
factory = AttackFactory()
attack = factory.create_attack(AttackType.MY_CUSTOM)
# Add test assertions
assert attack is not None
Testing Requirements
All code must be thoroughly tested before submission.
Coverage Target
- Minimum 90% code coverage
- Test all public functions and classes
- Include edge cases and error scenarios
Running Tests
# Run all tests
pytest
# Run with coverage
pytest --cov=wifi_jammer --cov-report=html
# Run specific test file
pytest tests/test_attacks.py
# Run with verbose output
pytest -v
Test Organization
- Mirror source code structure in tests
- Use descriptive test names
- Mock external dependencies and network calls
- Test boundary conditions and error scenarios
Example Test
import pytest
from unittest.mock import Mock, patch
from wifi_jammer.attacks.deauth_attack import DeauthAttack
from wifi_jammer.core.interfaces import AttackConfig, AttackType
def test_deauth_attack_creation():
"""Test deauth attack can be created."""
attack = DeauthAttack()
assert attack is not None
assert attack.attack_type == AttackType.DEAUTH
@patch('scapy.all.sendp')
def test_deauth_attack_execution(mock_sendp):
"""Test deauth attack execution."""
config = AttackConfig(
attack_type=AttackType.DEAUTH,
target_bssid="00:11:22:33:44:55",
interface="wlan0",
count=10
)
attack = DeauthAttack()
result = attack.execute(config)
assert result is True
assert mock_sendp.called
Code Quality Tools
Linting
# Run flake8
flake8 wifi_jammer/
# Run with specific rules
flake8 wifi_jammer/ --max-line-length=88
Formatting
# Format code with black
black wifi_jammer/
# Check formatting without changes
black --check wifi_jammer/
# Sort imports
isort wifi_jammer/
Type Checking
# Run mypy (if installed)
mypy wifi_jammer/
Pull Request Process
1. Create a Branch
git checkout -b feature/my-new-feature
# or
git checkout -b fix/bug-description
2. Make Your Changes
- Write clean, well-documented code
- Follow code style guidelines
- Add tests for new functionality
- Update documentation if needed
3. Commit Your Changes
git add .
git commit -m "Add feature: description of changes"
# Use clear, descriptive commit messages
4. Run Tests and Linters
# Run tests
pytest
# Check code style
black --check wifi_jammer/
flake8 wifi_jammer/
# Check coverage
pytest --cov=wifi_jammer --cov-report=term
5. Push and Create Pull Request
git push origin feature/my-new-feature
Then create a pull request on GitHub with:
- Clear description of changes
- Reference to related issues (if any)
- Screenshots (for UI changes)
- Test results
6. Code Review
Your PR will be reviewed for:
- Code quality and style compliance
- Test coverage (minimum 90%)
- SOLID principles adherence
- Security considerations
- Documentation completeness
Code Review Checklist
Before submitting a PR, ensure:
- ✅ All tests pass
- ✅ Code coverage is ≥90%
- ✅ Code follows PEP 8 style guide
- ✅ Type hints are present for all functions
- ✅ Docstrings follow Google style
- ✅ No linter errors or warnings
- ✅ Code is formatted with black
- ✅ Imports are sorted with isort
- ✅ SOLID principles are followed
- ✅ Error handling is appropriate
- ✅ Documentation is updated
- ✅ Security considerations are addressed
Reporting Issues
Found a bug or have a feature request? Please create an issue on GitHub.
Bug Reports
Include the following information:
- Operating system and version
- Python version
- WiFi Jammer version
- Steps to reproduce
- Expected behavior
- Actual behavior
- Error messages or logs
Feature Requests
Describe:
- What you want to achieve
- Why this feature would be useful
- How it should work
- Any alternatives you've considered
Getting Help
Need help getting started or have questions?
- Check the Usage Guide
- Read the Troubleshooting Guide
- Browse existing issues
- Start a discussion
License
By contributing to WiFi Jammer, you agree that your contributions will be licensed under the MIT License.