detkit-cli 0.1.3__tar.gz → 0.1.5__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.
- detkit_cli-0.1.5/.github/ISSUE_TEMPLATE/bug_report.md +20 -0
- detkit_cli-0.1.5/.github/ISSUE_TEMPLATE/feature_request.md +15 -0
- {detkit_cli-0.1.3 → detkit_cli-0.1.5}/.github/workflows/ci.yml +3 -3
- detkit_cli-0.1.5/.pre-commit-hooks.yaml +26 -0
- detkit_cli-0.1.5/CONTRIBUTING.md +44 -0
- {detkit_cli-0.1.3 → detkit_cli-0.1.5}/PKG-INFO +19 -4
- {detkit_cli-0.1.3 → detkit_cli-0.1.5}/README.md +17 -1
- detkit_cli-0.1.5/detkit/attack_enterprise.json +1484 -0
- {detkit_cli-0.1.3 → detkit_cli-0.1.5}/detkit/cli.py +98 -9
- detkit_cli-0.1.5/detkit/docs.py +334 -0
- {detkit_cli-0.1.3 → detkit_cli-0.1.5}/detkit/evaluator.py +22 -8
- {detkit_cli-0.1.3 → detkit_cli-0.1.5}/detkit_cli.egg-info/PKG-INFO +19 -4
- {detkit_cli-0.1.3 → detkit_cli-0.1.5}/detkit_cli.egg-info/SOURCES.txt +10 -0
- {detkit_cli-0.1.3 → detkit_cli-0.1.5}/detkit_cli.egg-info/scm_file_list.json +11 -1
- detkit_cli-0.1.5/detkit_cli.egg-info/scm_version.json +8 -0
- detkit_cli-0.1.5/examples/rules/powershell_encoded_command.test.yml +22 -0
- detkit_cli-0.1.5/examples/rules/powershell_encoded_command.yml +23 -0
- {detkit_cli-0.1.3 → detkit_cli-0.1.5}/examples/rules/whoami_execution.yml +3 -0
- {detkit_cli-0.1.3 → detkit_cli-0.1.5}/pyproject.toml +5 -3
- detkit_cli-0.1.5/tests/test_cli_json.py +22 -0
- detkit_cli-0.1.5/tests/test_docs.py +47 -0
- {detkit_cli-0.1.3 → detkit_cli-0.1.5}/tests/test_evaluator.py +18 -5
- detkit_cli-0.1.3/detkit_cli.egg-info/scm_version.json +0 -8
- {detkit_cli-0.1.3 → detkit_cli-0.1.5}/.github/workflows/publish.yml +0 -0
- {detkit_cli-0.1.3 → detkit_cli-0.1.5}/.gitignore +0 -0
- {detkit_cli-0.1.3 → detkit_cli-0.1.5}/LICENSE +0 -0
- {detkit_cli-0.1.3 → detkit_cli-0.1.5}/action.yml +0 -0
- {detkit_cli-0.1.3 → detkit_cli-0.1.5}/detkit/__init__.py +0 -0
- {detkit_cli-0.1.3 → detkit_cli-0.1.5}/detkit/__main__.py +0 -0
- {detkit_cli-0.1.3 → detkit_cli-0.1.5}/detkit-demo.gif +0 -0
- {detkit_cli-0.1.3 → detkit_cli-0.1.5}/detkit-demo.tape +0 -0
- {detkit_cli-0.1.3 → detkit_cli-0.1.5}/detkit_cli.egg-info/dependency_links.txt +0 -0
- {detkit_cli-0.1.3 → detkit_cli-0.1.5}/detkit_cli.egg-info/entry_points.txt +0 -0
- {detkit_cli-0.1.3 → detkit_cli-0.1.5}/detkit_cli.egg-info/requires.txt +0 -0
- {detkit_cli-0.1.3 → detkit_cli-0.1.5}/detkit_cli.egg-info/top_level.txt +0 -0
- {detkit_cli-0.1.3 → detkit_cli-0.1.5}/examples/rules/whoami_execution.test.yml +0 -0
- {detkit_cli-0.1.3 → detkit_cli-0.1.5}/setup.cfg +0 -0
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: Bug report
|
|
3
|
+
about: A rule evaluates the wrong way, or detkit crashes
|
|
4
|
+
labels: bug
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
**The rule** — paste the Sigma (a minimal version is fine):
|
|
8
|
+
|
|
9
|
+
```yaml
|
|
10
|
+
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
**The event and what you expected** — the sample event, whether it should match or not, and what detkit did instead:
|
|
14
|
+
|
|
15
|
+
```yaml
|
|
16
|
+
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
**Version:** output of `detkit --version`
|
|
20
|
+
**Command:** how you ran it, e.g. `detkit test rules`
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: Feature request
|
|
3
|
+
about: Suggest something detkit should do
|
|
4
|
+
labels: enhancement
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
**What are you trying to do?** Describe the workflow, not just the feature.
|
|
8
|
+
|
|
9
|
+
**What would help?**
|
|
10
|
+
|
|
11
|
+
**A Sigma rule or example, if it's relevant:**
|
|
12
|
+
|
|
13
|
+
```yaml
|
|
14
|
+
|
|
15
|
+
```
|
|
@@ -14,8 +14,8 @@ jobs:
|
|
|
14
14
|
- uses: actions/setup-python@v5
|
|
15
15
|
with:
|
|
16
16
|
python-version: ${{ matrix.python-version }}
|
|
17
|
-
- run: pip install -e .
|
|
18
|
-
- name:
|
|
19
|
-
run:
|
|
17
|
+
- run: pip install -e . pytest
|
|
18
|
+
- name: Run the test suite
|
|
19
|
+
run: pytest -q
|
|
20
20
|
- name: Example rules must pass their tests
|
|
21
21
|
run: detkit test examples/rules
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
# Lets other repos use detkit as a pre-commit hook. In a consuming repo's
|
|
2
|
+
# .pre-commit-config.yaml:
|
|
3
|
+
#
|
|
4
|
+
# repos:
|
|
5
|
+
# - repo: https://github.com/ELSATOAH/detkit
|
|
6
|
+
# rev: v0.1.3
|
|
7
|
+
# hooks:
|
|
8
|
+
# - id: detkit-test
|
|
9
|
+
# args: [rules] # path to your rules
|
|
10
|
+
- id: detkit-test
|
|
11
|
+
name: detkit test
|
|
12
|
+
description: Test Sigma detection rules against their sample events
|
|
13
|
+
entry: detkit test
|
|
14
|
+
language: python
|
|
15
|
+
types: [yaml]
|
|
16
|
+
args: [rules]
|
|
17
|
+
pass_filenames: false
|
|
18
|
+
|
|
19
|
+
- id: detkit-validate
|
|
20
|
+
name: detkit validate
|
|
21
|
+
description: Structurally validate Sigma detection rules
|
|
22
|
+
entry: detkit validate
|
|
23
|
+
language: python
|
|
24
|
+
types: [yaml]
|
|
25
|
+
args: [rules]
|
|
26
|
+
pass_filenames: false
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
# Contributing to detkit
|
|
2
|
+
|
|
3
|
+
Thanks for helping out. detkit is small on purpose, so getting started is quick.
|
|
4
|
+
|
|
5
|
+
## Setup
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
git clone https://github.com/ELSATOAH/detkit
|
|
9
|
+
cd detkit
|
|
10
|
+
pip install -e . # a venv or pipx works too
|
|
11
|
+
python3 tests/test_evaluator.py # the whole test suite, no framework needed
|
|
12
|
+
detkit test examples/rules # should print all green
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## Where things live
|
|
16
|
+
|
|
17
|
+
- `detkit/evaluator.py` — the core: evaluate a Sigma `detection`/`condition` against one event. Most changes go here.
|
|
18
|
+
- `detkit/cli.py` — the `test` / `validate` / `init` commands.
|
|
19
|
+
- `tests/test_evaluator.py` — plain `assert`s; run it directly or with pytest.
|
|
20
|
+
- `examples/rules/` — a rule and its `*.test.yml`, which doubles as a spec for the format.
|
|
21
|
+
|
|
22
|
+
## The one rule
|
|
23
|
+
|
|
24
|
+
Never return a confident wrong answer. What the evaluator can't handle yet is listed by `scan_unsupported()` and printed as a `WARN` at runtime instead of guessing. If you add a feature, either handle it properly or leave the warning in place.
|
|
25
|
+
|
|
26
|
+
## Adding support for a Sigma feature
|
|
27
|
+
|
|
28
|
+
1. Add the logic in `evaluator.py` — `_match_scalar` for modifiers, `_resolve_field` for field access, `_eval_condition` for conditions.
|
|
29
|
+
2. If it was in `scan_unsupported()`'s warn list, drop it from there.
|
|
30
|
+
3. Add a test: one event that should match, one that shouldn't.
|
|
31
|
+
|
|
32
|
+
Known ceilings are marked with `# ponytail:` comments in `evaluator.py`.
|
|
33
|
+
|
|
34
|
+
## Good places to start
|
|
35
|
+
|
|
36
|
+
- `|base64` / `|base64offset` modifier support (currently warns).
|
|
37
|
+
- Nested fields that descend into arrays of objects (right now it only walks dicts).
|
|
38
|
+
- A `--json` output mode for `detkit test`, for pipelines that want structured results.
|
|
39
|
+
|
|
40
|
+
## Releases
|
|
41
|
+
|
|
42
|
+
Maintainers only, and it's one step: `gh release create vX.Y.Z --generate-notes`. The tag sets the version (setuptools-scm) and GitHub Actions builds and publishes to PyPI.
|
|
43
|
+
|
|
44
|
+
MIT licensed. By contributing, you agree your work ships under it.
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: detkit-cli
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.5
|
|
4
4
|
Summary: dbt for detections — test, validate, and CI-gate Sigma detection rules as code.
|
|
5
5
|
Author: detkit
|
|
6
|
-
License: MIT
|
|
6
|
+
License-Expression: MIT
|
|
7
7
|
Project-URL: Homepage, https://github.com/ELSATOAH/detkit
|
|
8
8
|
Project-URL: Repository, https://github.com/ELSATOAH/detkit
|
|
9
9
|
Project-URL: Issues, https://github.com/ELSATOAH/detkit/issues
|
|
@@ -11,7 +11,6 @@ Keywords: sigma,detection-engineering,detection-as-code,siem,security,detections
|
|
|
11
11
|
Classifier: Development Status :: 3 - Alpha
|
|
12
12
|
Classifier: Intended Audience :: Information Technology
|
|
13
13
|
Classifier: Topic :: Security
|
|
14
|
-
Classifier: License :: OSI Approved :: MIT License
|
|
15
14
|
Classifier: Programming Language :: Python :: 3
|
|
16
15
|
Classifier: Operating System :: OS Independent
|
|
17
16
|
Requires-Python: >=3.9
|
|
@@ -22,7 +21,7 @@ Dynamic: license-file
|
|
|
22
21
|
|
|
23
22
|
# detkit
|
|
24
23
|
|
|
25
|
-
[](https://github.com/ELSATOAH/detkit/actions/workflows/ci.yml) [](https://pypi.org/project/detkit-cli/) [](https://github.com/ELSATOAH/detkit/blob/main/LICENSE)
|
|
24
|
+
[](https://github.com/ELSATOAH/detkit/actions/workflows/ci.yml) [](https://pypi.org/project/detkit-cli/) [](https://pypi.org/project/detkit-cli/) [](https://github.com/ELSATOAH/detkit/blob/main/LICENSE)
|
|
26
25
|
|
|
27
26
|
Unit tests for your Sigma detection rules. Write a rule, add a couple of example log events, and detkit tells you whether it fires on the ones that should trip it and stays quiet on the ones that shouldn't. Wire it into CI and a broken detection fails the pull request instead of failing silently in production.
|
|
28
27
|
|
|
@@ -90,6 +89,22 @@ jobs:
|
|
|
90
89
|
path: rules
|
|
91
90
|
```
|
|
92
91
|
|
|
92
|
+
## pre-commit
|
|
93
|
+
|
|
94
|
+
Prefer to catch it before the commit lands? Add detkit to your [pre-commit](https://pre-commit.com) config:
|
|
95
|
+
|
|
96
|
+
```yaml
|
|
97
|
+
# .pre-commit-config.yaml
|
|
98
|
+
repos:
|
|
99
|
+
- repo: https://github.com/ELSATOAH/detkit
|
|
100
|
+
rev: v0.1.3
|
|
101
|
+
hooks:
|
|
102
|
+
- id: detkit-test
|
|
103
|
+
args: [rules] # path to your rules
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
There's a `detkit-validate` hook too, for the lighter structural check.
|
|
107
|
+
|
|
93
108
|
## What it handles
|
|
94
109
|
|
|
95
110
|
detkit runs your rules locally. No SIEM, no credentials, nothing leaves your machine or CI runner. I ran it against every rule in the SigmaHQ repo, and about 91% use only features it understands today: `contains`, `startswith`, `endswith`, `re`, value wildcards (`*` and `?`), `|cidr`, keyword lists, and `X of` / `all of` conditions.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# detkit
|
|
2
2
|
|
|
3
|
-
[](https://github.com/ELSATOAH/detkit/actions/workflows/ci.yml) [](https://pypi.org/project/detkit-cli/) [](https://github.com/ELSATOAH/detkit/blob/main/LICENSE)
|
|
3
|
+
[](https://github.com/ELSATOAH/detkit/actions/workflows/ci.yml) [](https://pypi.org/project/detkit-cli/) [](https://pypi.org/project/detkit-cli/) [](https://github.com/ELSATOAH/detkit/blob/main/LICENSE)
|
|
4
4
|
|
|
5
5
|
Unit tests for your Sigma detection rules. Write a rule, add a couple of example log events, and detkit tells you whether it fires on the ones that should trip it and stays quiet on the ones that shouldn't. Wire it into CI and a broken detection fails the pull request instead of failing silently in production.
|
|
6
6
|
|
|
@@ -68,6 +68,22 @@ jobs:
|
|
|
68
68
|
path: rules
|
|
69
69
|
```
|
|
70
70
|
|
|
71
|
+
## pre-commit
|
|
72
|
+
|
|
73
|
+
Prefer to catch it before the commit lands? Add detkit to your [pre-commit](https://pre-commit.com) config:
|
|
74
|
+
|
|
75
|
+
```yaml
|
|
76
|
+
# .pre-commit-config.yaml
|
|
77
|
+
repos:
|
|
78
|
+
- repo: https://github.com/ELSATOAH/detkit
|
|
79
|
+
rev: v0.1.3
|
|
80
|
+
hooks:
|
|
81
|
+
- id: detkit-test
|
|
82
|
+
args: [rules] # path to your rules
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
There's a `detkit-validate` hook too, for the lighter structural check.
|
|
86
|
+
|
|
71
87
|
## What it handles
|
|
72
88
|
|
|
73
89
|
detkit runs your rules locally. No SIEM, no credentials, nothing leaves your machine or CI runner. I ran it against every rule in the SigmaHQ repo, and about 91% use only features it understands today: `contains`, `startswith`, `endswith`, `re`, value wildcards (`*` and `?`), `|cidr`, keyword lists, and `X of` / `all of` conditions.
|