PyWard
PyWard is a lightweight command-line linter for Python code. It helps developers catch optimization issues (like unused imports and unreachable code) and security vulnerabilities (such as unsafe eval/exec usage and known CVE patterns).
Features
-
Optimization Checks
- Detects unused imports
- Flags unreachable code blocks
-
Security Checks
- Flags usage of
eval()andexec()(e.g., CVE-2025-3248) - Detects vulnerable imports like
python_json_logger(e.g., CVE-2025-27607)
- Flags usage of
-
Flexible CLI
- Run all checks by default
- Use
-o/--optimizeto run only optimization checks - Use
-s/--securityto run only security checks - Use
-v/--verbosefor detailed output, even if no issues are found
Installation
Install from PyPI:
pip install pyward-cli
Ensure that you have Python 3.7 or newer.
Usage
Basic usage (runs both optimization and security checks):
pyward <your_python_file.py>
Options
-
-o, --optimize
Run only optimization checks (unused imports, unreachable code). -
-s, --security
Run only security checks (unsafe calls, CVE-based rules). -
-v, --verbose
Show detailed warnings and suggestions, even if no issues are detected.
Examples
Run all checks on demo.py:
pyward demo.py
Run only optimization checks:
pyward -o demo.py
Run only security checks:
pyward -s demo.py
Run with verbose mode:
pyward -v demo.py
Contributing
Contributions are welcome! To add new rules or improve existing ones:
- Fork the repository.
- Create a new branch (e.g.,
feature/new-rule). - Implement your changes and add tests if applicable.
- Open a pull request detailing your enhancements.
Please adhere to the project’s coding style and include meaningful commit messages. For more details on the contributing process, see the CONTRIBUTING
License
This project is licensed under the MIT License. See the LICENSE file for details.
Contributors
|
Karan Vasudevamurthy |
cafewang |
Reeck Mondal |
nature011235 |
DannyNavi |
Ritwik Singh |
|
Aydyn Maxadov |
Metadata
Release files for pyward-cli 0.2.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| pyward_cli-0.2.1.tar.gz | 19.5 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| pyward_cli-0.2.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 46.6 kB
Release files / pyward_cli-0.2.1.tar.gz
| Download URL | pyward_cli-0.2.1.tar.gz |
|---|---|
| Size | 19.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
854a1daf85df1dd3d1e43f869c46f02697b02a3f292ea430f07825045edad250
|
|
BLAKE2b-256 checksum How to use checksums |
e6848235157423343685dcbcd3bb4b4e3c371a5cd891373ad49917d3afe2b8c9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.3
|
Release files / pyward_cli-0.2.1-py3-none-any.whl
| Download URL | pyward_cli-0.2.1-py3-none-any.whl |
|---|---|
| Size | 27.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
6123ef313a5646df3934f267aba266b88cf9e50712e3c197303b46bcf4803a0f
|
|
BLAKE2b-256 checksum How to use checksums |
64f451da47a5f0fc0ecc8088004a6b258383d1795105b5ef296055d3ac8211ef
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.3
|