secrulekit 1.2.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- secrulekit-1.2.0/LICENSE +21 -0
- secrulekit-1.2.0/PKG-INFO +241 -0
- secrulekit-1.2.0/README.md +178 -0
- secrulekit-1.2.0/pyproject.toml +80 -0
- secrulekit-1.2.0/secrulekit/__init__.py +19 -0
- secrulekit-1.2.0/secrulekit/cli.py +244 -0
- secrulekit-1.2.0/secrulekit/converters/__init__.py +3 -0
- secrulekit-1.2.0/secrulekit/converters/converter.py +208 -0
- secrulekit-1.2.0/secrulekit/parsers/__init__.py +5 -0
- secrulekit-1.2.0/secrulekit/parsers/sigma_parser.py +109 -0
- secrulekit-1.2.0/secrulekit/parsers/suricata_parser.py +125 -0
- secrulekit-1.2.0/secrulekit/parsers/yara_parser.py +138 -0
- secrulekit-1.2.0/secrulekit/reporters/__init__.py +4 -0
- secrulekit-1.2.0/secrulekit/reporters/html_reporter.py +92 -0
- secrulekit-1.2.0/secrulekit/reporters/json_reporter.py +38 -0
- secrulekit-1.2.0/secrulekit/utils/__init__.py +3 -0
- secrulekit-1.2.0/secrulekit/utils/helpers.py +104 -0
- secrulekit-1.2.0/secrulekit/validators/__init__.py +3 -0
- secrulekit-1.2.0/secrulekit/validators/rule_validator.py +276 -0
- secrulekit-1.2.0/secrulekit.egg-info/PKG-INFO +241 -0
- secrulekit-1.2.0/secrulekit.egg-info/SOURCES.txt +27 -0
- secrulekit-1.2.0/secrulekit.egg-info/dependency_links.txt +1 -0
- secrulekit-1.2.0/secrulekit.egg-info/entry_points.txt +2 -0
- secrulekit-1.2.0/secrulekit.egg-info/requires.txt +13 -0
- secrulekit-1.2.0/secrulekit.egg-info/top_level.txt +1 -0
- secrulekit-1.2.0/setup.cfg +4 -0
- secrulekit-1.2.0/tests/test_converters.py +81 -0
- secrulekit-1.2.0/tests/test_parsers.py +186 -0
- secrulekit-1.2.0/tests/test_validators.py +137 -0
secrulekit-1.2.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Cherno.x
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,241 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: secrulekit
|
|
3
|
+
Version: 1.2.0
|
|
4
|
+
Summary: Parse, validate, convert, and manage YARA, Sigma, and Suricata security detection rules
|
|
5
|
+
Author-email: "Cherno.x" <long544844@gmail.com>
|
|
6
|
+
Maintainer-email: "Cherno.x" <long544844@gmail.com>
|
|
7
|
+
License: MIT License
|
|
8
|
+
|
|
9
|
+
Copyright (c) 2026 Cherno.x
|
|
10
|
+
|
|
11
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
12
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
13
|
+
in the Software without restriction, including without limitation the rights
|
|
14
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
15
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
16
|
+
furnished to do so, subject to the following conditions:
|
|
17
|
+
|
|
18
|
+
The above copyright notice and this permission notice shall be included in all
|
|
19
|
+
copies or substantial portions of the Software.
|
|
20
|
+
|
|
21
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
22
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
23
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
24
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
25
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
26
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
27
|
+
SOFTWARE.
|
|
28
|
+
|
|
29
|
+
Project-URL: Homepage, https://github.com/lkop32788/SecRuleKit
|
|
30
|
+
Project-URL: Documentation, https://github.com/lkop32788/SecRuleKit#readme
|
|
31
|
+
Project-URL: Repository, https://github.com/lkop32788/SecRuleKit
|
|
32
|
+
Project-URL: Issues, https://github.com/lkop32788/SecRuleKit/issues
|
|
33
|
+
Project-URL: Changelog, https://github.com/lkop32788/SecRuleKit/blob/main/CHANGELOG.md
|
|
34
|
+
Project-URL: Security Policy, https://github.com/lkop32788/SecRuleKit/blob/main/SECURITY.md
|
|
35
|
+
Keywords: yara,sigma,suricata,detection-rules,security,siem,threat-hunting
|
|
36
|
+
Classifier: Development Status :: 5 - Production/Stable
|
|
37
|
+
Classifier: Intended Audience :: Information Technology
|
|
38
|
+
Classifier: Intended Audience :: System Administrators
|
|
39
|
+
Classifier: Topic :: Security
|
|
40
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
41
|
+
Classifier: Programming Language :: Python :: 3
|
|
42
|
+
Classifier: Programming Language :: Python :: 3.8
|
|
43
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
44
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
45
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
46
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
47
|
+
Classifier: Operating System :: OS Independent
|
|
48
|
+
Classifier: Environment :: Console
|
|
49
|
+
Requires-Python: >=3.8
|
|
50
|
+
Description-Content-Type: text/markdown
|
|
51
|
+
License-File: LICENSE
|
|
52
|
+
Requires-Dist: click>=8.0
|
|
53
|
+
Requires-Dist: pyyaml>=6.0
|
|
54
|
+
Requires-Dist: rich>=13.0
|
|
55
|
+
Requires-Dist: typing-extensions>=4.0; python_version < "3.10"
|
|
56
|
+
Provides-Extra: dev
|
|
57
|
+
Requires-Dist: pytest>=7.0; extra == "dev"
|
|
58
|
+
Requires-Dist: pytest-cov>=4.0; extra == "dev"
|
|
59
|
+
Requires-Dist: ruff>=0.1.0; extra == "dev"
|
|
60
|
+
Requires-Dist: mypy>=1.0; extra == "dev"
|
|
61
|
+
Requires-Dist: types-PyYAML; extra == "dev"
|
|
62
|
+
Dynamic: license-file
|
|
63
|
+
|
|
64
|
+
# SecRuleKit
|
|
65
|
+
|
|
66
|
+
[](https://badge.fury.io/py/secrulekit)
|
|
67
|
+
[](https://www.python.org/downloads/)
|
|
68
|
+
[](https://opensource.org/licenses/MIT)
|
|
69
|
+
[](https://github.com/lkop32788/SecRuleKit/actions/workflows/ci.yml)
|
|
70
|
+
|
|
71
|
+
A Python toolkit for parsing, validating, converting, and managing security detection rules — supporting **YARA**, **Sigma**, and **Suricata/Snort** formats.
|
|
72
|
+
|
|
73
|
+
Security teams and researchers rely on SecRuleKit to validate rule syntax before deployment, convert rules across platforms, deduplicate rule libraries, and generate audit-ready reports.
|
|
74
|
+
|
|
75
|
+
## Features
|
|
76
|
+
|
|
77
|
+
- **Multi-format support** — Parse and validate YARA, Sigma, and Suricata rules from files, directories, or strings
|
|
78
|
+
- **Format conversion** — Convert Sigma rules to YARA skeleton, Suricata, ElasticSearch Query DSL, and Splunk SPL
|
|
79
|
+
- **Rule deduplication** — Fingerprint and detect duplicate/near-duplicate rules across large rule sets
|
|
80
|
+
- **Metadata enrichment** — Tag rules with MITRE ATT&CK tactics/techniques, severity, and platform
|
|
81
|
+
- **Batch reporting** — Export validation results as JSON, CSV, or HTML audit reports
|
|
82
|
+
- **CLI interface** — Full-featured command-line tool for CI/CD pipeline integration
|
|
83
|
+
- **Python API** — Clean library API for embedding in security tooling
|
|
84
|
+
|
|
85
|
+
## Installation
|
|
86
|
+
|
|
87
|
+
```bash
|
|
88
|
+
pip install secrulekit
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
Or install from source:
|
|
92
|
+
|
|
93
|
+
```bash
|
|
94
|
+
git clone https://github.com/lkop32788/SecRuleKit.git
|
|
95
|
+
cd secrulekit
|
|
96
|
+
pip install -e ".[dev]"
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
## Quick Start
|
|
100
|
+
|
|
101
|
+
### CLI
|
|
102
|
+
|
|
103
|
+
```bash
|
|
104
|
+
# Validate a directory of YARA rules
|
|
105
|
+
secrulekit validate --format yara ./rules/yara/
|
|
106
|
+
|
|
107
|
+
# Validate Sigma rules and output JSON report
|
|
108
|
+
secrulekit validate --format sigma ./rules/sigma/ --report report.json
|
|
109
|
+
|
|
110
|
+
# Convert Sigma rule to Splunk SPL
|
|
111
|
+
secrulekit convert --to splunk ./rules/sigma/lateral_movement.yml
|
|
112
|
+
|
|
113
|
+
# Deduplicate a large rule set
|
|
114
|
+
secrulekit dedup --format yara ./rules/ --output ./rules_deduped/
|
|
115
|
+
|
|
116
|
+
# Show rule metadata and ATT&CK mapping
|
|
117
|
+
secrulekit info ./rules/sigma/t1059_powershell.yml
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
### Python API
|
|
121
|
+
|
|
122
|
+
```python
|
|
123
|
+
from secrulekit import YaraParser, SigmaParser, RuleValidator, RuleConverter
|
|
124
|
+
|
|
125
|
+
# Parse and validate YARA rules
|
|
126
|
+
parser = YaraParser()
|
|
127
|
+
rules = parser.parse_directory("./rules/yara/")
|
|
128
|
+
|
|
129
|
+
validator = RuleValidator()
|
|
130
|
+
results = validator.validate_batch(rules)
|
|
131
|
+
print(f"Valid: {results.valid_count}, Errors: {results.error_count}")
|
|
132
|
+
|
|
133
|
+
# Convert Sigma to Splunk
|
|
134
|
+
converter = RuleConverter()
|
|
135
|
+
sigma = SigmaParser().parse_file("./rules/sigma/t1059.yml")
|
|
136
|
+
splunk_query = converter.to_splunk(sigma)
|
|
137
|
+
print(splunk_query)
|
|
138
|
+
|
|
139
|
+
# Generate HTML report
|
|
140
|
+
from secrulekit.reporters import HtmlReporter
|
|
141
|
+
HtmlReporter().generate(results, output="audit_report.html")
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
## Supported Rule Formats
|
|
145
|
+
|
|
146
|
+
| Format | Parse | Validate | Convert From | Convert To |
|
|
147
|
+
|------------|-------|----------|--------------|------------|
|
|
148
|
+
| YARA | ✅ | ✅ | — | — |
|
|
149
|
+
| Sigma | ✅ | ✅ | ✅ | ✅ |
|
|
150
|
+
| Suricata | ✅ | ✅ | — | ✅ |
|
|
151
|
+
| Snort | ✅ | ✅ | — | — |
|
|
152
|
+
|
|
153
|
+
## Sigma Conversion Targets
|
|
154
|
+
|
|
155
|
+
| Target | Flag |
|
|
156
|
+
|---------------------|---------------|
|
|
157
|
+
| Splunk SPL | `--to splunk` |
|
|
158
|
+
| ElasticSearch Query | `--to elastic`|
|
|
159
|
+
| YARA-L | `--to yaral` |
|
|
160
|
+
| QRadar AQL | `--to qradar` |
|
|
161
|
+
| Suricata | `--to suricata`|
|
|
162
|
+
|
|
163
|
+
## CLI Reference
|
|
164
|
+
|
|
165
|
+
```
|
|
166
|
+
Usage: secrulekit [OPTIONS] COMMAND [ARGS]...
|
|
167
|
+
|
|
168
|
+
Commands:
|
|
169
|
+
validate Validate rule files for syntax and semantic errors
|
|
170
|
+
convert Convert rules between formats
|
|
171
|
+
dedup Find and remove duplicate rules
|
|
172
|
+
info Display rule metadata and ATT&CK mapping
|
|
173
|
+
report Generate audit reports from cached results
|
|
174
|
+
stats Show statistics for a rule collection
|
|
175
|
+
|
|
176
|
+
Options:
|
|
177
|
+
--version Show version
|
|
178
|
+
--help Show help
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
### `secrulekit validate`
|
|
182
|
+
|
|
183
|
+
```
|
|
184
|
+
Options:
|
|
185
|
+
-f, --format [yara|sigma|suricata|snort|auto]
|
|
186
|
+
Rule format (default: auto-detect)
|
|
187
|
+
-r, --recursive Recurse into subdirectories
|
|
188
|
+
--strict Treat warnings as errors
|
|
189
|
+
--report FILE Write JSON/HTML report to FILE
|
|
190
|
+
--no-color Disable colored output
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
### `secrulekit convert`
|
|
194
|
+
|
|
195
|
+
```
|
|
196
|
+
Options:
|
|
197
|
+
--to [splunk|elastic|yaral|qradar|suricata]
|
|
198
|
+
Target format (required)
|
|
199
|
+
-o, --output FILE Write output to file (default: stdout)
|
|
200
|
+
--batch Convert all .yml files in directory
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
## Project Structure
|
|
204
|
+
|
|
205
|
+
```
|
|
206
|
+
secrulekit/
|
|
207
|
+
├── secrulekit/
|
|
208
|
+
│ ├── parsers/
|
|
209
|
+
│ │ ├── yara_parser.py # YARA rule parser
|
|
210
|
+
│ │ ├── sigma_parser.py # Sigma rule parser
|
|
211
|
+
│ │ └── suricata_parser.py # Suricata/Snort parser
|
|
212
|
+
│ ├── validators/
|
|
213
|
+
│ │ └── rule_validator.py # Multi-format validator
|
|
214
|
+
│ ├── converters/
|
|
215
|
+
│ │ └── converter.py # Format conversion engine
|
|
216
|
+
│ ├── reporters/
|
|
217
|
+
│ │ ├── json_reporter.py # JSON output
|
|
218
|
+
│ │ └── html_reporter.py # HTML audit report
|
|
219
|
+
│ ├── utils/
|
|
220
|
+
│ │ └── helpers.py # Fingerprinting, dedup, ATT&CK mapping
|
|
221
|
+
│ └── cli.py # CLI entry point
|
|
222
|
+
├── tests/
|
|
223
|
+
├── rules/ # Example rule sets
|
|
224
|
+
│ ├── yara/
|
|
225
|
+
│ └── sigma/
|
|
226
|
+
└── docs/
|
|
227
|
+
```
|
|
228
|
+
|
|
229
|
+
## Contributing
|
|
230
|
+
|
|
231
|
+
Contributions are welcome! Please read [CONTRIBUTING.md](CONTRIBUTING.md) before opening a pull request.
|
|
232
|
+
|
|
233
|
+
## Security
|
|
234
|
+
|
|
235
|
+
To report a security vulnerability in SecRuleKit itself (e.g., rule parsing that could cause denial-of-service or arbitrary code execution via crafted rule files), please follow the process in [SECURITY.md](SECURITY.md).
|
|
236
|
+
|
|
237
|
+
**Security Maintainer:** [@lkop32788](https://github.com/lkop32788)
|
|
238
|
+
|
|
239
|
+
## License
|
|
240
|
+
|
|
241
|
+
MIT © 2026 Cherno.x — see [LICENSE](LICENSE).
|
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
# SecRuleKit
|
|
2
|
+
|
|
3
|
+
[](https://badge.fury.io/py/secrulekit)
|
|
4
|
+
[](https://www.python.org/downloads/)
|
|
5
|
+
[](https://opensource.org/licenses/MIT)
|
|
6
|
+
[](https://github.com/lkop32788/SecRuleKit/actions/workflows/ci.yml)
|
|
7
|
+
|
|
8
|
+
A Python toolkit for parsing, validating, converting, and managing security detection rules — supporting **YARA**, **Sigma**, and **Suricata/Snort** formats.
|
|
9
|
+
|
|
10
|
+
Security teams and researchers rely on SecRuleKit to validate rule syntax before deployment, convert rules across platforms, deduplicate rule libraries, and generate audit-ready reports.
|
|
11
|
+
|
|
12
|
+
## Features
|
|
13
|
+
|
|
14
|
+
- **Multi-format support** — Parse and validate YARA, Sigma, and Suricata rules from files, directories, or strings
|
|
15
|
+
- **Format conversion** — Convert Sigma rules to YARA skeleton, Suricata, ElasticSearch Query DSL, and Splunk SPL
|
|
16
|
+
- **Rule deduplication** — Fingerprint and detect duplicate/near-duplicate rules across large rule sets
|
|
17
|
+
- **Metadata enrichment** — Tag rules with MITRE ATT&CK tactics/techniques, severity, and platform
|
|
18
|
+
- **Batch reporting** — Export validation results as JSON, CSV, or HTML audit reports
|
|
19
|
+
- **CLI interface** — Full-featured command-line tool for CI/CD pipeline integration
|
|
20
|
+
- **Python API** — Clean library API for embedding in security tooling
|
|
21
|
+
|
|
22
|
+
## Installation
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
pip install secrulekit
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
Or install from source:
|
|
29
|
+
|
|
30
|
+
```bash
|
|
31
|
+
git clone https://github.com/lkop32788/SecRuleKit.git
|
|
32
|
+
cd secrulekit
|
|
33
|
+
pip install -e ".[dev]"
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
## Quick Start
|
|
37
|
+
|
|
38
|
+
### CLI
|
|
39
|
+
|
|
40
|
+
```bash
|
|
41
|
+
# Validate a directory of YARA rules
|
|
42
|
+
secrulekit validate --format yara ./rules/yara/
|
|
43
|
+
|
|
44
|
+
# Validate Sigma rules and output JSON report
|
|
45
|
+
secrulekit validate --format sigma ./rules/sigma/ --report report.json
|
|
46
|
+
|
|
47
|
+
# Convert Sigma rule to Splunk SPL
|
|
48
|
+
secrulekit convert --to splunk ./rules/sigma/lateral_movement.yml
|
|
49
|
+
|
|
50
|
+
# Deduplicate a large rule set
|
|
51
|
+
secrulekit dedup --format yara ./rules/ --output ./rules_deduped/
|
|
52
|
+
|
|
53
|
+
# Show rule metadata and ATT&CK mapping
|
|
54
|
+
secrulekit info ./rules/sigma/t1059_powershell.yml
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
### Python API
|
|
58
|
+
|
|
59
|
+
```python
|
|
60
|
+
from secrulekit import YaraParser, SigmaParser, RuleValidator, RuleConverter
|
|
61
|
+
|
|
62
|
+
# Parse and validate YARA rules
|
|
63
|
+
parser = YaraParser()
|
|
64
|
+
rules = parser.parse_directory("./rules/yara/")
|
|
65
|
+
|
|
66
|
+
validator = RuleValidator()
|
|
67
|
+
results = validator.validate_batch(rules)
|
|
68
|
+
print(f"Valid: {results.valid_count}, Errors: {results.error_count}")
|
|
69
|
+
|
|
70
|
+
# Convert Sigma to Splunk
|
|
71
|
+
converter = RuleConverter()
|
|
72
|
+
sigma = SigmaParser().parse_file("./rules/sigma/t1059.yml")
|
|
73
|
+
splunk_query = converter.to_splunk(sigma)
|
|
74
|
+
print(splunk_query)
|
|
75
|
+
|
|
76
|
+
# Generate HTML report
|
|
77
|
+
from secrulekit.reporters import HtmlReporter
|
|
78
|
+
HtmlReporter().generate(results, output="audit_report.html")
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
## Supported Rule Formats
|
|
82
|
+
|
|
83
|
+
| Format | Parse | Validate | Convert From | Convert To |
|
|
84
|
+
|------------|-------|----------|--------------|------------|
|
|
85
|
+
| YARA | ✅ | ✅ | — | — |
|
|
86
|
+
| Sigma | ✅ | ✅ | ✅ | ✅ |
|
|
87
|
+
| Suricata | ✅ | ✅ | — | ✅ |
|
|
88
|
+
| Snort | ✅ | ✅ | — | — |
|
|
89
|
+
|
|
90
|
+
## Sigma Conversion Targets
|
|
91
|
+
|
|
92
|
+
| Target | Flag |
|
|
93
|
+
|---------------------|---------------|
|
|
94
|
+
| Splunk SPL | `--to splunk` |
|
|
95
|
+
| ElasticSearch Query | `--to elastic`|
|
|
96
|
+
| YARA-L | `--to yaral` |
|
|
97
|
+
| QRadar AQL | `--to qradar` |
|
|
98
|
+
| Suricata | `--to suricata`|
|
|
99
|
+
|
|
100
|
+
## CLI Reference
|
|
101
|
+
|
|
102
|
+
```
|
|
103
|
+
Usage: secrulekit [OPTIONS] COMMAND [ARGS]...
|
|
104
|
+
|
|
105
|
+
Commands:
|
|
106
|
+
validate Validate rule files for syntax and semantic errors
|
|
107
|
+
convert Convert rules between formats
|
|
108
|
+
dedup Find and remove duplicate rules
|
|
109
|
+
info Display rule metadata and ATT&CK mapping
|
|
110
|
+
report Generate audit reports from cached results
|
|
111
|
+
stats Show statistics for a rule collection
|
|
112
|
+
|
|
113
|
+
Options:
|
|
114
|
+
--version Show version
|
|
115
|
+
--help Show help
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
### `secrulekit validate`
|
|
119
|
+
|
|
120
|
+
```
|
|
121
|
+
Options:
|
|
122
|
+
-f, --format [yara|sigma|suricata|snort|auto]
|
|
123
|
+
Rule format (default: auto-detect)
|
|
124
|
+
-r, --recursive Recurse into subdirectories
|
|
125
|
+
--strict Treat warnings as errors
|
|
126
|
+
--report FILE Write JSON/HTML report to FILE
|
|
127
|
+
--no-color Disable colored output
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
### `secrulekit convert`
|
|
131
|
+
|
|
132
|
+
```
|
|
133
|
+
Options:
|
|
134
|
+
--to [splunk|elastic|yaral|qradar|suricata]
|
|
135
|
+
Target format (required)
|
|
136
|
+
-o, --output FILE Write output to file (default: stdout)
|
|
137
|
+
--batch Convert all .yml files in directory
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
## Project Structure
|
|
141
|
+
|
|
142
|
+
```
|
|
143
|
+
secrulekit/
|
|
144
|
+
├── secrulekit/
|
|
145
|
+
│ ├── parsers/
|
|
146
|
+
│ │ ├── yara_parser.py # YARA rule parser
|
|
147
|
+
│ │ ├── sigma_parser.py # Sigma rule parser
|
|
148
|
+
│ │ └── suricata_parser.py # Suricata/Snort parser
|
|
149
|
+
│ ├── validators/
|
|
150
|
+
│ │ └── rule_validator.py # Multi-format validator
|
|
151
|
+
│ ├── converters/
|
|
152
|
+
│ │ └── converter.py # Format conversion engine
|
|
153
|
+
│ ├── reporters/
|
|
154
|
+
│ │ ├── json_reporter.py # JSON output
|
|
155
|
+
│ │ └── html_reporter.py # HTML audit report
|
|
156
|
+
│ ├── utils/
|
|
157
|
+
│ │ └── helpers.py # Fingerprinting, dedup, ATT&CK mapping
|
|
158
|
+
│ └── cli.py # CLI entry point
|
|
159
|
+
├── tests/
|
|
160
|
+
├── rules/ # Example rule sets
|
|
161
|
+
│ ├── yara/
|
|
162
|
+
│ └── sigma/
|
|
163
|
+
└── docs/
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
## Contributing
|
|
167
|
+
|
|
168
|
+
Contributions are welcome! Please read [CONTRIBUTING.md](CONTRIBUTING.md) before opening a pull request.
|
|
169
|
+
|
|
170
|
+
## Security
|
|
171
|
+
|
|
172
|
+
To report a security vulnerability in SecRuleKit itself (e.g., rule parsing that could cause denial-of-service or arbitrary code execution via crafted rule files), please follow the process in [SECURITY.md](SECURITY.md).
|
|
173
|
+
|
|
174
|
+
**Security Maintainer:** [@lkop32788](https://github.com/lkop32788)
|
|
175
|
+
|
|
176
|
+
## License
|
|
177
|
+
|
|
178
|
+
MIT © 2026 Cherno.x — see [LICENSE](LICENSE).
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=68", "wheel"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "secrulekit"
|
|
7
|
+
version = "1.2.0"
|
|
8
|
+
description = "Parse, validate, convert, and manage YARA, Sigma, and Suricata security detection rules"
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
license = { file = "LICENSE" }
|
|
11
|
+
authors = [
|
|
12
|
+
{ name = "Cherno.x", email = "long544844@gmail.com" }
|
|
13
|
+
]
|
|
14
|
+
maintainers = [
|
|
15
|
+
{ name = "Cherno.x", email = "long544844@gmail.com" }
|
|
16
|
+
]
|
|
17
|
+
keywords = ["yara", "sigma", "suricata", "detection-rules", "security", "siem", "threat-hunting"]
|
|
18
|
+
classifiers = [
|
|
19
|
+
"Development Status :: 5 - Production/Stable",
|
|
20
|
+
"Intended Audience :: Information Technology",
|
|
21
|
+
"Intended Audience :: System Administrators",
|
|
22
|
+
"Topic :: Security",
|
|
23
|
+
"License :: OSI Approved :: MIT License",
|
|
24
|
+
"Programming Language :: Python :: 3",
|
|
25
|
+
"Programming Language :: Python :: 3.8",
|
|
26
|
+
"Programming Language :: Python :: 3.9",
|
|
27
|
+
"Programming Language :: Python :: 3.10",
|
|
28
|
+
"Programming Language :: Python :: 3.11",
|
|
29
|
+
"Programming Language :: Python :: 3.12",
|
|
30
|
+
"Operating System :: OS Independent",
|
|
31
|
+
"Environment :: Console",
|
|
32
|
+
]
|
|
33
|
+
requires-python = ">=3.8"
|
|
34
|
+
dependencies = [
|
|
35
|
+
"click>=8.0",
|
|
36
|
+
"pyyaml>=6.0",
|
|
37
|
+
"rich>=13.0",
|
|
38
|
+
"typing-extensions>=4.0; python_version < '3.10'",
|
|
39
|
+
]
|
|
40
|
+
|
|
41
|
+
[project.optional-dependencies]
|
|
42
|
+
dev = [
|
|
43
|
+
"pytest>=7.0",
|
|
44
|
+
"pytest-cov>=4.0",
|
|
45
|
+
"ruff>=0.1.0",
|
|
46
|
+
"mypy>=1.0",
|
|
47
|
+
"types-PyYAML",
|
|
48
|
+
]
|
|
49
|
+
|
|
50
|
+
[project.urls]
|
|
51
|
+
Homepage = "https://github.com/lkop32788/SecRuleKit"
|
|
52
|
+
Documentation = "https://github.com/lkop32788/SecRuleKit#readme"
|
|
53
|
+
Repository = "https://github.com/lkop32788/SecRuleKit"
|
|
54
|
+
Issues = "https://github.com/lkop32788/SecRuleKit/issues"
|
|
55
|
+
Changelog = "https://github.com/lkop32788/SecRuleKit/blob/main/CHANGELOG.md"
|
|
56
|
+
"Security Policy" = "https://github.com/lkop32788/SecRuleKit/blob/main/SECURITY.md"
|
|
57
|
+
|
|
58
|
+
[project.scripts]
|
|
59
|
+
secrulekit = "secrulekit.cli:main"
|
|
60
|
+
|
|
61
|
+
[tool.setuptools.packages.find]
|
|
62
|
+
where = ["."]
|
|
63
|
+
include = ["secrulekit*"]
|
|
64
|
+
|
|
65
|
+
[tool.pytest.ini_options]
|
|
66
|
+
testpaths = ["tests"]
|
|
67
|
+
addopts = "-v --tb=short"
|
|
68
|
+
|
|
69
|
+
[tool.ruff]
|
|
70
|
+
line-length = 100
|
|
71
|
+
target-version = "py38"
|
|
72
|
+
|
|
73
|
+
[tool.ruff.lint]
|
|
74
|
+
select = ["E", "F", "W", "I", "UP"]
|
|
75
|
+
ignore = ["E501"]
|
|
76
|
+
|
|
77
|
+
[tool.mypy]
|
|
78
|
+
python_version = "3.8"
|
|
79
|
+
strict = true
|
|
80
|
+
ignore_missing_imports = true
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"""SecRuleKit — Security detection rule parser, validator, and converter."""
|
|
2
|
+
|
|
3
|
+
from secrulekit.parsers.yara_parser import YaraParser
|
|
4
|
+
from secrulekit.parsers.sigma_parser import SigmaParser
|
|
5
|
+
from secrulekit.parsers.suricata_parser import SuricataParser
|
|
6
|
+
from secrulekit.validators.rule_validator import RuleValidator, ValidationResult
|
|
7
|
+
from secrulekit.converters.converter import RuleConverter
|
|
8
|
+
|
|
9
|
+
__version__ = "1.2.0"
|
|
10
|
+
__author__ = "Cherno.x"
|
|
11
|
+
|
|
12
|
+
__all__ = [
|
|
13
|
+
"YaraParser",
|
|
14
|
+
"SigmaParser",
|
|
15
|
+
"SuricataParser",
|
|
16
|
+
"RuleValidator",
|
|
17
|
+
"ValidationResult",
|
|
18
|
+
"RuleConverter",
|
|
19
|
+
]
|