sentinel-watch 0.3.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.
- sentinel_watch-0.3.0/CHANGELOG.md +31 -0
- sentinel_watch-0.3.0/CONTRIBUTING.md +24 -0
- sentinel_watch-0.3.0/LICENSE +21 -0
- sentinel_watch-0.3.0/MANIFEST.in +7 -0
- sentinel_watch-0.3.0/PKG-INFO +233 -0
- sentinel_watch-0.3.0/README.md +194 -0
- sentinel_watch-0.3.0/config.example.yaml +32 -0
- sentinel_watch-0.3.0/docs/ACTIONS.md +94 -0
- sentinel_watch-0.3.0/docs/CHANGELOG.md +31 -0
- sentinel_watch-0.3.0/docs/CLI.md +158 -0
- sentinel_watch-0.3.0/docs/CONFIG.md +93 -0
- sentinel_watch-0.3.0/docs/FAQ.md +59 -0
- sentinel_watch-0.3.0/docs/QUICKSTART.md +92 -0
- sentinel_watch-0.3.0/docs/RULES.md +83 -0
- sentinel_watch-0.3.0/docs/WEB.md +62 -0
- sentinel_watch-0.3.0/docs/index.md +17 -0
- sentinel_watch-0.3.0/examples/github-action.yml +30 -0
- sentinel_watch-0.3.0/examples/sentinel.yaml +17 -0
- sentinel_watch-0.3.0/mkdocs.yml +43 -0
- sentinel_watch-0.3.0/pyproject.toml +55 -0
- sentinel_watch-0.3.0/sentinel/__init__.py +1 -0
- sentinel_watch-0.3.0/sentinel/baseline.py +244 -0
- sentinel_watch-0.3.0/sentinel/cli.py +618 -0
- sentinel_watch-0.3.0/sentinel/config.py +84 -0
- sentinel_watch-0.3.0/sentinel/detect.py +226 -0
- sentinel_watch-0.3.0/sentinel/learn.py +28 -0
- sentinel_watch-0.3.0/sentinel/proc.py +47 -0
- sentinel_watch-0.3.0/sentinel/report.py +104 -0
- sentinel_watch-0.3.0/sentinel/respond.py +185 -0
- sentinel_watch-0.3.0/sentinel/serve.py +64 -0
- sentinel_watch-0.3.0/sentinel/vault.py +103 -0
- sentinel_watch-0.3.0/sentinel/watcher.py +65 -0
- sentinel_watch-0.3.0/sentinel_watch.egg-info/PKG-INFO +233 -0
- sentinel_watch-0.3.0/sentinel_watch.egg-info/SOURCES.txt +40 -0
- sentinel_watch-0.3.0/sentinel_watch.egg-info/dependency_links.txt +1 -0
- sentinel_watch-0.3.0/sentinel_watch.egg-info/entry_points.txt +2 -0
- sentinel_watch-0.3.0/sentinel_watch.egg-info/requires.txt +12 -0
- sentinel_watch-0.3.0/sentinel_watch.egg-info/top_level.txt +1 -0
- sentinel_watch-0.3.0/setup.cfg +4 -0
- sentinel_watch-0.3.0/tests/test_extra.py +93 -0
- sentinel_watch-0.3.0/tests/test_new.py +95 -0
- sentinel_watch-0.3.0/tests/test_sentinel.py +53 -0
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
## 0.3.0
|
|
4
|
+
|
|
5
|
+
- add `check` with risk clean/warn/high plus json and sarif
|
|
6
|
+
- add `why` to explain one file score
|
|
7
|
+
- add `diff` using vault copies
|
|
8
|
+
- add `protect` vault fill and restore clean
|
|
9
|
+
- add `update` fast rehash
|
|
10
|
+
- add `learn` to suggest burst
|
|
11
|
+
- add `timeline`, `serve` with /json, `config-init`, `doctor`
|
|
12
|
+
- add `watch --daemon`, rename and delete storm rules
|
|
13
|
+
- store entropy at baseline time
|
|
14
|
+
- add mail alerts, sarif output
|
|
15
|
+
- add mkdocs site plus pages and ci workflows
|
|
16
|
+
- human pass over all code and docs
|
|
17
|
+
|
|
18
|
+
## 0.2.0
|
|
19
|
+
|
|
20
|
+
- add `scan`, `report`, `events`, `snaps`, `restore`, `status`, `clean`
|
|
21
|
+
- add yaml config plus `.sentinelignore`
|
|
22
|
+
- add ransom note and ext scoring
|
|
23
|
+
- add json logs and html report
|
|
24
|
+
- add webhook, desktop note, optional kill
|
|
25
|
+
- add docs folder and examples
|
|
26
|
+
- threaded baseline
|
|
27
|
+
|
|
28
|
+
## 0.1.0
|
|
29
|
+
|
|
30
|
+
- first cut: `init`, `verify`, `watch`, `demo`
|
|
31
|
+
- burst plus entropy plus canary
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# Contributing
|
|
2
|
+
|
|
3
|
+
## Setup
|
|
4
|
+
|
|
5
|
+
```bash
|
|
6
|
+
pip install -e .[dev]
|
|
7
|
+
pytest -q
|
|
8
|
+
```
|
|
9
|
+
|
|
10
|
+
## Style
|
|
11
|
+
|
|
12
|
+
- short comments, plain words
|
|
13
|
+
- no banners, no em dashes in code
|
|
14
|
+
- keep functions small
|
|
15
|
+
- add a test for each rule tweak
|
|
16
|
+
|
|
17
|
+
## PRs
|
|
18
|
+
|
|
19
|
+
1. fork and branch
|
|
20
|
+
2. add test in `tests/`
|
|
21
|
+
3. run `pytest -q` and `sentinel demo`
|
|
22
|
+
4. explain what real folder you tried it on
|
|
23
|
+
|
|
24
|
+
Thanks.
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 sentinel contributors
|
|
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,7 @@
|
|
|
1
|
+
# keep sdist handy
|
|
2
|
+
include README.md LICENSE CHANGELOG.md CONTRIBUTING.md
|
|
3
|
+
include config.example.yaml mkdocs.yml
|
|
4
|
+
recursive-include docs *.md
|
|
5
|
+
recursive-include examples *
|
|
6
|
+
global-exclude __pycache__ *.pyc *.pyo
|
|
7
|
+
global-exclude .sentinel demo_run demo_ci site dist build *.egg-info
|
|
@@ -0,0 +1,233 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: sentinel-watch
|
|
3
|
+
Version: 0.3.0
|
|
4
|
+
Summary: tiny folder watchdog that spots ransomware-ish behavior
|
|
5
|
+
Author-email: HahaAhhDev <theabsolutesmartest@gmail.com>
|
|
6
|
+
License: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/HahaAhhDev/sentinel
|
|
8
|
+
Project-URL: Documentation, https://hahaahhdev.github.io/sentinel
|
|
9
|
+
Project-URL: Issues, https://github.com/HahaAhhDev/sentinel/issues
|
|
10
|
+
Project-URL: Changelog, https://github.com/HahaAhhDev/sentinel/blob/main/CHANGELOG.md
|
|
11
|
+
Keywords: security,ransomware,watchdog,integrity,monitoring
|
|
12
|
+
Classifier: Development Status :: 4 - Beta
|
|
13
|
+
Classifier: Intended Audience :: System Administrators
|
|
14
|
+
Classifier: Intended Audience :: Developers
|
|
15
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
16
|
+
Classifier: Operating System :: OS Independent
|
|
17
|
+
Classifier: Programming Language :: Python :: 3
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
21
|
+
Classifier: Topic :: Security
|
|
22
|
+
Classifier: Topic :: System :: Filesystems
|
|
23
|
+
Classifier: Topic :: System :: Monitoring
|
|
24
|
+
Requires-Python: >=3.10
|
|
25
|
+
Description-Content-Type: text/markdown
|
|
26
|
+
License-File: LICENSE
|
|
27
|
+
Requires-Dist: watchdog
|
|
28
|
+
Requires-Dist: typer
|
|
29
|
+
Requires-Dist: rich
|
|
30
|
+
Requires-Dist: pyyaml
|
|
31
|
+
Requires-Dist: psutil
|
|
32
|
+
Provides-Extra: dev
|
|
33
|
+
Requires-Dist: pytest; extra == "dev"
|
|
34
|
+
Requires-Dist: mkdocs; extra == "dev"
|
|
35
|
+
Requires-Dist: mkdocs-material; extra == "dev"
|
|
36
|
+
Requires-Dist: build; extra == "dev"
|
|
37
|
+
Requires-Dist: twine; extra == "dev"
|
|
38
|
+
Dynamic: license-file
|
|
39
|
+
|
|
40
|
+
# sentinel
|
|
41
|
+
|
|
42
|
+

