feat: add --disable-addon CLI option to selectively disable addons#8
Conversation
Add ability to disable specific addons via CLI argument or YAML config. This allows users to run the proxy with only the addons they need, providing more granular control over which security headers are removed or modified. Features: - CLI option --disable-addon accepts short names (CSP, COEP, etc.) or full class names - Supports comma-separated values: --disable-addon CSP,COEP - Supports repeated usage: --disable-addon CSP --disable-addon COEP - Case-insensitive addon name matching - YAML config support via disabled_addons list - Fuzzy matching with "Did you mean?" suggestions for typos - Configuration precedence: CLI > YAML > defaults Implementation: - Added addon name mapping and validation in devrelay/addons.py - Extended ConfigLoader to parse and validate disabled_addons - Updated ProxyServer to conditionally load addons - Updated CLI to display disabled addons on startup - Comprehensive test coverage (147 tests, 100% coverage) - Updated README.md with usage examples and configuration docs 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
There was a problem hiding this comment.
Pull Request Overview
This PR adds the ability to selectively disable proxy addons through a new --disable-addon CLI option. Users can now choose which security header manipulation addons to run, providing more granular control over the proxy's behavior.
Key changes:
- Added
disabled_addonsparameter to configuration system with validation against known addon names - Implemented fuzzy matching for addon name suggestions when invalid names are provided
- Extended CLI, proxy server, and configuration components to support the new functionality
Reviewed Changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| devrelay/addons.py | Added validate_addon_names() function with fuzzy matching and addon name mapping for short/full name support |
| devrelay/config.py | Added disabled_addons parameter with custom parsing for comma-separated and repeated CLI arguments |
| devrelay/cli.py | Updated methods to accept and display disabled addons |
| devrelay/proxy.py | Modified addon loading to conditionally skip disabled addons |
| README.md | Added documentation for the new --disable-addon option with usage examples |
| tests/test_proxy.py | Added comprehensive tests for disabled addons functionality |
| tests/test_devrelay.py | Updated tests to pass disabled_addons parameter |
| tests/test_config.py | Added extensive tests for addon list parsing and validation |
| tests/test_addons.py | Added tests for validate_addon_names() function |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
PR Review: Add --disable-addon CLI optionSummaryThis is an excellent, production-ready PR that implements selective addon disabling with robust error handling, comprehensive testing, and thorough documentation. The implementation demonstrates high code quality and follows best practices throughout. Code Quality & Best Practices ✅Strengths
Minor Suggestions
Potential Bugs 🐛None FoundThe code handles edge cases extremely well:
Performance Considerations ⚡Excellent
Notes
Security Concerns 🔒None Identified
Test Coverage 🧪Outstanding (100% coverage maintained)New Tests Added: 147 total tests (+16 new test cases) Coverage by Component:
Test Quality:
Additional ObservationsExcellent Practices
Alignment with Project Standards✅ AGENTS.md: Follows all coding standards RecommendationAPPROVE ✅ This PR is exemplary and ready to merge. The implementation is thoughtful, well-tested, and follows all project conventions. The minor suggestions above are optional refinements, not blockers. Optional Follow-ups (Non-blocking)
Great work! 🎉 🤖 Generated with Claude Code |
- Extract magic number 15 to SHORT_NAME_MAX_LENGTH constant for clarity - Derive valid_short_names from ADDON_NAME_MAP programmatically instead of hardcoding - Remove unused ALL_ADDON_NAMES constant (was defined but never used) These changes improve maintainability by ensuring a single source of truth for addon names and making the code more self-documenting. All tests still pass with 100% coverage maintained. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
Pull Request Review: Add --disable-addon CLI OptionOverall AssessmentVerdict: Excellent - Ready to Merge This is a high-quality PR that adds a valuable feature with excellent implementation. The code demonstrates strong software engineering practices with comprehensive testing, thoughtful design, and attention to detail. Strengths1. Code Quality & Best Practices - 5/5 StarsExcellent architecture and design patterns:
Strong naming conventions:
Documentation:
2. Security & Robustness - 5/5 StarsNo security concerns identified:
Robust error handling:
3. Test Coverage - 5/5 StarsOutstanding test coverage - 100% line and branch coverage:
4. Performance Considerations - 4/5 StarsEfficient implementation:
Minor optimization opportunity (not blocking): Issues FoundCritical Issues: NoneMajor Issues: NoneMinor Issues & Suggestions1. Potential UX Improvement (devrelay/addons.py:7)The SHORT_NAME_MAX_LENGTH of 15 feels arbitrary. Consider documenting why 15 was chosen, or use an explicit set of user-facing names.
2. Edge Case in _parse_addon_list (devrelay/config.py:127-129)The method handles non-string items with else: result.append(item). Consider adding type validation for defensive programming.
3. Documentation Clarity (devrelay/proxy.py:92-93)The comment could be slightly clearer about the double-negative logic.
Detailed Code Reviewdevrelay/addons.py (+79 lines) - Excellent
devrelay/config.py (+77 lines) - Excellent
devrelay/proxy.py (+18 lines) - Excellent
devrelay/cli.py (+9 lines) - Excellent
Tests (+436 lines) - Excellent
Documentation (README.md +76 lines) - Excellent
Best Practices ChecklistAll items passed:
PerformanceNegligible impact:
RecommendationsBefore MergeNone - This PR is ready to merge as-is. Future Enhancements (Post-Merge)
ConclusionThis PR exemplifies excellent software engineering:
Recommendation: Approve and merge immediately! The author has done an outstanding job addressing all aspects of quality software development. The minor suggestions above are truly optional refinements that could be addressed in future PRs if desired. Review conducted following AGENTS.md guidelines with focus on code quality, security, performance, and test coverage. |
Summary
Add the ability to disable specific addons via
--disable-addonCLI argument or YAML configuration. This provides users with granular control over which security headers are removed or modified by the proxy.Key Features
CSP,COEP,COOP,CORP,CORSInserter,CORSPreflight) and full class names (CSPRemoverAddon, etc.)--disable-addon CSP,COEP--disable-addon CSP --disable-addon COEPdisabled_addons: [CSP, COEP]csp,CSP, andCsPall workImplementation Details
Core Changes
devrelay/addons.py (+85 lines)
ADDON_NAME_MAPfor short name to class name mappingvalidate_addon_names()function with fuzzy matching for error suggestionsdifflib.get_close_matches()for typo detectiondevrelay/config.py (+84 lines)
ConfigLoaderwithdisabled_addonsparameter (type: list)_parse_addon_list()to handle both CLI and YAML formats_validate_value()to validate and normalize addon names_build_parser()to useaction='append'for repeated flag supportdevrelay/proxy.py (+24 lines)
disabled_addonsparameter toProxyServer.__init__()start()to conditionally load addons based on disabled listdevrelay/cli.py (+13 lines)
display_startup_info()to show disabled addonsrun_server()to pass disabled_addons to ProxyServerexecute()to extract disabled_addons from configDocumentation & Testing
README.md (+81 lines)
Comprehensive test coverage (+436 lines across 4 test files)
Usage Examples
CLI
YAML Configuration (~/.mitmproxy/devrelay.yaml)
Error Handling
If you type an invalid addon name, you'll get a helpful suggestion:
Test Plan
make checkpasses (format, lint, lintmd, typecheck, test)🤖 Generated with Claude Code