pipewatch-cli 0.2.0__tar.gz → 0.4.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,402 @@
1
+
2
+ pipewatch-cli is licensed under the Creative Commons Attribution 4.0
3
+ International License. To view a copy of this license, see below or
4
+ visit https://creativecommons.org/licenses/by/4.0/
5
+
6
+ =======================================================================
7
+
8
+ Attribution 4.0 International
9
+
10
+ =======================================================================
11
+
12
+ Creative Commons Corporation ("Creative Commons") is not a law firm and
13
+ does not provide legal services or legal advice. Distribution of
14
+ Creative Commons public licenses does not create a lawyer-client or
15
+ other relationship. Creative Commons makes its licenses and related
16
+ information available on an "as-is" basis. Creative Commons gives no
17
+ warranties regarding its licenses, any material licensed under their
18
+ terms and conditions, or any related information. Creative Commons
19
+ disclaims all liability for damages resulting from their use to the
20
+ fullest extent possible.
21
+
22
+ Using Creative Commons Public Licenses
23
+
24
+ Creative Commons public licenses provide a standard set of terms and
25
+ conditions that creators and other rights holders may use to share
26
+ original works of authorship and other material subject to copyright
27
+ and certain other rights specified in the public license below. The
28
+ following considerations are for informational purposes only, are not
29
+ exhaustive, and do not form part of our licenses.
30
+
31
+ Considerations for licensors: Our public licenses are
32
+ intended for use by those authorized to give the public
33
+ permission to use material in ways otherwise restricted by
34
+ copyright and certain other rights. Our licenses are
35
+ irrevocable. Licensors should read and understand the terms
36
+ and conditions of the license they choose before applying it.
37
+ Licensors should also secure all rights necessary before
38
+ applying our licenses so that the public can reuse the
39
+ material as expected. Licensors should clearly mark any
40
+ material not subject to the license. This includes other CC-
41
+ licensed material, or material used under an exception or
42
+ limitation to copyright. More considerations for licensors:
43
+ wiki.creativecommons.org/Considerations_for_licensors
44
+
45
+ Considerations for the public: By using one of our public
46
+ licenses, a licensor grants the public permission to use the
47
+ licensed material under specified terms and conditions. If
48
+ the licensor's permission is not necessary for any reason--for
49
+ example, because of any applicable exception or limitation to
50
+ copyright--then that use is not regulated by the license. Our
51
+ licenses grant only permissions under copyright and certain
52
+ other rights that a licensor has authority to grant. Use of
53
+ the licensed material may still be restricted for other
54
+ reasons, including because others have copyright or other
55
+ rights in the material. A licensor may make special requests,
56
+ such as asking that all changes be marked or described.
57
+ Although not required by our licenses, you are encouraged to
58
+ respect those requests where reasonable. More considerations
59
+ for the public:
60
+ wiki.creativecommons.org/Considerations_for_licensees
61
+
62
+ =======================================================================
63
+
64
+ Creative Commons Attribution 4.0 International Public License
65
+
66
+ By exercising the Licensed Rights (defined below), You accept and agree
67
+ to be bound by the terms and conditions of this Creative Commons
68
+ Attribution 4.0 International Public License ("Public License"). To the
69
+ extent this Public License may be interpreted as a contract, You are
70
+ granted the Licensed Rights in consideration of Your acceptance of
71
+ these terms and conditions, and the Licensor grants You such rights in
72
+ consideration of benefits the Licensor receives from making the
73
+ Licensed Material available under these terms and conditions.
74
+
75
+
76
+ Section 1 -- Definitions.
77
+
78
+ a. Adapted Material means material subject to Copyright and Similar
79
+ Rights that is derived from or based upon the Licensed Material
80
+ and in which the Licensed Material is translated, altered,
81
+ arranged, transformed, or otherwise modified in a manner requiring
82
+ permission under the Copyright and Similar Rights held by the
83
+ Licensor. For purposes of this Public License, where the Licensed
84
+ Material is a musical work, performance, or sound recording,
85
+ Adapted Material is always produced where the Licensed Material is
86
+ synched in timed relation with a moving image.
87
+
88
+ b. Adapter's License means the license You apply to Your Copyright
89
+ and Similar Rights in Your contributions to Adapted Material in
90
+ accordance with the terms and conditions of this Public License.
91
+
92
+ c. Copyright and Similar Rights means copyright and/or similar rights
93
+ closely related to copyright including, without limitation,
94
+ performance, broadcast, sound recording, and Sui Generis Database
95
+ Rights, without regard to how the rights are labeled or
96
+ categorized. For purposes of this Public License, the rights
97
+ specified in Section 2(b)(1)-(2) are not Copyright and Similar
98
+ Rights.
99
+
100
+ d. Effective Technological Measures means those measures that, in the
101
+ absence of proper authority, may not be circumvented under laws
102
+ fulfilling obligations under Article 11 of the WIPO Copyright
103
+ Treaty adopted on December 20, 1996, and/or similar international
104
+ agreements.
105
+
106
+ e. Exceptions and Limitations means fair use, fair dealing, and/or
107
+ any other exception or limitation to Copyright and Similar Rights
108
+ that applies to Your use of the Licensed Material.
109
+
110
+ f. Licensed Material means the artistic or literary work, database,
111
+ or other material to which the Licensor applied this Public
112
+ License.
113
+
114
+ g. Licensed Rights means the rights granted to You subject to the
115
+ terms and conditions of this Public License, which are limited to
116
+ all Copyright and Similar Rights that apply to Your use of the
117
+ Licensed Material and that the Licensor has authority to license.
118
+
119
+ h. Licensor means the individual(s) or entity(ies) granting rights
120
+ under this Public License.
121
+
122
+ i. Share means to provide material to the public by any means or
123
+ process that requires permission under the Licensed Rights, such
124
+ as reproduction, public display, public performance, distribution,
125
+ dissemination, communication, or importation, and to make material
126
+ available to the public including in ways that members of the
127
+ public may access the material from a place and at a time
128
+ individually chosen by them.
129
+
130
+ j. Sui Generis Database Rights means rights other than copyright
131
+ resulting from Directive 96/9/EC of the European Parliament and of
132
+ the Council of 11 March 1996 on the legal protection of databases,
133
+ as amended and/or succeeded, as well as other essentially
134
+ equivalent rights anywhere in the world.
135
+
136
+ k. You means the individual or entity exercising the Licensed Rights
137
+ under this Public License. Your has a corresponding meaning.
138
+
139
+
140
+ Section 2 -- Scope.
141
+
142
+ a. License grant.
143
+
144
+ 1. Subject to the terms and conditions of this Public License,
145
+ the Licensor hereby grants You a worldwide, royalty-free,
146
+ non-sublicensable, non-exclusive, irrevocable license to
147
+ exercise the Licensed Rights in the Licensed Material to:
148
+
149
+ a. reproduce and Share the Licensed Material, in whole or
150
+ in part; and
151
+
152
+ b. produce, reproduce, and Share Adapted Material.
153
+
154
+ 2. Exceptions and Limitations. For the avoidance of doubt, where
155
+ Exceptions and Limitations apply to Your use, this Public
156
+ License does not apply, and You do not need to comply with
157
+ its terms and conditions.
158
+
159
+ 3. Term. The term of this Public License is specified in Section
160
+ 6(a).
161
+
162
+ 4. Media and formats; technical modifications allowed. The
163
+ Licensor authorizes You to exercise the Licensed Rights in
164
+ all media and formats whether now known or hereafter created,
165
+ and to make technical modifications necessary to do so. The
166
+ Licensor waives and/or agrees not to assert any right or
167
+ authority to forbid You from making technical modifications
168
+ necessary to exercise the Licensed Rights, including
169
+ technical modifications necessary to circumvent Effective
170
+ Technological Measures. For purposes of this Public License,
171
+ simply making modifications authorized by this Section 2(a)
172
+ (4) never produces Adapted Material.
173
+
174
+ 5. Downstream recipients.
175
+
176
+ a. Offer from the Licensor -- Licensed Material. Every
177
+ recipient of the Licensed Material automatically
178
+ receives an offer from the Licensor to exercise the
179
+ Licensed Rights under the terms and conditions of this
180
+ Public License.
181
+
182
+ b. No downstream restrictions. You may not offer or impose
183
+ any additional or different terms or conditions on, or
184
+ apply any Effective Technological Measures to, the
185
+ Licensed Material if doing so restricts exercise of the
186
+ Licensed Rights by any recipient of the Licensed
187
+ Material.
188
+
189
+ 6. No endorsement. Nothing in this Public License constitutes or
190
+ may be construed as permission to assert or imply that You
191
+ are, or that Your use of the Licensed Material is, connected
192
+ with, or sponsored, endorsed, or granted official status by,
193
+ the Licensor or others designated to receive attribution as
194
+ provided in Section 3(a)(1)(A)(i).
195
+
196
+ b. Other rights.
197
+
198
+ 1. Moral rights, such as the right of integrity, are not
199
+ licensed under this Public License, nor are publicity,
200
+ privacy, and/or other similar personality rights; however, to
201
+ the extent possible, the Licensor waives and/or agrees not to
202
+ assert any such rights held by the Licensor to the limited
203
+ extent necessary to allow You to exercise the Licensed
204
+ Rights, but not otherwise.
205
+
206
+ 2. Patent and trademark rights are not licensed under this
207
+ Public License.
208
+
209
+ 3. To the extent possible, the Licensor waives any right to
210
+ collect royalties from You for the exercise of the Licensed
211
+ Rights, whether directly or through a collecting society
212
+ under any voluntary or waivable statutory or compulsory
213
+ licensing scheme. In all other cases the Licensor expressly
214
+ reserves any right to collect such royalties.
215
+
216
+
217
+ Section 3 -- License Conditions.
218
+
219
+ Your exercise of the Licensed Rights is expressly made subject to the
220
+ following conditions.
221
+
222
+ a. Attribution.
223
+
224
+ 1. If You Share the Licensed Material (including in modified
225
+ form), You must:
226
+
227
+ a. retain the following if it is supplied by the Licensor
228
+ with the Licensed Material:
229
+
230
+ i. identification of the creator(s) of the Licensed
231
+ Material and any others designated to receive
232
+ attribution, in any reasonable manner requested by
233
+ the Licensor (including by pseudonym if
234
+ designated);
235
+
236
+ ii. a copyright notice;
237
+
238
+ iii. a notice that refers to this Public License;
239
+
240
+ iv. a notice that refers to the disclaimer of
241
+ warranties;
242
+
243
+ v. a URI or hyperlink to the Licensed Material to the
244
+ extent reasonably practicable;
245
+
246
+ b. indicate if You modified the Licensed Material and
247
+ retain an indication of any previous modifications; and
248
+
249
+ c. indicate the Licensed Material is licensed under this
250
+ Public License, and include the text of, or the URI or
251
+ hyperlink to, this Public License.
252
+
253
+ 2. You may satisfy the conditions in Section 3(a)(1) in any
254
+ reasonable manner based on the medium, means, and context in
255
+ which You Share the Licensed Material. For example, it may be
256
+ reasonable to satisfy the conditions by providing a URI or
257
+ hyperlink to a resource that includes the required
258
+ information.
259
+
260
+ 3. If requested by the Licensor, You must remove any of the
261
+ information required by Section 3(a)(1)(A) to the extent
262
+ reasonably practicable.
263
+
264
+ 4. If You Share Adapted Material You produce, the Adapter's
265
+ License You apply must not prevent recipients of the Adapted
266
+ Material from complying with this Public License.
267
+
268
+
269
+ Section 4 -- Sui Generis Database Rights.
270
+
271
+ Where the Licensed Rights include Sui Generis Database Rights that
272
+ apply to Your use of the Licensed Material:
273
+
274
+ a. for the avoidance of doubt, Section 2(a)(1) grants You the right
275
+ to extract, reuse, reproduce, and Share all or a substantial
276
+ portion of the contents of the database;
277
+
278
+ b. if You include all or a substantial portion of the database
279
+ contents in a database in which You have Sui Generis Database
280
+ Rights, then the database in which You have Sui Generis Database
281
+ Rights (but not its individual contents) is Adapted Material; and
282
+
283
+ c. You must comply with the conditions in Section 3(a) if You Share
284
+ all or a substantial portion of the contents of the database.
285
+
286
+ For the avoidance of doubt, this Section 4 supplements and does not
287
+ replace Your obligations under this Public License where the Licensed
288
+ Rights include other Copyright and Similar Rights.
289
+
290
+
291
+ Section 5 -- Disclaimer of Warranties and Limitation of Liability.
292
+
293
+ a. UNLESS OTHERWISE SEPARATELY UNDERTAKEN BY THE LICENSOR, TO THE
294
+ EXTENT POSSIBLE, THE LICENSOR OFFERS THE LICENSED MATERIAL AS-IS
295
+ AND AS-AVAILABLE, AND MAKES NO REPRESENTATIONS OR WARRANTIES OF
296
+ ANY KIND CONCERNING THE LICENSED MATERIAL, WHETHER EXPRESS,
297
+ IMPLIED, STATUTORY, OR OTHER. THIS INCLUDES, WITHOUT LIMITATION,
298
+ WARRANTIES OF TITLE, MERCHANTABILITY, FITNESS FOR A PARTICULAR
299
+ PURPOSE, NON-INFRINGEMENT, ABSENCE OF LATENT OR OTHER DEFECTS,
300
+ ACCURACY, OR THE PRESENCE OR ABSENCE OF ERRORS, WHETHER OR NOT
301
+ KNOWN OR DISCOVERABLE. WHERE DISCLAIMERS OF WARRANTIES ARE NOT
302
+ ALLOWED IN FULL OR IN PART, THIS DISCLAIMER MAY NOT APPLY TO YOU.
303
+
304
+ b. TO THE EXTENT POSSIBLE, IN NO EVENT WILL THE LICENSOR BE LIABLE
305
+ TO YOU ON ANY LEGAL THEORY (INCLUDING, WITHOUT LIMITATION,
306
+ NEGLIGENCE) OR OTHERWISE FOR ANY DIRECT, SPECIAL, INDIRECT,
307
+ INCIDENTAL, CONSEQUENTIAL, PUNITIVE, EXEMPLARY, OR OTHER LOSSES,
308
+ COSTS, EXPENSES, OR DAMAGES ARISING OUT OF THIS PUBLIC LICENSE OR
309
+ USE OF THE LICENSED MATERIAL, EVEN IF THE LICENSOR HAS BEEN
310
+ ADVISED OF THE POSSIBILITY OF SUCH LOSSES, COSTS, EXPENSES, OR
311
+ DAMAGES. WHERE A LIMITATION OF LIABILITY IS NOT ALLOWED IN FULL OR
312
+ IN PART, THIS LIMITATION MAY NOT APPLY TO YOU.
313
+
314
+ c. The disclaimer of warranties and limitation of liability provided
315
+ above shall be interpreted in a manner that, to the extent
316
+ possible, most closely approximates an absolute disclaimer and
317
+ waiver of all liability.
318
+
319
+
320
+ Section 6 -- Term and Termination.
321
+
322
+ a. This Public License applies for the term of the Copyright and
323
+ Similar Rights licensed here. However, if You fail to comply with
324
+ this Public License, then Your rights under this Public License
325
+ terminate automatically.
326
+
327
+ b. Where Your right to use the Licensed Material has terminated under
328
+ Section 6(a), it reinstates:
329
+
330
+ 1. automatically as of the date the violation is cured, provided
331
+ it is cured within 30 days of Your discovery of the
332
+ violation; or
333
+
334
+ 2. upon express reinstatement by the Licensor.
335
+
336
+ For the avoidance of doubt, this Section 6(b) does not affect any
337
+ right the Licensor may have to seek remedies for Your violations
338
+ of this Public License.
339
+
340
+ c. For the avoidance of doubt, the Licensor may also offer the
341
+ Licensed Material under separate terms or conditions or stop
342
+ distributing the Licensed Material at any time; however, doing so
343
+ will not terminate this Public License.
344
+
345
+ d. Sections 1, 5, 6, 7, and 8 survive termination of this Public
346
+ License.
347
+
348
+
349
+ Section 7 -- Other Terms and Conditions.
350
+
351
+ a. The Licensor shall not be bound by any additional or different
352
+ terms or conditions communicated by You unless expressly agreed.
353
+
354
+ b. Any arrangements, understandings, or agreements regarding the
355
+ Licensed Material not stated herein are separate from and
356
+ independent of the terms and conditions of this Public License.
357
+
358
+
359
+ Section 8 -- Interpretation.
360
+
361
+ a. For the avoidance of doubt, this Public License does not, and
362
+ shall not be interpreted to, reduce, limit, restrict, or impose
363
+ conditions on any use of the Licensed Material that could lawfully
364
+ be made without permission under this Public License.
365
+
366
+ b. To the extent possible, if any provision of this Public License is
367
+ deemed unenforceable, it shall be automatically reformed to the
368
+ minimum extent necessary to make it enforceable. If the provision
369
+ cannot be reformed, it shall be severed from this Public License
370
+ without affecting the enforceability of the remaining terms and
371
+ conditions.
372
+
373
+ c. No term or condition of this Public License will be waived and no
374
+ failure to comply consented to unless expressly agreed to by the
375
+ Licensor.
376
+
377
+ d. Nothing in this Public License constitutes or may be interpreted
378
+ as a limitation upon, or waiver of, any privileges and immunities
379
+ that apply to the Licensor or You, including from the legal
380
+ processes of any jurisdiction or authority.
381
+
382
+
383
+ =======================================================================
384
+
385
+ Creative Commons is not a party to its public
386
+ licenses. Notwithstanding, Creative Commons may elect to apply one of
387
+ its public licenses to material it publishes and in those instances
388
+ will be considered the “Licensor.” The text of the Creative Commons
389
+ public licenses is dedicated to the public domain under the CC0 Public
390
+ Domain Dedication. Except for the limited purpose of indicating that
391
+ material is shared under a Creative Commons public license or as
392
+ otherwise permitted by the Creative Commons policies published at
393
+ creativecommons.org/policies, Creative Commons does not authorize the
394
+ use of the trademark "Creative Commons" or any other trademark or logo
395
+ of Creative Commons without its prior written consent including,
396
+ without limitation, in connection with any unauthorized modifications
397
+ to any of its public licenses or any other arrangements,
398
+ understandings, or agreements concerning use of licensed material. For
399
+ the avoidance of doubt, this paragraph does not form part of the
400
+ public licenses.
401
+
402
+ Creative Commons may be contacted at creativecommons.org.
@@ -0,0 +1,228 @@
1
+ Metadata-Version: 2.4
2
+ Name: pipewatch-cli
3
+ Version: 0.4.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
+ What It Detects
21
+ Check What it catches
22
+ Baseline diff Pipeline files modified, added, or deleted since a known-good commit
23
+ Step fingerprinting Individual steps injected, removed, or silently modified between commits
24
+ 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
25
+ Script injection run: blocks and env: blocks that route user-controlled context values (github.event.pull_request.title, github.event.comment.body, etc.) into shell commands — both direct interpolation and the indirect env: VAR: ${{ ctx }} → $VAR pattern are detected
26
+ Permission misconfiguration Missing permissions: blocks, write-all scopes, secrets: inherit
27
+ Mutable action pins uses: references not locked to a full commit SHA — tags like v3 can be silently overwritten by a supply-chain attacker
28
+ Invalid pinned SHAs Pinned SHAs that do not exist in the upstream action repo (typos, deleted commits, fork SHAs)
29
+ Unsafe workflow_run chains Write-permissioned workflows triggered indirectly by external pull requests or issues, creating a privilege escalation path
30
+ Self-hosted runners Non-ephemeral runners that persist state between runs and are not managed by GitHub
31
+ Runner environment drift Env var and tool version changes between CI runs that could indicate a compromised or modified runner
32
+
33
+ Findings are severity-ranked (CRITICAL → HIGH → MEDIUM → LOW → INFO) and always include a location, description, and evidence field.
34
+
35
+ Installation
36
+
37
+ Requires Python 3.12+. pyyaml is the only external dependency.
38
+
39
+ Via pip (recommended):
40
+
41
+ bash
42
+ pip install pipewatch-cli
43
+
44
+ Directly from GitHub (no clone required):
45
+
46
+ bash
47
+ pip install git+https://github.com/TheVoidThatConsumes/pipewatch.git
48
+
49
+ Copy into your project — if you prefer to keep pipewatch self-contained inside a repo you're monitoring, download pipewatch.py and drop it anywhere in that repo. Install pyyaml manually:
50
+
51
+ bash
52
+ pip install pyyaml
53
+
54
+ Then run it as py pipewatch.py <command> instead of pipewatch <command>.
55
+
56
+ Quick Start
57
+ bash
58
+ # Record the current HEAD as known-good
59
+ pipewatch baseline
60
+
61
+ # Scan for changes and misconfigurations
62
+ pipewatch scan
63
+
64
+ # Full audit in one pass (scan + pin-audit + static)
65
+ pipewatch audit --verify-shas
66
+ Commands
67
+ baseline
68
+
69
+ 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.
70
+
71
+ bash
72
+ pipewatch baseline [--repo PATH] [--commit SHA]
73
+ scan
74
+
75
+ 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.
76
+
77
+ bash
78
+ pipewatch scan [--repo PATH] [--baseline SHA] [--verbose] [--json]
79
+
80
+ Covers GitHub Actions, GitLab CI, and Jenkinsfile stages.
81
+
82
+ static
83
+
84
+ Static analysis with no baseline required. Audits all GitHub Actions workflow files in .github/workflows/ for structural misconfigurations.
85
+
86
+ bash
87
+ pipewatch static [--repo PATH] [--verbose] [--json]
88
+
89
+ Checks: pull_request_target misuse · script injection · missing/overpermissioned permissions: blocks · secrets: inherit · self-hosted runners · unsafe workflow_run trigger chains.
90
+
91
+ pin-audit
92
+
93
+ 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.
94
+
95
+ bash
96
+ pipewatch pin-audit [--repo PATH] [--verify-shas] [--token TOKEN] [--verbose] [--json]
97
+
98
+ Rate limit: 60 requests/hr unauthenticated, 5 000/hr with --token or GITHUB_TOKEN. API calls are deduplicated — the same owner/repo@sha is only verified once regardless of how many steps reference it. Findings are not deduplicated: if the same invalid SHA appears across multiple workflow files or jobs, each affected step produces its own finding so the full scope of a compromised action is visible in the report.
99
+
100
+ snapshot
101
+
102
+ Captures the runner environment — environment variables and tool versions — to a JSON file for later comparison.
103
+
104
+ bash
105
+ pipewatch snapshot [--output FILE]
106
+
107
+ 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.
108
+
109
+ 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. Note that a legitimately non-sensitive variable with one of these terms in its name will also be excluded; rename it if you need env-diff to track it.
110
+
111
+ Add the snapshot file to .gitignore to prevent it from being accidentally committed:
112
+
113
+ .pipewatch_env_snapshot.json
114
+ env-diff
115
+
116
+ 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.
117
+
118
+ bash
119
+ pipewatch env-diff BASELINE_SNAPSHOT [--current-snapshot FILE] [--repo PATH] [--verbose] [--json]
120
+ audit
121
+
122
+ Full audit in one pass: scan + pin-audit + static. Exits non-zero if any findings exist.
123
+
124
+ bash
125
+ pipewatch audit [--repo PATH] [--baseline SHA] [--verify-shas] [--token TOKEN] [--verbose] [--json]
126
+ init-runner
127
+
128
+ Prints a ready-to-paste GitHub Actions step block that adds runner environment monitoring to any existing job.
129
+
130
+ bash
131
+ pipewatch init-runner [--snapshot-path PATH]
132
+ Finding IDs
133
+ Prefix Category Default Severity
134
+ PW-DIFF-NNN Pipeline file added / modified / deleted HIGH / MEDIUM
135
+ PW-STEP-NNN Step fingerprint changed / injected / removed HIGH / MEDIUM
136
+ PW-PRT-NNN pull_request_target misuse HIGH
137
+ PW-INJ-NNN Script injection risk HIGH
138
+ PW-PERM-NNN Permission misconfiguration HIGH / MEDIUM
139
+ PW-CHAIN-NNN Unsafe workflow_run chain HIGH
140
+ PW-PIN-NNN Unpinned action reference MEDIUM
141
+ PW-SHA-NNN Pinned SHA not found in upstream repo HIGH
142
+ PW-RUNNER-NNN Self-hosted runner INFO
143
+ PW-ENV-NNN Runner environment drift MEDIUM / LOW
144
+ JSON Output
145
+
146
+ All commands accept --json:
147
+
148
+ json
149
+ {
150
+ "tool": "pipewatch",
151
+ "version": "0.2.0",
152
+ "timestamp": "2025-01-01T00:00:00+00:00",
153
+ "repo": "/path/to/repo",
154
+ "baseline_commit": "abc123...",
155
+ "findings": [
156
+ {
157
+ "id": "PW-INJ-001",
158
+ "severity": "HIGH",
159
+ "category": "script_injection",
160
+ "title": "Script injection risk: .github/workflows/ci.yml::build::step[2]",
161
+ "description": "A run: block interpolates a user-controlled context value...",
162
+ "location": ".github/workflows/ci.yml::build::step[2]",
163
+ "evidence": "dangerous expressions found: ['github.event.pull_request.title']"
164
+ }
165
+ ],
166
+ "summary": { "total": 1, "CRITICAL": 0, "HIGH": 1, "MEDIUM": 0, "LOW": 0, "INFO": 0 }
167
+ }
168
+
169
+ Gate on exit code, or filter with jq:
170
+
171
+ bash
172
+ # fail the build on any HIGH or CRITICAL finding
173
+ pipewatch audit --json | jq -e '.summary.HIGH == 0 and .summary.CRITICAL == 0'
174
+
175
+ # list all finding titles
176
+ pipewatch audit --json | jq -r '.findings[].title'
177
+ Tamper-Evident Baselines
178
+
179
+ Set PIPEWATCH_HMAC_KEY before running baseline. The baseline is stored as a signed JSON object:
180
+
181
+ json
182
+ {
183
+ "commit": "abc123...",
184
+ "timestamp": "2025-01-01T00:00:00+00:00",
185
+ "hmac": "<sha256-hmac-of-commit-and-timestamp>"
186
+ }
187
+
188
+ The HMAC is computed over both the commit SHA and the timestamp, bound together. This protects against two distinct attacks:
189
+
190
+ Tampering — an attacker who modifies the commit field to point to an older known-good commit cannot produce a valid HMAC without the key.
191
+ Replay — an attacker who reverts the baseline file to a previously-valid signed snapshot (to suppress findings introduced after that point) is also blocked, because the timestamp is part of the signed payload and the stored timestamp would no longer match the signature of any rewritten content.
192
+
193
+ On scan or audit, the HMAC is verified before the baseline commit is trusted. Any verification failure causes an immediate exit with an error.
194
+
195
+ Format-downgrade protection — if PIPEWATCH_HMAC_KEY is set and the baseline file is in plain-text format (a raw commit SHA rather than signed JSON), 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.
196
+
197
+ Store the key in a CI secret (PIPEWATCH_HMAC_KEY: ${{ secrets.PIPEWATCH_HMAC_KEY }}).
198
+
199
+ Pipeline Integration
200
+ yaml
201
+ - name: pipewatch audit
202
+ env:
203
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
204
+ PIPEWATCH_HMAC_KEY: ${{ secrets.PIPEWATCH_HMAC_KEY }}
205
+ run: |
206
+ pipewatch audit --verify-shas --json | tee pw-report.json
207
+ jq -e '.summary.HIGH == 0 and .summary.CRITICAL == 0' pw-report.json
208
+
209
+ Use init-runner to add runner environment monitoring alongside the audit step.
210
+
211
+ Design Decisions
212
+
213
+ 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.
214
+
215
+ Volatile variable exclusion — snapshot strips run-specific GitHub variables so that env-diff doesn't generate noise on every comparison. Only structurally stable variables that could indicate environment manipulation are tracked. Variables whose names suggest credentials (containing token, secret, key, password, etc.) are also excluded so secrets are never written to the snapshot file or the Actions cache.
216
+
217
+ Conservative SHA verification — --verify-shas treats network failures as non-findings. A flaky connection or GitHub API outage should not produce spurious HIGH alerts.
218
+
219
+ Stdlib-first — pyyaml is the only dependency. The tool audits supply-chain risk; its own footprint is minimal by design.
220
+
221
+ Platform Support
222
+ Platform Coverage
223
+ GitHub Actions (.github/workflows/*.yml) Full — file diff, step fingerprinting, static analysis, pin audit
224
+ GitLab CI (.gitlab-ci.yml) File diff + before_script / script / after_script fingerprinting
225
+ Jenkins (Jenkinsfile) File diff + best-effort stage / sh / bat fingerprinting (regex-based — not a Groovy parser)
226
+ License
227
+
228
+ Licensed under CC BY 4.0. See LICENSE.