envcert 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.
Files changed (38) hide show
  1. envcert-0.1.0/.gitignore +18 -0
  2. envcert-0.1.0/LICENSE +187 -0
  3. envcert-0.1.0/PKG-INFO +204 -0
  4. envcert-0.1.0/README.md +172 -0
  5. envcert-0.1.0/envcert/__init__.py +5 -0
  6. envcert-0.1.0/envcert/__main__.py +6 -0
  7. envcert-0.1.0/envcert/adapters/__init__.py +0 -0
  8. envcert-0.1.0/envcert/adapters/base.py +67 -0
  9. envcert-0.1.0/envcert/adapters/generic.py +40 -0
  10. envcert-0.1.0/envcert/adapters/harbor.py +96 -0
  11. envcert-0.1.0/envcert/attestations/__init__.py +0 -0
  12. envcert-0.1.0/envcert/attestations/intoto.py +87 -0
  13. envcert-0.1.0/envcert/checks/__init__.py +0 -0
  14. envcert-0.1.0/envcert/checks/base.py +68 -0
  15. envcert-0.1.0/envcert/checks/dynamic_checks.py +132 -0
  16. envcert-0.1.0/envcert/checks/mutation.py +142 -0
  17. envcert-0.1.0/envcert/checks/static_checks.py +796 -0
  18. envcert-0.1.0/envcert/cli/__init__.py +0 -0
  19. envcert-0.1.0/envcert/cli/main.py +269 -0
  20. envcert-0.1.0/envcert/core/__init__.py +0 -0
  21. envcert-0.1.0/envcert/core/config.py +139 -0
  22. envcert-0.1.0/envcert/core/digests.py +45 -0
  23. envcert-0.1.0/envcert/core/engine.py +141 -0
  24. envcert-0.1.0/envcert/core/errors.py +10 -0
  25. envcert-0.1.0/envcert/core/models.py +72 -0
  26. envcert-0.1.0/envcert/reports/__init__.py +0 -0
  27. envcert-0.1.0/envcert/reports/sarif.py +51 -0
  28. envcert-0.1.0/envcert/reports/text.py +35 -0
  29. envcert-0.1.0/envcert/runners/__init__.py +0 -0
  30. envcert-0.1.0/envcert/runners/base.py +32 -0
  31. envcert-0.1.0/envcert/runners/docker_runner.py +95 -0
  32. envcert-0.1.0/envcert/runners/local_runner.py +79 -0
  33. envcert-0.1.0/envcert/schemas/__init__.py +0 -0
  34. envcert-0.1.0/envcert/schemas/report.schema.json +65 -0
  35. envcert-0.1.0/envcert/utils/__init__.py +0 -0
  36. envcert-0.1.0/envcert/utils/dockerfile.py +105 -0
  37. envcert-0.1.0/envcert/utils/files.py +86 -0
  38. envcert-0.1.0/pyproject.toml +71 -0