|
|
43
|
+

|
|
44
|
+

|
|
45
|
+

|
|
46
|
+

|
|
47
|
+
|
|
48
|
+
Tiny folder watchdog that spots ransomware-like behavior. Baseline it, watch it, get told before it is too late.
|
|
49
|
+
|
|
50
|
+
Docs site: https://hahaahhdev.github.io/sentinel/
|
|
51
|
+
|
|
52
|
+
```
|
|
53
|
+
pip install sentinel-watch
|
|
54
|
+
sentinel init ~/Documents
|
|
55
|
+
sentinel watch ~/Documents
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
That is the pitch. No server. No signup. Files stay local.
|
|
59
|
+
|
|
60
|
+
---
|
|
61
|
+
|
|
62
|
+
## Why this one
|
|
63
|
+
|
|
64
|
+
Most integrity tools are built for servers and need setup. Most crypto detectors only scan once and miss live hits.
|
|
65
|
+
|
|
66
|
+
Sentinel does both, plus two things others skip:
|
|
67
|
+
|
|
68
|
+
- vault of clean copies, so `protect --restore-clean all` brings back pre hit text, not post hit junk
|
|
69
|
+
- one risk number via `check`, so CI and humans read the same line
|
|
70
|
+
|
|
71
|
+
Live rules plus one shot scan plus real restores. That combo is rare.
|
|
72
|
+
|
|
73
|
+
## Demo in 30 seconds
|
|
74
|
+
|
|
75
|
+
```bash
|
|
76
|
+
pip install -e .
|
|
77
|
+
sentinel demo
|
|
78
|
+
sentinel scan ./demo_run
|
|
79
|
+
sentinel check ./demo_run
|
|
80
|
+
sentinel report ./demo_run --out report.html
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
You get entropy, file scores, and a risk line like `risk warn 55`. Open `report.html` for the pretty page.
|
|
84
|
+
|
|
85
|
+
## Install
|
|
86
|
+
|
|
87
|
+
```bash
|
|
88
|
+
pip install sentinel-watch
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
From source:
|
|
92
|
+
|
|
93
|
+
```bash
|
|
94
|
+
git clone https://github.com/HahaAhhDev/sentinel
|
|
95
|
+
cd sentinel
|
|
96
|
+
pip install -e .
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
Needs Python 3.10+. Pulls `watchdog`, `typer`, `rich`, `pyyaml`, `psutil`. Dev extras add `pytest`, `mkdocs`, `mkdocs-material`.
|
|
100
|
+
|
|
101
|
+
## Quickstart
|
|
102
|
+
|
|
103
|
+
```bash
|
|
104
|
+
sentinel init ~/Documents
|
|
105
|
+
sentinel verify ~/Documents
|
|
106
|
+
sentinel scan ~/Documents
|
|
107
|
+
sentinel check ~/Documents
|
|
108
|
+
sentinel watch ~/Documents
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
Full walk is in [docs](https://hahaahhdev.github.io/sentinel/) under Quickstart. Short version: `init` once, `check` often, `watch` when it matters.
|
|
112
|
+
|
|
113
|
+
## Commands
|
|
114
|
+
|
|
115
|
+
| Command | What it does |
|
|
116
|
+
| --- | --- |
|
|
117
|
+
| `init` | Hash all, fill vault |
|
|
118
|
+
| `update` | Rehash only changed |
|
|
119
|
+
| `status` | Counts, dates, vault size |
|
|
120
|
+
| `verify` | Diff vs baseline |
|
|
121
|
+
| `diff` | Text diffs via vault |
|
|
122
|
+
| `scan` | Score files, json or sarif |
|
|
123
|
+
| `why FILE` | Explain one file |
|
|
124
|
+
| `check` | Verify plus scan plus risk, for CI |
|
|
125
|
+
| `watch` | Live loop, canary, notes, storms |
|
|
126
|
+
| `learn` | Watch quiet, suggest burst |
|
|
127
|
+
| `protect` | Fill vault or restore clean |
|
|
128
|
+
| `events`, `timeline` | Last hits |
|
|
129
|
+
| `snaps`, `restore` | Quarantine packs |
|
|
130
|
+
| `report`, `serve` | HTML page, local web |
|
|
131
|
+
| `config-init`, `doctor` | Scaffold yaml, self test |
|
|
132
|
+
| `clean`, `demo` | Wipe, fake hit |
|
|
133
|
+
|
|
134
|
+
See `docs/CLI.md` or the [web CLI page](https://hahaahhdev.github.io/sentinel/CLI/) for flags and copy paste samples.
|
|
135
|
+
|
|
136
|
+
## How it spots trouble
|
|
137
|
+
|
|
138
|
+
Four small rules that stack, plus one risk roll up.
|
|
139
|
+
|
|
140
|
+
- burst: N events in M secs, stock 25 in 10
|
|
141
|
+
- entropy: Shannon on first 1MB, stock line 7.5, zips and pics skipped by magic
|
|
142
|
+
- canary: `.sentinel/canary.txt` touched means now
|
|
143
|
+
- notes and exts: `.locked`, `READ_ME.txt`, words like `bitcoin` and `decrypt`
|
|
144
|
+
|
|
145
|
+
`scan` scores 0 to 100 per file. `check` rolls verify plus scan into risk `clean`, `warn`, `high`. Details in [Rules](https://hahaahhdev.github.io/sentinel/RULES/).
|
|
146
|
+
|
|
147
|
+
Tune with `learn`:
|
|
148
|
+
|
|
149
|
+
```bash
|
|
150
|
+
sentinel learn ~/Documents --secs 60
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
Work like normal for a minute, it tells you a sane burst.
|
|
154
|
+
|
|
155
|
+
## Config
|
|
156
|
+
|
|
157
|
+
```bash
|
|
158
|
+
sentinel config-init
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
Writes `sentinel.yaml`. Sentinel finds `sentinel.yaml`, `.sentinel.yaml`, `.sentinel/config.yaml` by walking up. Flags beat file.
|
|
162
|
+
|
|
163
|
+
```yaml
|
|
164
|
+
burst: 25
|
|
165
|
+
window: 10
|
|
166
|
+
cooldown: 30
|
|
167
|
+
entropy_line: 7.5
|
|
168
|
+
vault_max_mb: 5
|
|
169
|
+
risk_warn: 40
|
|
170
|
+
risk_high: 70
|
|
171
|
+
webhook: ""
|
|
172
|
+
notify: false
|
|
173
|
+
kill: false
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
Ignores merge from built ins, `.sentinelignore`, and yaml `ignore:`. Full list in [Config](https://hahaahhdev.github.io/sentinel/CONFIG/).
|
|
177
|
+
|
|
178
|
+
## Alerts and restores
|
|
179
|
+
|
|
180
|
+
Hits go to terminal, `.sentinel/sentinel.log`, `.sentinel/events.jsonl`. Optional webhook, mail via local smtp, desktop popup.
|
|
181
|
+
|
|
182
|
+
Two safety nets:
|
|
183
|
+
|
|
184
|
+
- quarantine in `.sentinel/quarantine/<ts>/`, post hit copies for forensics
|
|
185
|
+
- vault in `.sentinel/vault/`, pre hit clean copies for restores
|
|
186
|
+
|
|
187
|
+
```bash
|
|
188
|
+
sentinel snaps .
|
|
189
|
+
sentinel protect . --restore-clean all
|
|
190
|
+
```
|
|
191
|
+
|
|
192
|
+
Most tools only do the first. Vault is why restores actually work.
|
|
193
|
+
|
|
194
|
+
## CI and web
|
|
195
|
+
|
|
196
|
+
```bash
|
|
197
|
+
sentinel check ./uploads --fail-warn
|
|
198
|
+
sentinel scan . --sarif > results.sarif
|
|
199
|
+
sentinel report . --out report.html
|
|
200
|
+
sentinel serve . --port 8000
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
Sarif feeds GitHub code scanning. Html is one offline file. Serve adds `/json` for scripts. Workflow samples in `examples/` and [Actions](https://hahaahhdev.github.io/sentinel/ACTIONS/).
|
|
204
|
+
|
|
205
|
+
Web docs build with mkdocs material. `mkdocs serve` to preview, push to `main` to publish via Pages. How to in [Web docs](https://hahaahhdev.github.io/sentinel/WEB/).
|
|
206
|
+
|
|
207
|
+
## Layout
|
|
208
|
+
|
|
209
|
+
```
|
|
210
|
+
sentinel/
|
|
211
|
+
cli.py # commands
|
|
212
|
+
baseline.py # hash, sqlite, diff
|
|
213
|
+
detect.py # entropy, notes, risk
|
|
214
|
+
vault.py # clean copies
|
|
215
|
+
watcher.py # live loop
|
|
216
|
+
respond.py # logs, webhook, mail, sarif
|
|
217
|
+
report.py # html
|
|
218
|
+
serve.py # local web
|
|
219
|
+
learn.py # auto tune
|
|
220
|
+
proc.py # top writer, kill
|
|
221
|
+
config.py # yaml
|
|
222
|
+
docs/ # pages source
|
|
223
|
+
examples/
|
|
224
|
+
tests/
|
|
225
|
+
```
|
|
226
|
+
|
|
227
|
+
## Contributing
|
|
228
|
+
|
|
229
|
+
See `CONTRIBUTING.md`. Fork, `pip install -e .[dev]`, `pytest -q`, PR with a test and what folder you tried it on.
|
|
230
|
+
|
|
231
|
+
## License
|
|
232
|
+
|
|
233
|
+
MIT, see `LICENSE`.
|
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
# sentinel
|
|
2
|
+
|
|
3
|
+

|
|
4
|
+

|
|
5
|
+

|
|
6
|
+

|
|
7
|
+

|
|
8
|
+
|
|
9
|
+
Tiny folder watchdog that spots ransomware-like behavior. Baseline it, watch it, get told before it is too late.
|
|
10
|
+
|
|
11
|
+
Docs site: https://hahaahhdev.github.io/sentinel/
|
|
12
|
+
|
|
13
|
+
```
|
|
14
|
+
pip install sentinel-watch
|
|
15
|
+
sentinel init ~/Documents
|
|
16
|
+
sentinel watch ~/Documents
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
That is the pitch. No server. No signup. Files stay local.
|
|
20
|
+
|
|
21
|
+
---
|
|
22
|
+
|
|
23
|
+
## Why this one
|
|
24
|
+
|
|
25
|
+
Most integrity tools are built for servers and need setup. Most crypto detectors only scan once and miss live hits.
|
|
26
|
+
|
|
27
|
+
Sentinel does both, plus two things others skip:
|
|
28
|
+
|
|
29
|
+
- vault of clean copies, so `protect --restore-clean all` brings back pre hit text, not post hit junk
|
|
30
|
+
- one risk number via `check`, so CI and humans read the same line
|
|
31
|
+
|
|
32
|
+
Live rules plus one shot scan plus real restores. That combo is rare.
|
|
33
|
+
|
|
34
|
+
## Demo in 30 seconds
|
|
35
|
+
|
|
36
|
+
```bash
|
|
37
|
+
pip install -e .
|
|
38
|
+
sentinel demo
|
|
39
|
+
sentinel scan ./demo_run
|
|
40
|
+
sentinel check ./demo_run
|
|
41
|
+
sentinel report ./demo_run --out report.html
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
You get entropy, file scores, and a risk line like `risk warn 55`. Open `report.html` for the pretty page.
|
|
45
|
+
|
|
46
|
+
## Install
|
|
47
|
+
|
|
48
|
+
```bash
|
|
49
|
+
pip install sentinel-watch
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
From source:
|
|
53
|
+
|
|
54
|
+
```bash
|
|
55
|
+
git clone https://github.com/HahaAhhDev/sentinel
|
|
56
|
+
cd sentinel
|
|
57
|
+
pip install -e .
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
Needs Python 3.10+. Pulls `watchdog`, `typer`, `rich`, `pyyaml`, `psutil`. Dev extras add `pytest`, `mkdocs`, `mkdocs-material`.
|
|
61
|
+
|
|
62
|
+
## Quickstart
|
|
63
|
+
|
|
64
|
+
```bash
|
|
65
|
+
sentinel init ~/Documents
|
|
66
|
+
sentinel verify ~/Documents
|
|
67
|
+
sentinel scan ~/Documents
|
|
68
|
+
sentinel check ~/Documents
|
|
69
|
+
sentinel watch ~/Documents
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
Full walk is in [docs](https://hahaahhdev.github.io/sentinel/) under Quickstart. Short version: `init` once, `check` often, `watch` when it matters.
|
|
73
|
+
|
|
74
|
+
## Commands
|
|
75
|
+
|
|
76
|
+
| Command | What it does |
|
|
77
|
+
| --- | --- |
|
|
78
|
+
| `init` | Hash all, fill vault |
|
|
79
|
+
| `update` | Rehash only changed |
|
|
80
|
+
| `status` | Counts, dates, vault size |
|
|
81
|
+
| `verify` | Diff vs baseline |
|
|
82
|
+
| `diff` | Text diffs via vault |
|
|
83
|
+
| `scan` | Score files, json or sarif |
|
|
84
|
+
| `why FILE` | Explain one file |
|
|
85
|
+
| `check` | Verify plus scan plus risk, for CI |
|
|
86
|
+
| `watch` | Live loop, canary, notes, storms |
|
|
87
|
+
| `learn` | Watch quiet, suggest burst |
|
|
88
|
+
| `protect` | Fill vault or restore clean |
|
|
89
|
+
| `events`, `timeline` | Last hits |
|
|
90
|
+
| `snaps`, `restore` | Quarantine packs |
|
|
91
|
+
| `report`, `serve` | HTML page, local web |
|
|
92
|
+
| `config-init`, `doctor` | Scaffold yaml, self test |
|
|
93
|
+
| `clean`, `demo` | Wipe, fake hit |
|
|
94
|
+
|
|
95
|
+
See `docs/CLI.md` or the [web CLI page](https://hahaahhdev.github.io/sentinel/CLI/) for flags and copy paste samples.
|
|
96
|
+
|
|
97
|
+
## How it spots trouble
|
|
98
|
+
|
|
99
|
+
Four small rules that stack, plus one risk roll up.
|
|
100
|
+
|
|
101
|
+
- burst: N events in M secs, stock 25 in 10
|
|
102
|
+
- entropy: Shannon on first 1MB, stock line 7.5, zips and pics skipped by magic
|
|
103
|
+
- canary: `.sentinel/canary.txt` touched means now
|
|
104
|
+
- notes and exts: `.locked`, `READ_ME.txt`, words like `bitcoin` and `decrypt`
|
|
105
|
+
|
|
106
|
+
`scan` scores 0 to 100 per file. `check` rolls verify plus scan into risk `clean`, `warn`, `high`. Details in [Rules](https://hahaahhdev.github.io/sentinel/RULES/).
|
|
107
|
+
|
|
108
|
+
Tune with `learn`:
|
|
109
|
+
|
|
110
|
+
```bash
|
|
111
|
+
sentinel learn ~/Documents --secs 60
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
Work like normal for a minute, it tells you a sane burst.
|
|
115
|
+
|
|
116
|
+
## Config
|
|
117
|
+
|
|
118
|
+
```bash
|
|
119
|
+
sentinel config-init
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
Writes `sentinel.yaml`. Sentinel finds `sentinel.yaml`, `.sentinel.yaml`, `.sentinel/config.yaml` by walking up. Flags beat file.
|
|
123
|
+
|
|
124
|
+
```yaml
|
|
125
|
+
burst: 25
|
|
126
|
+
window: 10
|
|
127
|
+
cooldown: 30
|
|
128
|
+
entropy_line: 7.5
|
|
129
|
+
vault_max_mb: 5
|
|
130
|
+
risk_warn: 40
|
|
131
|
+
risk_high: 70
|
|
132
|
+
webhook: ""
|
|
133
|
+
notify: false
|
|
134
|
+
kill: false
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
Ignores merge from built ins, `.sentinelignore`, and yaml `ignore:`. Full list in [Config](https://hahaahhdev.github.io/sentinel/CONFIG/).
|
|
138
|
+
|
|
139
|
+
## Alerts and restores
|
|
140
|
+
|
|
141
|
+
Hits go to terminal, `.sentinel/sentinel.log`, `.sentinel/events.jsonl`. Optional webhook, mail via local smtp, desktop popup.
|
|
142
|
+
|
|
143
|
+
Two safety nets:
|
|
144
|
+
|
|
145
|
+
- quarantine in `.sentinel/quarantine/<ts>/`, post hit copies for forensics
|
|
146
|
+
- vault in `.sentinel/vault/`, pre hit clean copies for restores
|
|
147
|
+
|
|
148
|
+
```bash
|
|
149
|
+
sentinel snaps .
|
|
150
|
+
sentinel protect . --restore-clean all
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
Most tools only do the first. Vault is why restores actually work.
|
|
154
|
+
|
|
155
|
+
## CI and web
|
|
156
|
+
|
|
157
|
+
```bash
|
|
158
|
+
sentinel check ./uploads --fail-warn
|
|
159
|
+
sentinel scan . --sarif > results.sarif
|
|
160
|
+
sentinel report . --out report.html
|
|
161
|
+
sentinel serve . --port 8000
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
Sarif feeds GitHub code scanning. Html is one offline file. Serve adds `/json` for scripts. Workflow samples in `examples/` and [Actions](https://hahaahhdev.github.io/sentinel/ACTIONS/).
|
|
165
|
+
|
|
166
|
+
Web docs build with mkdocs material. `mkdocs serve` to preview, push to `main` to publish via Pages. How to in [Web docs](https://hahaahhdev.github.io/sentinel/WEB/).
|
|
167
|
+
|
|
168
|
+
## Layout
|
|
169
|
+
|
|
170
|
+
```
|
|
171
|
+
sentinel/
|
|
172
|
+
cli.py # commands
|
|
173
|
+
baseline.py # hash, sqlite, diff
|
|
174
|
+
detect.py # entropy, notes, risk
|
|
175
|
+
vault.py # clean copies
|
|
176
|
+
watcher.py # live loop
|
|
177
|
+
respond.py # logs, webhook, mail, sarif
|
|
178
|
+
report.py # html
|
|
179
|
+
serve.py # local web
|
|
180
|
+
learn.py # auto tune
|
|
181
|
+
proc.py # top writer, kill
|
|
182
|
+
config.py # yaml
|
|
183
|
+
docs/ # pages source
|
|
184
|
+
examples/
|
|
185
|
+
tests/
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
## Contributing
|
|
189
|
+
|
|
190
|
+
See `CONTRIBUTING.md`. Fork, `pip install -e .[dev]`, `pytest -q`, PR with a test and what folder you tried it on.
|
|
191
|
+
|
|
192
|
+
## License
|
|
193
|
+
|
|
194
|
+
MIT, see `LICENSE`.
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
# copy to sentinel.yaml and tweak
|
|
2
|
+
# all of these have sane defaults
|
|
3
|
+
|
|
4
|
+
path: "."
|
|
5
|
+
burst: 25
|
|
6
|
+
window: 10
|
|
7
|
+
cooldown: 30
|
|
8
|
+
entropy_line: 7.5
|
|
9
|
+
webhook: ""
|
|
10
|
+
notify: false
|
|
11
|
+
kill: false
|
|
12
|
+
|
|
13
|
+
# vault keeps clean copies for restores
|
|
14
|
+
vault_max_mb: 5
|
|
15
|
+
|
|
16
|
+
# risk lines for check
|
|
17
|
+
risk_warn: 40
|
|
18
|
+
risk_high: 70
|
|
19
|
+
|
|
20
|
+
# local web view
|
|
21
|
+
serve_port: 8000
|
|
22
|
+
|
|
23
|
+
# mail, blank means off
|
|
24
|
+
mail_to: ""
|
|
25
|
+
mail_from: "sentinel@localhost"
|
|
26
|
+
smtp_host: "localhost"
|
|
27
|
+
smtp_port: 25
|
|
28
|
+
|
|
29
|
+
# extra ignore globs on top of .sentinelignore
|
|
30
|
+
ignore:
|
|
31
|
+
- "*.tmp"
|
|
32
|
+
- "*.log"
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
# Actions and CI
|
|
2
|
+
|
|
3
|
+
Pipes and GitHub.
|
|
4
|
+
|
|
5
|
+
## The one command
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
sentinel check ./data
|
|
9
|
+
sentinel check ./data --fail-warn
|
|
10
|
+
echo $?
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
Fails on high or drift. Add `--fail-warn` to fail on warn too. Best gate for uploads and golden data.
|
|
14
|
+
|
|
15
|
+
Json for scripts:
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
sentinel check ./uploads --json > check.json
|
|
19
|
+
sentinel verify ./uploads --json > verify.json
|
|
20
|
+
sentinel scan ./uploads --json > scan.json
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
Sarif for code scanning:
|
|
24
|
+
|
|
25
|
+
```bash
|
|
26
|
+
sentinel scan . --sarif > results.sarif
|
|
27
|
+
sentinel check . --sarif > results.sarif
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
Upload with `github/codeql-action/upload-sarif`.
|
|
31
|
+
|
|
32
|
+
## Verify gate
|
|
33
|
+
|
|
34
|
+
```bash
|
|
35
|
+
sentinel verify ./data --fail
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
Exit 1 on changed or deleted. New files do not fail. Good when baseline is committed.
|
|
39
|
+
|
|
40
|
+
## Full workflow
|
|
41
|
+
|
|
42
|
+
See `examples/github-action.yml`. Minimal job:
|
|
43
|
+
|
|
44
|
+
```yaml
|
|
45
|
+
- uses: actions/checkout@v4
|
|
46
|
+
- uses: actions/setup-python@v5
|
|
47
|
+
with:
|
|
48
|
+
python-version: "3.12"
|
|
49
|
+
- run: pip install -e .
|
|
50
|
+
- run: sentinel check . --json > check.json
|
|
51
|
+
- uses: actions/upload-artifact@v4
|
|
52
|
+
with:
|
|
53
|
+
name: sentinel-check
|
|
54
|
+
path: check.json
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
Sarif job:
|
|
58
|
+
|
|
59
|
+
```yaml
|
|
60
|
+
- run: sentinel scan . --sarif > results.sarif
|
|
61
|
+
- uses: github/codeql-action/upload-sarif@v3
|
|
62
|
+
with:
|
|
63
|
+
sarif_file: results.sarif
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
Docs build runs in `ci.yml` too via `mkdocs build --strict`.
|
|
67
|
+
|
|
68
|
+
## HTML artifacts
|
|
69
|
+
|
|
70
|
+
```bash
|
|
71
|
+
sentinel report ./uploads --out report.html
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
One offline file. Upload it, link it in PRs.
|
|
75
|
+
|
|
76
|
+
## Pre commit
|
|
77
|
+
|
|
78
|
+
```yaml
|
|
79
|
+
- repo: local
|
|
80
|
+
hooks:
|
|
81
|
+
- id: sentinel-check
|
|
82
|
+
name: sentinel check
|
|
83
|
+
entry: sentinel check .
|
|
84
|
+
language: system
|
|
85
|
+
pass_filenames: false
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
## Alerts in prod
|
|
89
|
+
|
|
90
|
+
```bash
|
|
91
|
+
sentinel watch ./uploads --webhook "$WEBHOOK_URL"
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
Body is `{"text": "title\ndetail"}`. Works for Slack and Discord. Add mail via yaml `mail_to` plus local smtp if you run your own box.
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
## 0.3.0
|
|
4
|
+
|
|
5
|
+
- add `check` with risk clean/warn/high plus json and sarif
|
|
6
|
+
- add `why` to explain one file score
|
|
7
|
+
- add `diff` using vault copies
|
|
8
|
+
- add `protect` vault fill and restore clean
|
|
9
|
+
- add `update` fast rehash
|
|
10
|
+
- add `learn` to suggest burst
|
|
11
|
+
- add `timeline`, `serve` with /json, `config-init`, `doctor`
|
|
12
|
+
- add `watch --daemon`, rename and delete storm rules
|
|
13
|
+
- store entropy at baseline time
|
|
14
|
+
- add mail alerts, sarif output
|
|
15
|
+
- add mkdocs site plus pages and ci workflows
|
|
16
|
+
- human pass over all code and docs
|
|
17
|
+
|
|
18
|
+
## 0.2.0
|
|
19
|
+
|
|
20
|
+
- add `scan`, `report`, `events`, `snaps`, `restore`, `status`, `clean`
|
|
21
|
+
- add yaml config plus `.sentinelignore`
|
|
22
|
+
- add ransom note and ext scoring
|
|
23
|
+
- add json logs and html report
|
|
24
|
+
- add webhook, desktop note, optional kill
|
|
25
|
+
- add docs folder and examples
|
|
26
|
+
- threaded baseline
|
|
27
|
+
|
|
28
|
+
## 0.1.0
|
|
29
|
+
|
|
30
|
+
- first cut: `init`, `verify`, `watch`, `demo`
|
|
31
|
+
- burst plus entropy plus canary
|