| 1 | # Contributing Guidelines |
| 2 | |
| 3 | Thank you for your interest in contributing to sodium_compat. This document should help you get up and running. |
| 4 | |
| 5 | ## Branches |
| 6 | |
| 7 | This project maintains two main branches: |
| 8 | |
| 9 | * `master`: This is the active development branch for the latest major version of `sodium_compat`. |
| 10 | It only supports PHP 8.1 and newer.. |
| 11 | * `v1.x`: This branch supports a wider range of PHP versions, from 5.2.x up to the latest. Many projects that need to |
| 12 | support older version of PHP, such as WordPress, depend on the releases cut from the v1.x branch. |
| 13 | |
| 14 | ## Code Quality and Security |
| 15 | |
| 16 | This is a cryptography library, so security is of the utmost importance. |
| 17 | |
| 18 | We follow the principles of [Cryptographically Secure PHP Development](https://paragonie.com/blog/2017/02/cryptographically-secure-php-development). |
| 19 | Before contributing, please read the linked blog post. |
| 20 | |
| 21 | ## Scope of Contributions |
| 22 | |
| 23 | This library is a polyfill for [libsodium](https://github.com/jedisct1/libsodium). Therefore, we will only consider |
| 24 | contributions that implement features already present in libsodium proper. |
| 25 | |
| 26 | ### Reporting Security Vulnerabilities |
| 27 | |
| 28 | Please email `security at paragonie dot com` to disclose a security issue with sodium_compat. If you are reporting a |
| 29 | cryptographic weakness that also applies to libsodium, please disclose it upstream to libsodium first. |
| 30 | |
| 31 | ## Testing |
| 32 | |
| 33 | ### Unit Testing |
| 34 | |
| 35 | Before submitting a pull request, please ensure that all unit tests pass. |
| 36 | |
| 37 | You can run the tests using Composer: |
| 38 | |
| 39 | ```terminal |
| 40 | composer test |
| 41 | ``` |
| 42 | |
| 43 | If you want to go the extra mile (at the cost of a longer test runtime), run the pedantic tests too: |
| 44 | |
| 45 | ```terminal |
| 46 | vendor/bin/phpunit --bootstrap=autoload-pedantic.php |
| 47 | ``` |
| 48 | |
| 49 | Paragon Initiative Enterprises runs the pedantic tests before every release is cut. |
| 50 | |
| 51 | ### Mutation Testing |
| 52 | |
| 53 | We use [Infection](https://infection.github.io) for mutation testing. |
| 54 | |
| 55 | ```bash |
| 56 | composer mutation-test |
| 57 | ``` |
| 58 | |
| 59 | Please be aware that this command can take a long time to complete, and will generate some false positives. |
| 60 | |
| 61 | ### Fuzz Testing |
| 62 | |
| 63 | We use [Nikita Popov's PHP-Fuzzer](https://github.com/nikic/PHP-Fuzzer) for fuzz testing. To run the fuzz tests, use the |
| 64 | following command: |
| 65 | |
| 66 | ```bash |
| 67 | composer fuzz-test |
| 68 | ``` |
| 69 | |
| 70 | This command runs for a long time. To limit the fuzzer to 1000 runs: |
| 71 | |
| 72 | ```bash |
| 73 | vendor/bin/php-fuzzer --max-runs 1000 fuzz fuzzing/FuzzSodiumCompat.php |
| 74 | ``` |