Repository navigation
Expand file tree
/
Copy pathpyproject.toml
More file actions
434 lines (411 loc) · 19.2 KB
/
Copy pathpyproject.toml
File metadata and controls
434 lines (411 loc) · 19.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
[build-system]
# Cordon's own backend (scripts/backend/cordon_build.py): the standard library alone, so building
# the wheel, the sdist or an editable install runs no third-party code. The release still drives
# it through the hash-pinned `build` frontend (requirements-build.txt) with --no-isolation.
requires = []
build-backend = "cordon_build"
backend-path = ["scripts/backend"]
[project]
name = "cordon-scanner"
dynamic = ["version"]
description = "Software supply-chain and AI-agent security scanner. Detects malicious packages, suspicious install-time behaviour, poisoned agent skills and MCP servers, secrets, vulnerable dependencies, container and infrastructure-as-code risk, across ecosystems, offline."
readme = "README.md"
license = "Apache-2.0"
license-files = ["LICENSE", "NOTICE"]
authors = [
{ name = "Oluwatosin Amokeodo", email = "oluwatosin.amokeodo@gmail.com" },
]
maintainers = [
{ name = "Oluwatosin Amokeodo", email = "oluwatosin.amokeodo@gmail.com" },
]
keywords = [
"security",
"supply-chain",
"supply-chain-security",
"software-supply-chain",
"malware",
"malware-detection",
"malicious-packages",
"sast",
"sca",
"software-composition-analysis",
"sarif",
"dependency-scanning",
"dependency-confusion",
"typosquatting",
"vulnerability-scanner",
"cve",
"osv",
"sbom",
"cyclonedx",
"spdx",
"vex",
"openvex",
"license-compliance",
"slsa",
"sigstore",
"provenance",
"attestation",
"in-toto",
"dsse",
"rekor",
"openpgp",
"code-signing",
"secrets",
"secret-scanning",
"static-analysis",
"npm",
"pypi",
"cargo",
"maven",
"gradle",
"go-modules",
"rubygems",
"nuget",
"composer",
"homebrew",
"helm",
"ansible",
"docker",
"oci-images",
"vscode-extensions",
"github-actions",
"container-security",
"infrastructure-as-code",
"terraform",
"kubernetes",
"mcp",
"ai-agents",
"agent-security",
"agent-skills",
"ai-bom",
"llm-security",
"prompt-injection",
"model-security",
"pre-commit",
"ci-cd",
"devsecops",
"policy-as-code",
"zero-dependency",
"offline",
"air-gapped",
]
classifiers = [
"Development Status :: 4 - Beta",
"Environment :: Console",
"Intended Audience :: Developers",
"Intended Audience :: Information Technology",
"Intended Audience :: System Administrators",
"Natural Language :: English",
"Operating System :: OS Independent",
"Operating System :: POSIX :: Linux",
"Operating System :: MacOS",
"Operating System :: Microsoft :: Windows",
"Programming Language :: Python",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3 :: Only",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3.13",
"Programming Language :: Python :: 3.14",
"Programming Language :: Python :: 3.15",
"Programming Language :: Python :: Implementation :: CPython",
"Topic :: Security",
"Topic :: Security :: Cryptography",
"Topic :: Software Development :: Build Tools",
"Topic :: Software Development :: Quality Assurance",
"Topic :: Software Development :: Testing",
"Topic :: Software Development :: Libraries :: Python Modules",
"Topic :: System :: Software Distribution",
"Topic :: System :: Systems Administration",
"Typing :: Typed",
]
requires-python = ">=3.11"
# CONSTRAINT C1: the core has ZERO third-party runtime dependencies.
#
# This is not minimalism for its own sake. A supply-chain scanner that pulls a
# transitive dependency tree is asking to become the incident it was bought to
# prevent, and every dependency here would appear in the SBOM of every customer
# who installs it. It also makes the air-gapped story a single wheel with nothing
# to vendor, and it makes `pip download` reproducible without a resolver.
#
# Nothing is optional either: Cordon declares no extras. Every capability is its
# own standard-library code, so there is nothing to install to get more of it.
dependencies = []
# The development and CI toolchain. Never package metadata: no one installing Cordon can pull these
# in. CI installs the locked, hash-pinned set (ci/dev-requirements.txt) and Cordon with --no-deps.
[dependency-groups]
dev = [
"pytest>=8.0",
"pytest-cov>=5.0",
# Distributes the suite across CPU cores with `-n auto`, for fast local
# iteration. The timing-sensitive perf tests are kept out of a parallel run,
# where CPU contention would make their wall-clock assertions flap.
"pytest-xdist>=3.6",
"hypothesis>=6.100",
"ruff>=0.6",
"mypy>=1.11",
]
[project.scripts]
cordon-scanner = "cordon_scanner.cli.main:CommandLine.main"
# The runtime-analysis component. A separate entry point on purpose: the
# scanner never executes what it scans, and this does, so the two must not be
# reachable through the same command. It refuses to do anything without an
# explicit flag, and refuses again if isolation cannot be established.
cordon-sandbox = "cordon_sandbox.cli:SandboxCli.main"
[project.entry-points."cordon_scanner.detectors"]
# Built-in detectors register through the same entry-point mechanism third-party
# detectors use. There is no privileged path: if the plugin system is broken for
# third parties, it is broken for us too, and we find out immediately.
advisory = "cordon_scanner.detect.supply.advisories.detector:AdvisoryDetector"
agent-judge = "cordon_scanner.detect.agents.language_model.detector:AgentJudgeDetector"
agents = "cordon_scanner.detect.agents.chain:AgentChainDetector"
attestation = "cordon_scanner.detect.supply.attestation:AttestationDetector"
campaign-sibling = "cordon_scanner.detect.supply.campaign_sibling:CampaignSiblingDetector"
code-reuse = "cordon_scanner.detect.code.code_reuse:CodeReuseDetector"
recipe-digest = "cordon_scanner.detect.supply.recipe_digests:RecipeDigestDetector"
binary = "cordon_scanner.detect.binary.detector:BinaryDetector"
capability = "cordon_scanner.detect.code.capability.detector:CapabilityDetector"
clamav = "cordon_scanner.detect.binary.clamav:ClamavDetector"
code-model = "cordon_scanner.detect.code.code_model_scores:CodeModelScores"
rule-file = "cordon_scanner.detect.binary.rule_files:RuleFileDetector"
config = "cordon_scanner.detect.infra.config_files:ConfigDetector"
dependency = "cordon_scanner.detect.supply.dependency:DependencyDetector"
formats = "cordon_scanner.detect.binary.formats:FormatDetector"
iac = "cordon_scanner.detect.infra.iac:IacDetector"
license = "cordon_scanner.detect.supply.license:LicenseDetector"
lockfile = "cordon_scanner.detect.supply.lockfile:LockfileDetector"
manifest = "cordon_scanner.detect.supply.manifests.detector:ManifestDetector"
obfuscated-hook = "cordon_scanner.detect.supply.obfuscated_hook:ObfuscatedHookDetector"
pack-rules = "cordon_scanner.detect.code.pack_rules:PackRuleDetector"
mcp-live = "cordon_scanner.detect.agents.mcp_servers.live:LiveMcpDetector"
mcp-packages = "cordon_scanner.detect.agents.mcp_servers.packages:McpPackageDetector"
model = "cordon_scanner.detect.agents.model:ModelDetector"
obfuscation = "cordon_scanner.detect.code.obfuscation.detector:ObfuscationDetector"
os-packages = "cordon_scanner.detect.supply.ospackages:OsPackageDetector"
package-policy = "cordon_scanner.detect.supply.package_policy:PackagePolicyDetector"
provenance = "cordon_scanner.detect.supply.provenance:ProvenanceDetector"
registry = "cordon_scanner.detect.supply.registries.detector:RegistryDetector"
sbom = "cordon_scanner.detect.supply.sbom:SbomDetector"
secrets = "cordon_scanner.detect.secrets.detector:SecretDetector"
slopsquat = "cordon_scanner.detect.supply.slopsquat:SlopsquatDetector"
vcs = "cordon_scanner.detect.source.vcs:VcsDetector"
[project.entry-points."cordon_scanner.reporters"]
text = "cordon_scanner.report.text:TextReporter"
json = "cordon_scanner.report.json_:JsonReporter"
sarif = "cordon_scanner.report.sarif:SarifReporter"
junit = "cordon_scanner.report.junit:JunitReporter"
markdown = "cordon_scanner.report.markdown:MarkdownReporter"
github = "cordon_scanner.report.github:GithubReporter"
codeclimate = "cordon_scanner.report.codeclimate:CodeClimateReporter"
vex = "cordon_scanner.report.vex:VexReporter"
[project.entry-points."cordon_scanner.ecosystem_facts"]
# What classifying a dependency asks of the ecosystems (foundation.dependencies.EcosystemFacts):
# provided by the ecosystems layer, so the domain names no ecosystem.
builtin = "cordon_scanner.ecosystems.registry:RegistryFacts"
[project.entry-points."cordon_scanner.model_providers"]
# The language-model backends `--judge` names (detect.agents.language_model.review.ModelProviders):
# found by entry point, so detection never imports their transports or keys.
builtin = "cordon_scanner.judge.providers:ProviderFactory"
[project.entry-points."cordon_scanner.commands"]
# Front ends that drive the command line's own commands (`cordon-scanner mcp`): found by entry point,
# so the command line never imports the server that runs it.
mcp = "cordon_scanner.mcp.command:McpCommand"
[project.entry-points."cordon_scanner.notifiers"]
webhook = "cordon_scanner.notify.channels.webhook:WebhookChannel"
slack = "cordon_scanner.notify.channels.slack:SlackChannel"
teams = "cordon_scanner.notify.channels.teams:TeamsChannel"
[project.urls]
Homepage = "https://cordonscan.com"
Documentation = "https://github.com/Threx-code/cordon#readme"
Repository = "https://github.com/Threx-code/cordon.git"
"Bug Tracker" = "https://github.com/Threx-code/cordon/issues"
Changelog = "https://github.com/Threx-code/cordon/blob/main/CHANGELOG.md"
Releases = "https://github.com/Threx-code/cordon/releases"
Security = "https://github.com/Threx-code/cordon/blob/main/SECURITY.md"
Tutorials = "https://github.com/Threx-code/cordon/tree/main/tutorials"
Architecture = "https://github.com/Threx-code/cordon/blob/main/docs/01-ARCHITECTURE.md"
[tool.cordon-build]
version-file = "src/cordon_scanner/version.py"
source = "src"
# Every directory under these is a package, `__init__.py` or not, as setuptools' namespace
# discovery had it; the wheel carries each one's modules plus the package data below.
packages = ["cordon_scanner", "cordon_sandbox"]
# Build inputs, not run-time data: the third-party rules the built-in rule pack is assembled from.
# They ship in the sdist with their licence (MANIFEST.in), not in the wheel without it.
exclude = ["cordon_scanner/rules/rule_files/upstream"]
[[tool.cordon-build.native]]
# The anchor automaton (src/cordon_scanner/_native/anchors.c); without a compiler the wheel is pure
# and the rule engine reads anchors in Python, as `cordon-scanner --version` says.
name = "cordon_scanner._native._anchors"
sources = ["src/cordon_scanner/_native/anchors.c"]
[tool.cordon-build.package-data]
"cordon_scanner" = ["py.typed"]
"cordon_sandbox" = ["py.typed"]
"cordon_scanner.rules.builtin" = ["*.yaml", "derivations-*.json"]
# The built-in rule pack (`--rule-file builtin`, detect/binary/rule_files.py) and the records of where
# its rules came from and how they measured. Missing from the wheel before 2026-10-20: an install
# from PyPI had no pack to load.
"cordon_scanner.rules" = ["rule_files/*.yar", "rule_files/*.json"]
# The Public Suffix List snapshot the vt module's domain functions read (psl 2.1.238, MPL-2.0).
"cordon_scanner.detect.binary.modules.reports" = ["data/*.dat"]
# Syft's artifact-to-group map for jars named only by their file (scripts/build/syft_java_groups.py).
"cordon_scanner.images" = ["data/*.json"]
# The detection model's feature patterns (`cordon_scanner.model`).
"cordon_scanner.model" = ["data/*.json"]
# The generated package-name allowlist. A wheel without it falls back to the
# curated sets in `intel/real.py`, which is a working scanner with a far smaller
# allowlist -- so the consequence of leaving this out is not a crash, it is
# typosquat false positives on real packages in every install. Declared here as
# well as in MANIFEST.in because the two govern different artefacts: MANIFEST.in
# the sdist, this the wheel.
#
# `*.json.gz` is the OSV-derived advisory database (scripts/build/build_advisory_db.py)
# and `*.json` its build-metadata and digest sidecars. A wheel without them
# falls back to the small hand-curated `BUNDLED` set in `intel/advisories.py`
# -- again not a crash, but the difference between real vulnerability coverage
# and nine records. The advisory sets are compressed because they are the
# largest thing in the wheel and they are JSON; the sidecars are not, because
# they are read to decide whether the sets can be trusted at all.
# `reuse-index.bin` is the code-reuse index (item 54, `intel/malware/reuse_index.py`), refreshed
# daily through the feed (item 3B); a wheel without it has no reuse check at all.
# `*.tbl` is each advisory file's look-up table (scripts/build/build_advisory_tables.py, item 74):
# read by name with no per-process build, and refused unless it names its data file's digest.
"cordon_scanner.intel.data" = ["*.txt", "*.json", "*.json.gz", "*.csv.gz", "reuse-index.bin", "*.tbl"]
# The schema-generated infrastructure policies and the sidecar recording which
# provider versions produced them. A wheel without them is the curated table
# alone, which is a working scanner with a fifth of the coverage -- so the
# consequence of leaving them out is quiet, which is why they are declared in
# both places that govern an artefact.
"cordon_scanner.detect.data" = ["*.json", "*.json.gz"]
[tool.ruff]
target-version = "py311"
line-length = 100
src = ["src", "tests"]
[tool.ruff.lint]
select = [
"E", # pycodestyle errors
"W", # pycodestyle warnings
"F", # pyflakes
"I", # isort
"B", # bugbear
"C4", # comprehensions
"UP", # pyupgrade
"SIM", # simplify
"RUF", # ruff-specific
"S", # bandit: this project must pass its own class of check
"PTH", # use pathlib
"RET", # return consistency
"PIE", # unnecessary constructs
"PGH", # blanket `noqa` and `type: ignore` are refused: each names its code
"G", # logging calls format lazily
"LOG", # logging used as documented
"TID", # tidy imports
"FA", # postponed annotations where they are needed
"Q", # one quoting style
"BLE", # a blind `except Exception` must say why with `noqa: BLE001`: each one here reports the
# failure as an operational finding or contains it where a later step reports it
]
ignore = [
"E501", # line length is the formatter's job
]
[tool.ruff.lint.per-file-ignores]
# Tests deliberately construct hostile input and assert on it.
# S101 assert - the point of a test
# S105/S106 - fabricated credential shapes, none of them live
# S108 /tmp paths - fixtures
# S314 xml parsing - parsing output this project generated, not input
# S603/S607 subprocess - driving git to build a real repository fixture
"tests/**" = ["S101", "S105", "S106", "S108", "S314", "S603", "S607"]
# The model server's tests: the same, plus binding and calling loopback HTTP on purpose.
"model-server/tests/**" = ["S101", "S104", "S105", "S106", "S310"]
# The corpus is sample data, not source. It is never imported.
"corpus/**" = ["ALL"]
# Conformance cases are dependency files as package managers and projects write them (a Conan
# recipe, a setup.py), scanned as data and never imported or run.
"tests/conformance/cases/**" = ["ALL"]
# The benchmark drives git and the compared tools as subprocesses, and fetches its inputs over
# HTTPS, inside its own container.
# S310 urlopen - fixed https URLs
# S603/S607 subprocess - git, cordon-scanner, guarddog, osv-scanner, trivy by name
"bench/**" = ["S310", "S603", "S607"]
# CDI learning-pipeline tests use pytest asserts, like tests/**.
"bench/**/test_*.py" = ["S101", "S310", "S603", "S607"]
[tool.ruff.lint.isort]
known-first-party = ["cordon_scanner"]
[tool.mypy]
python_version = "3.11"
strict = true
warn_unreachable = true
# The scanner, the sandbox and the maintainers' scripts, all strict: a release or refresh script that
# fails on a type is as broken as the code it builds.
files = ["src/cordon_scanner", "src/cordon_sandbox", "scripts"]
mypy_path = "src"
explicit_package_bases = true
[[tool.mypy.overrides]]
# yaml: CI tooling only. fetch_agent_configs: a bench module scripts/build/import_atr.py puts on the
# path at run time.
module = ["yaml", "fetch_agent_configs"]
ignore_missing_imports = true
[tool.pytest.ini_options]
testpaths = ["tests"]
# So `tests/support.py` is importable as `support` without making `tests` a
# package, which would change collection semantics for every file in it.
pythonpath = ["tests"]
# An expected failure that starts passing fails the run, so a fixed bug's marker cannot outlive it.
xfail_strict = true
addopts = [
# Deselected by default. `perf` generates fifty thousand files, `fuzz`
# explores for hundreds of examples, and `network` reaches an upstream --
# none belongs in the run a developer does on every save. Each has its own
# CI job that selects it explicitly, and a command-line `-m` overrides this
# one because pytest takes the last such option.
"-m",
"not perf and not fuzz and not network",
"--strict-markers",
"--strict-config",
"--tb=short",
"-ra",
]
# A warning is a failure. The suite runs clean, and every warning it has reported so far was a
# real defect: a leaked pipe in the git batch reader, workers forked from a threaded process.
filterwarnings = ["error"]
markers = [
"slow: long-running tests, deselect with -m 'not slow'",
"soak: memory soaks (about 30 minutes); run on main, v* tags and manual runs, not on pull requests",
"corpus: runs against the sample corpus",
"hostile: feeds the scanner input designed to attack it",
"perf: performance budget assertions",
"network: checks bundled data against a live upstream; deselected by default",
"fuzz: property tests over arbitrary bytes; deselected by default",
"conformance(ecosystem, *clauses): proves support-contract clauses (tests/conformance/test_contract.py)",
]
[tool.coverage.run]
source = ["src/cordon_scanner"]
# Every Python process the suite starts is measured: a CLI run as a subprocess, and the scan's
# workers, forked and ended by SIGKILL or os._exit, which save as they go
# (tests/sitehooks/sitecustomize.py, CoverageInWorkers). Without these the gate saw 83% of a suite
# that runs far more, since the ecosystem parsers and detectors run in workers.
patch = ["subprocess", "fork", "_exit"]
# Line coverage only. Branch coverage is the expensive half of the measurement
# by a wide margin -- the same suite takes 418 seconds with it and 52 without --
# and it is measured on one job, on every push, as a gate rather than as a
# report somebody reads.
#
# What it costs: 4,624 branches, 569 of them only half taken, stop being
# visible. An `if` exercised in one direction now reads as covered.
branch = false
[tool.coverage.report]
show_missing = true
skip_covered = false
# 88, not 85, and the three points are not an improvement. Dropping branch
# coverage raises the same suite from 87% to 90% while testing exactly as much
# as it did before, so a threshold left at 85 would go from two points of slack
# to five without anybody choosing that. This keeps the tolerance where it was.
fail_under = 88
exclude_lines = [
"pragma: no cover",
"if TYPE_CHECKING:",
"raise NotImplementedError",
"\\.\\.\\.",
]