pipewatch-cli 0.4.0__tar.gz → 0.5.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.
- {pipewatch_cli-0.4.0 → pipewatch_cli-0.5.0}/LICENSE +3 -0
- pipewatch_cli-0.5.0/PKG-INFO +300 -0
- pipewatch_cli-0.5.0/README.md +289 -0
- {pipewatch_cli-0.4.0 → pipewatch_cli-0.5.0}/pipewatch.py +102 -14
- pipewatch_cli-0.5.0/pipewatch_cli.egg-info/PKG-INFO +300 -0
- {pipewatch_cli-0.4.0 → pipewatch_cli-0.5.0}/pyproject.toml +1 -1
- pipewatch_cli-0.4.0/PKG-INFO +0 -228
- pipewatch_cli-0.4.0/README.md +0 -217
- pipewatch_cli-0.4.0/pipewatch_cli.egg-info/PKG-INFO +0 -228
- {pipewatch_cli-0.4.0 → pipewatch_cli-0.5.0}/pipewatch_cli.egg-info/SOURCES.txt +0 -0
- {pipewatch_cli-0.4.0 → pipewatch_cli-0.5.0}/pipewatch_cli.egg-info/dependency_links.txt +0 -0
- {pipewatch_cli-0.4.0 → pipewatch_cli-0.5.0}/pipewatch_cli.egg-info/entry_points.txt +0 -0
- {pipewatch_cli-0.4.0 → pipewatch_cli-0.5.0}/pipewatch_cli.egg-info/requires.txt +0 -0
- {pipewatch_cli-0.4.0 → pipewatch_cli-0.5.0}/pipewatch_cli.egg-info/top_level.txt +0 -0
- {pipewatch_cli-0.4.0 → pipewatch_cli-0.5.0}/setup.cfg +0 -0
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
|
|
2
|
+
|
|
2
3
|
pipewatch-cli is licensed under the Creative Commons Attribution 4.0
|
|
3
4
|
International License. To view a copy of this license, see below or
|
|
4
5
|
visit https://creativecommons.org/licenses/by/4.0/
|
|
@@ -400,3 +401,5 @@ the avoidance of doubt, this paragraph does not form part of the
|
|
|
400
401
|
public licenses.
|
|
401
402
|
|
|
402
403
|
Creative Commons may be contacted at creativecommons.org.
|
|
404
|
+
|
|
405
|
+
Copyright (c) 2026 David Obi
|
|
@@ -0,0 +1,300 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: pipewatch-cli
|
|
3
|
+
Version: 0.5.0
|
|
4
|
+
Summary: Integrity monitoring and static analysis for CI/CD pipelines
|
|
5
|
+
License-Expression: CC-BY-4.0
|
|
6
|
+
Requires-Python: >=3.12
|
|
7
|
+
Description-Content-Type: text/markdown
|
|
8
|
+
License-File: LICENSE
|
|
9
|
+
Requires-Dist: pyyaml>=6.0
|
|
10
|
+
Dynamic: license-file
|
|
11
|
+
|
|
12
|
+
# pipewatch
|
|
13
|
+
|
|
14
|
+
**Integrity monitoring and static analysis for software supply chains.**
|
|
15
|
+
|
|
16
|
+
CI/CD pipelines are high-value targets: they run with elevated permissions, pull from external registries, and execute arbitrary code on every commit. A single injected step, mutable action pin, or misconfigured trigger is enough to exfiltrate secrets, backdoor build artifacts, or pivot into production infrastructure -- and the attack surface is almost always left unmonitored.
|
|
17
|
+
|
|
18
|
+
`pipewatch` audits GitHub Actions workflows, GitLab CI, and Jenkinsfiles for exactly these risks. It combines commit-anchored baseline diffing, per-step SHA-256 fingerprinting, static misconfiguration analysis, and runner environment tracking into a single CLI tool. All commands exit non-zero on findings and emit structured JSON -- suitable as a pipeline gate, a pre-merge check, or a periodic audit job.
|
|
19
|
+
|
|
20
|
+
---
|
|
21
|
+
|
|
22
|
+
## What It Detects
|
|
23
|
+
|
|
24
|
+
| Check | What it catches |
|
|
25
|
+
|---|---|
|
|
26
|
+
| **Baseline diff** | Pipeline files modified, added, or deleted since a known-good commit |
|
|
27
|
+
| **Step fingerprinting** | Individual steps injected, removed, or silently modified between commits |
|
|
28
|
+
| **pull_request_target misuse** | Workflows that check out and execute PR head code with base-branch write permissions -- the pattern behind numerous CI poisoning attacks |
|
|
29
|
+
| **Script injection** | run: blocks and env: blocks that route user-controlled context values into shell commands -- both direct interpolation and the indirect env: VAR -> $VAR pattern are detected |
|
|
30
|
+
| **Permission misconfiguration** | Missing permissions: blocks, write-all scopes, secrets: inherit |
|
|
31
|
+
| **Mutable action pins** | uses: references not locked to a full commit SHA -- tags like v3 can be silently overwritten by a supply-chain attacker |
|
|
32
|
+
| **Invalid pinned SHAs** | Pinned SHAs that do not exist in the upstream action repo (typos, deleted commits, fork SHAs) |
|
|
33
|
+
| **Unsafe workflow_run chains** | Write-permissioned workflows triggered indirectly by external pull requests or issues, creating a privilege escalation path |
|
|
34
|
+
| **Self-hosted runners** | Non-ephemeral runners that persist state between runs and are not managed by GitHub |
|
|
35
|
+
| **Runner environment drift** | Env var and tool version changes between CI runs that could indicate a compromised or modified runner |
|
|
36
|
+
|
|
37
|
+
Findings are severity-ranked (CRITICAL -> HIGH -> MEDIUM -> LOW -> INFO) and always include a location, description, and evidence field.
|
|
38
|
+
|
|
39
|
+
---
|
|
40
|
+
|
|
41
|
+
## Installation
|
|
42
|
+
|
|
43
|
+
Requires Python 3.12+. `pyyaml` is the only external dependency.
|
|
44
|
+
|
|
45
|
+
**Via pip (recommended):**
|
|
46
|
+
|
|
47
|
+
```
|
|
48
|
+
pip install pipewatch-cli
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
**Directly from GitHub (no clone required):**
|
|
52
|
+
|
|
53
|
+
```
|
|
54
|
+
pip install git+https://github.com/TheVoidThatConsumes/pipewatch.git
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
**Copy into your project** -- download `pipewatch.py` and drop it anywhere in the repo you want to monitor. Install `pyyaml` manually:
|
|
58
|
+
|
|
59
|
+
```
|
|
60
|
+
pip install pyyaml
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
Then run it as `py pipewatch.py <command>` instead of `pipewatch <command>`.
|
|
64
|
+
|
|
65
|
+
---
|
|
66
|
+
|
|
67
|
+
## Quick Start
|
|
68
|
+
|
|
69
|
+
```
|
|
70
|
+
# Record the current HEAD as known-good
|
|
71
|
+
pipewatch baseline
|
|
72
|
+
|
|
73
|
+
# Scan for changes and misconfigurations
|
|
74
|
+
pipewatch scan
|
|
75
|
+
|
|
76
|
+
# Full audit in one pass (scan + pin-audit + static)
|
|
77
|
+
pipewatch audit --verify-shas
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
---
|
|
81
|
+
|
|
82
|
+
## Commands
|
|
83
|
+
|
|
84
|
+
### `baseline`
|
|
85
|
+
|
|
86
|
+
Records the current (or a specified) commit as the integrity reference point. Set `PIPEWATCH_HMAC_KEY` to store a signed baseline -- if the file is modified to suppress future findings, the HMAC check will fail and the tool will refuse to proceed.
|
|
87
|
+
|
|
88
|
+
```
|
|
89
|
+
pipewatch baseline [--repo PATH] [--commit SHA]
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
---
|
|
93
|
+
|
|
94
|
+
### `scan`
|
|
95
|
+
|
|
96
|
+
Diffs pipeline files and per-step fingerprints against the baseline commit. Detects both file-level changes (unified diff) and step-level tampering -- a step whose `uses`, `run`, `with`, `env`, or `shell` fields change gets flagged even if the surrounding file diff looks innocuous.
|
|
97
|
+
|
|
98
|
+
```
|
|
99
|
+
pipewatch scan [--repo PATH] [--baseline SHA] [--verbose] [--json]
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
Covers GitHub Actions, GitLab CI, and Jenkinsfile stages.
|
|
103
|
+
|
|
104
|
+
---
|
|
105
|
+
|
|
106
|
+
### `static`
|
|
107
|
+
|
|
108
|
+
Static analysis with no baseline required. Audits all GitHub Actions workflow files in `.github/workflows/` for structural misconfigurations.
|
|
109
|
+
|
|
110
|
+
```
|
|
111
|
+
pipewatch static [--repo PATH] [--verbose] [--json]
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
Checks: `pull_request_target` misuse, script injection, missing or overpermissioned `permissions:` blocks, `secrets: inherit`, self-hosted runners, unsafe `workflow_run` trigger chains.
|
|
115
|
+
|
|
116
|
+
---
|
|
117
|
+
|
|
118
|
+
### `pin-audit`
|
|
119
|
+
|
|
120
|
+
Flags `uses:` references not pinned to a full 40- or 64-character commit SHA. With `--verify-shas`, makes live GitHub API calls to confirm each pinned SHA actually exists in its upstream repository.
|
|
121
|
+
|
|
122
|
+
```
|
|
123
|
+
pipewatch pin-audit [--repo PATH] [--verify-shas] [--token TOKEN] [--verbose] [--json]
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
Rate limit: 60 requests/hr unauthenticated, 5000/hr with `--token` or `GITHUB_TOKEN`. API calls are deduplicated -- the same `owner/repo@sha` is only verified once. Findings are **not** deduplicated: if the same invalid SHA appears across multiple files or jobs, each affected step produces its own finding so the full scope of a compromised action is visible.
|
|
127
|
+
|
|
128
|
+
---
|
|
129
|
+
|
|
130
|
+
### `snapshot`
|
|
131
|
+
|
|
132
|
+
Captures the runner environment -- environment variables and tool versions -- to a JSON file for later comparison.
|
|
133
|
+
|
|
134
|
+
```
|
|
135
|
+
pipewatch snapshot [--output FILE]
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
Tracked tools: `python3`, `python`, `node`, `npm`, `pip`, `pip3`, `git`, `curl`, `wget`, `docker`, `kubectl`, `terraform`, `aws`, `gcloud`, `az`. Volatile per-run variables (`GITHUB_RUN_ID`, `RUNNER_TEMP`, etc.) are excluded to prevent noise on every comparison.
|
|
139
|
+
|
|
140
|
+
**Credential exclusion** -- environment variables whose names contain `token`, `secret`, `key`, `password`, `passwd`, `pwd`, `auth`, `credential`, `private`, or `api_key` (case-insensitive) are never written to the snapshot file. This prevents secrets such as `GITHUB_TOKEN` or `PIPEWATCH_HMAC_KEY` from being persisted to disk or uploaded to the Actions cache.
|
|
141
|
+
|
|
142
|
+
Add the snapshot file to `.gitignore` to prevent it from being accidentally committed:
|
|
143
|
+
|
|
144
|
+
```
|
|
145
|
+
.pipewatch_env_snapshot.json
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
---
|
|
149
|
+
|
|
150
|
+
### `env-diff`
|
|
151
|
+
|
|
152
|
+
Diffs two runner environment snapshots. Detects new, removed, or changed environment variables and tool versions -- useful for identifying runner poisoning or unexpected environment mutations between runs. If `--current-snapshot` is omitted, captures the live environment.
|
|
153
|
+
|
|
154
|
+
```
|
|
155
|
+
pipewatch env-diff BASELINE_SNAPSHOT [--current-snapshot FILE] [--repo PATH] [--verbose] [--json]
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
---
|
|
159
|
+
|
|
160
|
+
### `audit`
|
|
161
|
+
|
|
162
|
+
Full audit in one pass: `scan` + `pin-audit` + `static`. Exits non-zero if any findings exist.
|
|
163
|
+
|
|
164
|
+
```
|
|
165
|
+
pipewatch audit [--repo PATH] [--baseline SHA] [--verify-shas] [--token TOKEN] [--verbose] [--json]
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
---
|
|
169
|
+
|
|
170
|
+
### `init-runner`
|
|
171
|
+
|
|
172
|
+
Prints a ready-to-paste GitHub Actions step block that adds runner environment monitoring to any existing job.
|
|
173
|
+
|
|
174
|
+
```
|
|
175
|
+
pipewatch init-runner [--snapshot-path PATH]
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
---
|
|
179
|
+
|
|
180
|
+
## Finding IDs
|
|
181
|
+
|
|
182
|
+
| Prefix | Category | Default Severity |
|
|
183
|
+
|---|---|---|
|
|
184
|
+
| `PW-DIFF-NNN` | Pipeline file added / modified / deleted | HIGH / MEDIUM |
|
|
185
|
+
| `PW-STEP-NNN` | Step fingerprint changed / injected / removed | HIGH / MEDIUM |
|
|
186
|
+
| `PW-PRT-NNN` | pull_request_target misuse | HIGH |
|
|
187
|
+
| `PW-INJ-NNN` | Script injection risk | HIGH |
|
|
188
|
+
| `PW-PERM-NNN` | Permission misconfiguration | HIGH / MEDIUM |
|
|
189
|
+
| `PW-CHAIN-NNN` | Unsafe workflow_run chain | HIGH |
|
|
190
|
+
| `PW-PIN-NNN` | Unpinned action reference | MEDIUM |
|
|
191
|
+
| `PW-SHA-NNN` | Pinned SHA not found in upstream repo | HIGH |
|
|
192
|
+
| `PW-RUNNER-NNN` | Self-hosted runner | INFO |
|
|
193
|
+
| `PW-ENV-NNN` | Runner environment drift | MEDIUM / LOW |
|
|
194
|
+
|
|
195
|
+
---
|
|
196
|
+
|
|
197
|
+
## JSON Output
|
|
198
|
+
|
|
199
|
+
All commands accept `--json`:
|
|
200
|
+
|
|
201
|
+
```
|
|
202
|
+
{
|
|
203
|
+
"tool": "pipewatch",
|
|
204
|
+
"version": "0.2.0",
|
|
205
|
+
"timestamp": "2025-01-01T00:00:00+00:00",
|
|
206
|
+
"repo": "/path/to/repo",
|
|
207
|
+
"baseline_commit": "abc123...",
|
|
208
|
+
"findings": [
|
|
209
|
+
{
|
|
210
|
+
"id": "PW-INJ-001",
|
|
211
|
+
"severity": "HIGH",
|
|
212
|
+
"category": "script_injection",
|
|
213
|
+
"title": "Script injection risk: .github/workflows/ci.yml::build::step[2]",
|
|
214
|
+
"description": "A run: block interpolates a user-controlled context value...",
|
|
215
|
+
"location": ".github/workflows/ci.yml::build::step[2]",
|
|
216
|
+
"evidence": "dangerous expressions found: ['github.event.pull_request.title']"
|
|
217
|
+
}
|
|
218
|
+
],
|
|
219
|
+
"summary": { "total": 1, "CRITICAL": 0, "HIGH": 1, "MEDIUM": 0, "LOW": 0, "INFO": 0 }
|
|
220
|
+
}
|
|
221
|
+
```
|
|
222
|
+
|
|
223
|
+
Gate on exit code, or filter with `jq`:
|
|
224
|
+
|
|
225
|
+
```
|
|
226
|
+
# fail the build on any HIGH or CRITICAL finding
|
|
227
|
+
pipewatch audit --json | jq -e '.summary.HIGH == 0 and .summary.CRITICAL == 0'
|
|
228
|
+
|
|
229
|
+
# list all finding titles
|
|
230
|
+
pipewatch audit --json | jq -r '.findings[].title'
|
|
231
|
+
```
|
|
232
|
+
|
|
233
|
+
---
|
|
234
|
+
|
|
235
|
+
## Tamper-Evident Baselines
|
|
236
|
+
|
|
237
|
+
Set `PIPEWATCH_HMAC_KEY` before running `baseline`. The baseline is stored as a signed JSON object:
|
|
238
|
+
|
|
239
|
+
```
|
|
240
|
+
{
|
|
241
|
+
"commit": "abc123...",
|
|
242
|
+
"timestamp": "2025-01-01T00:00:00+00:00",
|
|
243
|
+
"hmac": "<sha256-hmac-of-commit-and-timestamp>"
|
|
244
|
+
}
|
|
245
|
+
```
|
|
246
|
+
|
|
247
|
+
The HMAC is computed over both the commit SHA **and** the timestamp, bound together. This protects against two distinct attacks:
|
|
248
|
+
|
|
249
|
+
- **Tampering** -- an attacker who modifies the `commit` field cannot produce a valid HMAC without the key.
|
|
250
|
+
- **Replay** -- an attacker who reverts the baseline file to a previously-valid signed snapshot is also blocked, because the timestamp is part of the signed payload.
|
|
251
|
+
|
|
252
|
+
On `scan` or `audit`, the HMAC is verified before the baseline commit is trusted. Any verification failure causes an immediate exit with an error.
|
|
253
|
+
|
|
254
|
+
**Format-downgrade protection** -- if `PIPEWATCH_HMAC_KEY` is set and the baseline file is in plain-text format, the tool refuses to proceed. An attacker cannot bypass signing by overwriting the file with an unsigned commit SHA. If you set `PIPEWATCH_HMAC_KEY` for the first time on a repo that already has an unsigned baseline, re-run `pipewatch baseline` to generate a signed one before your next scan.
|
|
255
|
+
|
|
256
|
+
Store the key in a CI secret.
|
|
257
|
+
|
|
258
|
+
---
|
|
259
|
+
|
|
260
|
+
## Pipeline Integration
|
|
261
|
+
|
|
262
|
+
```
|
|
263
|
+
- name: pipewatch audit
|
|
264
|
+
env:
|
|
265
|
+
GITHUB_TOKEN: (your GITHUB_TOKEN secret)
|
|
266
|
+
PIPEWATCH_HMAC_KEY: (your PIPEWATCH_HMAC_KEY secret)
|
|
267
|
+
run: |
|
|
268
|
+
pipewatch audit --verify-shas --json | tee pw-report.json
|
|
269
|
+
jq -e '.summary.HIGH == 0 and .summary.CRITICAL == 0' pw-report.json
|
|
270
|
+
```
|
|
271
|
+
|
|
272
|
+
Use `init-runner` to add runner environment monitoring alongside the audit step.
|
|
273
|
+
|
|
274
|
+
---
|
|
275
|
+
|
|
276
|
+
## Design Decisions
|
|
277
|
+
|
|
278
|
+
**HMAC-signed baselines** -- tamper-evident storage for the known-good commit reference. The HMAC covers both the commit SHA and the timestamp, so an attacker who can write to the repo but wants to suppress findings would need to forge the HMAC -- not just overwrite the file or revert it to an older signed state. Attempting to downgrade a signed baseline to unsigned plain text is also refused when `PIPEWATCH_HMAC_KEY` is set.
|
|
279
|
+
|
|
280
|
+
**Volatile variable exclusion** -- `snapshot` strips run-specific GitHub variables so that `env-diff` does not generate noise on every comparison. Only structurally stable variables that could indicate environment manipulation are tracked. Variables whose names suggest credentials are also excluded so secrets are never written to the snapshot file or the Actions cache.
|
|
281
|
+
|
|
282
|
+
**Conservative SHA verification** -- `--verify-shas` treats network failures as non-findings. A flaky connection or GitHub API outage should not produce spurious HIGH alerts.
|
|
283
|
+
|
|
284
|
+
**Stdlib-first** -- `pyyaml` is the only dependency. The tool audits supply-chain risk; its own footprint is minimal by design.
|
|
285
|
+
|
|
286
|
+
---
|
|
287
|
+
|
|
288
|
+
## Platform Support
|
|
289
|
+
|
|
290
|
+
| Platform | Coverage |
|
|
291
|
+
|---|---|
|
|
292
|
+
| GitHub Actions (.github/workflows/*.yml) | Full -- file diff, step fingerprinting, static analysis, pin audit. Step evidence includes uses, run first line, or step name. |
|
|
293
|
+
| GitLab CI (.gitlab-ci.yml) | File diff + before_script / script / after_script fingerprinting. Step evidence shows the first command in the changed block. |
|
|
294
|
+
| Jenkins (Jenkinsfile) | File diff + best-effort stage / sh / bat fingerprinting (regex-based, not a Groovy parser). Step evidence shows the first sh/bat command where extractable; falls back to stage name. |
|
|
295
|
+
|
|
296
|
+
---
|
|
297
|
+
|
|
298
|
+
## License
|
|
299
|
+
|
|
300
|
+
Copyright (c) 2026 David Obi. Licensed under [CC BY 4.0](https://creativecommons.org/licenses/by/4.0/). See [LICENSE](LICENSE).
|
|
@@ -0,0 +1,289 @@
|
|
|
1
|
+
# pipewatch
|
|
2
|
+
|
|
3
|
+
**Integrity monitoring and static analysis for software supply chains.**
|
|
4
|
+
|
|
5
|
+
CI/CD pipelines are high-value targets: they run with elevated permissions, pull from external registries, and execute arbitrary code on every commit. A single injected step, mutable action pin, or misconfigured trigger is enough to exfiltrate secrets, backdoor build artifacts, or pivot into production infrastructure -- and the attack surface is almost always left unmonitored.
|
|
6
|
+
|
|
7
|
+
`pipewatch` audits GitHub Actions workflows, GitLab CI, and Jenkinsfiles for exactly these risks. It combines commit-anchored baseline diffing, per-step SHA-256 fingerprinting, static misconfiguration analysis, and runner environment tracking into a single CLI tool. All commands exit non-zero on findings and emit structured JSON -- suitable as a pipeline gate, a pre-merge check, or a periodic audit job.
|
|
8
|
+
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
## What It Detects
|
|
12
|
+
|
|
13
|
+
| Check | What it catches |
|
|
14
|
+
|---|---|
|
|
15
|
+
| **Baseline diff** | Pipeline files modified, added, or deleted since a known-good commit |
|
|
16
|
+
| **Step fingerprinting** | Individual steps injected, removed, or silently modified between commits |
|
|
17
|
+
| **pull_request_target misuse** | Workflows that check out and execute PR head code with base-branch write permissions -- the pattern behind numerous CI poisoning attacks |
|
|
18
|
+
| **Script injection** | run: blocks and env: blocks that route user-controlled context values into shell commands -- both direct interpolation and the indirect env: VAR -> $VAR pattern are detected |
|
|
19
|
+
| **Permission misconfiguration** | Missing permissions: blocks, write-all scopes, secrets: inherit |
|
|
20
|
+
| **Mutable action pins** | uses: references not locked to a full commit SHA -- tags like v3 can be silently overwritten by a supply-chain attacker |
|
|
21
|
+
| **Invalid pinned SHAs** | Pinned SHAs that do not exist in the upstream action repo (typos, deleted commits, fork SHAs) |
|
|
22
|
+
| **Unsafe workflow_run chains** | Write-permissioned workflows triggered indirectly by external pull requests or issues, creating a privilege escalation path |
|
|
23
|
+
| **Self-hosted runners** | Non-ephemeral runners that persist state between runs and are not managed by GitHub |
|
|
24
|
+
| **Runner environment drift** | Env var and tool version changes between CI runs that could indicate a compromised or modified runner |
|
|
25
|
+
|
|
26
|
+
Findings are severity-ranked (CRITICAL -> HIGH -> MEDIUM -> LOW -> INFO) and always include a location, description, and evidence field.
|
|
27
|
+
|
|
28
|
+
---
|
|
29
|
+
|
|
30
|
+
## Installation
|
|
31
|
+
|
|
32
|
+
Requires Python 3.12+. `pyyaml` is the only external dependency.
|
|
33
|
+
|
|
34
|
+
**Via pip (recommended):**
|
|
35
|
+
|
|
36
|
+
```
|
|
37
|
+
pip install pipewatch-cli
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
**Directly from GitHub (no clone required):**
|
|
41
|
+
|
|
42
|
+
```
|
|
43
|
+
pip install git+https://github.com/TheVoidThatConsumes/pipewatch.git
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
**Copy into your project** -- download `pipewatch.py` and drop it anywhere in the repo you want to monitor. Install `pyyaml` manually:
|
|
47
|
+
|
|
48
|
+
```
|
|
49
|
+
pip install pyyaml
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
Then run it as `py pipewatch.py <command>` instead of `pipewatch <command>`.
|
|
53
|
+
|
|
54
|
+
---
|
|
55
|
+
|
|
56
|
+
## Quick Start
|
|
57
|
+
|
|
58
|
+
```
|
|
59
|
+
# Record the current HEAD as known-good
|
|
60
|
+
pipewatch baseline
|
|
61
|
+
|
|
62
|
+
# Scan for changes and misconfigurations
|
|
63
|
+
pipewatch scan
|
|
64
|
+
|
|
65
|
+
# Full audit in one pass (scan + pin-audit + static)
|
|
66
|
+
pipewatch audit --verify-shas
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
---
|
|
70
|
+
|
|
71
|
+
## Commands
|
|
72
|
+
|
|
73
|
+
### `baseline`
|
|
74
|
+
|
|
75
|
+
Records the current (or a specified) commit as the integrity reference point. Set `PIPEWATCH_HMAC_KEY` to store a signed baseline -- if the file is modified to suppress future findings, the HMAC check will fail and the tool will refuse to proceed.
|
|
76
|
+
|
|
77
|
+
```
|
|
78
|
+
pipewatch baseline [--repo PATH] [--commit SHA]
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
---
|
|
82
|
+
|
|
83
|
+
### `scan`
|
|
84
|
+
|
|
85
|
+
Diffs pipeline files and per-step fingerprints against the baseline commit. Detects both file-level changes (unified diff) and step-level tampering -- a step whose `uses`, `run`, `with`, `env`, or `shell` fields change gets flagged even if the surrounding file diff looks innocuous.
|
|
86
|
+
|
|
87
|
+
```
|
|
88
|
+
pipewatch scan [--repo PATH] [--baseline SHA] [--verbose] [--json]
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
Covers GitHub Actions, GitLab CI, and Jenkinsfile stages.
|
|
92
|
+
|
|
93
|
+
---
|
|
94
|
+
|
|
95
|
+
### `static`
|
|
96
|
+
|
|
97
|
+
Static analysis with no baseline required. Audits all GitHub Actions workflow files in `.github/workflows/` for structural misconfigurations.
|
|
98
|
+
|
|
99
|
+
```
|
|
100
|
+
pipewatch static [--repo PATH] [--verbose] [--json]
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
Checks: `pull_request_target` misuse, script injection, missing or overpermissioned `permissions:` blocks, `secrets: inherit`, self-hosted runners, unsafe `workflow_run` trigger chains.
|
|
104
|
+
|
|
105
|
+
---
|
|
106
|
+
|
|
107
|
+
### `pin-audit`
|
|
108
|
+
|
|
109
|
+
Flags `uses:` references not pinned to a full 40- or 64-character commit SHA. With `--verify-shas`, makes live GitHub API calls to confirm each pinned SHA actually exists in its upstream repository.
|
|
110
|
+
|
|
111
|
+
```
|
|
112
|
+
pipewatch pin-audit [--repo PATH] [--verify-shas] [--token TOKEN] [--verbose] [--json]
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
Rate limit: 60 requests/hr unauthenticated, 5000/hr with `--token` or `GITHUB_TOKEN`. API calls are deduplicated -- the same `owner/repo@sha` is only verified once. Findings are **not** deduplicated: if the same invalid SHA appears across multiple files or jobs, each affected step produces its own finding so the full scope of a compromised action is visible.
|
|
116
|
+
|
|
117
|
+
---
|
|
118
|
+
|
|
119
|
+
### `snapshot`
|
|
120
|
+
|
|
121
|
+
Captures the runner environment -- environment variables and tool versions -- to a JSON file for later comparison.
|
|
122
|
+
|
|
123
|
+
```
|
|
124
|
+
pipewatch snapshot [--output FILE]
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
Tracked tools: `python3`, `python`, `node`, `npm`, `pip`, `pip3`, `git`, `curl`, `wget`, `docker`, `kubectl`, `terraform`, `aws`, `gcloud`, `az`. Volatile per-run variables (`GITHUB_RUN_ID`, `RUNNER_TEMP`, etc.) are excluded to prevent noise on every comparison.
|
|
128
|
+
|
|
129
|
+
**Credential exclusion** -- environment variables whose names contain `token`, `secret`, `key`, `password`, `passwd`, `pwd`, `auth`, `credential`, `private`, or `api_key` (case-insensitive) are never written to the snapshot file. This prevents secrets such as `GITHUB_TOKEN` or `PIPEWATCH_HMAC_KEY` from being persisted to disk or uploaded to the Actions cache.
|
|
130
|
+
|
|
131
|
+
Add the snapshot file to `.gitignore` to prevent it from being accidentally committed:
|
|
132
|
+
|
|
133
|
+
```
|
|
134
|
+
.pipewatch_env_snapshot.json
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
---
|
|
138
|
+
|
|
139
|
+
### `env-diff`
|
|
140
|
+
|
|
141
|
+
Diffs two runner environment snapshots. Detects new, removed, or changed environment variables and tool versions -- useful for identifying runner poisoning or unexpected environment mutations between runs. If `--current-snapshot` is omitted, captures the live environment.
|
|
142
|
+
|
|
143
|
+
```
|
|
144
|
+
pipewatch env-diff BASELINE_SNAPSHOT [--current-snapshot FILE] [--repo PATH] [--verbose] [--json]
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
---
|
|
148
|
+
|
|
149
|
+
### `audit`
|
|
150
|
+
|
|
151
|
+
Full audit in one pass: `scan` + `pin-audit` + `static`. Exits non-zero if any findings exist.
|
|
152
|
+
|
|
153
|
+
```
|
|
154
|
+
pipewatch audit [--repo PATH] [--baseline SHA] [--verify-shas] [--token TOKEN] [--verbose] [--json]
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
---
|
|
158
|
+
|
|
159
|
+
### `init-runner`
|
|
160
|
+
|
|
161
|
+
Prints a ready-to-paste GitHub Actions step block that adds runner environment monitoring to any existing job.
|
|
162
|
+
|
|
163
|
+
```
|
|
164
|
+
pipewatch init-runner [--snapshot-path PATH]
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
---
|
|
168
|
+
|
|
169
|
+
## Finding IDs
|
|
170
|
+
|
|
171
|
+
| Prefix | Category | Default Severity |
|
|
172
|
+
|---|---|---|
|
|
173
|
+
| `PW-DIFF-NNN` | Pipeline file added / modified / deleted | HIGH / MEDIUM |
|
|
174
|
+
| `PW-STEP-NNN` | Step fingerprint changed / injected / removed | HIGH / MEDIUM |
|
|
175
|
+
| `PW-PRT-NNN` | pull_request_target misuse | HIGH |
|
|
176
|
+
| `PW-INJ-NNN` | Script injection risk | HIGH |
|
|
177
|
+
| `PW-PERM-NNN` | Permission misconfiguration | HIGH / MEDIUM |
|
|
178
|
+
| `PW-CHAIN-NNN` | Unsafe workflow_run chain | HIGH |
|
|
179
|
+
| `PW-PIN-NNN` | Unpinned action reference | MEDIUM |
|
|
180
|
+
| `PW-SHA-NNN` | Pinned SHA not found in upstream repo | HIGH |
|
|
181
|
+
| `PW-RUNNER-NNN` | Self-hosted runner | INFO |
|
|
182
|
+
| `PW-ENV-NNN` | Runner environment drift | MEDIUM / LOW |
|
|
183
|
+
|
|
184
|
+
---
|
|
185
|
+
|
|
186
|
+
## JSON Output
|
|
187
|
+
|
|
188
|
+
All commands accept `--json`:
|
|
189
|
+
|
|
190
|
+
```
|
|
191
|
+
{
|
|
192
|
+
"tool": "pipewatch",
|
|
193
|
+
"version": "0.2.0",
|
|
194
|
+
"timestamp": "2025-01-01T00:00:00+00:00",
|
|
195
|
+
"repo": "/path/to/repo",
|
|
196
|
+
"baseline_commit": "abc123...",
|
|
197
|
+
"findings": [
|
|
198
|
+
{
|
|
199
|
+
"id": "PW-INJ-001",
|
|
200
|
+
"severity": "HIGH",
|
|
201
|
+
"category": "script_injection",
|
|
202
|
+
"title": "Script injection risk: .github/workflows/ci.yml::build::step[2]",
|
|
203
|
+
"description": "A run: block interpolates a user-controlled context value...",
|
|
204
|
+
"location": ".github/workflows/ci.yml::build::step[2]",
|
|
205
|
+
"evidence": "dangerous expressions found: ['github.event.pull_request.title']"
|
|
206
|
+
}
|
|
207
|
+
],
|
|
208
|
+
"summary": { "total": 1, "CRITICAL": 0, "HIGH": 1, "MEDIUM": 0, "LOW": 0, "INFO": 0 }
|
|
209
|
+
}
|
|
210
|
+
```
|
|
211
|
+
|
|
212
|
+
Gate on exit code, or filter with `jq`:
|
|
213
|
+
|
|
214
|
+
```
|
|
215
|
+
# fail the build on any HIGH or CRITICAL finding
|
|
216
|
+
pipewatch audit --json | jq -e '.summary.HIGH == 0 and .summary.CRITICAL == 0'
|
|
217
|
+
|
|
218
|
+
# list all finding titles
|
|
219
|
+
pipewatch audit --json | jq -r '.findings[].title'
|
|
220
|
+
```
|
|
221
|
+
|
|
222
|
+
---
|
|
223
|
+
|
|
224
|
+
## Tamper-Evident Baselines
|
|
225
|
+
|
|
226
|
+
Set `PIPEWATCH_HMAC_KEY` before running `baseline`. The baseline is stored as a signed JSON object:
|
|
227
|
+
|
|
228
|
+
```
|
|
229
|
+
{
|
|
230
|
+
"commit": "abc123...",
|
|
231
|
+
"timestamp": "2025-01-01T00:00:00+00:00",
|
|
232
|
+
"hmac": "<sha256-hmac-of-commit-and-timestamp>"
|
|
233
|
+
}
|
|
234
|
+
```
|
|
235
|
+
|
|
236
|
+
The HMAC is computed over both the commit SHA **and** the timestamp, bound together. This protects against two distinct attacks:
|
|
237
|
+
|
|
238
|
+
- **Tampering** -- an attacker who modifies the `commit` field cannot produce a valid HMAC without the key.
|
|
239
|
+
- **Replay** -- an attacker who reverts the baseline file to a previously-valid signed snapshot is also blocked, because the timestamp is part of the signed payload.
|
|
240
|
+
|
|
241
|
+
On `scan` or `audit`, the HMAC is verified before the baseline commit is trusted. Any verification failure causes an immediate exit with an error.
|
|
242
|
+
|
|
243
|
+
**Format-downgrade protection** -- if `PIPEWATCH_HMAC_KEY` is set and the baseline file is in plain-text format, the tool refuses to proceed. An attacker cannot bypass signing by overwriting the file with an unsigned commit SHA. If you set `PIPEWATCH_HMAC_KEY` for the first time on a repo that already has an unsigned baseline, re-run `pipewatch baseline` to generate a signed one before your next scan.
|
|
244
|
+
|
|
245
|
+
Store the key in a CI secret.
|
|
246
|
+
|
|
247
|
+
---
|
|
248
|
+
|
|
249
|
+
## Pipeline Integration
|
|
250
|
+
|
|
251
|
+
```
|
|
252
|
+
- name: pipewatch audit
|
|
253
|
+
env:
|
|
254
|
+
GITHUB_TOKEN: (your GITHUB_TOKEN secret)
|
|
255
|
+
PIPEWATCH_HMAC_KEY: (your PIPEWATCH_HMAC_KEY secret)
|
|
256
|
+
run: |
|
|
257
|
+
pipewatch audit --verify-shas --json | tee pw-report.json
|
|
258
|
+
jq -e '.summary.HIGH == 0 and .summary.CRITICAL == 0' pw-report.json
|
|
259
|
+
```
|
|
260
|
+
|
|
261
|
+
Use `init-runner` to add runner environment monitoring alongside the audit step.
|
|
262
|
+
|
|
263
|
+
---
|
|
264
|
+
|
|
265
|
+
## Design Decisions
|
|
266
|
+
|
|
267
|
+
**HMAC-signed baselines** -- tamper-evident storage for the known-good commit reference. The HMAC covers both the commit SHA and the timestamp, so an attacker who can write to the repo but wants to suppress findings would need to forge the HMAC -- not just overwrite the file or revert it to an older signed state. Attempting to downgrade a signed baseline to unsigned plain text is also refused when `PIPEWATCH_HMAC_KEY` is set.
|
|
268
|
+
|
|
269
|
+
**Volatile variable exclusion** -- `snapshot` strips run-specific GitHub variables so that `env-diff` does not generate noise on every comparison. Only structurally stable variables that could indicate environment manipulation are tracked. Variables whose names suggest credentials are also excluded so secrets are never written to the snapshot file or the Actions cache.
|
|
270
|
+
|
|
271
|
+
**Conservative SHA verification** -- `--verify-shas` treats network failures as non-findings. A flaky connection or GitHub API outage should not produce spurious HIGH alerts.
|
|
272
|
+
|
|
273
|
+
**Stdlib-first** -- `pyyaml` is the only dependency. The tool audits supply-chain risk; its own footprint is minimal by design.
|
|
274
|
+
|
|
275
|
+
---
|
|
276
|
+
|
|
277
|
+
## Platform Support
|
|
278
|
+
|
|
279
|
+
| Platform | Coverage |
|
|
280
|
+
|---|---|
|
|
281
|
+
| GitHub Actions (.github/workflows/*.yml) | Full -- file diff, step fingerprinting, static analysis, pin audit. Step evidence includes uses, run first line, or step name. |
|
|
282
|
+
| GitLab CI (.gitlab-ci.yml) | File diff + before_script / script / after_script fingerprinting. Step evidence shows the first command in the changed block. |
|
|
283
|
+
| Jenkins (Jenkinsfile) | File diff + best-effort stage / sh / bat fingerprinting (regex-based, not a Groovy parser). Step evidence shows the first sh/bat command where extractable; falls back to stage name. |
|
|
284
|
+
|
|
285
|
+
---
|
|
286
|
+
|
|
287
|
+
## License
|
|
288
|
+
|
|
289
|
+
Copyright (c) 2026 David Obi. Licensed under [CC BY 4.0](https://creativecommons.org/licenses/by/4.0/). See [LICENSE](LICENSE).
|