2020-12-13 15:14:13 +00:00
|
|
|
|
# Contributing
|
|
|
|
|
|
|
|
|
|
As an open source project, mitmproxy welcomes contributions of all forms. If you would like to bring the project
|
|
|
|
|
forward, please consider contributing in the following areas:
|
|
|
|
|
|
|
|
|
|
- **Maintenance:** We are *incredibly* thankful for individuals who are stepping up and helping with maintenance. This
|
|
|
|
|
includes (but is not limited to) triaging issues, reviewing pull requests and picking up stale ones, helping out other
|
2021-11-16 09:26:38 +00:00
|
|
|
|
users on [GitHub Discussions](https://github.com/mitmproxy/mitmproxy/discussions), creating minimal, complete and
|
2020-12-13 15:14:13 +00:00
|
|
|
|
verifiable examples or test cases for existing bug reports, updating documentation, or fixing minor bugs that have
|
|
|
|
|
recently been reported.
|
|
|
|
|
- **Code Contributions:** We actively mark issues that we consider are [good first contributions](
|
|
|
|
|
https://github.com/mitmproxy/mitmproxy/issues?q=is%3Aissue+is%3Aopen+label%3A%22help+wanted%22). If you intend to work
|
|
|
|
|
on a larger contribution to the project, please come talk to us first.
|
|
|
|
|
|
|
|
|
|
## Development Setup
|
|
|
|
|
|
2023-02-27 07:21:41 +00:00
|
|
|
|
To get started hacking on mitmproxy, please install the latest version of Python and do the following:
|
2020-12-13 15:14:13 +00:00
|
|
|
|
|
2021-01-18 12:56:27 +00:00
|
|
|
|
##### Linux / macOS
|
2021-03-11 18:13:02 +00:00
|
|
|
|
|
2020-12-13 15:14:13 +00:00
|
|
|
|
```shell
|
2021-01-18 12:56:27 +00:00
|
|
|
|
# 1) Verify that these commands work:
|
2020-12-13 15:14:13 +00:00
|
|
|
|
python3 --version
|
|
|
|
|
python3 -m pip --help
|
|
|
|
|
python3 -m venv --help
|
2021-01-18 12:56:27 +00:00
|
|
|
|
# 2) Install:
|
|
|
|
|
git clone https://github.com/mitmproxy/mitmproxy.git
|
|
|
|
|
cd mitmproxy
|
|
|
|
|
python3 -m venv venv
|
2021-02-05 03:11:23 +00:00
|
|
|
|
venv/bin/pip install -e ".[dev]"
|
2020-12-13 15:14:13 +00:00
|
|
|
|
```
|
|
|
|
|
|
2021-01-18 12:56:27 +00:00
|
|
|
|
##### Windows
|
2021-03-11 18:13:02 +00:00
|
|
|
|
|
2020-12-13 15:14:13 +00:00
|
|
|
|
```shell
|
2021-01-18 12:56:27 +00:00
|
|
|
|
# 1) Verify that this command works:
|
|
|
|
|
python --version
|
|
|
|
|
# 2) Install:
|
2020-12-13 15:14:13 +00:00
|
|
|
|
git clone https://github.com/mitmproxy/mitmproxy.git
|
|
|
|
|
cd mitmproxy
|
2021-01-18 12:56:27 +00:00
|
|
|
|
python -m venv venv
|
|
|
|
|
venv\Scripts\pip install -e .[dev]
|
2020-12-13 15:14:13 +00:00
|
|
|
|
```
|
|
|
|
|
|
2021-01-18 12:56:27 +00:00
|
|
|
|
This will clone mitmproxy's source code into a directory with the same name,
|
|
|
|
|
and then create an isolated Python environment (a [virtualenv](https://virtualenv.pypa.io/)) into which all dependencies are installed.
|
|
|
|
|
Mitmproxy itself is installed as "editable", so any changes to the source in the repository will be reflected live in the virtualenv.
|
2020-12-13 15:14:13 +00:00
|
|
|
|
|
2021-01-18 12:56:27 +00:00
|
|
|
|
The main executables for the project – `mitmdump`, `mitmproxy`, and `mitmweb` – are all created within the virtualenv.
|
2020-12-13 15:14:13 +00:00
|
|
|
|
After activating the virtualenv, they will be on your $PATH, and you can run them like any other command:
|
|
|
|
|
|
2021-01-18 12:56:27 +00:00
|
|
|
|
##### Linux / macOS
|
2021-03-11 18:13:02 +00:00
|
|
|
|
|
2021-01-18 12:56:27 +00:00
|
|
|
|
```shell
|
|
|
|
|
source venv/bin/activate
|
|
|
|
|
mitmdump --version
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
##### Windows
|
2021-03-11 18:13:02 +00:00
|
|
|
|
|
2020-12-13 15:14:13 +00:00
|
|
|
|
```shell
|
2021-01-18 12:56:27 +00:00
|
|
|
|
venv\Scripts\activate
|
2020-12-13 15:14:13 +00:00
|
|
|
|
mitmdump --version
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
## Testing
|
|
|
|
|
|
|
|
|
|
If you've followed the procedure above, you already have all the development requirements installed, and you can run the
|
|
|
|
|
basic test suite with [tox](https://tox.readthedocs.io/):
|
|
|
|
|
|
|
|
|
|
```shell
|
|
|
|
|
tox -e py # runs Python tests
|
|
|
|
|
```
|
|
|
|
|
|
2021-01-18 12:56:27 +00:00
|
|
|
|
Our CI system has additional tox environments that are run on every pull request (see [tox.ini](./tox.ini)).
|
2020-12-13 15:14:13 +00:00
|
|
|
|
|
2021-01-18 12:56:27 +00:00
|
|
|
|
For speedier testing, you can also run [pytest](http://pytest.org/) directly on individual test files or folders:
|
2020-12-13 15:14:13 +00:00
|
|
|
|
|
|
|
|
|
```shell
|
|
|
|
|
cd test/mitmproxy/addons
|
2023-12-02 01:37:37 +00:00
|
|
|
|
pytest --looponfail test_anticache.py
|
2020-12-13 15:14:13 +00:00
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
Please ensure that all patches are accompanied by matching changes in the test suite. The project tries to maintain 100%
|
|
|
|
|
test coverage and enforces this strictly for some parts of the codebase.
|
|
|
|
|
|
2021-01-18 12:56:27 +00:00
|
|
|
|
### Code Style
|
2020-12-13 15:14:13 +00:00
|
|
|
|
|
2021-01-18 12:56:27 +00:00
|
|
|
|
Keeping to a consistent code style throughout the project makes it easier to contribute and collaborate.
|
2020-12-13 15:14:13 +00:00
|
|
|
|
|
2021-01-18 12:56:27 +00:00
|
|
|
|
We enforce the following check for all PRs:
|
2020-12-13 15:14:13 +00:00
|
|
|
|
|
|
|
|
|
```shell
|
2023-10-31 15:03:53 +00:00
|
|
|
|
tox -e lint
|
2020-12-13 15:14:13 +00:00
|
|
|
|
```
|
|
|
|
|
|
2021-01-18 12:56:27 +00:00
|
|
|
|
If a linting error is detected, the automated pull request checks will fail and block merging.
|
2020-12-13 15:14:13 +00:00
|
|
|
|
|
2021-01-18 12:56:27 +00:00
|
|
|
|
## Documentation
|
2020-12-13 15:14:13 +00:00
|
|
|
|
|
2021-01-18 12:56:27 +00:00
|
|
|
|
Please check [docs/README.md](./docs/README.md) for instructions.
|