raftward 0.1.1__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.
- raftward-0.1.1/LICENSE +158 -0
- raftward-0.1.1/MANIFEST.in +3 -0
- raftward-0.1.1/PKG-INFO +282 -0
- raftward-0.1.1/README.md +266 -0
- raftward-0.1.1/REVIEW.md +93 -0
- raftward-0.1.1/examples/config.toml +43 -0
- raftward-0.1.1/pyproject.toml +27 -0
- raftward-0.1.1/raftward/__init__.py +2 -0
- raftward-0.1.1/raftward/__main__.py +3 -0
- raftward-0.1.1/raftward/alerts.py +127 -0
- raftward-0.1.1/raftward/audit.py +61 -0
- raftward-0.1.1/raftward/cli.py +355 -0
- raftward-0.1.1/raftward/config.py +97 -0
- raftward-0.1.1/raftward/guard.py +289 -0
- raftward-0.1.1/raftward/reports.py +16 -0
- raftward-0.1.1/raftward/safety.py +259 -0
- raftward-0.1.1/raftward/scanner.py +314 -0
- raftward-0.1.1/raftward.egg-info/PKG-INFO +282 -0
- raftward-0.1.1/raftward.egg-info/SOURCES.txt +32 -0
- raftward-0.1.1/raftward.egg-info/dependency_links.txt +1 -0
- raftward-0.1.1/raftward.egg-info/entry_points.txt +2 -0
- raftward-0.1.1/raftward.egg-info/requires.txt +3 -0
- raftward-0.1.1/raftward.egg-info/top_level.txt +1 -0
- raftward-0.1.1/setup.cfg +4 -0
- raftward-0.1.1/tests/conftest.py +54 -0
- raftward-0.1.1/tests/test_alerts.py +44 -0
- raftward-0.1.1/tests/test_boundaries.py +149 -0
- raftward-0.1.1/tests/test_cli.py +213 -0
- raftward-0.1.1/tests/test_guard.py +117 -0
- raftward-0.1.1/tests/test_proc.py +320 -0
- raftward-0.1.1/tests/test_real_proc.py +151 -0
- raftward-0.1.1/tests/test_redaction.py +19 -0
- raftward-0.1.1/tests/test_rules.py +113 -0
- raftward-0.1.1/tests/test_scanner.py +297 -0
raftward-0.1.1/LICENSE
ADDED
|
@@ -0,0 +1,158 @@
|
|
|
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, and
|
|
10
|
+
distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by the copyright
|
|
13
|
+
owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all other entities
|
|
16
|
+
that control, are controlled by, or are under common control with that entity.
|
|
17
|
+
For the purposes of this definition, "control" means (i) the power, direct or
|
|
18
|
+
indirect, to cause the direction or management of such entity, whether by
|
|
19
|
+
contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
20
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
21
|
+
|
|
22
|
+
"You" (or "Your") shall mean an individual or Legal Entity exercising
|
|
23
|
+
permissions granted by this License.
|
|
24
|
+
|
|
25
|
+
"Source" form shall mean the preferred form for making modifications, including
|
|
26
|
+
but not limited to software source code, documentation source, and configuration
|
|
27
|
+
files.
|
|
28
|
+
|
|
29
|
+
"Object" form shall mean any form resulting from mechanical transformation or
|
|
30
|
+
translation of a Source form, including but not limited to compiled object code,
|
|
31
|
+
generated documentation, and conversions to other media types.
|
|
32
|
+
|
|
33
|
+
"Work" shall mean the work of authorship, whether in Source or Object form,
|
|
34
|
+
made available under the License, as indicated by a copyright notice that is
|
|
35
|
+
included in or attached to the work.
|
|
36
|
+
|
|
37
|
+
"Derivative Works" shall mean any work, whether in Source or Object form, that
|
|
38
|
+
is based on (or derived from) the Work and for which the editorial revisions,
|
|
39
|
+
annotations, elaborations, or other modifications represent, as a whole, an
|
|
40
|
+
original work of authorship. For the purposes of this License, Derivative Works
|
|
41
|
+
shall not include works that remain separable from, or merely link (or bind by
|
|
42
|
+
name) to the interfaces of, the Work and Derivative Works thereof.
|
|
43
|
+
|
|
44
|
+
"Contribution" shall mean any work of authorship, including the original
|
|
45
|
+
version of the Work and any modifications or additions to that Work or
|
|
46
|
+
Derivative Works thereof, that is intentionally submitted to Licensor for
|
|
47
|
+
inclusion in the Work by the copyright owner or by an individual or Legal Entity
|
|
48
|
+
authorized to submit on behalf of the copyright owner. For the purposes of this
|
|
49
|
+
definition, "submitted" means any form of electronic, verbal, or written
|
|
50
|
+
communication sent to the Licensor or its representatives, including but not
|
|
51
|
+
limited to communication on electronic mailing lists, source code control
|
|
52
|
+
systems, and issue tracking systems that are managed by, or on behalf of, the
|
|
53
|
+
Licensor for the purpose of discussing and improving the Work, but excluding
|
|
54
|
+
communication that is conspicuously marked or otherwise designated in writing by
|
|
55
|
+
the copyright owner as "Not a Contribution."
|
|
56
|
+
|
|
57
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity on behalf
|
|
58
|
+
of whom a Contribution has been received by Licensor and subsequently
|
|
59
|
+
incorporated within the Work.
|
|
60
|
+
|
|
61
|
+
2. Grant of Copyright License. Subject to the terms and conditions of this
|
|
62
|
+
License, each Contributor hereby grants to You a perpetual, worldwide,
|
|
63
|
+
non-exclusive, no-charge, royalty-free, irrevocable copyright license to
|
|
64
|
+
reproduce, prepare Derivative Works of, publicly display, publicly perform,
|
|
65
|
+
sublicense, and distribute the Work and such Derivative Works in Source or
|
|
66
|
+
Object form.
|
|
67
|
+
|
|
68
|
+
3. Grant of Patent License. Subject to the terms and conditions of this License,
|
|
69
|
+
each Contributor hereby grants to You a perpetual, worldwide, non-exclusive,
|
|
70
|
+
no-charge, royalty-free, irrevocable patent license to make, have made, use,
|
|
71
|
+
offer to sell, sell, import, and otherwise transfer the Work, where such license
|
|
72
|
+
applies only to those patent claims licensable by such Contributor that are
|
|
73
|
+
necessarily infringed by their Contribution(s) alone or by combination of their
|
|
74
|
+
Contribution(s) with the Work to which such Contribution(s) was submitted. If
|
|
75
|
+
You institute patent litigation against any entity (including a cross-claim or
|
|
76
|
+
counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated
|
|
77
|
+
within the Work constitutes direct or contributory patent infringement, then any
|
|
78
|
+
patent licenses granted to You under this License for that Work shall terminate
|
|
79
|
+
as of the date such litigation is filed.
|
|
80
|
+
|
|
81
|
+
4. Redistribution. You may reproduce and distribute copies of the Work or
|
|
82
|
+
Derivative Works thereof in any medium, with or without modifications, and in
|
|
83
|
+
Source or Object form, provided that You meet the following conditions:
|
|
84
|
+
|
|
85
|
+
(a) You must give any other recipients of the Work or Derivative Works a copy of
|
|
86
|
+
this License; and
|
|
87
|
+
|
|
88
|
+
(b) You must cause any modified files to carry prominent notices stating that
|
|
89
|
+
You changed the files; and
|
|
90
|
+
|
|
91
|
+
(c) You must retain, in the Source form of any Derivative Works that You
|
|
92
|
+
distribute, all copyright, patent, trademark, and attribution notices from the
|
|
93
|
+
Source form of the Work, excluding those notices that do not pertain to any part
|
|
94
|
+
of the Derivative Works; and
|
|
95
|
+
|
|
96
|
+
(d) If the Work includes a "NOTICE" text file as part of its distribution, then
|
|
97
|
+
any Derivative Works that You distribute must include a readable copy of the
|
|
98
|
+
attribution notices contained within such NOTICE file, excluding those notices
|
|
99
|
+
that do not pertain to any part of the Derivative Works, in at least one of the
|
|
100
|
+
following places: within a NOTICE text file distributed as part of the
|
|
101
|
+
Derivative Works; within the Source form or documentation, if provided along
|
|
102
|
+
with the Derivative Works; or, within a display generated by the Derivative
|
|
103
|
+
Works, if and wherever such third-party notices normally appear. The contents of
|
|
104
|
+
the NOTICE file are for informational purposes only and do not modify the
|
|
105
|
+
License. You may add Your own attribution notices within Derivative Works that
|
|
106
|
+
You distribute, alongside or as an addendum to the NOTICE text from the Work,
|
|
107
|
+
provided that such additional attribution notices cannot be construed as
|
|
108
|
+
modifying the License.
|
|
109
|
+
|
|
110
|
+
You may add Your own copyright statement to Your modifications and may provide
|
|
111
|
+
additional or different license terms and conditions for use, reproduction, or
|
|
112
|
+
distribution of Your modifications, or for any such Derivative Works as a whole,
|
|
113
|
+
provided Your use, reproduction, and distribution of the Work otherwise complies
|
|
114
|
+
with the conditions stated in this License.
|
|
115
|
+
|
|
116
|
+
5. Submission of Contributions. Unless You explicitly state otherwise, any
|
|
117
|
+
Contribution intentionally submitted for inclusion in the Work by You to the
|
|
118
|
+
Licensor shall be under the terms and conditions of this License, without any
|
|
119
|
+
additional terms or conditions. Notwithstanding the above, nothing herein shall
|
|
120
|
+
supersede or modify the terms of any separate license agreement you may have
|
|
121
|
+
executed with Licensor regarding such Contributions.
|
|
122
|
+
|
|
123
|
+
6. Trademarks. This License does not grant permission to use the trade names,
|
|
124
|
+
trademarks, service marks, or product names of the Licensor, except as required
|
|
125
|
+
for reasonable and customary use in describing the origin of the Work and
|
|
126
|
+
reproducing the content of the NOTICE file.
|
|
127
|
+
|
|
128
|
+
7. Disclaimer of Warranty. Unless required by applicable law or agreed to in
|
|
129
|
+
writing, Licensor provides the Work (and each Contributor provides its
|
|
130
|
+
Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
131
|
+
KIND, either express or implied, including, without limitation, any warranties or
|
|
132
|
+
conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
133
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
134
|
+
appropriateness of using or redistributing the Work and assume any risks
|
|
135
|
+
associated with Your exercise of permissions under this License.
|
|
136
|
+
|
|
137
|
+
8. Limitation of Liability. In no event and under no legal theory, whether in
|
|
138
|
+
tort (including negligence), contract, or otherwise, unless required by
|
|
139
|
+
applicable law (such as deliberate and grossly negligent acts) or agreed to in
|
|
140
|
+
writing, shall any Contributor be liable to You for damages, including any
|
|
141
|
+
direct, indirect, special, incidental, or consequential damages of any character
|
|
142
|
+
arising as a result of this License or out of the use or inability to use the
|
|
143
|
+
Work (including but not limited to damages for loss of goodwill, work stoppage,
|
|
144
|
+
computer failure or malfunction, or any and all other commercial damages or
|
|
145
|
+
losses), even if such Contributor has been advised of the possibility of such
|
|
146
|
+
damages.
|
|
147
|
+
|
|
148
|
+
9. Accepting Warranty or Additional Liability. While redistributing the Work or
|
|
149
|
+
Derivative Works thereof, You may choose to offer, and charge a fee for,
|
|
150
|
+
acceptance of support, warranty, indemnity, or other liability obligations
|
|
151
|
+
and/or rights consistent with this License. However, in accepting such
|
|
152
|
+
obligations, You may act only on Your own behalf and on Your sole
|
|
153
|
+
responsibility, not on behalf of any other Contributor, and only if You agree to
|
|
154
|
+
indemnify, defend, and hold each Contributor harmless for any liability incurred
|
|
155
|
+
by, or claims asserted against, such Contributor by reason of your accepting any
|
|
156
|
+
such warranty or additional liability.
|
|
157
|
+
|
|
158
|
+
END OF TERMS AND CONDITIONS
|
raftward-0.1.1/PKG-INFO
ADDED
|
@@ -0,0 +1,282 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: raftward
|
|
3
|
+
Version: 0.1.1
|
|
4
|
+
Summary: Offline, guarded integrity checks for closed SQLite databases and backups
|
|
5
|
+
License-Expression: Apache-2.0
|
|
6
|
+
Project-URL: Homepage, https://github.com/Dragon-Lady/raftward
|
|
7
|
+
Project-URL: Issues, https://github.com/Dragon-Lady/raftward/issues
|
|
8
|
+
Classifier: Programming Language :: Python :: 3
|
|
9
|
+
Classifier: Operating System :: POSIX :: Linux
|
|
10
|
+
Classifier: Topic :: Security
|
|
11
|
+
Requires-Python: >=3.10
|
|
12
|
+
Description-Content-Type: text/markdown
|
|
13
|
+
License-File: LICENSE
|
|
14
|
+
Requires-Dist: tomli>=2; python_version < "3.11"
|
|
15
|
+
Dynamic: license-file
|
|
16
|
+
|
|
17
|
+
# Raft Ward
|
|
18
|
+
|
|
19
|
+
Raft Ward checks the integrity of closed SQLite databases, frozen exports, and
|
|
20
|
+
backup folders. It detects missing files, corruption, suspicious shrinkage,
|
|
21
|
+
permission changes, and patterns consistent with bulk encryption or renaming.
|
|
22
|
+
It does not repair, restore, quarantine, or modify the files it watches.
|
|
23
|
+
|
|
24
|
+
Version 0.1.1 is free software under Apache-2.0, for Linux with Python 3.10
|
|
25
|
+
or newer. Its only runtime dependency is
|
|
26
|
+
`tomli` on Python 3.10.
|
|
27
|
+
|
|
28
|
+
## Posture
|
|
29
|
+
|
|
30
|
+
- Local, read-only target access; no telemetry. No network or child processes by
|
|
31
|
+
default. Configured alert delivery is the only network feature.
|
|
32
|
+
- Every watched target has configured owning applications. A running app or
|
|
33
|
+
background worker skips its own target, with its name and reason in the report.
|
|
34
|
+
Other targets continue. No metadata, hashing, or integrity work starts for a
|
|
35
|
+
target whose owner is already observed running.
|
|
36
|
+
- Unknown process visibility or any configured nonlocal machine also defers the
|
|
37
|
+
entire run. A stale local status file never counts as remote closure.
|
|
38
|
+
- Owner matching is generic and case insensitive across Linux `/proc` process
|
|
39
|
+
names, executable paths, and command lines. Cursor and Codex are defaults, not
|
|
40
|
+
special cases. There is no owning-process allowlist.
|
|
41
|
+
- Targets are opened only with read-only descriptors, no locks. SQLite is never
|
|
42
|
+
connected to an original. Source symlinks, unsupported files, foreign-owned
|
|
43
|
+
paths, a visible same-UID foreign target/sidecar descriptor, transfer locks, and running
|
|
44
|
+
configured transfer programs defer the run.
|
|
45
|
+
- Writes are restricted to private application state, an explicit new report
|
|
46
|
+
file, and disposable private SQLite copies under `$XDG_RUNTIME_DIR/raftward`.
|
|
47
|
+
Report/state/runtime locations cannot overlap configured target trees.
|
|
48
|
+
- Persistent state contains local paths, keyed identifiers, file metadata,
|
|
49
|
+
SHA-256 file digests, entropy measurements, findings, and timestamps. It contains
|
|
50
|
+
no database rows, message text, file excerpts, full process arguments, or
|
|
51
|
+
conversation data. SQLite copies contain source bytes briefly and are deleted
|
|
52
|
+
in cleanup on success, deferral, interruption, or exception. On the next run,
|
|
53
|
+
stale private copies are removed from the runtime directory.
|
|
54
|
+
|
|
55
|
+
Keep all involved applications and workers closed for the full run. A polling
|
|
56
|
+
guard cannot establish an atomic interlock with an unrelated application. Raft
|
|
57
|
+
Ward reaches one checkpoint after each 64 KiB source chunk, throughout
|
|
58
|
+
directory walks, and every 100 SQLite virtual-machine instructions. Repeated
|
|
59
|
+
process enumeration is throttled to a 100 ms interval measured from the end of
|
|
60
|
+
the previous enumeration at these checkpoints.
|
|
61
|
+
Mandatory checks bypass that interval before target metadata/open, initial source
|
|
62
|
+
copying, private-copy creation, SQLite connection/integrity work, and completion.
|
|
63
|
+
A slow process enumeration, bounded retry, or blocked filesystem call can extend
|
|
64
|
+
the wall-clock delay; this is not a real-time deadline. Once a running owner is
|
|
65
|
+
observed, that target's result is discarded while other targets continue; cleanup
|
|
66
|
+
closes descriptors and removes its private copy. An app can start between a check
|
|
67
|
+
and a syscall or entirely between
|
|
68
|
+
checks. No zero-race protection is claimed.
|
|
69
|
+
|
|
70
|
+
## Install and configure
|
|
71
|
+
|
|
72
|
+
From a reviewed checkout:
|
|
73
|
+
|
|
74
|
+
```sh
|
|
75
|
+
python3 -m pip install .
|
|
76
|
+
raftward --help
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
Copy and edit `examples/config.toml` into
|
|
80
|
+
`$XDG_CONFIG_HOME/raftward/config.toml` (default
|
|
81
|
+
`~/.config/raftward/config.toml`). Create that configuration with mode **0600**.
|
|
82
|
+
There are no automatically scanned targets. Every target has a unique simple
|
|
83
|
+
name, `path`, `class`, and nonempty `owners` list. If `owners` is omitted it
|
|
84
|
+
defaults to all configured owners. The default owners are `cursor` and `codex`.
|
|
85
|
+
|
|
86
|
+
```toml
|
|
87
|
+
machines = ["local"]
|
|
88
|
+
alert_channels = ["stdout"]
|
|
89
|
+
|
|
90
|
+
[owners]
|
|
91
|
+
notes = ["notes-app", "notes-worker"]
|
|
92
|
+
|
|
93
|
+
[[targets]]
|
|
94
|
+
name = "notes-export"
|
|
95
|
+
path = "~/backups/notes.sqlite"
|
|
96
|
+
class = "frozen"
|
|
97
|
+
sqlite = true
|
|
98
|
+
owners = ["notes"]
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
`live` tolerates ordinary hash and mtime changes. `frozen` flags changes in hash,
|
|
102
|
+
size, or mtime. `folder` recursively checks mixed files and evaluates bulk changes
|
|
103
|
+
since the last completed run. `sqlite = true` identifies an expected database
|
|
104
|
+
even if its header is already damaged; it defaults true for `live`. Recognizable
|
|
105
|
+
SQLite files found in any class also get integrity checks. Prefer explicit
|
|
106
|
+
`sqlite = true` for frozen database exports.
|
|
107
|
+
|
|
108
|
+
File and directory globs support `*`, `?`, and bracket patterns. Recursive `**`
|
|
109
|
+
globs defer; use a `folder` target for recursive scanning. Symlinks are never
|
|
110
|
+
followed. Defaults are 10,000 files and a 20-file mass-change threshold. A folder
|
|
111
|
+
containing other users' files defers rather than silently skipping them. Broad
|
|
112
|
+
owner substrings may yield conservative false positives.
|
|
113
|
+
|
|
114
|
+
**Multi-machine operation:** list every involved machine in `machines`, including
|
|
115
|
+
`local`. v0.1 cannot prove current remote app state and therefore always defers if
|
|
116
|
+
this list includes another machine. There is no SSH, remote helper, status-file
|
|
117
|
+
override, or network probe. Do not omit an involved machine to get around this
|
|
118
|
+
gate. Coordinated cross-machine inspection remains a review/release gap.
|
|
119
|
+
|
|
120
|
+
## Commands
|
|
121
|
+
|
|
122
|
+
```sh
|
|
123
|
+
raftward guard
|
|
124
|
+
raftward baseline
|
|
125
|
+
raftward check --quick --max-gb 2
|
|
126
|
+
raftward check --target notes-export --format html --output /tmp/raft-report.html
|
|
127
|
+
raftward accept notes-export --reason "verified closed export"
|
|
128
|
+
raftward baseline export --format json
|
|
129
|
+
raftward status
|
|
130
|
+
raftward report --since 7d
|
|
131
|
+
raftward report --since 24h --send
|
|
132
|
+
raftward targets list
|
|
133
|
+
raftward targets add packets ~/backups/packets --class folder --owner notes
|
|
134
|
+
raftward targets remove packets
|
|
135
|
+
raftward print-timer --interval 30m
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
All commands accept `--format text|json|md|html` and `--output NEW_FILE`.
|
|
139
|
+
Global `--config FILE` and `--state DIR` options precede the command. Report
|
|
140
|
+
destinations must already have a parent directory; existing files are never
|
|
141
|
+
overwritten. Text output is a readable metadata record; JSON is structured data.
|
|
142
|
+
Markdown and HTML escape all interpolated values and load no external assets.
|
|
143
|
+
|
|
144
|
+
`guard` inspects process state and configured transfer-lock metadata only; it does
|
|
145
|
+
not stat or open watched targets. `status`, `report`, `targets list`, and `baseline
|
|
146
|
+
export` read stored application metadata only and do not scan sources. A guard
|
|
147
|
+
result is valid at that checkpoint, not a promise about a later check.
|
|
148
|
+
|
|
149
|
+
`baseline` captures all targets or `--target NAME`; replacing an existing baseline
|
|
150
|
+
requires `--force`. `accept TARGET` re-baselines one reviewed change. Neither will
|
|
151
|
+
bless missing targets, a lost expected SQLite header, failed integrity, or future
|
|
152
|
+
mtime. An accept records time, target, and an HMAC fingerprint of the optional
|
|
153
|
+
reason; it intentionally does **not** retain free text, which might contain
|
|
154
|
+
credentials or personal conversation. `targets add/remove` writes a private
|
|
155
|
+
complete target list in state that takes precedence over the TOML target list;
|
|
156
|
+
owner definitions still come from TOML.
|
|
157
|
+
|
|
158
|
+
Checks use `nice(10)` when allowed. `--max-gb` limits source bytes for the entire
|
|
159
|
+
run; exceeding it defers rather than recording a partial success. The runtime
|
|
160
|
+
directory must be available in `XDG_RUNTIME_DIR`. `--quick` requests
|
|
161
|
+
`PRAGMA quick_check`; full `integrity_check` is the default.
|
|
162
|
+
|
|
163
|
+
Exit codes: **0** no findings/success, **1** findings or rejected unsafe baseline,
|
|
164
|
+
**2** usage/runtime/alert-delivery error, **3** deferred or partial check/guard/status. A report
|
|
165
|
+
returns 1 when the requested history contains findings. Timer unit text is printed
|
|
166
|
+
as report data only. Review the `ExecStart` executable path before installing
|
|
167
|
+
units yourself; Raft Ward never installs, enables, or starts timers.
|
|
168
|
+
|
|
169
|
+
## SQLite and transfer boundaries
|
|
170
|
+
|
|
171
|
+
For a closed source without sidecars, Raft Ward copies bytes through bounded
|
|
172
|
+
read-only reads into a unique 0700 directory. The copy is created 0600 before any
|
|
173
|
+
bytes are written. Source device/inode, size, mtime, ctime, and mode are checked
|
|
174
|
+
again. The copy is opened with `mode=ro&immutable=1`, `query_only=ON`,
|
|
175
|
+
`trusted_schema=OFF`, and `temp_store=MEMORY`. Only `ok`/`not ok` and page count
|
|
176
|
+
are retained from SQLite; diagnostic strings may reveal content and are discarded.
|
|
177
|
+
|
|
178
|
+
**Any `-wal`, `-shm`, or `-journal` beside a SQLite target defers the entire run.**
|
|
179
|
+
Raft Ward never assumes immutable mode validates uncheckpointed WAL contents. It
|
|
180
|
+
does not checkpoint or remove sidecars. A closed WAL-mode main database without
|
|
181
|
+
sidecars can be checked as a main-file snapshot. WAL reconstruction and live WAL
|
|
182
|
+
integrity validation are explicitly unsupported.
|
|
183
|
+
|
|
184
|
+
Configured `transfer_commands` default to `rclone` and `rsync`. Any matching
|
|
185
|
+
process stops the entire run even when its arguments do not identify a target.
|
|
186
|
+
This includes permanent `rclone mount` processes and rsync daemons: they can defer
|
|
187
|
+
every run indefinitely. The 24-hour deferral notice names this conservative
|
|
188
|
+
transfer policy. Subcommand/target attribution has not been proven safe and no
|
|
189
|
+
mount or daemon exemption is applied. `transfer_dirs` stops work if a process
|
|
190
|
+
command references a configured directory; `transfer_locks` and singular
|
|
191
|
+
`transfer_lock` are supported. No process is stopped or signaled.
|
|
192
|
+
|
|
193
|
+
Raft Ward requires a full host `/proc` view. A restricted `hidepid` mount defers;
|
|
194
|
+
a PID namespace containing only a subset of the host is not proof that other
|
|
195
|
+
owners are closed. Owner/worker and transfer matching uses `comm` plus `cmdline`
|
|
196
|
+
for every visible process, with `exe` as supplementary identity when readable.
|
|
197
|
+
Only Raft Ward's own PID is excluded; its parent, sibling processes, and workers
|
|
198
|
+
are still checked. Same-UID identity/descriptor permission failures get three
|
|
199
|
+
50 ms rereads. A persistently unavailable `exe` may be omitted when identity
|
|
200
|
+
remains readable. A same-UID process whose `/proc/PID/fd` is kernel-owned, such
|
|
201
|
+
as a non-dumpable user service, participates in name matching while its open-file
|
|
202
|
+
check is reported as `unverifiable`. The same applies when fd entries remain
|
|
203
|
+
listable but their readlinks return EACCES/EPERM after retries and the process's
|
|
204
|
+
CapPrm or CapEff contains capabilities absent from our own. Readable fd links
|
|
205
|
+
still participate in target-handle checks. Other unreadable same-UID identity
|
|
206
|
+
or descriptors still defer.
|
|
207
|
+
`process-descriptor-state-unknown` distinguishes descriptor visibility failure.
|
|
208
|
+
|
|
209
|
+
Other-UID `exe` and descriptor access is normally restricted by Linux. Raft Ward
|
|
210
|
+
matches those processes using readable `comm`/`cmdline`; at least one identity
|
|
211
|
+
field must be readable. It does not inspect other-UID descriptors and cannot prove
|
|
212
|
+
that another user (including root) has no target file open. This is an explicit
|
|
213
|
+
visibility gap, not a closed-state claim. Transient ENOENT/ESRCH means a vanished
|
|
214
|
+
process/descriptor; readable owner names are retained when only `exe` disappears.
|
|
215
|
+
PID reuse/UID changes trigger a reread. No owner allowlist or privilege request is
|
|
216
|
+
used to make an unknown state pass.
|
|
217
|
+
|
|
218
|
+
## Findings
|
|
219
|
+
|
|
220
|
+
| Rule | Condition |
|
|
221
|
+
| --- | --- |
|
|
222
|
+
| `RF-DELETED` | Missing configured target or previously baselined file |
|
|
223
|
+
| `RF-FROZEN-CHANGED` | Frozen file hash, size, or mtime changed |
|
|
224
|
+
| `RF-SQLITE-HEADER` | Expected SQLite magic lost |
|
|
225
|
+
| `RF-INTEGRITY` | SQLite copy check did not return `ok` |
|
|
226
|
+
| `RF-SHRINK` | Live database empty or below 50% of its baseline size |
|
|
227
|
+
| `RF-ENTROPY` | First 4 KiB moved from below 7.0 to above 7.5 bits/byte |
|
|
228
|
+
| `RF-MASS-CHANGE` | Folder changes exceed 20 files or 30%, over 10 new-extension files appear, or a new decrypt/recover/readme-text note appears |
|
|
229
|
+
| `RF-MODE` | Any permission bits loosened relative to baseline |
|
|
230
|
+
| `RF-FUTURE-MTIME` | Mtime ahead of the check clock |
|
|
231
|
+
| `RF-DEFERRED` | More than 24 hours continuously deferred; one informational alert per episode |
|
|
232
|
+
|
|
233
|
+
Renames that retain an inode retain the entropy comparison. A replacement written
|
|
234
|
+
to a new inode/path cannot be reliably associated with the old file; deletion,
|
|
235
|
+
extension, and mass-change findings still apply. These are evidence signals, not
|
|
236
|
+
a malware diagnosis. Entropy is estimated from a sample, not the whole file.
|
|
237
|
+
|
|
238
|
+
## State, privacy, and alerts
|
|
239
|
+
|
|
240
|
+
State is under `$XDG_STATE_HOME/raftward` (default `~/.local/state/raftward`), mode
|
|
241
|
+
0700. Files are created 0600 with `os.open`; no post-write chmod is used. Unsafe
|
|
242
|
+
existing state permissions or symlinked parents are refused, not repaired.
|
|
243
|
+
|
|
244
|
+
- `fp.key`: 32 random bytes used for HMAC-SHA256 identifiers (`fp:` plus 16 hex
|
|
245
|
+
characters). A missing key beside an existing baseline is an error.
|
|
246
|
+
- `baseline.json`, `previous.json`, `last.json`: metadata and findings.
|
|
247
|
+
- `history.jsonl`: at most 30 days and 4 MiB of recent metadata (older rows trimmed).
|
|
248
|
+
- `accepts.jsonl`: review records with reason fingerprints, at most 4 MiB.
|
|
249
|
+
- `targets.json`: optional CLI-managed targets; `deferred.json`: deferral episode;
|
|
250
|
+
`alerts.json`: hashed delivery receipts with a 24-hour dedupe period.
|
|
251
|
+
|
|
252
|
+
Paths appear only locally. Recognized token-shaped substrings in local metadata
|
|
253
|
+
are HMAC-redacted. Because arbitrary filenames and operator-supplied configuration
|
|
254
|
+
are not universally recognizable as secrets, keep credentials out of target
|
|
255
|
+
names and paths. File contents are never rendered or scanned for display.
|
|
256
|
+
|
|
257
|
+
Critical findings alert during `check`. Other findings are available in reports;
|
|
258
|
+
`report --send` explicitly delivers their aggregate summary. `alert_channels`
|
|
259
|
+
accepts `stdout`, `slack`, `ntfy`, or `email`; an empty list means stdout. Network
|
|
260
|
+
delivery is opt-in by configuring a non-stdout channel. Payloads contain rule IDs,
|
|
261
|
+
counts, and severity only, and end with
|
|
262
|
+
"run `raftward report` locally for details". They contain no hostname, paths,
|
|
263
|
+
process arguments, or file content. Delivery is deduped for 24 hours and uses a
|
|
264
|
+
five-second timeout. Redirects are not followed.
|
|
265
|
+
|
|
266
|
+
Use environment-variable **names**, never inline credentials:
|
|
267
|
+
`alert_slack_webhook_env`, `alert_ntfy_token_env`, `alert_smtp_password_env`.
|
|
268
|
+
Other channel keys are `alert_ntfy_topic`, `alert_smtp_host`, `alert_smtp_port`,
|
|
269
|
+
`alert_smtp_security` (`starttls`, `ssl`, or loopback-only `none`),
|
|
270
|
+
`alert_smtp_username`, `alert_smtp_from`, and `alert_email`. HTTPS is required
|
|
271
|
+
except on loopback; SMTP encryption is required off loopback. Errors never echo
|
|
272
|
+
remote credential-bearing URLs.
|
|
273
|
+
|
|
274
|
+
## Development and review
|
|
275
|
+
|
|
276
|
+
```sh
|
|
277
|
+
python3 -m pytest -q
|
|
278
|
+
```
|
|
279
|
+
|
|
280
|
+
Tests use a temporary HOME, fixture databases, and injected process listings.
|
|
281
|
+
They do not inspect real application data. No timer is installed. See
|
|
282
|
+
`REVIEW.md` for the independent acceptance report and remaining limits.
|