@@ -0,0 +1,18 @@
1
+ __pycache__/
2
+ *.py[cod]
3
+ *.egg-info/
4
+ dist/
5
+ build/
6
+ .venv/
7
+ venv/
8
+ .pytest_cache/
9
+ .mypy_cache/
10
+ .ruff_cache/
11
+ .coverage
12
+ htmlcov/
13
+ *.sarif
14
+ report.json
15
+ attestation.json
16
+ .DS_Store
17
+ .idea/
18
+ .vscode/
envcert-0.1.0/LICENSE ADDED
@@ -0,0 +1,187 @@
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
13
+ copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all other
16
+ entities that control, are controlled by, or are under common control with
17
+ that entity. For the purposes of this definition, "control" means (i) the
18
+ power, direct or indirect, to cause the direction or management of such
19
+ entity, whether by contract or otherwise, or (ii) ownership of fifty percent
20
+ (50%) or more of the outstanding shares, or (iii) beneficial ownership of
21
+ such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity exercising
24
+ permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation source,
28
+ and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical transformation
31
+ or translation of a Source form, including but not limited to compiled
32
+ object code, generated documentation, and conversions to other media types.
33
+
34
+ "Work" shall mean the work of authorship, whether in Source or Object
35
+ form, made available under the License, as indicated by a copyright notice
36
+ that is included in or attached to (an example is provided in the Appendix
37
+ below) the work.
38
+
39
+ "Derivative Works" shall mean any work, whether in Source or Object form,
40
+ that is based on (or derived from) the Work and for which the editorial
41
+ revisions, annotations, elaborations, or other modifications represent, as
42
+ a whole, an original work of authorship. For the purposes of this License,
43
+ Derivative Works shall not include works that remain separable from, or
44
+ merely link (or bind by name) to the interfaces of, the Work and Derivative
45
+ Works thereof.
46
+
47
+ "Contribution" shall mean any work of authorship, including the original
48
+ version of the Work and any modifications or additions to that Work or
49
+ Derivative Works thereof, that is intentionally submitted to Licensor for
50
+ inclusion in the Work by the copyright owner or by an individual or Legal
51
+ Entity authorized to submit on behalf of the copyright owner. For the
52
+ purposes of this definition, "submitted" means any form of electronic,
53
+ verbal, or written communication sent to the Licensor or its
54
+ representatives, including but not limited to communication on electronic
55
+ mailing lists, source code control systems, and issue tracking systems that
56
+ are managed by, or on behalf of, the Licensor for the purpose of discussing
57
+ and improving the Work, but excluding communication that is conspicuously
58
+ marked or otherwise designated in writing by the copyright owner as "Not a
59
+ Contribution."
60
+
61
+ "Contributor" shall mean Licensor and any individual or Legal Entity on
62
+ behalf of whom a Contribution has been received by Licensor and
63
+ subsequently incorporated within the Work.
64
+
65
+ 2. Grant of Copyright License. Subject to the terms and conditions of this
66
+ License, each Contributor hereby grants to You a perpetual, worldwide,
67
+ non-exclusive, no-charge, royalty-free, irrevocable copyright license to
68
+ reproduce, prepare Derivative Works of, publicly display, publicly perform,
69
+ sublicense, and distribute the Work and such Derivative Works in Source or
70
+ Object form.
71
+
72
+ 3. Grant of Patent License. Subject to the terms and conditions of this
73
+ License, each Contributor hereby grants to You a perpetual, worldwide,
74
+ non-exclusive, no-charge, royalty-free, irrevocable (except as stated in
75
+ this section) patent license to make, have made, use, offer to sell, sell,
76
+ import, and otherwise transfer the Work, where such license applies only to
77
+ those patent claims licensable by such Contributor that are necessarily
78
+ infringed by their Contribution(s) alone or by combination of their
79
+ Contribution(s) with the Work to which such Contribution(s) was submitted.
80
+ If You institute patent litigation against any entity (including a
81
+ cross-claim or counterclaim in a lawsuit) alleging that the Work or a
82
+ Contribution incorporated within the Work constitutes direct or contributory
83
+ patent infringement, then any patent licenses granted to You under this
84
+ License for that Work shall terminate as of the date such litigation is filed.
85
+
86
+ 4. Redistribution. You may reproduce and distribute copies of the Work or
87
+ Derivative Works thereof in any medium, with or without modifications, and
88
+ in Source or Object form, provided that You meet the following conditions:
89
+
90
+ (a) You must give any other recipients of the Work or Derivative Works a
91
+ copy of this License; and
92
+
93
+ (b) You must cause any modified files to carry prominent notices stating
94
+ that You changed the files; and
95
+
96
+ (c) You must retain, in the Source form of any Derivative Works that You
97
+ distribute, all copyright, patent, trademark, and attribution notices from
98
+ the Source form of the Work, excluding those notices that do not pertain to
99
+ any part of the Derivative Works; and
100
+
101
+ (d) If the Work includes a "NOTICE" text file as part of its distribution,
102
+ then any Derivative Works that You distribute must include a readable copy
103
+ of the attribution notices contained within such NOTICE file, in at least
104
+ one of the following places: within a NOTICE text file distributed as part
105
+ of the Derivative Works; within the Source form or documentation, if
106
+ provided along with the Derivative Works; or, within a display generated by
107
+ the Derivative Works, if and wherever such third-party notices normally
108
+ appear. The contents of the NOTICE file are for informational purposes only
109
+ and do not modify the License. You may add Your own attribution notices
110
+ within Derivative Works that You distribute, alongside or as an addendum to
111
+ the NOTICE text from the Work, provided that such additional attribution
112
+ notices cannot be construed as modifying the License.
113
+
114
+ You may add Your own copyright statement to Your modifications and may
115
+ provide additional or different license terms and conditions for use,
116
+ reproduction, or distribution of Your modifications, or for any such
117
+ Derivative Works as a whole, provided Your use, reproduction, and
118
+ distribution of the Work otherwise complies with the conditions stated in
119
+ this License.
120
+
121
+ 5. Submission of Contributions. Unless You explicitly state otherwise, any
122
+ Contribution intentionally submitted for inclusion in the Work by You to the
123
+ Licensor shall be under the terms and conditions of this License, without
124
+ any additional terms or conditions. Notwithstanding the above, nothing
125
+ herein shall supersede or modify the terms of any separate license
126
+ agreement you may have executed with Licensor regarding such Contributions.
127
+
128
+ 6. Trademarks. This License does not grant permission to use the trade
129
+ names, trademarks, service marks, or product names of the Licensor, except
130
+ as required for reasonable and customary use in describing the origin of
131
+ the Work and reproducing the content of the NOTICE file.
132
+
133
+ 7. Disclaimer of Warranty. Unless required by applicable law or agreed to
134
+ in writing, Licensor provides the Work (and each Contributor provides its
135
+ Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
136
+ ANY KIND, either express or implied, including, without limitation, any
137
+ warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or
138
+ FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for
139
+ determining the appropriateness of using or redistributing the Work and
140
+ assume any risks associated with Your use of this Document.
141
+
142
+ 8. Limitation of Liability. In no event and under no legal theory, whether
143
+ in tort (including negligence), contract, or otherwise, unless required by
144
+ applicable law (such as deliberate and grossly negligent acts) or agreed
145
+ to in writing, shall any Contributor be liable to You for damages,
146
+ including any direct, indirect, special, incidental, or consequential
147
+ damages of any character arising as a result of this License or out of the
148
+ use or inability to use the Work (including but not limited to damages for
149
+ loss of goodwill, work stoppage, computer failure or malfunction, or any
150
+ and all other commercial damages or losses), even if such Contributor has
151
+ been advised of the possibility of such damages.
152
+
153
+ 9. Accepting Warranty or Additional Liability. While redistributing the
154
+ Work or Derivative Works thereof, You may choose to offer, and charge a fee
155
+ for, acceptance of support, warranty, indemnity, or other liability
156
+ obligations and/or rights consistent with this License. However, in
157
+ accepting such obligations, You may act only on Your own behalf and on
158
+ Your sole responsibility, not on behalf of any other Contributor, and only
159
+ if You agree to indemnify, defend, and hold each Contributor harmless for
160
+ any liability incurred by, or claims asserted against, such Contributor by
161
+ reason of your accepting any such warranty or additional liability.
162
+
163
+ END OF TERMS AND CONDITIONS
164
+
165
+ APPENDIX: How to apply the Apache License to your work.
166
+
167
+ To apply the Apache License to your work, attach the following boilerplate
168
+ notice, with the fields enclosed by brackets "[]" replaced with your own
169
+ identifying information. (Don't include the brackets!) The text should be
170
+ enclosed in the appropriate comment syntax for the file format. We also
171
+ recommend that a file or class name and description of purpose be included
172
+ on the same "printed page" as the copyright notice for easier
173
+ identification within third-party archives.
174
+
175
+ Copyright 2026 EnvCert contributors
176
+
177
+ Licensed under the Apache License, Version 2.0 (the "License");
178
+ you may not use this file except in compliance with the License.
179
+ You may obtain a copy of the License at
180
+
181
+ http://www.apache.org/licenses/LICENSE-2.0
182
+
183
+ Unless required by applicable law or agreed to in writing, software
184
+ distributed under the License is distributed on an "AS IS" BASIS,
185
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
186
+ See the License for the specific language governing permissions and
187
+ limitations under the License.
envcert-0.1.0/PKG-INFO ADDED
@@ -0,0 +1,204 @@
1
+ Metadata-Version: 2.4
2
+ Name: envcert
3
+ Version: 0.1.0
4
+ Summary: Independent, extensible integrity verification and evidence generation for AI training and evaluation environments
5
+ Project-URL: Homepage, https://github.com/EricMaxwellnetizen/envcert
6
+ Project-URL: Repository, https://github.com/EricMaxwellnetizen/envcert
7
+ Project-URL: Issues, https://github.com/EricMaxwellnetizen/envcert/issues
8
+ Author: EnvCert contributors
9
+ License: Apache-2.0
10
+ License-File: LICENSE
11
+ Keywords: ai,attestation,benchmark,evaluation,harbor,reward-hacking,verification
12
+ Classifier: Development Status :: 3 - Alpha
13
+ Classifier: Intended Audience :: Developers
14
+ Classifier: Programming Language :: Python :: 3
15
+ Classifier: Programming Language :: Python :: 3.11
16
+ Classifier: Programming Language :: Python :: 3.12
17
+ Classifier: Programming Language :: Python :: 3.13
18
+ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
19
+ Classifier: Topic :: Software Development :: Testing
20
+ Requires-Python: >=3.11
21
+ Provides-Extra: dev
22
+ Requires-Dist: build>=1.2; extra == 'dev'
23
+ Requires-Dist: jsonschema>=4.20; extra == 'dev'
24
+ Requires-Dist: mypy>=1.10; extra == 'dev'
25
+ Requires-Dist: pytest-cov>=5.0; extra == 'dev'
26
+ Requires-Dist: pytest>=8.0; extra == 'dev'
27
+ Requires-Dist: ruff>=0.6; extra == 'dev'
28
+ Requires-Dist: twine>=5.0; extra == 'dev'
29
+ Provides-Extra: validate
30
+ Requires-Dist: jsonschema>=4.20; extra == 'validate'
31
+ Description-Content-Type: text/markdown
32
+
33
+ # EnvCert
34
+
35
+ **Integrity verification and evidence for AI training and evaluation environments.**
36
+
37
+ EnvCert checks whether an AI evaluation environment — a task bundle with an
38
+ instruction, a Docker environment, a reference solution and a verifier — is
39
+ actually trustworthy: Is the answer leaked to the agent? Can agent-controlled
40
+ files influence the verifier? Would an incorrect solution pass? Is the build
41
+ reproducible, the network policy declared, the evidence reproducible?
42
+
43
+ It answers with explicit, deterministic findings (never a single score),
44
+ a schema-versioned JSON report, SARIF for code scanning, and an optional
45
+ digest-bound [in-toto](https://in-toto.io) attestation.
46
+
47
+ EnvCert is **not** a certification authority and never claims an environment
48
+ is unhackable. It is an independent, extensible verification and evidence
49
+ layer — complementary to Harbor / NeMo Gym (which run tasks), BenchJack /
50
+ trustworthy-env (which hunt exploits with AI agents), and Trivy/Hadolint/
51
+ Semgrep (CVE/lint/SAST). See `docs/research/COMPETITIVE_ANALYSIS.md`.
52
+
53
+ ## Who is it for?
54
+
55
+ Environment developers, benchmark maintainers, AI researchers and model
56
+ developers who publish or consume evaluation tasks and need to know *what
57
+ was checked, what failed, what could not be checked, and whether someone
58
+ else can reproduce that*.
59
+
60
+ ## Install
61
+
62
+ Requires Python 3.11+.
63
+
64
+ ```bash
65
+ pip install envcert # once published to PyPI
66
+ # From this repository (current):
67
+ pip install .
68
+ pipx install . # or isolated
69
+ ```
70
+
71
+ The core has **zero runtime dependencies**: static analysis works offline,
72
+ with no Docker, account, network or API key.
73
+
74
+ ## Quick start
75
+
76
+ ```bash
77
+ envcert check ./examples/safe-environment
78
+ envcert check ./examples/intentionally-vulnerable-environment # exit 1: try it
79
+ envcert check ./my-task --format json --output report.json
80
+ envcert check ./my-task --format sarif --output envcert.sarif
81
+ envcert verify report.json --task ./my-task
82
+ envcert list-checks
83
+ envcert explain EC011
84
+ ```
85
+
86
+ Real output (safe example, abridged):
87
+
88
+ ```text
89
+ EnvCert 0.1.0 report schema 1.0.0
90
+ Task: envcert/hello-file adapter=harbor files=8
91
+ Profile: harbor execution: none fail_on: CRITICAL, HIGH
92
+
93
+ [PASS] EC001 (INFO/PASS) Task structure is recognisable and complete
94
+ [PASS] EC011 (INFO/PASS) Reference solution is not copied into the agent environment
95
+ [PASS] EC020 (INFO/PASS) Verifier runs separated from the agent where the framework supports it
96
+ [PASS] EC051 (INFO/PASS) Verifier produces a reward in the framework's expected location
97
+ [SKIP] EC060 (INFO/NOT_RUN) Reference (gold) solution passes the verifier
98
+ Dynamic checks are opt-in: re-run with --execution docker or --execution local-python.
99
+ Summary: 28 findings {'PASS': 24, 'NOT_RUN': 4}
100
+ Policy: PASSED (fail_on=CRITICAL, HIGH)
101
+ ```
102
+
103
+ The intentionally vulnerable example produces (among others):
104
+
105
+ ```text
106
+ [FAIL] EC010 (HIGH/FAIL) .git metadata is inside the Docker build context and not excluded by .dockerignore
107
+ [FAIL] EC011 (CRITICAL/FAIL) Reference/answer material inside the build context is plausibly copied into the image by 'COPY .'
108
+ [FAIL] EC052 (CRITICAL/FAIL) Possible unconditional-success path in verifier: unconditional 'echo 1 > reward.txt'
109
+ [WARN] EC021 (HIGH/WARN) 'environment/conftest.py' is in an agent-visible area and pytest auto-loads conftest.py ...
110
+ ```
111
+
112
+ ## What it checks
113
+
114
+ 28 checks with stable public IDs (full catalog:
115
+ `docs/architecture/CHECK_CATALOG.md`, or `envcert list-checks -v`):
116
+
117
+ | Area | Checks | Examples |
118
+ |---|---|---|
119
+ | Structure | EC001–EC003 | missing verifier/instruction, absent reference solution |
120
+ | Leakage | EC010–EC014 | .git in build context, solution copied into image, gold files, hard-coded secrets, instruction disclosing the solution |
121
+ | Agent/verifier boundary | EC020–EC024 | shared verifier mode, sitecustomize/conftest shadowing, PATH tool shadowing, world-writable paths, docker.sock/privileged |
122
+ | Docker | EC030–EC033 | unpinned base images, root user, remote ADD / curl\|sh, undeclared network policy |
123
+ | Dependencies | EC040–EC041 | unpinned pip deps, unverified downloads |
124
+ | Verifier quality | EC050–EC054 | missing/empty verifier, no reward production, unconditional success, assertion-free tests, self-reported rewards |
125
+ | Dynamic (opt-in) | EC060–EC062 | gold run, no-op negative control, repeatability |
126
+ | Mutation (opt-in) | EC063 | AST mutants of a Python solution; rejection rate as a strength signal |
127
+
128
+ Every finding carries evidence, a severity, a confidence, a remediation and
129
+ stated limitations. Heuristics report WARN — EnvCert does not present a
130
+ potential exposure as a confirmed vulnerability.
131
+
132
+ ## What it cannot do
133
+
134
+ - Prove a verifier semantically correct, or an environment unhackable.
135
+ - See runtime mounts/configuration outside the task bundle (static mode).
136
+ - Scan base images for CVEs (use Trivy/Grype) or replace an adversarial
137
+ audit (BenchJack-style) for high-stakes benchmarks.
138
+ - Dynamic Docker checks need a Docker daemon; `local-python` execution has
139
+ **no sandbox** and must only be used on trusted tasks. See
140
+ `docs/guides/DYNAMIC_EXECUTION.md`.
141
+
142
+ ## Dynamic & mutation checks (opt-in)
143
+
144
+ ```bash
145
+ envcert check ./my-harbor-task --execution docker # restricted container run
146
+ envcert check ./examples/python-task --execution local-python --mutation
147
+ # EC060 PASS gold, EC061 PASS no-op rejected, EC062 PASS repeatable, EC063 mutation rejection rate
148
+ ```
149
+
150
+ ## Reports, verification, attestations
151
+
152
+ ```bash
153
+ envcert check ./my-task --format json --output report.json
154
+ envcert verify report.json --task ./my-task # schema + bundle-digest recomputation
155
+ envcert schema # published JSON Schema (report 1.0.0)
156
+ envcert attest report.json --output attestation.json # in-toto Test Result statement
157
+ envcert attest report.json --dsse --sign --key cosign.key # DSSE + Cosign, when installed
158
+ ```
159
+
160
+ Unsigned attestations are labelled unsigned everywhere — they are portable
161
+ evidence records, not cryptographic proof. Report fields and the attestation
162
+ extension are specified in `docs/architecture/REPORT_SCHEMA.md`.
163
+
164
+ ## GitHub Actions
165
+
166
+ See `action.yml` (composite action), `examples/github-actions/` and
167
+ `docs/guides/CI.md`. Static checks by default; dynamic execution only when
168
+ you explicitly select it.
169
+
170
+ Exit codes: `0` policy passed · `1` policy failed · `2` invalid
171
+ input/config · `3` internal/execution error.
172
+
173
+ ## Supported formats
174
+
175
+ | Format | Status |
176
+ |---|---|
177
+ | Harbor task directories (task.toml schema 1.x) | Implemented and fixture-tested |
178
+ | Generic Docker task bundles (Dockerfile + tests/solution) | Implemented, reduced-confidence heuristics |
179
+ | NeMo Gym JSONL/resources layouts, Inspect AI tasks | Not yet — roadmap, not promised (`docs/architecture/ROADMAP.md`) |
180
+
181
+ ## Configuration
182
+
183
+ `envcert init` writes `envcert.toml` (profiles: harbor/strict/minimal/ci,
184
+ per-check enable/disable, `fail_on` policy). See `docs/guides/CONFIGURATION.md`.
185
+
186
+ ## Contributing
187
+
188
+ See `CONTRIBUTING.md` and `docs/guides/WRITING_A_CHECK.md` — adding a check
189
+ needs a triggering fixture *and* a near-miss false-positive control.
190
+
191
+ ## Development
192
+
193
+ ```bash
194
+ pip install -e ".[dev]"
195
+ pytest --cov=envcert
196
+ ruff check envcert tests
197
+ mypy envcert
198
+ python -m build
199
+ ```
200
+
201
+ ## Licence
202
+
203
+ Apache-2.0. Research and design rationale: `docs/research/`,
204
+ `docs/architecture/`. Release status: `RELEASE_READINESS.md`.
@@ -0,0 +1,172 @@
1
+ # EnvCert
2
+
3
+ **Integrity verification and evidence for AI training and evaluation environments.**
4
+
5
+ EnvCert checks whether an AI evaluation environment — a task bundle with an
6
+ instruction, a Docker environment, a reference solution and a verifier — is
7
+ actually trustworthy: Is the answer leaked to the agent? Can agent-controlled
8
+ files influence the verifier? Would an incorrect solution pass? Is the build
9
+ reproducible, the network policy declared, the evidence reproducible?
10
+
11
+ It answers with explicit, deterministic findings (never a single score),
12
+ a schema-versioned JSON report, SARIF for code scanning, and an optional
13
+ digest-bound [in-toto](https://in-toto.io) attestation.
14
+
15
+ EnvCert is **not** a certification authority and never claims an environment
16
+ is unhackable. It is an independent, extensible verification and evidence
17
+ layer — complementary to Harbor / NeMo Gym (which run tasks), BenchJack /
18
+ trustworthy-env (which hunt exploits with AI agents), and Trivy/Hadolint/
19
+ Semgrep (CVE/lint/SAST). See `docs/research/COMPETITIVE_ANALYSIS.md`.
20
+
21
+ ## Who is it for?
22
+
23
+ Environment developers, benchmark maintainers, AI researchers and model
24
+ developers who publish or consume evaluation tasks and need to know *what
25
+ was checked, what failed, what could not be checked, and whether someone
26
+ else can reproduce that*.
27
+
28
+ ## Install
29
+
30
+ Requires Python 3.11+.
31
+
32
+ ```bash
33
+ pip install envcert # once published to PyPI
34
+ # From this repository (current):
35
+ pip install .
36
+ pipx install . # or isolated
37
+ ```
38
+
39
+ The core has **zero runtime dependencies**: static analysis works offline,
40
+ with no Docker, account, network or API key.
41
+
42
+ ## Quick start
43
+
44
+ ```bash
45
+ envcert check ./examples/safe-environment
46
+ envcert check ./examples/intentionally-vulnerable-environment # exit 1: try it
47
+ envcert check ./my-task --format json --output report.json
48
+ envcert check ./my-task --format sarif --output envcert.sarif
49
+ envcert verify report.json --task ./my-task
50
+ envcert list-checks
51
+ envcert explain EC011
52
+ ```
53
+
54
+ Real output (safe example, abridged):
55
+
56
+ ```text
57
+ EnvCert 0.1.0 report schema 1.0.0
58
+ Task: envcert/hello-file adapter=harbor files=8
59
+ Profile: harbor execution: none fail_on: CRITICAL, HIGH
60
+
61
+ [PASS] EC001 (INFO/PASS) Task structure is recognisable and complete
62
+ [PASS] EC011 (INFO/PASS) Reference solution is not copied into the agent environment
63
+ [PASS] EC020 (INFO/PASS) Verifier runs separated from the agent where the framework supports it
64
+ [PASS] EC051 (INFO/PASS) Verifier produces a reward in the framework's expected location
65
+ [SKIP] EC060 (INFO/NOT_RUN) Reference (gold) solution passes the verifier
66
+ Dynamic checks are opt-in: re-run with --execution docker or --execution local-python.
67
+ Summary: 28 findings {'PASS': 24, 'NOT_RUN': 4}
68
+ Policy: PASSED (fail_on=CRITICAL, HIGH)
69
+ ```
70
+
71
+ The intentionally vulnerable example produces (among others):
72
+
73
+ ```text
74
+ [FAIL] EC010 (HIGH/FAIL) .git metadata is inside the Docker build context and not excluded by .dockerignore
75
+ [FAIL] EC011 (CRITICAL/FAIL) Reference/answer material inside the build context is plausibly copied into the image by 'COPY .'
76
+ [FAIL] EC052 (CRITICAL/FAIL) Possible unconditional-success path in verifier: unconditional 'echo 1 > reward.txt'
77
+ [WARN] EC021 (HIGH/WARN) 'environment/conftest.py' is in an agent-visible area and pytest auto-loads conftest.py ...
78
+ ```
79
+
80
+ ## What it checks
81
+
82
+ 28 checks with stable public IDs (full catalog:
83
+ `docs/architecture/CHECK_CATALOG.md`, or `envcert list-checks -v`):
84
+
85
+ | Area | Checks | Examples |
86
+ |---|---|---|
87
+ | Structure | EC001–EC003 | missing verifier/instruction, absent reference solution |
88
+ | Leakage | EC010–EC014 | .git in build context, solution copied into image, gold files, hard-coded secrets, instruction disclosing the solution |
89
+ | Agent/verifier boundary | EC020–EC024 | shared verifier mode, sitecustomize/conftest shadowing, PATH tool shadowing, world-writable paths, docker.sock/privileged |
90
+ | Docker | EC030–EC033 | unpinned base images, root user, remote ADD / curl\|sh, undeclared network policy |
91
+ | Dependencies | EC040–EC041 | unpinned pip deps, unverified downloads |
92
+ | Verifier quality | EC050–EC054 | missing/empty verifier, no reward production, unconditional success, assertion-free tests, self-reported rewards |
93
+ | Dynamic (opt-in) | EC060–EC062 | gold run, no-op negative control, repeatability |
94
+ | Mutation (opt-in) | EC063 | AST mutants of a Python solution; rejection rate as a strength signal |
95
+
96
+ Every finding carries evidence, a severity, a confidence, a remediation and
97
+ stated limitations. Heuristics report WARN — EnvCert does not present a
98
+ potential exposure as a confirmed vulnerability.
99
+
100
+ ## What it cannot do
101
+
102
+ - Prove a verifier semantically correct, or an environment unhackable.
103
+ - See runtime mounts/configuration outside the task bundle (static mode).
104
+ - Scan base images for CVEs (use Trivy/Grype) or replace an adversarial
105
+ audit (BenchJack-style) for high-stakes benchmarks.
106
+ - Dynamic Docker checks need a Docker daemon; `local-python` execution has
107
+ **no sandbox** and must only be used on trusted tasks. See
108
+ `docs/guides/DYNAMIC_EXECUTION.md`.
109
+
110
+ ## Dynamic & mutation checks (opt-in)
111
+
112
+ ```bash
113
+ envcert check ./my-harbor-task --execution docker # restricted container run
114
+ envcert check ./examples/python-task --execution local-python --mutation
115
+ # EC060 PASS gold, EC061 PASS no-op rejected, EC062 PASS repeatable, EC063 mutation rejection rate
116
+ ```
117
+
118
+ ## Reports, verification, attestations
119
+
120
+ ```bash
121
+ envcert check ./my-task --format json --output report.json
122
+ envcert verify report.json --task ./my-task # schema + bundle-digest recomputation
123
+ envcert schema # published JSON Schema (report 1.0.0)
124
+ envcert attest report.json --output attestation.json # in-toto Test Result statement
125
+ envcert attest report.json --dsse --sign --key cosign.key # DSSE + Cosign, when installed
126
+ ```
127
+
128
+ Unsigned attestations are labelled unsigned everywhere — they are portable
129
+ evidence records, not cryptographic proof. Report fields and the attestation
130
+ extension are specified in `docs/architecture/REPORT_SCHEMA.md`.
131
+
132
+ ## GitHub Actions
133
+
134
+ See `action.yml` (composite action), `examples/github-actions/` and
135
+ `docs/guides/CI.md`. Static checks by default; dynamic execution only when
136
+ you explicitly select it.
137
+
138
+ Exit codes: `0` policy passed · `1` policy failed · `2` invalid
139
+ input/config · `3` internal/execution error.
140
+
141
+ ## Supported formats
142
+
143
+ | Format | Status |
144
+ |---|---|
145
+ | Harbor task directories (task.toml schema 1.x) | Implemented and fixture-tested |
146
+ | Generic Docker task bundles (Dockerfile + tests/solution) | Implemented, reduced-confidence heuristics |
147
+ | NeMo Gym JSONL/resources layouts, Inspect AI tasks | Not yet — roadmap, not promised (`docs/architecture/ROADMAP.md`) |
148
+
149
+ ## Configuration
150
+
151
+ `envcert init` writes `envcert.toml` (profiles: harbor/strict/minimal/ci,
152
+ per-check enable/disable, `fail_on` policy). See `docs/guides/CONFIGURATION.md`.
153
+
154
+ ## Contributing
155
+
156
+ See `CONTRIBUTING.md` and `docs/guides/WRITING_A_CHECK.md` — adding a check
157
+ needs a triggering fixture *and* a near-miss false-positive control.
158
+
159
+ ## Development
160
+
161
+ ```bash
162
+ pip install -e ".[dev]"
163
+ pytest --cov=envcert
164
+ ruff check envcert tests
165
+ mypy envcert
166
+ python -m build
167
+ ```
168
+
169
+ ## Licence
170
+
171
+ Apache-2.0. Research and design rationale: `docs/research/`,
172
+ `docs/architecture/`. Release status: `RELEASE_READINESS.md`.
@@ -0,0 +1,5 @@
1
+ """EnvCert: integrity verification and evidence for AI evaluation environments."""
2
+
3
+ __version__ = "0.1.0"
4
+ REPORT_SCHEMA_VERSION = "1.0.0"
5
+ __all__ = ["__version__", "REPORT_SCHEMA_VERSION"]
@@ -0,0 +1,6 @@
1
+ import sys
2
+
3
+ from envcert.cli.main import main
4
+
5
+ if __name__ == "__main__":
6
+ sys.exit(main())
File without changes
@@ -0,0 +1,67 @@
1
+ from __future__ import annotations
2
+
3
+ from dataclasses import dataclass, field
4
+ from pathlib import Path
5
+ from typing import Any
6
+
7
+ from envcert.utils.dockerfile import Dockerfile, parse_dockerfile
8
+ from envcert.utils.files import iter_task_files, read_text_safe
9
+
10
+
11
+ @dataclass
12
+ class TaskContext:
13
+ root: Path
14
+ adapter: str
15
+ task_name: str = ""
16
+ config: dict[str, Any] = field(default_factory=dict)
17
+ config_path: Path | None = None
18
+ files: list[str] = field(default_factory=list)
19
+ symlinks: list[str] = field(default_factory=list)
20
+ instruction_path: Path | None = None
21
+ dockerfile_path: Path | None = None
22
+ dockerfile: Dockerfile | None = None
23
+ dockerignore_patterns: list[str] = field(default_factory=list)
24
+ build_context: Path | None = None
25
+ tests_dir: Path | None = None
26
+ solution_dir: Path | None = None
27
+ environment_dir: Path | None = None
28
+ warnings: list[str] = field(default_factory=list)
29
+ _text_cache: dict[str, str | None] = field(default_factory=dict, repr=False)
30
+
31
+ def text(self, rel: str) -> str | None:
32
+ if rel not in self._text_cache:
33
+ self._text_cache[rel] = read_text_safe(self.root / rel)
34
+ return self._text_cache[rel]
35
+
36
+ def abs(self, rel: str) -> Path:
37
+ return self.root / rel
38
+
39
+ def files_under(self, prefix: str) -> list[str]:
40
+ prefix = prefix.strip("/") + "/"
41
+ return [f for f in self.files if f == prefix[:-1] or f.startswith(prefix)]
42
+
43
+ def has(self, rel: str) -> bool:
44
+ return rel in self.files
45
+
46
+
47
+ def load_dockerfile(ctx: TaskContext, dockerfile_rel: str, context_rel: str) -> None:
48
+ ctx.dockerfile_path = ctx.root / dockerfile_rel
49
+ text = ctx.text(dockerfile_rel)
50
+ if text is not None:
51
+ ctx.dockerfile = parse_dockerfile(text)
52
+ ctx.build_context = ctx.root / context_rel if context_rel else ctx.root
53
+ ignore = ctx.build_context / ".dockerignore"
54
+ if ignore.is_file():
55
+ content = read_text_safe(ignore) or ""
56
+ ctx.dockerignore_patterns = [ln.strip() for ln in content.splitlines() if ln.strip() and not ln.strip().startswith("#")]
57
+ env_ignore = ctx.root / ".dockerignore"
58
+ if not ctx.dockerignore_patterns and env_ignore.is_file():
59
+ content = read_text_safe(env_ignore) or ""
60
+ ctx.dockerignore_patterns = [ln.strip() for ln in content.splitlines() if ln.strip() and not ln.strip().startswith("#")]
61
+
62
+
63
+ def scan_files(ctx: TaskContext) -> None:
64
+ for rel, _path, is_link in iter_task_files(ctx.root):
65
+ ctx.files.append(rel)
66
+ if is_link:
67
+ ctx.symlinks.append(rel)