pindrift 0.1.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.
- pindrift-0.1.0/.github/actions/pindrift/action.yml +174 -0
- pindrift-0.1.0/.github/workflows/ci.yml +39 -0
- pindrift-0.1.0/.github/workflows/release.yml +43 -0
- pindrift-0.1.0/.gitignore +22 -0
- pindrift-0.1.0/AGENTS.md +158 -0
- pindrift-0.1.0/CLAUDE.md +29 -0
- pindrift-0.1.0/LICENSE +21 -0
- pindrift-0.1.0/PKG-INFO +271 -0
- pindrift-0.1.0/README.md +244 -0
- pindrift-0.1.0/docs/DESIGN.md +206 -0
- pindrift-0.1.0/docs/TASKS.md +184 -0
- pindrift-0.1.0/docs/THREAT-MODEL.md +174 -0
- pindrift-0.1.0/examples/demo.py +137 -0
- pindrift-0.1.0/pyproject.toml +49 -0
- pindrift-0.1.0/src/pindrift/__init__.py +6 -0
- pindrift-0.1.0/src/pindrift/__main__.py +6 -0
- pindrift-0.1.0/src/pindrift/capability.py +337 -0
- pindrift-0.1.0/src/pindrift/cli.py +591 -0
- pindrift-0.1.0/src/pindrift/detect.py +228 -0
- pindrift-0.1.0/src/pindrift/differ.py +394 -0
- pindrift-0.1.0/src/pindrift/discover.py +544 -0
- pindrift-0.1.0/src/pindrift/fingerprint.py +204 -0
- pindrift-0.1.0/src/pindrift/hook.py +284 -0
- pindrift-0.1.0/src/pindrift/models.py +291 -0
- pindrift-0.1.0/src/pindrift/probe.py +231 -0
- pindrift-0.1.0/src/pindrift/report.py +539 -0
- pindrift-0.1.0/src/pindrift/store.py +209 -0
- pindrift-0.1.0/src/pindrift/trust.py +191 -0
- pindrift-0.1.0/tests/conftest.py +26 -0
- pindrift-0.1.0/tests/fixtures/facet_corpus.jsonl +149 -0
- pindrift-0.1.0/tests/fixtures/fake_mcp_server.py +151 -0
- pindrift-0.1.0/tests/test_capability.py +200 -0
- pindrift-0.1.0/tests/test_detect.py +92 -0
- pindrift-0.1.0/tests/test_differ.py +149 -0
- pindrift-0.1.0/tests/test_differ_visible.py +27 -0
- pindrift-0.1.0/tests/test_discover.py +255 -0
- pindrift-0.1.0/tests/test_fingerprint.py +84 -0
- pindrift-0.1.0/tests/test_hook.py +215 -0
- pindrift-0.1.0/tests/test_pin_identity.py +227 -0
- pindrift-0.1.0/tests/test_probe.py +64 -0
- pindrift-0.1.0/tests/test_report.py +337 -0
- pindrift-0.1.0/tests/test_store.py +61 -0
- pindrift-0.1.0/tests/test_trust.py +219 -0
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
name: pindrift check
|
|
2
|
+
description: >-
|
|
3
|
+
Detect drift in configured MCP servers, upload the SARIF report, and fail the job
|
|
4
|
+
when a finding is at or above the threshold.
|
|
5
|
+
author: pindrift
|
|
6
|
+
|
|
7
|
+
# The caller's job needs `permissions: security-events: write` for the upload step.
|
|
8
|
+
# Set `upload: "false"` to use the report without GitHub code scanning.
|
|
9
|
+
|
|
10
|
+
inputs:
|
|
11
|
+
fail-on:
|
|
12
|
+
description: Minimum severity that fails the job (info, low, medium, high, critical).
|
|
13
|
+
required: false
|
|
14
|
+
default: high
|
|
15
|
+
version:
|
|
16
|
+
description: >-
|
|
17
|
+
pindrift version to install, without a leading "v" (for example 0.1.0). Leave
|
|
18
|
+
empty for the latest release; pin it when reproducibility matters.
|
|
19
|
+
required: false
|
|
20
|
+
default: ""
|
|
21
|
+
python-version:
|
|
22
|
+
description: Python used to run pindrift. Requires 3.10 or newer.
|
|
23
|
+
required: false
|
|
24
|
+
default: "3.12"
|
|
25
|
+
sarif-file:
|
|
26
|
+
description: Path for the SARIF report, relative to the workspace unless absolute.
|
|
27
|
+
required: false
|
|
28
|
+
default: pindrift.sarif
|
|
29
|
+
upload:
|
|
30
|
+
description: Upload the report with github/codeql-action/upload-sarif.
|
|
31
|
+
required: false
|
|
32
|
+
default: "true"
|
|
33
|
+
pins-file:
|
|
34
|
+
description: >-
|
|
35
|
+
Path to a pins.json baseline to check against, for example one committed to the
|
|
36
|
+
repository. Empty uses the runner's existing store at $PINDRIFT_HOME.
|
|
37
|
+
required: false
|
|
38
|
+
default: ""
|
|
39
|
+
root:
|
|
40
|
+
description: Project root for project-scoped configs. Empty uses the workspace.
|
|
41
|
+
required: false
|
|
42
|
+
default: ""
|
|
43
|
+
dedupe:
|
|
44
|
+
description: >-
|
|
45
|
+
Collapse one server configured identically by several clients into one result.
|
|
46
|
+
Must match how the baseline was pinned: the merged id is the first client
|
|
47
|
+
alphabetically.
|
|
48
|
+
required: false
|
|
49
|
+
default: "false"
|
|
50
|
+
no-project:
|
|
51
|
+
description: Ignore project-scoped configs and read only user-level ones.
|
|
52
|
+
required: false
|
|
53
|
+
default: "false"
|
|
54
|
+
timeout:
|
|
55
|
+
description: Per-server probe timeout in seconds.
|
|
56
|
+
required: false
|
|
57
|
+
default: "20"
|
|
58
|
+
|
|
59
|
+
outputs:
|
|
60
|
+
exit-code:
|
|
61
|
+
description: pindrift exit code (0 clean, 2 findings at or above the threshold).
|
|
62
|
+
value: ${{ steps.check.outputs.exit-code }}
|
|
63
|
+
sarif-file:
|
|
64
|
+
description: Path of the generated SARIF report.
|
|
65
|
+
value: ${{ inputs.sarif-file }}
|
|
66
|
+
|
|
67
|
+
runs:
|
|
68
|
+
using: composite
|
|
69
|
+
steps:
|
|
70
|
+
- name: Set up Python
|
|
71
|
+
uses: actions/setup-python@v5
|
|
72
|
+
with:
|
|
73
|
+
python-version: ${{ inputs.python-version }}
|
|
74
|
+
|
|
75
|
+
- name: Install pindrift
|
|
76
|
+
shell: bash
|
|
77
|
+
env:
|
|
78
|
+
PINDRIFT_VERSION: ${{ inputs.version }}
|
|
79
|
+
run: |
|
|
80
|
+
if [ -n "$PINDRIFT_VERSION" ]; then
|
|
81
|
+
python -m pip install --disable-pip-version-check "pindrift==${PINDRIFT_VERSION#v}"
|
|
82
|
+
else
|
|
83
|
+
python -m pip install --disable-pip-version-check pindrift
|
|
84
|
+
fi
|
|
85
|
+
|
|
86
|
+
- name: Require a baseline
|
|
87
|
+
shell: bash
|
|
88
|
+
env:
|
|
89
|
+
PINS_FILE: ${{ inputs.pins-file }}
|
|
90
|
+
run: |
|
|
91
|
+
if [ -n "$PINS_FILE" ]; then
|
|
92
|
+
if [ ! -f "$PINS_FILE" ]; then
|
|
93
|
+
echo "::error title=pindrift::Baseline '$PINS_FILE' does not exist."
|
|
94
|
+
exit 1
|
|
95
|
+
fi
|
|
96
|
+
# Copy instead of using the file in place so the run never mutates the
|
|
97
|
+
# baseline committed to the repository, and never touches a runner's
|
|
98
|
+
# real store.
|
|
99
|
+
home="${RUNNER_TEMP:-${TMPDIR:-/tmp}}/pindrift-home"
|
|
100
|
+
mkdir -p "$home"
|
|
101
|
+
cp "$PINS_FILE" "$home/pins.json"
|
|
102
|
+
echo "PINDRIFT_HOME=$home" >> "$GITHUB_ENV"
|
|
103
|
+
else
|
|
104
|
+
home="${PINDRIFT_HOME:-$HOME/.pindrift}"
|
|
105
|
+
fi
|
|
106
|
+
if [ ! -f "$home/pins.json" ]; then
|
|
107
|
+
echo "::error title=pindrift::No baseline found. Pass a committed pins.json as 'pins-file', or pin on this runner first."
|
|
108
|
+
exit 1
|
|
109
|
+
fi
|
|
110
|
+
echo "checking against $home/pins.json"
|
|
111
|
+
|
|
112
|
+
- name: Check for drift
|
|
113
|
+
id: check
|
|
114
|
+
shell: bash
|
|
115
|
+
env:
|
|
116
|
+
FAIL_ON: ${{ inputs.fail-on }}
|
|
117
|
+
SARIF_FILE: ${{ inputs.sarif-file }}
|
|
118
|
+
ROOT: ${{ inputs.root }}
|
|
119
|
+
NO_PROJECT: ${{ inputs.no-project }}
|
|
120
|
+
DEDUPE: ${{ inputs.dedupe }}
|
|
121
|
+
TIMEOUT: ${{ inputs.timeout }}
|
|
122
|
+
run: |
|
|
123
|
+
set +e
|
|
124
|
+
args=(check --format sarif --fail-on "$FAIL_ON" --timeout "$TIMEOUT")
|
|
125
|
+
if [ -n "$ROOT" ]; then
|
|
126
|
+
args+=(--root "$ROOT")
|
|
127
|
+
fi
|
|
128
|
+
if [ "$NO_PROJECT" = "true" ]; then
|
|
129
|
+
args+=(--no-project)
|
|
130
|
+
fi
|
|
131
|
+
if [ "$DEDUPE" = "true" ]; then
|
|
132
|
+
args+=(--dedupe)
|
|
133
|
+
fi
|
|
134
|
+
python -m pindrift "${args[@]}" > "$SARIF_FILE"
|
|
135
|
+
code=$?
|
|
136
|
+
set -e
|
|
137
|
+
|
|
138
|
+
echo "exit-code=$code" >> "$GITHUB_OUTPUT"
|
|
139
|
+
if [ -s "$SARIF_FILE" ]; then
|
|
140
|
+
echo "has-sarif=true" >> "$GITHUB_OUTPUT"
|
|
141
|
+
else
|
|
142
|
+
echo "has-sarif=false" >> "$GITHUB_OUTPUT"
|
|
143
|
+
fi
|
|
144
|
+
|
|
145
|
+
# Never fail here: an unreadable report is still worth uploading when one
|
|
146
|
+
# exists, and the final step is the single place that decides the job result.
|
|
147
|
+
exit 0
|
|
148
|
+
|
|
149
|
+
- name: Upload SARIF
|
|
150
|
+
if: ${{ inputs.upload == 'true' && steps.check.outputs.has-sarif == 'true' }}
|
|
151
|
+
uses: github/codeql-action/upload-sarif@v3
|
|
152
|
+
with:
|
|
153
|
+
sarif_file: ${{ inputs.sarif-file }}
|
|
154
|
+
category: pindrift
|
|
155
|
+
|
|
156
|
+
- name: Fail on findings
|
|
157
|
+
if: ${{ steps.check.outcome == 'success' && steps.check.outputs.exit-code != '0' }}
|
|
158
|
+
shell: bash
|
|
159
|
+
env:
|
|
160
|
+
EXIT_CODE: ${{ steps.check.outputs.exit-code }}
|
|
161
|
+
FAIL_ON: ${{ inputs.fail-on }}
|
|
162
|
+
run: |
|
|
163
|
+
case "$EXIT_CODE" in
|
|
164
|
+
2)
|
|
165
|
+
echo "::error title=pindrift::Drift at or above '$FAIL_ON'. Review the SARIF report or run 'pindrift check' locally, then re-pin with 'pindrift approve <server>' if the change is intended."
|
|
166
|
+
;;
|
|
167
|
+
64)
|
|
168
|
+
echo "::error title=pindrift::pindrift rejected the command line; check the action inputs."
|
|
169
|
+
;;
|
|
170
|
+
*)
|
|
171
|
+
echo "::error title=pindrift::pindrift failed with exit code $EXIT_CODE."
|
|
172
|
+
;;
|
|
173
|
+
esac
|
|
174
|
+
exit "$EXIT_CODE"
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
name: ci
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: [main]
|
|
6
|
+
pull_request:
|
|
7
|
+
workflow_dispatch:
|
|
8
|
+
|
|
9
|
+
jobs:
|
|
10
|
+
test:
|
|
11
|
+
strategy:
|
|
12
|
+
fail-fast: false
|
|
13
|
+
matrix:
|
|
14
|
+
os: [ubuntu-latest, windows-latest, macos-latest]
|
|
15
|
+
python: ["3.10", "3.11", "3.12", "3.13"]
|
|
16
|
+
runs-on: ${{ matrix.os }}
|
|
17
|
+
steps:
|
|
18
|
+
- uses: actions/checkout@v4
|
|
19
|
+
- uses: actions/setup-python@v5
|
|
20
|
+
with:
|
|
21
|
+
python-version: ${{ matrix.python }}
|
|
22
|
+
- name: Install
|
|
23
|
+
run: |
|
|
24
|
+
python -m pip install --upgrade pip
|
|
25
|
+
python -m pip install -e ".[dev]"
|
|
26
|
+
- name: Test
|
|
27
|
+
run: python -m pytest -q
|
|
28
|
+
|
|
29
|
+
demo:
|
|
30
|
+
runs-on: ubuntu-latest
|
|
31
|
+
steps:
|
|
32
|
+
- uses: actions/checkout@v4
|
|
33
|
+
- uses: actions/setup-python@v5
|
|
34
|
+
with:
|
|
35
|
+
python-version: "3.12"
|
|
36
|
+
- name: Install
|
|
37
|
+
run: python -m pip install -e .
|
|
38
|
+
- name: Reproduce the rug-pull demo
|
|
39
|
+
run: python examples/demo.py
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
name: release
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
release:
|
|
5
|
+
types: [published]
|
|
6
|
+
workflow_dispatch:
|
|
7
|
+
|
|
8
|
+
permissions:
|
|
9
|
+
contents: read
|
|
10
|
+
|
|
11
|
+
jobs:
|
|
12
|
+
build:
|
|
13
|
+
runs-on: ubuntu-latest
|
|
14
|
+
steps:
|
|
15
|
+
- uses: actions/checkout@v4
|
|
16
|
+
- uses: actions/setup-python@v5
|
|
17
|
+
with:
|
|
18
|
+
python-version: "3.12"
|
|
19
|
+
- name: Build sdist and wheel
|
|
20
|
+
run: |
|
|
21
|
+
python -m pip install --upgrade pip build
|
|
22
|
+
python -m build
|
|
23
|
+
- uses: actions/upload-artifact@v4
|
|
24
|
+
with:
|
|
25
|
+
name: dist
|
|
26
|
+
path: dist/
|
|
27
|
+
|
|
28
|
+
publish:
|
|
29
|
+
needs: build
|
|
30
|
+
runs-on: ubuntu-latest
|
|
31
|
+
environment:
|
|
32
|
+
name: pypi
|
|
33
|
+
url: https://pypi.org/project/pindrift/
|
|
34
|
+
permissions:
|
|
35
|
+
id-token: write
|
|
36
|
+
steps:
|
|
37
|
+
- uses: actions/download-artifact@v4
|
|
38
|
+
with:
|
|
39
|
+
name: dist
|
|
40
|
+
path: dist/
|
|
41
|
+
- uses: pypa/gh-action-pypi-publish@release/v1
|
|
42
|
+
with:
|
|
43
|
+
attestations: true
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
__pycache__/
|
|
2
|
+
*.py[cod]
|
|
3
|
+
*.egg-info/
|
|
4
|
+
.eggs/
|
|
5
|
+
dist/
|
|
6
|
+
build/
|
|
7
|
+
.venv/
|
|
8
|
+
venv/
|
|
9
|
+
env/
|
|
10
|
+
.pytest_cache/
|
|
11
|
+
.ruff_cache/
|
|
12
|
+
.coverage
|
|
13
|
+
htmlcov/
|
|
14
|
+
.coverage.*
|
|
15
|
+
*.sarif
|
|
16
|
+
.pindrift/
|
|
17
|
+
.idea/
|
|
18
|
+
.vscode/
|
|
19
|
+
.DS_Store
|
|
20
|
+
Thumbs.db
|
|
21
|
+
.orca/
|
|
22
|
+
worktrees/
|
pindrift-0.1.0/AGENTS.md
ADDED
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
# AGENTS.md
|
|
2
|
+
|
|
3
|
+
Context for any coding agent working in this repository. Read this before the first
|
|
4
|
+
edit. It is written to be sufficient on its own: you should not need to ask a human
|
|
5
|
+
what the constraints are.
|
|
6
|
+
|
|
7
|
+
## What this project is
|
|
8
|
+
|
|
9
|
+
`pindrift` is a CLI that monitors **drift** in MCP servers and agent skills. Scanners
|
|
10
|
+
check a server once before install; `pindrift` pins the state a human approved and
|
|
11
|
+
compares against that pin on every run.
|
|
12
|
+
|
|
13
|
+
The single case that justifies the whole project: a server whose config file and code
|
|
14
|
+
are byte-identical but whose runtime tool manifest has changed. Everything is built
|
|
15
|
+
around being able to see that.
|
|
16
|
+
|
|
17
|
+
## Hard constraints
|
|
18
|
+
|
|
19
|
+
These are not preferences. Breaking one is a bug, not a style choice.
|
|
20
|
+
|
|
21
|
+
1. **Python 3.10 minimum.** `requires-python = ">=3.10"`. No `tomllib` unguarded (it is
|
|
22
|
+
3.11+; `discover.py` already guards it). No `typing.Self`, no `except*`, no 3.12+
|
|
23
|
+
syntax. `X | Y` annotations are fine because every module starts with
|
|
24
|
+
`from __future__ import annotations`.
|
|
25
|
+
2. **Zero runtime dependencies.** `dependencies = []` in `pyproject.toml` stays empty.
|
|
26
|
+
The tool is installed with `pipx` by people auditing it; every dependency is a
|
|
27
|
+
reason not to trust it.
|
|
28
|
+
3. **No network access at runtime.** Ever. Not for version resolution, not for
|
|
29
|
+
telemetry, not for update checks. This is why npm/PyPI targets are fingerprinted
|
|
30
|
+
without resolving their versions, and why that weakness is documented instead of
|
|
31
|
+
fixed.
|
|
32
|
+
4. **Secrets never reach disk.** Environment *values* are excluded from fingerprints;
|
|
33
|
+
only key names are stored. Command-line arguments pass through
|
|
34
|
+
`detect.redact_arg()` before persistence. If you add a code path that writes config
|
|
35
|
+
data, it must go through redaction.
|
|
36
|
+
5. **`unknown` is never folded into `ok`.** If the tool could not verify something, the
|
|
37
|
+
state is `State.UNKNOWN`. Collapsing it into success is the one failure mode that
|
|
38
|
+
makes a security monitor actively harmful.
|
|
39
|
+
6. **No `shell=True`.** Subprocess calls resolve the executable and build an argv list.
|
|
40
|
+
On Windows, `.cmd`/`.bat` are routed through `cmd.exe /c` explicitly (see
|
|
41
|
+
`probe._wrap_for_windows`).
|
|
42
|
+
|
|
43
|
+
## Layout
|
|
44
|
+
|
|
45
|
+
```
|
|
46
|
+
src/pindrift/
|
|
47
|
+
models.py dataclasses: ToolManifest, Artifact, ServerFingerprint, Finding,
|
|
48
|
+
ServerResult, State, Severity. Serialisation is explicit, not asdict().
|
|
49
|
+
discover.py find + parse client configs into ServerSpec. Tolerant: an unreadable
|
|
50
|
+
file is reported, never fatal. Reads with utf-8-sig (BOM tolerance).
|
|
51
|
+
fingerprint.py three hashes: hash_config, artifact sha256, hash_tools.
|
|
52
|
+
probe.py stdio JSON-RPC handshake, paged tools/list, bounded by timeout.
|
|
53
|
+
capability.py Facet table + weighted phrase scoring -> capability facets.
|
|
54
|
+
detect.py content heuristics (hidden chars, injection phrasing, credential
|
|
55
|
+
paths, URLs, encoded blobs), diff_lines(), redact_arg().
|
|
56
|
+
differ.py compare(pin, current) -> ServerResult with graded Findings.
|
|
57
|
+
store.py ~/.pindrift/pins.json, atomic write via os.replace.
|
|
58
|
+
trust.py HMAC-SHA256 signing for shared baselines; key from env or trust.key.
|
|
59
|
+
report.py text / JSON / SARIF renderers.
|
|
60
|
+
cli.py argparse subcommands, exit codes.
|
|
61
|
+
tests/ full suite; fixtures/fake_mcp_server.py is a stdio MCP server.
|
|
62
|
+
docs/ DESIGN.md (internals), THREAT-MODEL.md (coverage and gaps).
|
|
63
|
+
examples/ demo.py reproduces the rug-pull narrative end to end.
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
## Data flow
|
|
67
|
+
|
|
68
|
+
```
|
|
69
|
+
config files -> ServerSpec -> ServerFingerprint -> compare() -> Findings -> report
|
|
70
|
+
^ ^
|
|
71
|
+
probe.py store.py (pin)
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
`discover` produces specs. `fingerprint.build()` turns a spec into a fingerprint,
|
|
75
|
+
optionally with a manifest from `probe`. `differ.compare()` takes the pin and the
|
|
76
|
+
current fingerprint and returns a `ServerResult`. `report` renders it.
|
|
77
|
+
|
|
78
|
+
## Design rules worth preserving
|
|
79
|
+
|
|
80
|
+
- **Capability delta over text diff.** Diff size is a bad proxy for risk. Use
|
|
81
|
+
`capability.infer_capabilities()` on both sides and compare sets.
|
|
82
|
+
- **Specificity weighting.** In `capability.py`, a phrase containing a space,
|
|
83
|
+
underscore, or three or more CJK characters is *specific* and scores 2 in a
|
|
84
|
+
description; a generic single word scores 1. Name matches score 3. Threshold is 2.
|
|
85
|
+
Do not flatten this — it is what keeps `overwrite` from firing on unrelated tools.
|
|
86
|
+
- **Evidence on every finding.** Any new heuristic must record *what fired* so a human
|
|
87
|
+
can overrule it. Findings without evidence are not acceptable.
|
|
88
|
+
- **Escape before display.** `differ.visible()` renders control and invisible
|
|
89
|
+
characters as `\x1b`, `\u200b` etc. Evidence passes through it. Raw ESC sequences in
|
|
90
|
+
terminal output or an issue comment defeat the purpose of reporting them.
|
|
91
|
+
- **Probe only what is already trusted.** `check` probes servers that have a pin;
|
|
92
|
+
untrusted servers are never executed just because a check ran. Preserve this.
|
|
93
|
+
- **No database.** The pin file is a trust anchor and must stay small enough for a
|
|
94
|
+
human to read during an incident.
|
|
95
|
+
|
|
96
|
+
## Working standards
|
|
97
|
+
|
|
98
|
+
- Every new detection heuristic needs a test with a **real** sample of the pattern it
|
|
99
|
+
targets, plus a negative test proving it does not fire on benign input.
|
|
100
|
+
- Every new capability facet needs a positive test and access to the risk grading.
|
|
101
|
+
- Run the full suite before claiming a change works:
|
|
102
|
+
|
|
103
|
+
```bash
|
|
104
|
+
python -m venv .venv
|
|
105
|
+
.venv/Scripts/python -m pip install -e ".[dev]" # .venv/bin/python on POSIX
|
|
106
|
+
python -m pytest -q
|
|
107
|
+
python examples/demo.py # must still reproduce the narrative
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
- Line length 100 (`[tool.ruff]`). Stdlib only. Prefer explicit over clever.
|
|
111
|
+
- Commit messages: imperative subject, body explains *why*. No `--no-verify`.
|
|
112
|
+
- If you change user-visible behaviour, update `README.md`; if you change internals or
|
|
113
|
+
limits, update `docs/DESIGN.md`; if you change what is or is not detected, update
|
|
114
|
+
`docs/THREAT-MODEL.md`. The threat model is a promise — keep it accurate.
|
|
115
|
+
|
|
116
|
+
## Reporting language
|
|
117
|
+
|
|
118
|
+
Report to the human in **Simplified Chinese**: status updates, explanations, questions,
|
|
119
|
+
summaries, and anything you say back in a chat. Say it directly rather than translating
|
|
120
|
+
English phrasing word for word.
|
|
121
|
+
|
|
122
|
+
Everything that lives in the repository stays in **English**: code, comments,
|
|
123
|
+
docstrings, commit messages, and every file under `docs/`, plus `README.md` and this
|
|
124
|
+
file.
|
|
125
|
+
|
|
126
|
+
Do not translate quoted material. File paths, command output and error messages keep
|
|
127
|
+
their original form — a translated error message is a useless error message.
|
|
128
|
+
|
|
129
|
+
## Extension recipes
|
|
130
|
+
|
|
131
|
+
**Add a capability facet** — append a `Facet` to `capability.FACETS` with `name`,
|
|
132
|
+
`risk`, `label`, `phrases`, optional `schema_keys`. Scoring, aggregation and severity
|
|
133
|
+
mapping are generic. Add a positive and a negative test in `tests/test_capability.py`.
|
|
134
|
+
|
|
135
|
+
**Add a client config location** — add a `ConfigSource` in
|
|
136
|
+
`discover.user_config_sources()` for the platform, or in `project_config_sources()`
|
|
137
|
+
for project scope. Nothing else changes. Add a parse test in `tests/test_discover.py`.
|
|
138
|
+
|
|
139
|
+
**Add a content heuristic** — extend `HIDDEN_PATTERNS`, `INSTRUCTION_PHRASES` or
|
|
140
|
+
`SENSITIVE_PATH_PATTERNS` in `detect.py`, then map it to a severity inside
|
|
141
|
+
`ContentRisk.severity()`. Test with a real sample in `tests/test_detect.py`.
|
|
142
|
+
|
|
143
|
+
**Add an output format** — write a renderer in `report.py`, add a `choices` entry in
|
|
144
|
+
the corresponding `cli.py` subparser. Keep the JSON shape stable; SARIF must stay
|
|
145
|
+
schema-valid (2.1.0).
|
|
146
|
+
|
|
147
|
+
## Non-goals
|
|
148
|
+
|
|
149
|
+
Do not implement these without an explicit new decision, because each one was
|
|
150
|
+
considered and deferred for a recorded reason:
|
|
151
|
+
|
|
152
|
+
- sandboxing or intercepting MCP traffic (that is a different product)
|
|
153
|
+
- runtime output-poisoning detection (happens after the last observation)
|
|
154
|
+
- installing, updating, or launching servers on the user's behalf
|
|
155
|
+
- any hosted service, account, or telemetry
|
|
156
|
+
- resolving package versions over the network
|
|
157
|
+
|
|
158
|
+
See `docs/THREAT-MODEL.md` for why each is out of scope.
|
pindrift-0.1.0/CLAUDE.md
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
# CLAUDE.md
|
|
2
|
+
|
|
3
|
+
@AGENTS.md
|
|
4
|
+
|
|
5
|
+
The import above is the source of truth for architecture, constraints and standards.
|
|
6
|
+
Only Claude-specific working notes belong here.
|
|
7
|
+
|
|
8
|
+
## Verify before claiming done
|
|
9
|
+
|
|
10
|
+
```bash
|
|
11
|
+
python -m pytest -q # full suite, all must pass
|
|
12
|
+
python examples/demo.py # must still print critical drift in step 4
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## Things that have already caused bugs here
|
|
16
|
+
|
|
17
|
+
- A `json.loads` on a UTF-8 BOM crashed config parsing. Read files with
|
|
18
|
+
`encoding="utf-8-sig"`. Windows editors and PowerShell write BOMs.
|
|
19
|
+
- Capability scoring was too loose: a single description match scored 1 against a
|
|
20
|
+
threshold of 2, so "description now mentions writing a file" was missed. The
|
|
21
|
+
specificity weighting exists because of this. Do not simplify it away.
|
|
22
|
+
- Evidence printed raw ANSI escapes into the terminal. Use `differ.visible()`.
|
|
23
|
+
- `pyproject.toml` references `README.md`; deleting or renaming it breaks the build.
|
|
24
|
+
|
|
25
|
+
## Tone for this codebase
|
|
26
|
+
|
|
27
|
+
Comments explain *why*, especially where a heuristic is a guess. Do not write comments
|
|
28
|
+
that restate the code. Where the tool has a real limitation, state it in
|
|
29
|
+
`docs/THREAT-MODEL.md` rather than hiding it in a code comment.
|
pindrift-0.1.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 SHer
|
|
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.
|