Skip to content

Commit b9b1c02

Browse files
Add contributor guide for writing custom PySpector rules (#19)
Add contributor guide to contributing.md --------- Co-authored-by: Tommaso Bona <piergeolo@gmail.com>
1 parent 7e9fa3b commit b9b1c02

1 file changed

Lines changed: 27 additions & 0 deletions

File tree

CONTRIBUTING.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,33 @@ When adding a new rule, please include a clear `description`, a `severity` level
7575
7676
---
7777
78+
## Writing Custom Rules
79+
80+
PySpector rules define *what* the engine looks for during analysis. Each rule describes a pattern or behavior that represents a potential security issue.
81+
82+
A rule typically consists of:
83+
- Metadata (name, severity, description)
84+
- A matcher or condition
85+
- A message explaining the issue
86+
87+
Rules are loaded at runtime and applied uniformly across the scanned codebase.
88+
89+
### Minimal Example
90+
91+
Below is a minimal conceptual example of a rule:
92+
93+
```toml
94+
file_pattern = "*.py"
95+
96+
[[rule]]
97+
id = "PY200"
98+
description = "Use of 'eval' detected."
99+
severity = "High"
100+
remediation = "Avoid using eval(). Use safer alternatives like ast.literal_eval or explicit parsing."
101+
ast_match = "Call(func.id=eval)"
102+
103+
104+
78105
## ✅ Submitting Your Contribution
79106
80107
Ready to submit your changes? Just follow these steps:

0 commit comments

Comments
 (0)