hearthwatch 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.
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright [yyyy] [name of copyright owner]
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
@@ -0,0 +1,16 @@
1
+ Hearthwatch's check_repo.py contains detection rules (regular expressions and their severity logic)
2
+ adapted from RepoBeagle:
3
+
4
+ RepoBeagle https://github.com/javierbits/repobeagle
5
+ Copyright 2026 javierbits
6
+ Licensed under the Apache License, Version 2.0 https://www.apache.org/licenses/LICENSE-2.0
7
+ Source pinned to commit 581e01e976 (v1.201.1).
8
+
9
+ Changes by Hearthwatch: a standard-library-only subset was ported (install hooks, download-and-run,
10
+ decode-and-run, hidden Unicode, agent prompt injection, MCP/tool manifests and tool poisoning,
11
+ read-secret-then-send, GitHub workflow tricks, program-behind-text-extension). Fetching was redesigned
12
+ (no checkout; files read from git objects). No RepoBeagle code is executed. Thank you to
13
+ SolanceLab's stack-guard (https://github.com/SolanceLab/stack-guard) for the ideas.
14
+
15
+ RepoBeagle and Hearthwatch are both licensed under the Apache License 2.0; the full license text is in
16
+ LICENSE and applies to the adapted rules as well.
@@ -0,0 +1,315 @@
1
+ Metadata-Version: 2.4
2
+ Name: hearthwatch
3
+ Version: 0.3.0
4
+ Summary: Check code before you install it, find live keys in git history, and watch a Linux server's packages. Reports only; never blocks or deletes.
5
+ Author: Hearthwatch
6
+ License-Expression: Apache-2.0
7
+ Project-URL: Homepage, https://github.com/ReyesHouse/Hearthwatch
8
+ Project-URL: Issues, https://github.com/ReyesHouse/Hearthwatch/issues
9
+ Project-URL: Changelog, https://github.com/ReyesHouse/Hearthwatch/blob/main/CHANGELOG.md
10
+ Keywords: security,supply-chain,prompt-injection,pre-install,secrets,agents
11
+ Classifier: Programming Language :: Python :: 3
12
+ Classifier: Operating System :: OS Independent
13
+ Classifier: Topic :: Security
14
+ Classifier: Environment :: Console
15
+ Requires-Python: >=3.10
16
+ Description-Content-Type: text/markdown
17
+ License-File: LICENSE
18
+ License-File: NOTICE
19
+ Dynamic: license-file
20
+
21
+ <p align="center"><img src="docs/banner.jpg" alt="A warm room on a stormy night: a small server with a green light on the desk, a lighthouse beam through the rainy window" width="100%"></p>
22
+
23
+ # Hearthwatch
24
+
25
+ Hearthwatch checks code before you install it, looks for keys you still use in git history, and (on a Linux
26
+ server) watches the packages you run for known malware and serious holes. It has extra checks for hidden
27
+ instructions aimed at AI coding agents. You decide what to do with each finding: it **only reports**, and
28
+ never blocks, deletes or "fixes" anything. Small, readable, standard-library Python.
29
+
30
+ Three tools that work on their own:
31
+
32
+ | Tool | Answers | Windows | macOS | Linux |
33
+ |---|---|:-:|:-:|:-:|
34
+ | `check_repo` | *What should I inspect before installing this repo?* | ✅ | ✅ | ✅ |
35
+ | `keys` | *Did a key I'm using right now leak into git history?* | ✅ | ✅ | ✅ |
36
+ | `scan` | *Was a reported package version on my server at the last scan? Is anything I run badly vulnerable?* | — | — | ✅ |
37
+
38
+ `check_repo` and `keys` run on your own computer, whatever it is. `scan` reads a Linux server's running
39
+ services and package list, so it is for Linux servers only. All three need Python 3.10+ and `git`.
40
+
41
+ Using an AI coding agent? Hearthwatch plugs into **Claude Code, Codex and Gemini** so the agent checks before
42
+ it installs. See **Use it from your coding AI** below.
43
+
44
+ ## Install (one command)
45
+
46
+ ```sh
47
+ pip install "git+https://github.com/ReyesHouse/Hearthwatch@v0.3.0"
48
+ ```
49
+
50
+ (`py -3 -m pip install ...` on Windows.) That gives you three commands:
51
+
52
+ | Command | Does |
53
+ |---|---|
54
+ | `hearthwatch-check <link or folder>` | check before you install |
55
+ | `hearthwatch-keys` | look for your live keys in git history |
56
+ | `hearthwatch-scan scan` | package watch (Linux servers) |
57
+
58
+ Run them from **outside** the folder you are checking (`hearthwatch-check C:\Downloads\some-repo`, not
59
+ `cd some-repo` first): a planted file in that folder could otherwise run before the check does. No other
60
+ packages are pulled in: Hearthwatch uses only Python's standard library. Use it alongside your
61
+ normal antivirus, not instead of it: it catches known tricks in code, not every kind of malware.
62
+
63
+ ## Try it first (one minute, nothing to set up)
64
+
65
+ **Windows** (PowerShell or Command Prompt):
66
+
67
+ ```powershell
68
+ git clone https://github.com/ReyesHouse/Hearthwatch.git
69
+ cd Hearthwatch
70
+ py -3 -I hw_check.py .
71
+ ```
72
+
73
+ **macOS / Linux**:
74
+
75
+ ```sh
76
+ git clone https://github.com/ReyesHouse/Hearthwatch.git
77
+ cd Hearthwatch
78
+ python3 -I hw_check.py .
79
+ ```
80
+
81
+ **Expect RED on this demo.** Hearthwatch's own tests are full of examples of the tricks it flags. Look at the
82
+ reported file names and line numbers to see what triggered each finding (add `--show-text` to see the lines
83
+ themselves). That is how you read a finding on any repo. To check something before installing it, pass a link
84
+ instead of `.`, for example `py -3 -I hw_check.py https://github.com/owner/repo`.
85
+
86
+ ## How it works
87
+
88
+ <p align="center"><img src="docs/how-it-works.svg" alt="How Hearthwatch works: check_repo before you install, scan every day on your server, keys over your git history" width="560"></p>
89
+
90
+ ## Who it's for
91
+
92
+ Anyone who installs code from the internet: on a Windows, Mac or Linux computer, or on one Linux server (a
93
+ small website, a VPS, a homelab) with no security team. It is especially for setups where AI agents install
94
+ things and change code by themselves. Big security tools are built for companies. This one is built for one
95
+ person, and tells you plainly what it can't see.
96
+
97
+ ## Use it from your coding AI (Claude Code, Codex, Gemini)
98
+
99
+ Hearthwatch's pre-install check works the same way in all three. Each AI gets one short instruction:
100
+ before installing anything new from the internet, run `check_repo`; stop on RED or INCOMPLETE and tell you.
101
+
102
+ - **Claude Code** (plugin, one step):
103
+
104
+ ```
105
+ /plugin install hearthwatch --marketplace ReyesHouse/Hearthwatch
106
+ ```
107
+
108
+ It adds a `check` skill (`/hearthwatch:check`). It is an instruction, not a hook: it does not slow down
109
+ your other commands.
110
+ - **Gemini CLI** (extension): `gemini extensions install https://github.com/ReyesHouse/Hearthwatch`
111
+ (it loads `GEMINI.md`).
112
+ - **Codex** (and any agent that reads `AGENTS.md`): clone Hearthwatch, then copy the text of
113
+ [`AGENTS.md`](AGENTS.md) into your project's `AGENTS.md` or your global `~/.codex/AGENTS.md`.
114
+
115
+ Works on **Linux, Windows and macOS** for `check_repo` (links and folders) and `keys`. Windows and macOS
116
+ notes: the whole-job time limit and the memory and process limits apply on Linux and macOS, not on
117
+ Windows, and macOS is tested less. The package watch (`scan`) and the server setup below are Linux only.
118
+
119
+ ## Setup from a clone (settings, and Linux servers)
120
+
121
+ **On your own computer (Windows, macOS, Linux):** clone it and run `check_repo` as shown above. Nothing to
122
+ install. To use the key search, make a settings file listing your repos and the files that hold your live keys,
123
+ then run it:
124
+
125
+ ```sh
126
+ # settings: Windows %APPDATA%\Hearthwatch\config.json
127
+ # macOS ~/Library/Application Support/Hearthwatch/config.json
128
+ # Linux ~/.config/hearthwatch/config.json (or set HEARTHWATCH_CONFIG to any file)
129
+ # {"keys": {"repos": ["C:/code/myapp"], "live_secret_files": ["C:/code/myapp/.env"]}}
130
+ py -3 -m hearthwatch.keys # Windows (python3 -m hearthwatch.keys elsewhere), from the Hearthwatch folder
131
+ ```
132
+
133
+ Its reports stay in your own user folder. Leave the allowlist and report locations out of your settings unless
134
+ you need them elsewhere: the defaults are already private to you.
135
+
136
+ **On a Linux server (all three tools, run as their own users):** Python 3.10+ and a recent `git` (tested with
137
+ 2.53). No packages to install.
138
+
139
+ ```sh
140
+ git clone https://github.com/ReyesHouse/Hearthwatch.git /opt/hearthwatch
141
+ sudo useradd --system --no-create-home hearthwatch-scan # runs check_repo and scan
142
+ sudo useradd --system --no-create-home hearthwatch-keys # runs keys; give it READ access to the repos you list
143
+ sudo mkdir -p /etc/hearthwatch && sudo cp /opt/hearthwatch/config.example.json /etc/hearthwatch/config.json
144
+ sudo install -d -m 0700 -o hearthwatch-scan /var/lib/hearthwatch-scan # scan's private state
145
+ sudo install -d -m 0700 -o hearthwatch-keys /var/lib/hearthwatch-keys # keys' private reports
146
+ ```
147
+
148
+ Run `scan hit` as `hearthwatch-scan` too: the state folder is private on purpose.
149
+
150
+ Edit `/etc/hearthwatch/config.json`. Every key is optional. A missing file means defaults, and a broken file
151
+ stops the tool with an error (it never runs half-configured).
152
+
153
+ ## 1. `check_repo`: check before you install
154
+
155
+ ```sh
156
+ cd /opt/hearthwatch
157
+ sudo -u hearthwatch-scan python3 -m hearthwatch.check_repo https://github.com/someone/some-tool
158
+ ```
159
+
160
+ It **never runs the repo**. A link is cloned with no checkout (depth 1, hooks off, no submodules, no LFS, no
161
+ credentials, https on port 443 only, allowlisted hosts) and every file is read straight out of git objects.
162
+ Memory, CPU, file size and time are capped.
163
+
164
+ It looks for: hidden instructions aimed at AI agents (prompt injection, invisible or right-to-left unicode),
165
+ download-and-run (`curl ... | sh`), decode-and-run (`eval(atob(...))`), install hooks, MCP tool poisoning,
166
+ reading a secret near a network call, GitHub workflow tricks, programs hiding behind text extensions.
167
+
168
+ | Exit | Verdict | Meaning |
169
+ |---|---|---|
170
+ | 0 | GREEN | No known trick found. Not a promise. |
171
+ | 1 | YELLOW | Normal for many honest repos (install scripts, workflows). Read the findings. |
172
+ | 2 | RED | A high or critical finding. Stop. Have a person look before installing. |
173
+ | 3 | error | It couldn't run (bad link, git missing...). |
174
+ | 4 | INCOMPLETE | Something couldn't be read. Treat it like RED. |
175
+
176
+ **Tip for agent setups:** make it a rule that your agents run `check_repo` before installing anything new, and
177
+ stop on RED **and on INCOMPLETE or error**. That one habit stops the known "paste this line" tricks it has rules for.
178
+
179
+ By default it prints only the rule, file and line, **never text from the repo**: an agent reading the output would
180
+ otherwise read the very injection it caught. A person can add `--show-text` to see the lines.
181
+
182
+ **Your own repos** will often show findings (a security tool's tests are full of tricks; this repo itself
183
+ scans **RED** for exactly that reason). Mark reviewed findings as known-okay in the allowlist: each entry is
184
+ bound to the file's sha256, so if the file changes, the finding counts again.
185
+
186
+ ```json
187
+ [{"file": "tests/test_x.py", "rule": "download-and-run", "sha256": "<sha256 of the file>",
188
+ "reason": "test sample", "review": "2027-06-01"}]
189
+ ```
190
+
191
+ ## 2. `scan`: the package watch
192
+
193
+ ```sh
194
+ sudo -u hearthwatch-scan python3 -m hearthwatch.scan scan # inventory + OSV lookup
195
+ sudo -u hearthwatch-scan python3 -m hearthwatch.scan hit somepackage 1.2.3 # were we hit?
196
+ ```
197
+
198
+ 1. **Inventory of what actually runs.** It asks systemd which services are running, follows them to their
199
+ Python venvs (and `PYTHONPATH` folders) and Node projects, and reads installed packages **as text**
200
+ (`dist-info/METADATA`, `node_modules/.package-lock.json`, `/var/lib/dpkg/status`). It never runs
201
+ `pip list` or imports anything, because a malicious `.pth` file runs on Python startup.
202
+ 2. **OSV.dev lookup** for PyPI and npm: only names and versions leave the machine. `MAL-` advisories are
203
+ malware; CRITICAL/HIGH are flagged; a package that went **backwards** since the last scan is flagged too.
204
+ 3. **`hit`**: when you read about a compromised package, ask *were we hit?* You get YES (where), NO (not in
205
+ the inventory as of <time>), or UNKNOWN (the inventory is incomplete or missing). UNKNOWN is never NO.
206
+ A running Python/Node service whose packages can't be traced, or a folder it can't read, makes the
207
+ inventory incomplete. Folders that are unreadable on purpose go in `scan.accepted_unreadable`: they are
208
+ named in every report instead.
209
+ 4. **Honest grades:** an advisory whose severity can't be read is shown as *severity unknown*, never as minor.
210
+ A short answer from OSV is an error, not "clean".
211
+
212
+ Writes `inventory.json`, `findings.json` and a readable `report.md` to `state_dir`. Run it daily, for example
213
+ with a systemd timer:
214
+
215
+ ```ini
216
+ # /etc/systemd/system/hearthwatch-scan.service
217
+ [Service]
218
+ Type=oneshot
219
+ User=hearthwatch-scan
220
+ WorkingDirectory=/opt/hearthwatch
221
+ ExecStart=/usr/bin/python3 -m hearthwatch.scan scan
222
+ StateDirectory=hearthwatch-scan
223
+ StateDirectoryMode=0700
224
+ ProtectSystem=strict
225
+ NoNewPrivileges=yes
226
+ # /etc/systemd/system/hearthwatch-scan.timer
227
+ [Timer]
228
+ OnCalendar=daily
229
+ RandomizedDelaySec=1h
230
+ Persistent=true
231
+ [Install]
232
+ WantedBy=timers.target
233
+ ```
234
+
235
+ ## 3. `keys`: the leaked-key search
236
+
237
+ ```sh
238
+ sudo -u hearthwatch-keys python3 -m hearthwatch.keys # a dedicated user with READ access to the repos (not root)
239
+ ```
240
+
241
+ Reads the locally reachable history of the repos in `keys.repos` for key-shaped strings, and fingerprints the keys in your
242
+ `keys.live_secret_files`. If a string in history has the **same fingerprint as a key you're using now**, it
243
+ counts in `live_keys_in_history`. **Anything above 0 means a live key is in git history: rotate it.** The
244
+ report holds the key type and a fingerprint, **never the key**. It exits **4 (incomplete)** if a repo or a
245
+ live secret file couldn't be read, and git is run so a repo's own settings can't make it run anything. `details.json` is written 0600; mark reviewed
246
+ test keys as known-okay in `keys.allowlist` (`[{"fp", "reason", "review"}]`).
247
+
248
+ ## What it does NOT catch (read this)
249
+
250
+ - `scan` asks the system service manager (`systemctl`) what runs. Services started with `systemctl --user`,
251
+ containers (Docker, Podman) and programs started by hand are not seen.
252
+
253
+ - Attacks nobody has reported yet. OSV and the check rules only know known tricks.
254
+ - OS packages are inventoried for `hit` but not yet checked against advisories.
255
+ - Anything you `exclude`, repos you don't list, and other machines.
256
+ - A determined attacker who already has root: they can change anything, including this tool. Keep a copy
257
+ of its reports somewhere else.
258
+ - GREEN never means "safe". It means "no known trick found".
259
+
260
+ ### Known limits of 0.1 (honest list, from eight outside review rounds)
261
+
262
+ Before release an outside model reviewed this code eight times, each round hunting for any way a check could report
263
+ GREEN, NO or complete while wrong. Each round's findings were fixed and tested (97 tests). The last rounds were finding
264
+ ever rarer corners (an unusual `node` option, a key glued to an accented letter in a file name), so more will exist.
265
+ When a check cannot be sure, it is built to say UNKNOWN or INCOMPLETE rather than guess; please report any case where
266
+ it does not.
267
+
268
+
269
+ - `check_repo`: binary files are not read as text (programs hidden behind text extensions are still flagged);
270
+ `.git`, `node_modules` and `__pycache__` folders are skipped in local-folder mode; linked files and folders are
271
+ named, not followed; on non-Linux systems local folders are read by path, without the Linux directory-handle
272
+ protection. File names are shown escaped and truncated, but a hostile name can still be odd prose. Treat all
273
+ output as data.
274
+ - `scan`: Node packages come from the lockfile, so aliased or linked packages and a stale lockfile can mislead;
275
+ services started through opaque wrapper scripts can't be traced (traceable runtimes that can't be resolved are
276
+ reported), and a `PYTHONPATH` set in an `EnvironmentFile` is not read. OSV severity is read from the GitHub label
277
+ only, so other advisories show as *severity unknown*; "fixed in" lists candidate versions from all advisories for
278
+ a package; version comparison for downgrades is numeric, so pre-releases can be misordered. Package names and
279
+ versions are sent to OSV.dev: list secret internal package names in `scan.osv_skip`. Package names and paths in
280
+ reports come from files on disk; control characters are removed, but treat them as data. The three state files
281
+ are written one after another; `findings.json` carries `inventory_at`, so a reader can check they belong together.
282
+ - `keys`: reads the locally reachable history (every patch from the first commit, binary-marked files as text,
283
+ file names and commit messages); changes that exist only inside merge commits and private-key bodies (only the
284
+ header is matched) are not covered. A shallow or partial
285
+ clone, a grafts file or a failed check is reported as incomplete. It ignores system and global git settings and
286
+ turns off every network protocol, signature checks, pagers and replace refs, but it still reads each repo's own
287
+ `.git/config`: only point it at repos you trust.
288
+
289
+ ## Roadmap
290
+
291
+ 1. **The guard**: a scheduled sweep of the server that sends a phone alert when something breaks or looks
292
+ planted, and an "all clear" when it's fixed, plus a fire drill to prove the checks work.
293
+ 2. **A Claude Code plugin** that runs `check_repo` automatically before an agent installs something.
294
+ 3. **A skill** that teaches an agent the method: survey, plan, build, check, drill.
295
+
296
+ ## Safety design, in one breath
297
+
298
+ Alert-only. Unprivileged users. Nothing scanned is executed. Network use is OSV.dev and the git host you
299
+ asked for. Reports name the machine and what they don't cover. Every check has a test that forces it red.
300
+
301
+ ## Contributing and reporting bugs
302
+
303
+ Bug reports and small fixes are welcome: see [CONTRIBUTING.md](CONTRIBUTING.md). If you found a way to trick
304
+ Hearthwatch, please report it privately: see [SECURITY.md](SECURITY.md).
305
+
306
+ ## Credits
307
+
308
+ - Detection rules in `check_repo` adapted from [RepoBeagle](https://github.com/javierbits/repobeagle)
309
+ (Apache-2.0), pinned to commit 581e01e976. See `NOTICE`.
310
+ - Thank you to SolanceLab's [stack-guard](https://github.com/SolanceLab/stack-guard) for the ideas.
311
+ - Vulnerability data from [OSV.dev](https://osv.dev).
312
+
313
+ ## License
314
+
315
+ Apache License 2.0. See `LICENSE` and `NOTICE`.