guardana-reference-pack 0.1.2__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.
- guardana_reference_pack-0.1.2/.gitignore +47 -0
- guardana_reference_pack-0.1.2/LICENSE +202 -0
- guardana_reference_pack-0.1.2/PKG-INFO +99 -0
- guardana_reference_pack-0.1.2/README.md +85 -0
- guardana_reference_pack-0.1.2/guardana-lock.yaml +23 -0
- guardana_reference_pack-0.1.2/pyproject.toml +41 -0
- guardana_reference_pack-0.1.2/src/guardana_reference_pack/__init__.py +71 -0
- guardana_reference_pack-0.1.2/src/guardana_reference_pack/controls.py +40 -0
- guardana_reference_pack-0.1.2/src/guardana_reference_pack/evaluator.py +34 -0
- guardana_reference_pack-0.1.2/src/guardana_reference_pack/file_reporter.py +90 -0
- guardana_reference_pack-0.1.2/src/guardana_reference_pack/guardana-pack.yaml +28 -0
- guardana_reference_pack-0.1.2/src/guardana_reference_pack/py.typed +0 -0
- guardana_reference_pack-0.1.2/src/guardana_reference_pack/rules/codename_disclosure.yaml +27 -0
- guardana_reference_pack-0.1.2/src/guardana_reference_pack/summary.py +103 -0
- guardana_reference_pack-0.1.2/src/guardana_reference_pack/target.py +66 -0
- guardana_reference_pack-0.1.2/src/guardana_reference_pack/unpinned.py +200 -0
- guardana_reference_pack-0.1.2/tests/test_reference_commands.py +140 -0
- guardana_reference_pack-0.1.2/tests/test_reference_outputs.py +101 -0
- guardana_reference_pack-0.1.2/tests/test_reference_rules.py +139 -0
- guardana_reference_pack-0.1.2/tests/test_reference_surface.py +144 -0
- guardana_reference_pack-0.1.2/tests/test_reference_target.py +59 -0
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
__pycache__/
|
|
2
|
+
*.py[cod]
|
|
3
|
+
.venv/
|
|
4
|
+
.uv/
|
|
5
|
+
/dist/
|
|
6
|
+
# Written by scripts/generate_sbom.py; published as release assets, never committed.
|
|
7
|
+
sbom/
|
|
8
|
+
/build/
|
|
9
|
+
*.egg-info/
|
|
10
|
+
**/*.egg-info/
|
|
11
|
+
.mypy_cache/
|
|
12
|
+
.ruff_cache/
|
|
13
|
+
.pytest_cache/
|
|
14
|
+
.import_linter_cache/
|
|
15
|
+
.coverage
|
|
16
|
+
.coverage.*
|
|
17
|
+
coverage.xml
|
|
18
|
+
htmlcov/
|
|
19
|
+
.python-version
|
|
20
|
+
|
|
21
|
+
# OS
|
|
22
|
+
.DS_Store
|
|
23
|
+
Thumbs.db
|
|
24
|
+
|
|
25
|
+
# Env / secrets
|
|
26
|
+
.env
|
|
27
|
+
.env.*
|
|
28
|
+
|
|
29
|
+
# Editors
|
|
30
|
+
.vscode/
|
|
31
|
+
.idea/
|
|
32
|
+
|
|
33
|
+
# Logs
|
|
34
|
+
*.log
|
|
35
|
+
|
|
36
|
+
# Agent tooling. `.claude/settings.json`, `.claude/skills/`, `.claude/agents/` and
|
|
37
|
+
# `.claude/rules/` ARE checked in on purpose: every agent working here gets the hooks
|
|
38
|
+
# and the project's own procedures, and an ignored hook is a promise nobody keeps.
|
|
39
|
+
# Only machine-local state and gate logs stay out.
|
|
40
|
+
.claude/settings.local.json
|
|
41
|
+
.claude/scheduled_tasks.lock
|
|
42
|
+
.claude/worktrees/
|
|
43
|
+
.playwright-mcp/
|
|
44
|
+
cache/
|
|
45
|
+
|
|
46
|
+
# Work in flight, plans, audits and research notes: never published.
|
|
47
|
+
.work/
|
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright 2026 Guardana contributors
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: guardana-reference-pack
|
|
3
|
+
Version: 0.1.2
|
|
4
|
+
Summary: A Guardana extension pack that uses all six extension points through the supported surface only.
|
|
5
|
+
Project-URL: Homepage, https://guardana.dev
|
|
6
|
+
Project-URL: Repository, https://github.com/guardana/guardana
|
|
7
|
+
Project-URL: Documentation, https://guardana.dev/docs/
|
|
8
|
+
License-Expression: Apache-2.0
|
|
9
|
+
License-File: LICENSE
|
|
10
|
+
Classifier: Typing :: Typed
|
|
11
|
+
Requires-Python: >=3.11
|
|
12
|
+
Requires-Dist: guardana-core>=0.41
|
|
13
|
+
Description-Content-Type: text/markdown
|
|
14
|
+
|
|
15
|
+
# `guardana-reference-pack`
|
|
16
|
+
|
|
17
|
+
A Guardana extension pack that uses all six extension points and imports nothing outside
|
|
18
|
+
the [supported surface](../../docs/compatibility.md). It has its own version (`0.1.2`),
|
|
19
|
+
depends on `guardana-core>=0.41` with no upper bound, and declares the `extension_api` and
|
|
20
|
+
`output_api` ranges it runs on in its manifest. `guardana pack validate` checks those ranges;
|
|
21
|
+
installing the pack or running a scan does not. A CI job that depends on the pack therefore
|
|
22
|
+
runs `guardana pack validate` and `guardana pack lock --check`. Install it from this directory
|
|
23
|
+
or from the wheel and sdist attached to each GitHub Release. The release workflow's PyPI step
|
|
24
|
+
for the pack is off unless a maintainer has registered the pack's trusted publisher on PyPI
|
|
25
|
+
and switched the step on in the repository settings.
|
|
26
|
+
|
|
27
|
+
`custom_rule` and `output_pack` teach one idea each. This pack is an example a third party
|
|
28
|
+
can copy: everything in it is checked by the commands and the conformance kit Guardana
|
|
29
|
+
ships, from an isolated install.
|
|
30
|
+
|
|
31
|
+
## What it ships
|
|
32
|
+
|
|
33
|
+
| Extension point | What | File |
|
|
34
|
+
|---|---|---|
|
|
35
|
+
| `guardana.rules` | `reference.prompt.codename_disclosure`, a YAML rule graded by the pack's own evaluator | `src/guardana_reference_pack/rules/codename_disclosure.yaml` |
|
|
36
|
+
| `guardana.rules` | `reference.supply_chain.unpinned_requirement`, a Python rule over pip requirement files | `src/guardana_reference_pack/unpinned.py` |
|
|
37
|
+
| `guardana.evaluators` | `reference.marker`: a reply fails when it repeats a configured marker | `src/guardana_reference_pack/evaluator.py` |
|
|
38
|
+
| `guardana.targets` | `reference-requirements://<dir>`: the requirement files under a directory | `src/guardana_reference_pack/target.py` |
|
|
39
|
+
| `guardana.taxonomies` | `REFERENCE-CONTROLS`, the pack's own control catalogue (`REF-1`, `REF-2`) | `src/guardana_reference_pack/controls.py` |
|
|
40
|
+
| `guardana.renderers` | `--format reference-summary`: the run as Markdown | `src/guardana_reference_pack/summary.py` |
|
|
41
|
+
| `guardana.reporters` | `--reporter reference-file://<dir>`: that Markdown, written to `<dir>/guardana-<run id>.md` | `src/guardana_reference_pack/file_reporter.py` |
|
|
42
|
+
|
|
43
|
+
Both rules declare a finding, a clean and an inconclusive sample, so
|
|
44
|
+
`guardana rule test 'reference.*'` proves each one fires, stays silent and declines. The
|
|
45
|
+
manifest, `src/guardana_reference_pack/guardana-pack.yaml`, is schema 3, and
|
|
46
|
+
`guardana-lock.yaml` pins what the pack registers.
|
|
47
|
+
|
|
48
|
+
The reporter's `prepare` only checks the locator. `deliver` writes through a temporary
|
|
49
|
+
file, `fsync`s it and moves it into place, then reports `delivered`; a directory that does
|
|
50
|
+
not exist is `unreachable`, and an `OSError` while writing is `rejected`. The file is
|
|
51
|
+
readable by its owner only.
|
|
52
|
+
|
|
53
|
+
## Try it
|
|
54
|
+
|
|
55
|
+
From the repository root:
|
|
56
|
+
|
|
57
|
+
```bash
|
|
58
|
+
uv pip install ./examples/reference_pack
|
|
59
|
+
ADMIT="--plugins allowlist --allow-plugin guardana-reference-pack"
|
|
60
|
+
uv run guardana rule test 'reference.*' $ADMIT
|
|
61
|
+
uv run guardana pack validate $ADMIT
|
|
62
|
+
mkdir -p summaries
|
|
63
|
+
uv run guardana scan --target reference-requirements://. $ADMIT \
|
|
64
|
+
--format reference-summary --reporter reference-file://summaries
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
## Its own suite
|
|
68
|
+
|
|
69
|
+
`tests/` runs from an isolated install, the way CI and `scripts/ci_local.sh` run it:
|
|
70
|
+
|
|
71
|
+
```bash
|
|
72
|
+
uv run --isolated --no-cache \
|
|
73
|
+
--with ./packages/guardana-core --with ./packages/guardana-rules \
|
|
74
|
+
--with ./packages/guardana-cli --with ./packages/guardana-report \
|
|
75
|
+
--with ./examples/reference_pack --with pytest pytest examples/reference_pack/tests
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
`tests/test_reference_surface.py` walks every import in `src/` and `tests/` and refuses a
|
|
79
|
+
`guardana.*` name outside the supported surface, computed from the installed build:
|
|
80
|
+
`__all__` of `guardana.core` (less `Runner`), `guardana.core.verify`,
|
|
81
|
+
`guardana.core.doubles`, `guardana.core.target.protocols`, `guardana.core.output`,
|
|
82
|
+
`guardana.testing` and `guardana.core.testing`, plus `guardana.core.target.WireProtocol`
|
|
83
|
+
and the public names of `guardana.core.rule.fixture`.
|
|
84
|
+
|
|
85
|
+
`guardana-lock.yaml` holds the pack's own entry only: the built-in pack's entry moves with
|
|
86
|
+
every Guardana release, so the lock test takes it from the installed build and runs
|
|
87
|
+
`pack lock --check` over both. After changing a rule, regenerate the lock from an isolated
|
|
88
|
+
install:
|
|
89
|
+
|
|
90
|
+
```bash
|
|
91
|
+
uv run --isolated --no-cache \
|
|
92
|
+
--with ./packages/guardana-core --with ./packages/guardana-rules \
|
|
93
|
+
--with ./packages/guardana-cli --with ./packages/guardana-report \
|
|
94
|
+
--with ./examples/reference_pack \
|
|
95
|
+
guardana pack lock examples/reference_pack/guardana-lock.yaml \
|
|
96
|
+
--plugins allowlist --allow-plugin guardana-reference-pack
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
Then delete every entry but `guardana-reference-pack` under `packs:`.
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
# `guardana-reference-pack`
|
|
2
|
+
|
|
3
|
+
A Guardana extension pack that uses all six extension points and imports nothing outside
|
|
4
|
+
the [supported surface](../../docs/compatibility.md). It has its own version (`0.1.2`),
|
|
5
|
+
depends on `guardana-core>=0.41` with no upper bound, and declares the `extension_api` and
|
|
6
|
+
`output_api` ranges it runs on in its manifest. `guardana pack validate` checks those ranges;
|
|
7
|
+
installing the pack or running a scan does not. A CI job that depends on the pack therefore
|
|
8
|
+
runs `guardana pack validate` and `guardana pack lock --check`. Install it from this directory
|
|
9
|
+
or from the wheel and sdist attached to each GitHub Release. The release workflow's PyPI step
|
|
10
|
+
for the pack is off unless a maintainer has registered the pack's trusted publisher on PyPI
|
|
11
|
+
and switched the step on in the repository settings.
|
|
12
|
+
|
|
13
|
+
`custom_rule` and `output_pack` teach one idea each. This pack is an example a third party
|
|
14
|
+
can copy: everything in it is checked by the commands and the conformance kit Guardana
|
|
15
|
+
ships, from an isolated install.
|
|
16
|
+
|
|
17
|
+
## What it ships
|
|
18
|
+
|
|
19
|
+
| Extension point | What | File |
|
|
20
|
+
|---|---|---|
|
|
21
|
+
| `guardana.rules` | `reference.prompt.codename_disclosure`, a YAML rule graded by the pack's own evaluator | `src/guardana_reference_pack/rules/codename_disclosure.yaml` |
|
|
22
|
+
| `guardana.rules` | `reference.supply_chain.unpinned_requirement`, a Python rule over pip requirement files | `src/guardana_reference_pack/unpinned.py` |
|
|
23
|
+
| `guardana.evaluators` | `reference.marker`: a reply fails when it repeats a configured marker | `src/guardana_reference_pack/evaluator.py` |
|
|
24
|
+
| `guardana.targets` | `reference-requirements://<dir>`: the requirement files under a directory | `src/guardana_reference_pack/target.py` |
|
|
25
|
+
| `guardana.taxonomies` | `REFERENCE-CONTROLS`, the pack's own control catalogue (`REF-1`, `REF-2`) | `src/guardana_reference_pack/controls.py` |
|
|
26
|
+
| `guardana.renderers` | `--format reference-summary`: the run as Markdown | `src/guardana_reference_pack/summary.py` |
|
|
27
|
+
| `guardana.reporters` | `--reporter reference-file://<dir>`: that Markdown, written to `<dir>/guardana-<run id>.md` | `src/guardana_reference_pack/file_reporter.py` |
|
|
28
|
+
|
|
29
|
+
Both rules declare a finding, a clean and an inconclusive sample, so
|
|
30
|
+
`guardana rule test 'reference.*'` proves each one fires, stays silent and declines. The
|
|
31
|
+
manifest, `src/guardana_reference_pack/guardana-pack.yaml`, is schema 3, and
|
|
32
|
+
`guardana-lock.yaml` pins what the pack registers.
|
|
33
|
+
|
|
34
|
+
The reporter's `prepare` only checks the locator. `deliver` writes through a temporary
|
|
35
|
+
file, `fsync`s it and moves it into place, then reports `delivered`; a directory that does
|
|
36
|
+
not exist is `unreachable`, and an `OSError` while writing is `rejected`. The file is
|
|
37
|
+
readable by its owner only.
|
|
38
|
+
|
|
39
|
+
## Try it
|
|
40
|
+
|
|
41
|
+
From the repository root:
|
|
42
|
+
|
|
43
|
+
```bash
|
|
44
|
+
uv pip install ./examples/reference_pack
|
|
45
|
+
ADMIT="--plugins allowlist --allow-plugin guardana-reference-pack"
|
|
46
|
+
uv run guardana rule test 'reference.*' $ADMIT
|
|
47
|
+
uv run guardana pack validate $ADMIT
|
|
48
|
+
mkdir -p summaries
|
|
49
|
+
uv run guardana scan --target reference-requirements://. $ADMIT \
|
|
50
|
+
--format reference-summary --reporter reference-file://summaries
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
## Its own suite
|
|
54
|
+
|
|
55
|
+
`tests/` runs from an isolated install, the way CI and `scripts/ci_local.sh` run it:
|
|
56
|
+
|
|
57
|
+
```bash
|
|
58
|
+
uv run --isolated --no-cache \
|
|
59
|
+
--with ./packages/guardana-core --with ./packages/guardana-rules \
|
|
60
|
+
--with ./packages/guardana-cli --with ./packages/guardana-report \
|
|
61
|
+
--with ./examples/reference_pack --with pytest pytest examples/reference_pack/tests
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
`tests/test_reference_surface.py` walks every import in `src/` and `tests/` and refuses a
|
|
65
|
+
`guardana.*` name outside the supported surface, computed from the installed build:
|
|
66
|
+
`__all__` of `guardana.core` (less `Runner`), `guardana.core.verify`,
|
|
67
|
+
`guardana.core.doubles`, `guardana.core.target.protocols`, `guardana.core.output`,
|
|
68
|
+
`guardana.testing` and `guardana.core.testing`, plus `guardana.core.target.WireProtocol`
|
|
69
|
+
and the public names of `guardana.core.rule.fixture`.
|
|
70
|
+
|
|
71
|
+
`guardana-lock.yaml` holds the pack's own entry only: the built-in pack's entry moves with
|
|
72
|
+
every Guardana release, so the lock test takes it from the installed build and runs
|
|
73
|
+
`pack lock --check` over both. After changing a rule, regenerate the lock from an isolated
|
|
74
|
+
install:
|
|
75
|
+
|
|
76
|
+
```bash
|
|
77
|
+
uv run --isolated --no-cache \
|
|
78
|
+
--with ./packages/guardana-core --with ./packages/guardana-rules \
|
|
79
|
+
--with ./packages/guardana-cli --with ./packages/guardana-report \
|
|
80
|
+
--with ./examples/reference_pack \
|
|
81
|
+
guardana pack lock examples/reference_pack/guardana-lock.yaml \
|
|
82
|
+
--plugins allowlist --allow-plugin guardana-reference-pack
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
Then delete every entry but `guardana-reference-pack` under `packs:`.
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
schema_version: 3
|
|
2
|
+
extension_api: 2
|
|
3
|
+
packs:
|
|
4
|
+
- name: guardana-reference-pack
|
|
5
|
+
distribution: guardana-reference-pack
|
|
6
|
+
version: 0.1.2
|
|
7
|
+
rules:
|
|
8
|
+
reference.prompt.codename_disclosure:
|
|
9
|
+
digest: b00991d5ddc71066
|
|
10
|
+
reference.supply_chain.unpinned_requirement:
|
|
11
|
+
digest: 533087d5b5815f7b
|
|
12
|
+
evaluators:
|
|
13
|
+
- reference.marker
|
|
14
|
+
targets:
|
|
15
|
+
- ReferenceRequirementsTarget
|
|
16
|
+
renderers:
|
|
17
|
+
- reference-summary
|
|
18
|
+
reporters:
|
|
19
|
+
- reference-file
|
|
20
|
+
taxonomies:
|
|
21
|
+
REFERENCE-CONTROLS:
|
|
22
|
+
digest: sha256:5a3eabd6733c45b3622b5d60efa2b50c35dd1a38f2ba7ce6af6a1608d3a0abb6
|
|
23
|
+
unlocked: []
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
name = "guardana-reference-pack"
|
|
3
|
+
version = "0.1.2"
|
|
4
|
+
description = "A Guardana extension pack that uses all six extension points through the supported surface only."
|
|
5
|
+
readme = "README.md"
|
|
6
|
+
requires-python = ">=3.11"
|
|
7
|
+
license = "Apache-2.0"
|
|
8
|
+
license-files = ["LICENSE"]
|
|
9
|
+
classifiers = ["Typing :: Typed"]
|
|
10
|
+
dependencies = ["guardana-core>=0.41"]
|
|
11
|
+
|
|
12
|
+
[project.urls]
|
|
13
|
+
Homepage = "https://guardana.dev"
|
|
14
|
+
Repository = "https://github.com/guardana/guardana"
|
|
15
|
+
Documentation = "https://guardana.dev/docs/"
|
|
16
|
+
|
|
17
|
+
[project.entry-points."guardana.rules"]
|
|
18
|
+
reference = "guardana_reference_pack:provide_rules"
|
|
19
|
+
|
|
20
|
+
[project.entry-points."guardana.evaluators"]
|
|
21
|
+
reference = "guardana_reference_pack:provide_evaluators"
|
|
22
|
+
|
|
23
|
+
[project.entry-points."guardana.targets"]
|
|
24
|
+
reference = "guardana_reference_pack:provide_targets"
|
|
25
|
+
|
|
26
|
+
[project.entry-points."guardana.taxonomies"]
|
|
27
|
+
reference = "guardana_reference_pack:provide_taxonomies"
|
|
28
|
+
|
|
29
|
+
[project.entry-points."guardana.renderers"]
|
|
30
|
+
reference-summary = "guardana_reference_pack:provide_summary"
|
|
31
|
+
|
|
32
|
+
[project.entry-points."guardana.reporters"]
|
|
33
|
+
reference-file = "guardana_reference_pack:provide_file_reporter"
|
|
34
|
+
|
|
35
|
+
[build-system]
|
|
36
|
+
# Exact, like the five packages: the release builds and publishes this pack too.
|
|
37
|
+
requires = ["hatchling==1.32.4"]
|
|
38
|
+
build-backend = "hatchling.build"
|
|
39
|
+
|
|
40
|
+
[tool.hatch.build.targets.wheel]
|
|
41
|
+
packages = ["src/guardana_reference_pack"]
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
"""Guardana's reference pack: one of every extension point, through the supported surface only.
|
|
2
|
+
|
|
3
|
+
Each provider below is what one entry point in `pyproject.toml` names. The two output
|
|
4
|
+
providers import their module inside the function, so a run that selects neither output
|
|
5
|
+
imports neither.
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
from importlib import resources
|
|
9
|
+
|
|
10
|
+
from guardana.core import Evaluator, Registry, Rule, RuleLoadError, Target, TaxonomyRef
|
|
11
|
+
from guardana.core.output import RendererSpec, ReporterSpec
|
|
12
|
+
|
|
13
|
+
from guardana_reference_pack.controls import CONTROLS
|
|
14
|
+
from guardana_reference_pack.evaluator import MarkerEvaluator
|
|
15
|
+
from guardana_reference_pack.target import ReferenceRequirementsTarget
|
|
16
|
+
from guardana_reference_pack.unpinned import UnpinnedRequirementRule
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
def provide_rules() -> list[Rule]:
|
|
20
|
+
"""Entry point target for `guardana.rules`: the Python rule and every YAML rule."""
|
|
21
|
+
return [UnpinnedRequirementRule(), *_yaml_rules()]
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
def provide_evaluators() -> list[Evaluator]:
|
|
25
|
+
"""Entry point target for `guardana.evaluators`: `reference.marker`."""
|
|
26
|
+
return [MarkerEvaluator()]
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
def provide_targets() -> list[type[Target]]:
|
|
30
|
+
"""Entry point target for `guardana.targets`: `reference-requirements://`."""
|
|
31
|
+
return [ReferenceRequirementsTarget]
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
def provide_taxonomies() -> list[TaxonomyRef]:
|
|
35
|
+
"""Entry point target for `guardana.taxonomies`: the `REFERENCE-CONTROLS` catalogue."""
|
|
36
|
+
return list(CONTROLS)
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
def provide_summary() -> RendererSpec:
|
|
40
|
+
"""Entry point target for `guardana.renderers`: the `reference-summary` format."""
|
|
41
|
+
from guardana_reference_pack import summary # noqa: PLC0415 — imported only when selected
|
|
42
|
+
|
|
43
|
+
return summary.spec()
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
def provide_file_reporter() -> ReporterSpec:
|
|
47
|
+
"""Entry point target for `guardana.reporters`: the `reference-file` reporter."""
|
|
48
|
+
from guardana_reference_pack import file_reporter # noqa: PLC0415 — imported only when selected
|
|
49
|
+
|
|
50
|
+
return file_reporter.spec()
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
def _yaml_rules() -> tuple[Rule, ...]:
|
|
54
|
+
"""Load every YAML rule shipped in `rules/`, raising when any one of them does not load.
|
|
55
|
+
|
|
56
|
+
`Registry.load_yaml_rule_dirs` records a broken file instead of raising; raised here,
|
|
57
|
+
the whole provider fails, so a run reports the pack as broken rather than short a rule.
|
|
58
|
+
"""
|
|
59
|
+
registry = Registry()
|
|
60
|
+
folder = resources.files(__name__).joinpath("rules")
|
|
61
|
+
for entry in sorted(folder.iterdir(), key=lambda item: item.name):
|
|
62
|
+
if not entry.name.endswith(".yaml"):
|
|
63
|
+
continue
|
|
64
|
+
with resources.as_file(entry) as path:
|
|
65
|
+
loaded = registry.load_yaml_rule_dirs([path])
|
|
66
|
+
if loaded.errors:
|
|
67
|
+
problems = "; ".join(f"{error.source}: {error.reason}" for error in loaded.errors)
|
|
68
|
+
raise RuleLoadError(f"a rule shipped with the reference pack did not load: {problems}")
|
|
69
|
+
if not registry.rules():
|
|
70
|
+
raise RuleLoadError("the reference pack was installed without its YAML rules")
|
|
71
|
+
return registry.rules()
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"""The pack's own control catalogue, and the public entries its rules map to beside it.
|
|
2
|
+
|
|
3
|
+
The catalogue is registered through `guardana.taxonomies` before any rule loads, which
|
|
4
|
+
is what lets the YAML rule write `taxonomy: [REF-2]`. The OWASP entries are written out
|
|
5
|
+
in full because the supported surface offers no lookup; the suite checks that each one
|
|
6
|
+
equals what the engine's own catalogue resolves.
|
|
7
|
+
"""
|
|
8
|
+
|
|
9
|
+
from guardana.core import TaxonomyRef
|
|
10
|
+
|
|
11
|
+
SCHEME = "REFERENCE-CONTROLS"
|
|
12
|
+
|
|
13
|
+
PINNED_DEPENDENCIES = TaxonomyRef(
|
|
14
|
+
scheme=SCHEME,
|
|
15
|
+
id="REF-1",
|
|
16
|
+
title="Every dependency is pinned to one version",
|
|
17
|
+
)
|
|
18
|
+
CONFIDENTIAL_NAMES = TaxonomyRef(
|
|
19
|
+
scheme=SCHEME,
|
|
20
|
+
id="REF-2",
|
|
21
|
+
title="Internal names stay inside the organisation",
|
|
22
|
+
)
|
|
23
|
+
|
|
24
|
+
CONTROLS = (PINNED_DEPENDENCIES, CONFIDENTIAL_NAMES)
|
|
25
|
+
"""Every control the catalogue registers."""
|
|
26
|
+
|
|
27
|
+
OWASP_LLM02_2025 = TaxonomyRef(
|
|
28
|
+
scheme="OWASP-LLM",
|
|
29
|
+
id="LLM02",
|
|
30
|
+
title="Sensitive Information Disclosure",
|
|
31
|
+
edition="2025",
|
|
32
|
+
rank=2,
|
|
33
|
+
)
|
|
34
|
+
OWASP_LLM03_2025 = TaxonomyRef(
|
|
35
|
+
scheme="OWASP-LLM",
|
|
36
|
+
id="LLM03",
|
|
37
|
+
title="Supply Chain",
|
|
38
|
+
edition="2025",
|
|
39
|
+
rank=3,
|
|
40
|
+
)
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"""`reference.marker`: a reply fails when it repeats a configured marker."""
|
|
2
|
+
|
|
3
|
+
from typing import ClassVar
|
|
4
|
+
|
|
5
|
+
from guardana.core import Evaluator, Exchange, Expectation, Verdict
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
class MarkerEvaluator(Evaluator):
|
|
9
|
+
"""Fail a reply that contains `expect.marker`, in any case; decline one with no text."""
|
|
10
|
+
|
|
11
|
+
id = "reference.marker"
|
|
12
|
+
expects: ClassVar[dict[str, bool]] = {"marker": True}
|
|
13
|
+
deterministic: ClassVar[bool] = True
|
|
14
|
+
|
|
15
|
+
@property
|
|
16
|
+
def judge_calls_per_verdict(self) -> int:
|
|
17
|
+
"""Reads the reply and asks no model, so a plan prices it at nothing."""
|
|
18
|
+
return 0
|
|
19
|
+
|
|
20
|
+
def evaluate(self, exchange: Exchange, expectation: Expectation) -> Verdict:
|
|
21
|
+
"""Return `fail` when the reply holds the marker, `pass` when it does not.
|
|
22
|
+
|
|
23
|
+
Raises `TypeError` when the rule set no usable marker: grading against an empty
|
|
24
|
+
marker would match every reply or none.
|
|
25
|
+
"""
|
|
26
|
+
marker = expectation.get("marker")
|
|
27
|
+
if not isinstance(marker, str) or not marker.strip():
|
|
28
|
+
raise TypeError(f"{self.id} needs expect.marker as a non-empty string")
|
|
29
|
+
reply = exchange.reply_text
|
|
30
|
+
if reply is None or not reply.strip():
|
|
31
|
+
return Verdict("inconclusive", 0.0, "the reply holds no text to read", self.id)
|
|
32
|
+
if marker.casefold() in reply.casefold():
|
|
33
|
+
return Verdict("fail", 1.0, f"the reply repeats the marker {marker!r}", self.id)
|
|
34
|
+
return Verdict("pass", 1.0, "the reply does not repeat the marker", self.id)
|