canari-mcp 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.
- canari_mcp-0.1.0/LICENSE +202 -0
- canari_mcp-0.1.0/PKG-INFO +194 -0
- canari_mcp-0.1.0/README.md +172 -0
- canari_mcp-0.1.0/canari/__init__.py +12 -0
- canari_mcp-0.1.0/canari/__main__.py +3 -0
- canari_mcp-0.1.0/canari/anomaly.py +98 -0
- canari_mcp-0.1.0/canari/attestation-v0.1.json +309 -0
- canari_mcp-0.1.0/canari/baseline.py +922 -0
- canari_mcp-0.1.0/canari/cadence.py +101 -0
- canari_mcp-0.1.0/canari/consumer.py +88 -0
- canari_mcp-0.1.0/canari/dead_letter.py +49 -0
- canari_mcp-0.1.0/canari/drift.py +146 -0
- canari_mcp-0.1.0/canari/drift_cli.py +35 -0
- canari_mcp-0.1.0/canari/feed.py +63 -0
- canari_mcp-0.1.0/canari/gate.py +266 -0
- canari_mcp-0.1.0/canari/gate_cli.py +67 -0
- canari_mcp-0.1.0/canari/guard.py +184 -0
- canari_mcp-0.1.0/canari/log.py +4 -0
- canari_mcp-0.1.0/canari/mcp_server.py +164 -0
- canari_mcp-0.1.0/canari/native.py +103 -0
- canari_mcp-0.1.0/canari/npm_enum.py +371 -0
- canari_mcp-0.1.0/canari/pypi_native.py +95 -0
- canari_mcp-0.1.0/canari/scanner_adapter.py +168 -0
- canari_mcp-0.1.0/canari/schema.py +86 -0
- canari_mcp-0.1.0/canari/score.py +144 -0
- canari_mcp-0.1.0/canari/signing.py +333 -0
- canari_mcp-0.1.0/canari/state.py +91 -0
- canari_mcp-0.1.0/canari/typosquat.py +105 -0
- canari_mcp-0.1.0/canari/verify_cli.py +357 -0
- canari_mcp-0.1.0/canari_mcp.egg-info/PKG-INFO +194 -0
- canari_mcp-0.1.0/canari_mcp.egg-info/SOURCES.txt +73 -0
- canari_mcp-0.1.0/canari_mcp.egg-info/dependency_links.txt +1 -0
- canari_mcp-0.1.0/canari_mcp.egg-info/entry_points.txt +7 -0
- canari_mcp-0.1.0/canari_mcp.egg-info/requires.txt +5 -0
- canari_mcp-0.1.0/canari_mcp.egg-info/top_level.txt +1 -0
- canari_mcp-0.1.0/pyproject.toml +52 -0
- canari_mcp-0.1.0/setup.cfg +4 -0
- canari_mcp-0.1.0/tests/test_baseline_offline.py +85 -0
- canari_mcp-0.1.0/tests/test_cov_baseline.py +77 -0
- canari_mcp-0.1.0/tests/test_cov_cli2.py +43 -0
- canari_mcp-0.1.0/tests/test_cov_final.py +278 -0
- canari_mcp-0.1.0/tests/test_cov_modules.py +85 -0
- canari_mcp-0.1.0/tests/test_cov_npm_enum.py +57 -0
- canari_mcp-0.1.0/tests/test_cov_state_score.py +86 -0
- canari_mcp-0.1.0/tests/test_covx_core.py +296 -0
- canari_mcp-0.1.0/tests/test_covx_enum2.py +225 -0
- canari_mcp-0.1.0/tests/test_covx_final2.py +129 -0
- canari_mcp-0.1.0/tests/test_covx_last.py +85 -0
- canari_mcp-0.1.0/tests/test_covx_last2.py +23 -0
- canari_mcp-0.1.0/tests/test_covx_mod.py +264 -0
- canari_mcp-0.1.0/tests/test_covx_mutkill.py +199 -0
- canari_mcp-0.1.0/tests/test_covx_verify2.py +169 -0
- canari_mcp-0.1.0/tests/test_deep_adversarial.py +178 -0
- canari_mcp-0.1.0/tests/test_deep_feed.py +44 -0
- canari_mcp-0.1.0/tests/test_deep_fuzz.py +137 -0
- canari_mcp-0.1.0/tests/test_deep_props.py +67 -0
- canari_mcp-0.1.0/tests/test_differential.py +139 -0
- canari_mcp-0.1.0/tests/test_fixtures.py +114 -0
- canari_mcp-0.1.0/tests/test_gate.py +130 -0
- canari_mcp-0.1.0/tests/test_gate_expansion.py +143 -0
- canari_mcp-0.1.0/tests/test_native.py +134 -0
- canari_mcp-0.1.0/tests/test_propagation.py +43 -0
- canari_mcp-0.1.0/tests/test_pypi_native.py +47 -0
- canari_mcp-0.1.0/tests/test_round13_fixes.py +148 -0
- canari_mcp-0.1.0/tests/test_round14_fixes.py +153 -0
- canari_mcp-0.1.0/tests/test_round15_dsh.py +78 -0
- canari_mcp-0.1.0/tests/test_round16_consumer.py +136 -0
- canari_mcp-0.1.0/tests/test_round17_guard.py +80 -0
- canari_mcp-0.1.0/tests/test_round18_chain_fork.py +51 -0
- canari_mcp-0.1.0/tests/test_scanner_adapter.py +91 -0
- canari_mcp-0.1.0/tests/test_schema_and_gate.py +101 -0
- canari_mcp-0.1.0/tests/test_schema_edge.py +180 -0
- canari_mcp-0.1.0/tests/test_schema_sync.py +37 -0
- canari_mcp-0.1.0/tests/test_signing.py +71 -0
- canari_mcp-0.1.0/tests/test_verify_cli.py +104 -0
canari_mcp-0.1.0/LICENSE
ADDED
|
@@ -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 [yyyy] [name of copyright owner]
|
|
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,194 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: canari-mcp
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Canari - agent component verification ledger: signed, offline-verifiable attestations for MCP servers and agent skills
|
|
5
|
+
Author: Canari contributors
|
|
6
|
+
License: Apache-2.0
|
|
7
|
+
Project-URL: Homepage, https://github.com/lanbass869-cell/canari
|
|
8
|
+
Keywords: mcp,agent,supply-chain,attestation,security,in-toto,dsse
|
|
9
|
+
Classifier: Development Status :: 3 - Alpha
|
|
10
|
+
Classifier: Intended Audience :: Developers
|
|
11
|
+
Classifier: License :: OSI Approved :: Apache Software License
|
|
12
|
+
Classifier: Programming Language :: Python :: 3
|
|
13
|
+
Classifier: Topic :: Security
|
|
14
|
+
Requires-Python: >=3.10
|
|
15
|
+
Description-Content-Type: text/markdown
|
|
16
|
+
License-File: LICENSE
|
|
17
|
+
Requires-Dist: jsonschema>=4.0
|
|
18
|
+
Requires-Dist: in-toto>=3.1
|
|
19
|
+
Provides-Extra: dev
|
|
20
|
+
Requires-Dist: pytest>=7; extra == "dev"
|
|
21
|
+
Dynamic: license-file
|
|
22
|
+
|
|
23
|
+
# Canari
|
|
24
|
+
|
|
25
|
+
[](https://github.com/lanbass869-cell/canari/actions/workflows/ci.yml)
|
|
26
|
+

|
|
27
|
+

|
|
28
|
+
-brightgreen)
|
|
29
|
+

|
|
30
|
+
|
|
31
|
+
Agent component verification ledger - signed, offline-verifiable, history-preserving attestations for MCP servers, agent skills, and DSH plugins.
|
|
32
|
+
|
|
33
|
+
Named after the canary in the coal mine: the first to detect that something went wrong.
|
|
34
|
+
|
|
35
|
+
## What it does
|
|
36
|
+
|
|
37
|
+
1. **Weekly scan** of agent component ecosystems (npm, PyPI, MCP Registry, dsh.so)
|
|
38
|
+
2. Each component gets a **signed attestation** (DSSE/in-toto, ed25519) binding: artifact hash + host version + scan scenario
|
|
39
|
+
3. Attestations are **offline-verifiable** by anyone with the public key
|
|
40
|
+
4. History is **never deleted** - version changes create supersession chains
|
|
41
|
+
5. Public **machine-readable feed** for any AI agent or host to consume
|
|
42
|
+
6. **Trust heuristics**: release cadence (L2.4), metadata anomaly (L2.5), typosquatting (L2.6)
|
|
43
|
+
7. **Consumer install gate** with policies: `canari-verify bundle.json --key pub.json --gate --gate-policy paranoid`
|
|
44
|
+
|
|
45
|
+
## Install
|
|
46
|
+
|
|
47
|
+
From the latest GitHub release (wheel + sdist, checksum + Ed25519 signed):
|
|
48
|
+
|
|
49
|
+
```
|
|
50
|
+
pip install https://github.com/lanbass869-cell/canari/releases/download/v0.1.0/canari_mcp-0.1.0-py3-none-any.whl
|
|
51
|
+
canari-gate --store out --list
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
Then verify what you downloaded (see `docs/release-process.md` for the one-liner).
|
|
55
|
+
|
|
56
|
+
## Quality gates (enforced in CI)
|
|
57
|
+
|
|
58
|
+
| Gate | Threshold | Current |
|
|
59
|
+
|---|---|---|
|
|
60
|
+
| tests | green on 3.10/3.12/3.13 | 357 passing |
|
|
61
|
+
| line coverage | >= 85% | 90% |
|
|
62
|
+
| mutation kill rate | >= 90% (equivalent mutants excluded) | 100% (50/50) |
|
|
63
|
+
| live-data audit | sampled attestations re-derive from npm/PyPI | 18/18 |
|
|
64
|
+
|
|
65
|
+
Run them yourself: `python scripts/quality_gate.py`
|
|
66
|
+
|
|
67
|
+
## Quick start
|
|
68
|
+
|
|
69
|
+
```
|
|
70
|
+
# install
|
|
71
|
+
pip install canari-mcp
|
|
72
|
+
|
|
73
|
+
# run a scan
|
|
74
|
+
canari-baseline --limit 50
|
|
75
|
+
|
|
76
|
+
# verify an attestation offline
|
|
77
|
+
canari-verify out/attestations/npm_some-package.bundle.json --key out/public_key.json
|
|
78
|
+
|
|
79
|
+
# verify + policy gate (exit 0 ALLOW / 5 BLOCK / 6 REVIEW)
|
|
80
|
+
canari-verify out/attestations/npm_some-package.bundle.json --key out/public_key.json \\
|
|
81
|
+
--gate --gate-policy strict
|
|
82
|
+
|
|
83
|
+
# custom policy file
|
|
84
|
+
canari-verify bundle.json --key out/public_key.json --gate --gate-policy-file my-policy.json
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
### Policy file example
|
|
88
|
+
|
|
89
|
+
```json
|
|
90
|
+
{"name": "my-policy", "block_on_findings": true, "require_native_provenance": false}
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
## Consumer side (the part a host actually uses)
|
|
94
|
+
|
|
95
|
+
### 1. Look up a component and gate it
|
|
96
|
+
|
|
97
|
+
```
|
|
98
|
+
# resolve the newest signed attestation for a component and run the gate
|
|
99
|
+
canari-gate --store out --registry npm --name express
|
|
100
|
+
canari-gate --store out --registry dsh-registry --name aegis --policy paranoid --json
|
|
101
|
+
|
|
102
|
+
# exit codes: 0 ALLOW, 5 BLOCK, 6 REVIEW, 3 not found
|
|
103
|
+
canari-gate --store out --list
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
### 2. Drift report (what changed since last week)
|
|
107
|
+
|
|
108
|
+
```
|
|
109
|
+
canari-drift --store out --write out/drift
|
|
110
|
+
# verdict flips / same-version silent changes / findings added / findings removed
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
`run_weekly.py` writes this report automatically after every scan.
|
|
114
|
+
|
|
115
|
+
### 3. Use it from any MCP host (dsh, Codex, Claude, ...)
|
|
116
|
+
|
|
117
|
+
`canari-mcp` speaks MCP over stdio (zero dependencies) and exposes three tools:
|
|
118
|
+
`gate_check`, `verify_bundle`, `store_summary`.
|
|
119
|
+
|
|
120
|
+
```json
|
|
121
|
+
{
|
|
122
|
+
"mcpServers": {
|
|
123
|
+
"canari": {
|
|
124
|
+
"command": "canari-mcp",
|
|
125
|
+
"args": ["--store", "E:/Temp/tbdig/canari/out",
|
|
126
|
+
"--key", "E:/Temp/tbdig/canari/out/public_key.json"]
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
A host (or agent) can then ask: "is npm:express allowed to install?" and get
|
|
133
|
+
`ALLOW / BLOCK / REVIEW` with reasons, backed by a signed, offline-verifiable
|
|
134
|
+
attestation.
|
|
135
|
+
|
|
136
|
+
### 4. Gate the actual install command
|
|
137
|
+
|
|
138
|
+
`canari-guard` wraps an install command, checks every component against the
|
|
139
|
+
ledger, and refuses to execute when the verdict blocks:
|
|
140
|
+
|
|
141
|
+
```
|
|
142
|
+
canari-guard -- dsh plugin --profile wbpj add dsh-purge
|
|
143
|
+
canari-guard -- npm install some-mcp-server
|
|
144
|
+
canari-guard -- pip install mcp-server-fetch==0.2.1
|
|
145
|
+
|
|
146
|
+
# exit 0 allowed+executed | 5 blocked by ledger | 6 review not confirmed
|
|
147
|
+
# --dry-run prints what would run; --allow-review accepts pass-with-findings
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
The host is never patched - the guard sits in front of the install command.
|
|
151
|
+
|
|
152
|
+
For DeepSeek Harness (dsh), add this to the profile's `cordis.patch.yml`
|
|
153
|
+
(verified end-to-end on dsh: the model called `mcp__canari__store_summary` and
|
|
154
|
+
received the live component count):
|
|
155
|
+
|
|
156
|
+
```yaml
|
|
157
|
+
- id: mcp-canari
|
|
158
|
+
name: '@deepseek-ai/dsh-mcp-client'
|
|
159
|
+
config:
|
|
160
|
+
serverName: canari
|
|
161
|
+
transport: stdio
|
|
162
|
+
command: 'E:\Temp\tbdig\_venv_pr_a\Scripts\python.exe'
|
|
163
|
+
args: ['-m', 'canari.mcp_server', '--store', 'E:\Temp\tbdig\canari\out',
|
|
164
|
+
'--key', 'E:\Temp\tbdig\canari\out\public_key.json']
|
|
165
|
+
cwd: 'E:\Temp\tbdig\canari'
|
|
166
|
+
failOnStartupError: true
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
|
|
170
|
+
## Multi-registry coverage
|
|
171
|
+
|
|
172
|
+
| Registry | Source | What we check | What we inherit |
|
|
173
|
+
|---|---|---|---|
|
|
174
|
+
| npm | search API + packument + tarball sha256 | existence, version, artifact hash, maintainers | - |
|
|
175
|
+
| PyPI | Simple API + JSON API | same | - |
|
|
176
|
+
| MCP Registry | official REST | identity presence | - |
|
|
177
|
+
| dsh.so | JSON API | **reference existing L1-L5 conclusions** (not re-scanned) | dsh.so verdicts |
|
|
178
|
+
|
|
179
|
+
## Honest limitations
|
|
180
|
+
|
|
181
|
+
- This is a **risk signal, not a safety guarantee**
|
|
182
|
+
- M0/M1 covers meta-level checks (L1-L2); behavioral checks (L3+) are M1+
|
|
183
|
+
- Scan coverage is limited to what registries expose publicly
|
|
184
|
+
- `expires_at` is 7 days - attestations go stale, re-scan needed
|
|
185
|
+
|
|
186
|
+
## The threat model this addresses
|
|
187
|
+
|
|
188
|
+
postmark-mcp (MITRE ATLAS AML.CS0053): 15 clean versions, then one poisoned commit, ~300 orgs affected. After takedown, **no host was notified**. The gap: no longitudinal observation, no cross-host revocation feed, no portable verdict.
|
|
189
|
+
|
|
190
|
+
Canari fills that gap.
|
|
191
|
+
|
|
192
|
+
## License
|
|
193
|
+
|
|
194
|
+
Apache-2.0. See LICENSE and SECURITY.md.
|
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
# Canari
|
|
2
|
+
|
|
3
|
+
[](https://github.com/lanbass869-cell/canari/actions/workflows/ci.yml)
|
|
4
|
+

|
|
5
|
+

|
|
6
|
+
-brightgreen)
|
|
7
|
+

|
|
8
|
+
|
|
9
|
+
Agent component verification ledger - signed, offline-verifiable, history-preserving attestations for MCP servers, agent skills, and DSH plugins.
|
|
10
|
+
|
|
11
|
+
Named after the canary in the coal mine: the first to detect that something went wrong.
|
|
12
|
+
|
|
13
|
+
## What it does
|
|
14
|
+
|
|
15
|
+
1. **Weekly scan** of agent component ecosystems (npm, PyPI, MCP Registry, dsh.so)
|
|
16
|
+
2. Each component gets a **signed attestation** (DSSE/in-toto, ed25519) binding: artifact hash + host version + scan scenario
|
|
17
|
+
3. Attestations are **offline-verifiable** by anyone with the public key
|
|
18
|
+
4. History is **never deleted** - version changes create supersession chains
|
|
19
|
+
5. Public **machine-readable feed** for any AI agent or host to consume
|
|
20
|
+
6. **Trust heuristics**: release cadence (L2.4), metadata anomaly (L2.5), typosquatting (L2.6)
|
|
21
|
+
7. **Consumer install gate** with policies: `canari-verify bundle.json --key pub.json --gate --gate-policy paranoid`
|
|
22
|
+
|
|
23
|
+
## Install
|
|
24
|
+
|
|
25
|
+
From the latest GitHub release (wheel + sdist, checksum + Ed25519 signed):
|
|
26
|
+
|
|
27
|
+
```
|
|
28
|
+
pip install https://github.com/lanbass869-cell/canari/releases/download/v0.1.0/canari_mcp-0.1.0-py3-none-any.whl
|
|
29
|
+
canari-gate --store out --list
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
Then verify what you downloaded (see `docs/release-process.md` for the one-liner).
|
|
33
|
+
|
|
34
|
+
## Quality gates (enforced in CI)
|
|
35
|
+
|
|
36
|
+
| Gate | Threshold | Current |
|
|
37
|
+
|---|---|---|
|
|
38
|
+
| tests | green on 3.10/3.12/3.13 | 357 passing |
|
|
39
|
+
| line coverage | >= 85% | 90% |
|
|
40
|
+
| mutation kill rate | >= 90% (equivalent mutants excluded) | 100% (50/50) |
|
|
41
|
+
| live-data audit | sampled attestations re-derive from npm/PyPI | 18/18 |
|
|
42
|
+
|
|
43
|
+
Run them yourself: `python scripts/quality_gate.py`
|
|
44
|
+
|
|
45
|
+
## Quick start
|
|
46
|
+
|
|
47
|
+
```
|
|
48
|
+
# install
|
|
49
|
+
pip install canari-mcp
|
|
50
|
+
|
|
51
|
+
# run a scan
|
|
52
|
+
canari-baseline --limit 50
|
|
53
|
+
|
|
54
|
+
# verify an attestation offline
|
|
55
|
+
canari-verify out/attestations/npm_some-package.bundle.json --key out/public_key.json
|
|
56
|
+
|
|
57
|
+
# verify + policy gate (exit 0 ALLOW / 5 BLOCK / 6 REVIEW)
|
|
58
|
+
canari-verify out/attestations/npm_some-package.bundle.json --key out/public_key.json \\
|
|
59
|
+
--gate --gate-policy strict
|
|
60
|
+
|
|
61
|
+
# custom policy file
|
|
62
|
+
canari-verify bundle.json --key out/public_key.json --gate --gate-policy-file my-policy.json
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
### Policy file example
|
|
66
|
+
|
|
67
|
+
```json
|
|
68
|
+
{"name": "my-policy", "block_on_findings": true, "require_native_provenance": false}
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
## Consumer side (the part a host actually uses)
|
|
72
|
+
|
|
73
|
+
### 1. Look up a component and gate it
|
|
74
|
+
|
|
75
|
+
```
|
|
76
|
+
# resolve the newest signed attestation for a component and run the gate
|
|
77
|
+
canari-gate --store out --registry npm --name express
|
|
78
|
+
canari-gate --store out --registry dsh-registry --name aegis --policy paranoid --json
|
|
79
|
+
|
|
80
|
+
# exit codes: 0 ALLOW, 5 BLOCK, 6 REVIEW, 3 not found
|
|
81
|
+
canari-gate --store out --list
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
### 2. Drift report (what changed since last week)
|
|
85
|
+
|
|
86
|
+
```
|
|
87
|
+
canari-drift --store out --write out/drift
|
|
88
|
+
# verdict flips / same-version silent changes / findings added / findings removed
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
`run_weekly.py` writes this report automatically after every scan.
|
|
92
|
+
|
|
93
|
+
### 3. Use it from any MCP host (dsh, Codex, Claude, ...)
|
|
94
|
+
|
|
95
|
+
`canari-mcp` speaks MCP over stdio (zero dependencies) and exposes three tools:
|
|
96
|
+
`gate_check`, `verify_bundle`, `store_summary`.
|
|
97
|
+
|
|
98
|
+
```json
|
|
99
|
+
{
|
|
100
|
+
"mcpServers": {
|
|
101
|
+
"canari": {
|
|
102
|
+
"command": "canari-mcp",
|
|
103
|
+
"args": ["--store", "E:/Temp/tbdig/canari/out",
|
|
104
|
+
"--key", "E:/Temp/tbdig/canari/out/public_key.json"]
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
A host (or agent) can then ask: "is npm:express allowed to install?" and get
|
|
111
|
+
`ALLOW / BLOCK / REVIEW` with reasons, backed by a signed, offline-verifiable
|
|
112
|
+
attestation.
|
|
113
|
+
|
|
114
|
+
### 4. Gate the actual install command
|
|
115
|
+
|
|
116
|
+
`canari-guard` wraps an install command, checks every component against the
|
|
117
|
+
ledger, and refuses to execute when the verdict blocks:
|
|
118
|
+
|
|
119
|
+
```
|
|
120
|
+
canari-guard -- dsh plugin --profile wbpj add dsh-purge
|
|
121
|
+
canari-guard -- npm install some-mcp-server
|
|
122
|
+
canari-guard -- pip install mcp-server-fetch==0.2.1
|
|
123
|
+
|
|
124
|
+
# exit 0 allowed+executed | 5 blocked by ledger | 6 review not confirmed
|
|
125
|
+
# --dry-run prints what would run; --allow-review accepts pass-with-findings
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
The host is never patched - the guard sits in front of the install command.
|
|
129
|
+
|
|
130
|
+
For DeepSeek Harness (dsh), add this to the profile's `cordis.patch.yml`
|
|
131
|
+
(verified end-to-end on dsh: the model called `mcp__canari__store_summary` and
|
|
132
|
+
received the live component count):
|
|
133
|
+
|
|
134
|
+
```yaml
|
|
135
|
+
- id: mcp-canari
|
|
136
|
+
name: '@deepseek-ai/dsh-mcp-client'
|
|
137
|
+
config:
|
|
138
|
+
serverName: canari
|
|
139
|
+
transport: stdio
|
|
140
|
+
command: 'E:\Temp\tbdig\_venv_pr_a\Scripts\python.exe'
|
|
141
|
+
args: ['-m', 'canari.mcp_server', '--store', 'E:\Temp\tbdig\canari\out',
|
|
142
|
+
'--key', 'E:\Temp\tbdig\canari\out\public_key.json']
|
|
143
|
+
cwd: 'E:\Temp\tbdig\canari'
|
|
144
|
+
failOnStartupError: true
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
|
|
148
|
+
## Multi-registry coverage
|
|
149
|
+
|
|
150
|
+
| Registry | Source | What we check | What we inherit |
|
|
151
|
+
|---|---|---|---|
|
|
152
|
+
| npm | search API + packument + tarball sha256 | existence, version, artifact hash, maintainers | - |
|
|
153
|
+
| PyPI | Simple API + JSON API | same | - |
|
|
154
|
+
| MCP Registry | official REST | identity presence | - |
|
|
155
|
+
| dsh.so | JSON API | **reference existing L1-L5 conclusions** (not re-scanned) | dsh.so verdicts |
|
|
156
|
+
|
|
157
|
+
## Honest limitations
|
|
158
|
+
|
|
159
|
+
- This is a **risk signal, not a safety guarantee**
|
|
160
|
+
- M0/M1 covers meta-level checks (L1-L2); behavioral checks (L3+) are M1+
|
|
161
|
+
- Scan coverage is limited to what registries expose publicly
|
|
162
|
+
- `expires_at` is 7 days - attestations go stale, re-scan needed
|
|
163
|
+
|
|
164
|
+
## The threat model this addresses
|
|
165
|
+
|
|
166
|
+
postmark-mcp (MITRE ATLAS AML.CS0053): 15 clean versions, then one poisoned commit, ~300 orgs affected. After takedown, **no host was notified**. The gap: no longitudinal observation, no cross-host revocation feed, no portable verdict.
|
|
167
|
+
|
|
168
|
+
Canari fills that gap.
|
|
169
|
+
|
|
170
|
+
## License
|
|
171
|
+
|
|
172
|
+
Apache-2.0. See LICENSE and SECURITY.md.
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"""Canari - Agent Component Verification Ledger.
|
|
2
|
+
|
|
3
|
+
Cross-host attestation ledger for agent components (MCP servers / agent
|
|
4
|
+
skills / DSH plugins). Weekly scans produce signed, offline-verifiable,
|
|
5
|
+
history-preserving verification attestations.
|
|
6
|
+
|
|
7
|
+
Zero-heavy-dependency philosophy (inherited from MemTether):
|
|
8
|
+
hard deps: jsonschema, in-toto (signing), nothing else.
|
|
9
|
+
"""
|
|
10
|
+
|
|
11
|
+
__version__ = "0.1.0"
|
|
12
|
+
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
"""anomaly.py - H2: Metadata anomaly detection.
|
|
2
|
+
|
|
3
|
+
Compares current package metadata with previous metadata from state.json.
|
|
4
|
+
Detects three types of ownership/repository changes:
|
|
5
|
+
1. maintainer_identity_change: author/maintainer changed
|
|
6
|
+
2. project_ownership_change: owner/organization changed
|
|
7
|
+
3. declared_repository_change: source repository URL changed to non-overlapping location
|
|
8
|
+
|
|
9
|
+
trustcheck reference: malicious.py _metadata_anomaly_findings L844-918
|
|
10
|
+
"""
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
def detect_metadata_anomaly(current_meta, previous_meta):
|
|
14
|
+
"""Compare current and previous package metadata for ownership changes.
|
|
15
|
+
|
|
16
|
+
Args:
|
|
17
|
+
current_meta: dict with keys like maintainers, homepage, etc.
|
|
18
|
+
previous_meta: dict from state.json (same structure) or None
|
|
19
|
+
|
|
20
|
+
Returns:
|
|
21
|
+
list of finding dicts, each with id, verdict, tool, evidence_ref.
|
|
22
|
+
Empty list = no anomalies.
|
|
23
|
+
"""
|
|
24
|
+
if not previous_meta or not current_meta:
|
|
25
|
+
return []
|
|
26
|
+
|
|
27
|
+
findings = []
|
|
28
|
+
|
|
29
|
+
# 1. Maintainer identity change
|
|
30
|
+
current_maintainers = _maintainer_identities(current_meta)
|
|
31
|
+
previous_maintainers = _maintainer_identities(previous_meta)
|
|
32
|
+
if current_maintainers and previous_maintainers and current_maintainers != previous_maintainers:
|
|
33
|
+
findings.append({
|
|
34
|
+
"id": "L2.5_METADATA_ANOMALY",
|
|
35
|
+
"verdict": "pass",
|
|
36
|
+
"tool": "canari-anomaly/0.1",
|
|
37
|
+
"evidence_ref": "finding: maintainer_identity_change - previous=%s current=%s" % (
|
|
38
|
+
",".join(sorted(previous_maintainers)),
|
|
39
|
+
",".join(sorted(current_maintainers)),
|
|
40
|
+
),
|
|
41
|
+
})
|
|
42
|
+
|
|
43
|
+
# 2. Repository URL change (non-overlapping)
|
|
44
|
+
current_repos = _repository_urls(current_meta)
|
|
45
|
+
previous_repos = _repository_urls(previous_meta)
|
|
46
|
+
if current_repos and previous_repos and not current_repos.intersection(previous_repos):
|
|
47
|
+
findings.append({
|
|
48
|
+
"id": "L2.5_METADATA_ANOMALY",
|
|
49
|
+
"verdict": "pass",
|
|
50
|
+
"tool": "canari-anomaly/0.1",
|
|
51
|
+
"evidence_ref": "finding: declared_repository_change - previous=%s current=%s" % (
|
|
52
|
+
",".join(sorted(previous_repos)),
|
|
53
|
+
",".join(sorted(current_repos)),
|
|
54
|
+
),
|
|
55
|
+
})
|
|
56
|
+
|
|
57
|
+
return findings
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
def _maintainer_identities(meta):
|
|
61
|
+
"""Extract maintainer identity strings from metadata."""
|
|
62
|
+
identities = set()
|
|
63
|
+
for key in ("maintainers", "author", "author_email"):
|
|
64
|
+
value = meta.get(key)
|
|
65
|
+
if isinstance(value, list):
|
|
66
|
+
for item in value:
|
|
67
|
+
if isinstance(item, dict):
|
|
68
|
+
name = item.get("name", "")
|
|
69
|
+
email = item.get("email", "")
|
|
70
|
+
if name:
|
|
71
|
+
identities.add(name.strip().casefold())
|
|
72
|
+
elif isinstance(item, str) and item.strip():
|
|
73
|
+
identities.add(item.strip().casefold())
|
|
74
|
+
elif isinstance(value, str) and value.strip():
|
|
75
|
+
identities.add(value.strip().casefold())
|
|
76
|
+
return identities
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
def _repository_urls(meta):
|
|
80
|
+
"""Extract normalized repository URLs from metadata."""
|
|
81
|
+
urls = set()
|
|
82
|
+
for key in ("homepage", "repository", "repo_url"):
|
|
83
|
+
value = meta.get(key)
|
|
84
|
+
if isinstance(value, str) and value.strip():
|
|
85
|
+
urls.add(_normalize_url(value))
|
|
86
|
+
if isinstance(value, dict):
|
|
87
|
+
url = value.get("url", "")
|
|
88
|
+
if url and isinstance(url, str):
|
|
89
|
+
urls.add(_normalize_url(url))
|
|
90
|
+
return urls
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
def _normalize_url(url):
|
|
94
|
+
"""Normalize a URL for comparison (lowercase, strip trailing slash, strip .git)."""
|
|
95
|
+
url = url.strip().casefold().rstrip("/")
|
|
96
|
+
if url.endswith(".git"):
|
|
97
|
+
url = url[:-4]
|
|
98
|
+
return url
|