cordon-scanner 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (214) hide show
  1. cordon_scanner-0.1.0/CHANGELOG.md +177 -0
  2. cordon_scanner-0.1.0/CONTRIBUTING.md +68 -0
  3. cordon_scanner-0.1.0/LICENSE +202 -0
  4. cordon_scanner-0.1.0/MANIFEST.in +47 -0
  5. cordon_scanner-0.1.0/NOTICE +26 -0
  6. cordon_scanner-0.1.0/PKG-INFO +657 -0
  7. cordon_scanner-0.1.0/README.md +619 -0
  8. cordon_scanner-0.1.0/SECURITY.md +67 -0
  9. cordon_scanner-0.1.0/action/action.yml +253 -0
  10. cordon_scanner-0.1.0/corpus/benign/config/Dockerfile +10 -0
  11. cordon_scanner-0.1.0/corpus/benign/config/infra.tf +13 -0
  12. cordon_scanner-0.1.0/corpus/benign/config/settings-safe.py +14 -0
  13. cordon_scanner-0.1.0/corpus/benign/config/workflow-ci.yml +25 -0
  14. cordon_scanner-0.1.0/corpus/benign/container-aware/runtime.py +19 -0
  15. cordon_scanner-0.1.0/corpus/benign/gitlab-ordinary/.gitlab-ci.yml +15 -0
  16. cordon_scanner-0.1.0/corpus/benign/javascript/api-client.js +20 -0
  17. cordon_scanner-0.1.0/corpus/benign/javascript/image-utils.js +11 -0
  18. cordon_scanner-0.1.0/corpus/benign/k8s-least-privilege/role.yaml +10 -0
  19. cordon_scanner-0.1.0/corpus/benign/keyring-owner/store.py +17 -0
  20. cordon_scanner-0.1.0/corpus/benign/minified/vendor.min.js +1 -0
  21. cordon_scanner-0.1.0/corpus/benign/npm-native-build/package.json +1 -0
  22. cordon_scanner-0.1.0/corpus/benign/ops/deploy.py +14 -0
  23. cordon_scanner-0.1.0/corpus/benign/ops/healthcheck.py +12 -0
  24. cordon_scanner-0.1.0/corpus/benign/ops/sync.py +10 -0
  25. cordon_scanner-0.1.0/corpus/benign/ordinary-gradle/build.gradle +21 -0
  26. cordon_scanner-0.1.0/corpus/benign/ordinary-makefile/Makefile +21 -0
  27. cordon_scanner-0.1.0/corpus/benign/python/build_helper.py +18 -0
  28. cordon_scanner-0.1.0/corpus/benign/python/settings.py +21 -0
  29. cordon_scanner-0.1.0/corpus/benign/release-attested/.github/workflows/release.yml +24 -0
  30. cordon_scanner-0.1.0/corpus/benign/release-attested/expected.yaml +6 -0
  31. cordon_scanner-0.1.0/corpus/benign/release-unattested/.github/workflows/release.yml +20 -0
  32. cordon_scanner-0.1.0/corpus/benign/release-unattested/expected.yaml +8 -0
  33. cordon_scanner-0.1.0/corpus/benign/retry-backoff/client.py +21 -0
  34. cordon_scanner-0.1.0/corpus/benign/scoped-public-deps/package.json +14 -0
  35. cordon_scanner-0.1.0/corpus/benign/setup-helper/_version.py +7 -0
  36. cordon_scanner-0.1.0/corpus/benign/setup-helper/setup.py +5 -0
  37. cordon_scanner-0.1.0/corpus/benign/string-building/paths.py +12 -0
  38. cordon_scanner-0.1.0/corpus/benign/submodule-pinned/.gitmodules +3 -0
  39. cordon_scanner-0.1.0/corpus/benign/subprocess-git/release.py +16 -0
  40. cordon_scanner-0.1.0/corpus/benign/vendored-binary/vendor/libexample.so +0 -0
  41. cordon_scanner-0.1.0/corpus/benign/webhook-notifier/notify.py +19 -0
  42. cordon_scanner-0.1.0/docs/01-ARCHITECTURE.md +674 -0
  43. cordon_scanner-0.1.0/docs/02-THREAT-MODEL.md +319 -0
  44. cordon_scanner-0.1.0/docs/03-INTERFACES.md +703 -0
  45. cordon_scanner-0.1.0/docs/04-OPERATIONS.md +471 -0
  46. cordon_scanner-0.1.0/docs/05-COVERAGE-MATRIX.md +207 -0
  47. cordon_scanner-0.1.0/docs/06-SANDBOX.md +132 -0
  48. cordon_scanner-0.1.0/docs/assets/demo.svg +37 -0
  49. cordon_scanner-0.1.0/pyproject.toml +219 -0
  50. cordon_scanner-0.1.0/requirements-build.txt +20 -0
  51. cordon_scanner-0.1.0/scripts/generate_sbom.py +175 -0
  52. cordon_scanner-0.1.0/scripts/pin_action_requirements.py +116 -0
  53. cordon_scanner-0.1.0/scripts/render_demo.py +236 -0
  54. cordon_scanner-0.1.0/setup.cfg +4 -0
  55. cordon_scanner-0.1.0/src/cordon_sandbox/__init__.py +29 -0
  56. cordon_scanner-0.1.0/src/cordon_sandbox/cli.py +151 -0
  57. cordon_scanner-0.1.0/src/cordon_sandbox/fetch.py +156 -0
  58. cordon_scanner-0.1.0/src/cordon_sandbox/isolation.py +228 -0
  59. cordon_scanner-0.1.0/src/cordon_sandbox/observe.py +611 -0
  60. cordon_scanner-0.1.0/src/cordon_sandbox/py.typed +0 -0
  61. cordon_scanner-0.1.0/src/cordon_scanner/__init__.py +236 -0
  62. cordon_scanner-0.1.0/src/cordon_scanner/__main__.py +15 -0
  63. cordon_scanner-0.1.0/src/cordon_scanner/archive/__init__.py +0 -0
  64. cordon_scanner-0.1.0/src/cordon_scanner/archive/safe.py +641 -0
  65. cordon_scanner-0.1.0/src/cordon_scanner/cli/__init__.py +0 -0
  66. cordon_scanner-0.1.0/src/cordon_scanner/cli/__main__.py +6 -0
  67. cordon_scanner-0.1.0/src/cordon_scanner/cli/main.py +1342 -0
  68. cordon_scanner-0.1.0/src/cordon_scanner/cli/progress.py +297 -0
  69. cordon_scanner-0.1.0/src/cordon_scanner/core/__init__.py +0 -0
  70. cordon_scanner-0.1.0/src/cordon_scanner/core/audit.py +182 -0
  71. cordon_scanner-0.1.0/src/cordon_scanner/core/bundle.py +267 -0
  72. cordon_scanner-0.1.0/src/cordon_scanner/core/cache.py +631 -0
  73. cordon_scanner-0.1.0/src/cordon_scanner/core/closure.py +137 -0
  74. cordon_scanner-0.1.0/src/cordon_scanner/core/config.py +1891 -0
  75. cordon_scanner-0.1.0/src/cordon_scanner/core/content.py +607 -0
  76. cordon_scanner-0.1.0/src/cordon_scanner/core/distribution.py +153 -0
  77. cordon_scanner-0.1.0/src/cordon_scanner/core/engine.py +2065 -0
  78. cordon_scanner-0.1.0/src/cordon_scanner/core/errors.py +123 -0
  79. cordon_scanner-0.1.0/src/cordon_scanner/core/guard.py +523 -0
  80. cordon_scanner-0.1.0/src/cordon_scanner/core/limits.py +239 -0
  81. cordon_scanner-0.1.0/src/cordon_scanner/core/models.py +1215 -0
  82. cordon_scanner-0.1.0/src/cordon_scanner/core/parallel.py +411 -0
  83. cordon_scanner-0.1.0/src/cordon_scanner/core/paths.py +54 -0
  84. cordon_scanner-0.1.0/src/cordon_scanner/core/policy.py +484 -0
  85. cordon_scanner-0.1.0/src/cordon_scanner/core/progress.py +83 -0
  86. cordon_scanner-0.1.0/src/cordon_scanner/core/prose.py +51 -0
  87. cordon_scanner-0.1.0/src/cordon_scanner/core/redact.py +295 -0
  88. cordon_scanner-0.1.0/src/cordon_scanner/core/registry.py +251 -0
  89. cordon_scanner-0.1.0/src/cordon_scanner/core/scoring.py +289 -0
  90. cordon_scanner-0.1.0/src/cordon_scanner/core/taxonomy.py +306 -0
  91. cordon_scanner-0.1.0/src/cordon_scanner/core/walker.py +845 -0
  92. cordon_scanner-0.1.0/src/cordon_scanner/detect/__init__.py +0 -0
  93. cordon_scanner-0.1.0/src/cordon_scanner/detect/advisory.py +181 -0
  94. cordon_scanner-0.1.0/src/cordon_scanner/detect/attestation.py +213 -0
  95. cordon_scanner-0.1.0/src/cordon_scanner/detect/base.py +364 -0
  96. cordon_scanner-0.1.0/src/cordon_scanner/detect/binary.py +506 -0
  97. cordon_scanner-0.1.0/src/cordon_scanner/detect/capability.py +727 -0
  98. cordon_scanner-0.1.0/src/cordon_scanner/detect/catalogue.py +81 -0
  99. cordon_scanner-0.1.0/src/cordon_scanner/detect/config_files.py +977 -0
  100. cordon_scanner-0.1.0/src/cordon_scanner/detect/dependency.py +732 -0
  101. cordon_scanner-0.1.0/src/cordon_scanner/detect/embedded.py +199 -0
  102. cordon_scanner-0.1.0/src/cordon_scanner/detect/lockfile.py +290 -0
  103. cordon_scanner-0.1.0/src/cordon_scanner/detect/manifest.py +449 -0
  104. cordon_scanner-0.1.0/src/cordon_scanner/detect/obfuscation.py +623 -0
  105. cordon_scanner-0.1.0/src/cordon_scanner/detect/pyast.py +454 -0
  106. cordon_scanner-0.1.0/src/cordon_scanner/detect/registry.py +563 -0
  107. cordon_scanner-0.1.0/src/cordon_scanner/detect/sbom.py +265 -0
  108. cordon_scanner-0.1.0/src/cordon_scanner/detect/secrets.py +1065 -0
  109. cordon_scanner-0.1.0/src/cordon_scanner/detect/vcs.py +269 -0
  110. cordon_scanner-0.1.0/src/cordon_scanner/ecosystems/base.py +402 -0
  111. cordon_scanner-0.1.0/src/cordon_scanner/ecosystems/npm.py +368 -0
  112. cordon_scanner-0.1.0/src/cordon_scanner/ecosystems/others.py +705 -0
  113. cordon_scanner-0.1.0/src/cordon_scanner/ecosystems/pypi.py +483 -0
  114. cordon_scanner-0.1.0/src/cordon_scanner/ecosystems/registry.py +201 -0
  115. cordon_scanner-0.1.0/src/cordon_scanner/intel/__init__.py +0 -0
  116. cordon_scanner-0.1.0/src/cordon_scanner/intel/advisories.py +269 -0
  117. cordon_scanner-0.1.0/src/cordon_scanner/intel/hosts.py +264 -0
  118. cordon_scanner-0.1.0/src/cordon_scanner/intel/popular.py +387 -0
  119. cordon_scanner-0.1.0/src/cordon_scanner/intel/registry_client.py +344 -0
  120. cordon_scanner-0.1.0/src/cordon_scanner/langs/__init__.py +0 -0
  121. cordon_scanner-0.1.0/src/cordon_scanner/langs/registry.py +180 -0
  122. cordon_scanner-0.1.0/src/cordon_scanner/py.typed +0 -0
  123. cordon_scanner-0.1.0/src/cordon_scanner/report/__init__.py +0 -0
  124. cordon_scanner-0.1.0/src/cordon_scanner/report/base.py +228 -0
  125. cordon_scanner-0.1.0/src/cordon_scanner/report/github.py +97 -0
  126. cordon_scanner-0.1.0/src/cordon_scanner/report/json_.py +53 -0
  127. cordon_scanner-0.1.0/src/cordon_scanner/report/junit.py +114 -0
  128. cordon_scanner-0.1.0/src/cordon_scanner/report/markdown.py +114 -0
  129. cordon_scanner-0.1.0/src/cordon_scanner/report/sarif.py +283 -0
  130. cordon_scanner-0.1.0/src/cordon_scanner/report/text.py +427 -0
  131. cordon_scanner-0.1.0/src/cordon_scanner/rules/__init__.py +0 -0
  132. cordon_scanner-0.1.0/src/cordon_scanner/rules/builtin/__init__.py +0 -0
  133. cordon_scanner-0.1.0/src/cordon_scanner/rules/builtin/capabilities-build.yaml +479 -0
  134. cordon_scanner-0.1.0/src/cordon_scanner/rules/builtin/capabilities-dotnet.yaml +228 -0
  135. cordon_scanner-0.1.0/src/cordon_scanner/rules/builtin/capabilities-javascript.yaml +270 -0
  136. cordon_scanner-0.1.0/src/cordon_scanner/rules/builtin/capabilities-jvm-go-ruby.yaml +636 -0
  137. cordon_scanner-0.1.0/src/cordon_scanner/rules/builtin/capabilities-malware-iocs.yaml +616 -0
  138. cordon_scanner-0.1.0/src/cordon_scanner/rules/builtin/capabilities-python.yaml +308 -0
  139. cordon_scanner-0.1.0/src/cordon_scanner/rules/builtin/capabilities-shell.yaml +305 -0
  140. cordon_scanner-0.1.0/src/cordon_scanner/rules/builtin/composites.yaml +701 -0
  141. cordon_scanner-0.1.0/src/cordon_scanner/rules/loader.py +1350 -0
  142. cordon_scanner-0.1.0/src/cordon_scanner/sources/__init__.py +0 -0
  143. cordon_scanner-0.1.0/src/cordon_scanner/sources/base.py +152 -0
  144. cordon_scanner-0.1.0/src/cordon_scanner/sources/git.py +700 -0
  145. cordon_scanner-0.1.0/src/cordon_scanner/version.py +54 -0
  146. cordon_scanner-0.1.0/src/cordon_scanner.egg-info/PKG-INFO +657 -0
  147. cordon_scanner-0.1.0/src/cordon_scanner.egg-info/SOURCES.txt +212 -0
  148. cordon_scanner-0.1.0/src/cordon_scanner.egg-info/dependency_links.txt +1 -0
  149. cordon_scanner-0.1.0/src/cordon_scanner.egg-info/entry_points.txt +26 -0
  150. cordon_scanner-0.1.0/src/cordon_scanner.egg-info/requires.txt +7 -0
  151. cordon_scanner-0.1.0/src/cordon_scanner.egg-info/top_level.txt +2 -0
  152. cordon_scanner-0.1.0/tests/conftest.py +45 -0
  153. cordon_scanner-0.1.0/tests/e2e/test_cli.py +406 -0
  154. cordon_scanner-0.1.0/tests/fuzz/test_parsers.py +206 -0
  155. cordon_scanner-0.1.0/tests/integration/test_audit_criticals.py +235 -0
  156. cordon_scanner-0.1.0/tests/integration/test_audit_high.py +385 -0
  157. cordon_scanner-0.1.0/tests/integration/test_audit_log.py +227 -0
  158. cordon_scanner-0.1.0/tests/integration/test_baseline.py +205 -0
  159. cordon_scanner-0.1.0/tests/integration/test_blinding.py +757 -0
  160. cordon_scanner-0.1.0/tests/integration/test_bundle.py +234 -0
  161. cordon_scanner-0.1.0/tests/integration/test_container_images.py +110 -0
  162. cordon_scanner-0.1.0/tests/integration/test_corpus.py +409 -0
  163. cordon_scanner-0.1.0/tests/integration/test_detector_liveness.py +98 -0
  164. cordon_scanner-0.1.0/tests/integration/test_ecosystem_parity.py +147 -0
  165. cordon_scanner-0.1.0/tests/integration/test_git_modes.py +302 -0
  166. cordon_scanner-0.1.0/tests/integration/test_hostile.py +449 -0
  167. cordon_scanner-0.1.0/tests/integration/test_leakage.py +196 -0
  168. cordon_scanner-0.1.0/tests/integration/test_ordinary_formatting.py +201 -0
  169. cordon_scanner-0.1.0/tests/integration/test_policy_distribution.py +231 -0
  170. cordon_scanner-0.1.0/tests/integration/test_review_advisories.py +330 -0
  171. cordon_scanner-0.1.0/tests/integration/test_review_commands.py +220 -0
  172. cordon_scanner-0.1.0/tests/integration/test_review_critical.py +434 -0
  173. cordon_scanner-0.1.0/tests/integration/test_review_detection.py +294 -0
  174. cordon_scanner-0.1.0/tests/integration/test_review_medium.py +307 -0
  175. cordon_scanner-0.1.0/tests/integration/test_review_rules.py +173 -0
  176. cordon_scanner-0.1.0/tests/integration/test_rule_baselines.py +115 -0
  177. cordon_scanner-0.1.0/tests/matrix.py +135 -0
  178. cordon_scanner-0.1.0/tests/perf/test_budgets.py +189 -0
  179. cordon_scanner-0.1.0/tests/support.py +134 -0
  180. cordon_scanner-0.1.0/tests/unit/test_attestation.py +119 -0
  181. cordon_scanner-0.1.0/tests/unit/test_binary.py +138 -0
  182. cordon_scanner-0.1.0/tests/unit/test_cache.py +280 -0
  183. cordon_scanner-0.1.0/tests/unit/test_composite_scope.py +159 -0
  184. cordon_scanner-0.1.0/tests/unit/test_config.py +492 -0
  185. cordon_scanner-0.1.0/tests/unit/test_content_walker.py +422 -0
  186. cordon_scanner-0.1.0/tests/unit/test_coverage_matrix.py +52 -0
  187. cordon_scanner-0.1.0/tests/unit/test_dependency_domain2.py +160 -0
  188. cordon_scanner-0.1.0/tests/unit/test_detectors.py +459 -0
  189. cordon_scanner-0.1.0/tests/unit/test_documentation.py +354 -0
  190. cordon_scanner-0.1.0/tests/unit/test_ecosystems.py +552 -0
  191. cordon_scanner-0.1.0/tests/unit/test_embedded.py +127 -0
  192. cordon_scanner-0.1.0/tests/unit/test_engine.py +374 -0
  193. cordon_scanner-0.1.0/tests/unit/test_enterprise_noise.py +673 -0
  194. cordon_scanner-0.1.0/tests/unit/test_git_source.py +352 -0
  195. cordon_scanner-0.1.0/tests/unit/test_guard.py +327 -0
  196. cordon_scanner-0.1.0/tests/unit/test_lockfile_parsers.py +492 -0
  197. cordon_scanner-0.1.0/tests/unit/test_models.py +454 -0
  198. cordon_scanner-0.1.0/tests/unit/test_parallel.py +201 -0
  199. cordon_scanner-0.1.0/tests/unit/test_pattern_safety.py +110 -0
  200. cordon_scanner-0.1.0/tests/unit/test_progress.py +393 -0
  201. cordon_scanner-0.1.0/tests/unit/test_pyast.py +241 -0
  202. cordon_scanner-0.1.0/tests/unit/test_real_world_noise.py +142 -0
  203. cordon_scanner-0.1.0/tests/unit/test_redact.py +242 -0
  204. cordon_scanner-0.1.0/tests/unit/test_registry_detector.py +438 -0
  205. cordon_scanner-0.1.0/tests/unit/test_release_artefacts.py +220 -0
  206. cordon_scanner-0.1.0/tests/unit/test_reporters.py +485 -0
  207. cordon_scanner-0.1.0/tests/unit/test_review_defects.py +249 -0
  208. cordon_scanner-0.1.0/tests/unit/test_rules.py +517 -0
  209. cordon_scanner-0.1.0/tests/unit/test_sandbox.py +350 -0
  210. cordon_scanner-0.1.0/tests/unit/test_sbom.py +137 -0
  211. cordon_scanner-0.1.0/tests/unit/test_scoring_policy.py +480 -0
  212. cordon_scanner-0.1.0/tests/unit/test_secrets_assembled.py +209 -0
  213. cordon_scanner-0.1.0/tests/unit/test_taxonomy.py +99 -0
  214. cordon_scanner-0.1.0/tests/unit/test_vcs.py +127 -0
@@ -0,0 +1,177 @@
1
+ # Changelog
2
+
3
+ Format follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).
4
+ Versions follow [semantic versioning](https://semver.org/spec/v2.0.0.html).
5
+
6
+ ## [0.1.0] - 2026-09-09
7
+
8
+ First release. Everything below is in it; there is no earlier published
9
+ version, so nothing here is a change from one.
10
+
11
+ ### Names
12
+
13
+ The distribution is `cordon-scanner`, the console script is `cordon-scanner`,
14
+ and the import package is `cordon_scanner`.
15
+
16
+ Not `cordon` in any of the three. That name belongs on PyPI to an unrelated
17
+ project which ships both a top-level `cordon` package and a `cordon` console
18
+ script, so installing both into one environment has pip write two distributions
19
+ into the same directory and leave whichever landed last. Configuration
20
+ filenames (`cordon.yaml`), cache paths and the `CORDON_*` variables are
21
+ unaffected -- they are not installed names and cannot collide.
22
+
23
+ ### Scanning
24
+
25
+ - Scans a directory, a file or an archive across eight package ecosystems, with
26
+ no third-party runtime dependencies and no network access.
27
+ - `--staged`, `--tracked` and `--git-diff REF`, through a file-source
28
+ abstraction. Staged mode reads blobs from the git index rather than the
29
+ working tree, so a payload cannot be staged and the clean copy restored.
30
+ - Findings in five categories with independent severity and confidence axes.
31
+ `MALICIOUS` at `CONFIRMED` confidence is reachable only through an exact
32
+ package-and-version match against the advisory database.
33
+ - `text`, `json`, `sarif`, `markdown` and `junit` output.
34
+ - A live progress line on standard error while a scan runs, showing the phase,
35
+ the count and the current file. On only when standard error is an
36
+ interactive terminal; `--progress always|never` overrides that. It is on
37
+ standard error so it stays out of the report a pipeline parses, and the paths
38
+ it shows are escaped, because a filename may legally contain an ANSI control
39
+ sequence or a bidirectional override. The line is measured in terminal
40
+ columns rather than code points, so a CJK or emoji filename does not wrap.
41
+ - Incremental cache keyed on content, configuration and detector identity, with
42
+ every entry authenticated by a per-machine HMAC.
43
+ - `cordon-scanner baseline create|compare` and `scan --baseline PATH`, so the tool can
44
+ be adopted on a repository that is not clean yet.
45
+ - `cordon-scanner rules`, `cordon-scanner config`, `cordon-scanner inventory`, `cordon-scanner report` and
46
+ `cordon-scanner guard`, plus `python -m cordon_scanner_scanner`.
47
+
48
+ ### Not looking is reported as not looking
49
+
50
+ The invariant the design is built around: a scan that examined nothing must
51
+ never report like a scan that found nothing.
52
+
53
+ - Configuration supplied by the scan target cannot exclude paths, disable
54
+ detectors or disable rules without that appearing in the report at a severity
55
+ the default gate fails on.
56
+ - A scan that examined no files fails, whether the files were excluded, removed
57
+ by the selected source, or could not be read.
58
+ - Truncated files, per-file and whole-scan timeouts, memory and path limits,
59
+ rejected archive members and detector failures are each reported and mark the
60
+ scan incomplete.
61
+ - Reporting thresholds cannot hide a finding from the failure gate.
62
+ - Organisation policy acts as a ceiling that command-line overrides are
63
+ re-checked against.
64
+
65
+ ### Not becoming the leak
66
+
67
+ - Evidence is redacted at construction, never at render time, so unredacted
68
+ content never reaches a reporter. Secret-category rules cannot opt out.
69
+ - Package coordinates are bounded at the model, so a parser that reads past the
70
+ field it wanted cannot publish the rest of the line.
71
+ - Reports carry no absolute filesystem paths.
72
+
73
+ ### Not executing the target
74
+
75
+ - Manifests and lockfiles are parsed, never invoked; `setup.py` is read through
76
+ `ast.parse` and nothing in it is evaluated.
77
+ - Git runs with system and global configuration disabled and with every
78
+ configuration key that names an external command neutralised, so a
79
+ repository cannot execute code through the scan that examines it.
80
+ - Rule patterns are validated by walking the parsed regex, so nesting,
81
+ lookaheads and non-capturing groups cannot hide a catastrophic shape. Every
82
+ pattern compiled inside the package is held to the same rule by test.
83
+ - File loading opens with `O_NOFOLLOW` and checks the descriptor, closing a
84
+ time-of-check/time-of-use window. Symbolic links are recorded, never
85
+ followed.
86
+ - A third-party distribution cannot shadow a built-in detector.
87
+
88
+ ### The Action
89
+
90
+ - Installs with `--require-hashes` against `action/requirements.txt`, generated
91
+ at release time from the artefacts actually published. Pinning the Action to
92
+ a commit SHA covers `action.yml` only; without this it says nothing about
93
+ what pip downloads, and a compromised index or release account would replace
94
+ the scanner in every workflow using it.
95
+ - A ref carrying no pin refuses to install rather than installing unverified.
96
+ `allow-unverified-install: true` overrides that in the workflow file, where
97
+ it is reviewable, and warns about what it gives up.
98
+ - Every action referenced by this project's own workflows is pinned to a commit
99
+ digest, enforced by test rather than by review.
100
+
101
+ ### Rule kinds
102
+
103
+ `MatchKind` declares `ast`, `structural` and `graph`, and nothing implements
104
+ them. A rule pack using one is refused at load with a message saying so, rather
105
+ than accepted and silently unable to match. A rule that never fires looks
106
+ exactly like a rule that found nothing, which is the failure this project is
107
+ organised around, applied to rules.
108
+
109
+ ### Air-gapped installation
110
+
111
+ - `cordon-scanner bundle create|verify|install` moves a release across an air
112
+ gap with the transfer made checkable. The bundle carries a `MANIFEST.sha256`
113
+ in `sha256sum` format, so an operator who distrusts it does not have to run
114
+ the program inside it to decide whether to trust it.
115
+ - `verify` fails closed on a modified file, a missing file, an unlisted extra
116
+ file, a traversal member, a symlink, or a missing manifest. `install`
117
+ verifies first and writes nothing if verification fails.
118
+ - It reports what it did *not* prove: the manifest shows the bundle is the one
119
+ its own manifest describes, not who produced it. That comes from the detached
120
+ signature made at release.
121
+
122
+ ### Organisation policy distribution
123
+
124
+ - `--policy` accepts a URL, which must carry a `#sha256=` digest. Without one
125
+ it is refused: an organisation policy is the ceiling, so whoever controls the
126
+ network would otherwise control whether the ceiling exists.
127
+ - Fetching requires `--allow-network`, the only network operation the tool has.
128
+ Scanning never uses the network.
129
+ - Verified policies are cached by digest, so the second scan on a machine needs
130
+ no network and an air-gapped site can populate the cache by hand. The digest
131
+ is re-checked on every use, because the cache is an ordinary directory other
132
+ processes can write.
133
+ - HTTPS only, a 1 MB cap, and nothing is cached when verification fails.
134
+
135
+ ### Audit
136
+
137
+ - `--audit-log PATH` appends one JSON line per scan: the rule pack and
138
+ configuration hashes, the commit, counts by severity, whether the scan
139
+ completed, the exit code, and every suppression that applied with its
140
+ justification, approver and expiry. Never file content.
141
+ - A git remote is recorded with its credential stripped. Every CI checkout
142
+ looks like `https://x-access-token:<token>@host/org/repo.git`, and an audit
143
+ log is retained longer and read by more people than a report.
144
+ - An unwritable path is refused before the scan runs, not after it.
145
+ - `Repository.revision` and `remote` are now populated. They were declared,
146
+ serialised into every report and SARIF upload, and never set, so results
147
+ recorded `null` for the two fields that say which code was examined.
148
+
149
+ ### Release integrity
150
+
151
+ - Every release carries a CycloneDX and an SPDX SBOM, generated from packaging
152
+ metadata rather than restated, and recording the digests of the exact files
153
+ published. The dependency list is empty and that is the point: the claim is
154
+ checkable rather than asserted.
155
+ - Artefacts and both SBOMs are signed with Sigstore keyless signing, so there
156
+ is no signing key to protect, rotate or leak.
157
+ - SLSA build provenance is attested for each artefact, and PyPI receives PEP
158
+ 740 attestations, so an installer can ask not only whether the project signed
159
+ something but whether it was built by the process the project describes.
160
+ - Builds set `SOURCE_DATE_EPOCH`, so a third party can rebuild from the tag and
161
+ compare digests with the SBOM.
162
+
163
+ ### Known limits
164
+
165
+ - The bundled advisory database is deliberately small and covers documented
166
+ supply-chain incidents. It is not a substitute for a feed; load one with
167
+ `--advisories`.
168
+ - Semantic (`ast`), structural and graph rule kinds are not implemented, and a
169
+ pack declaring one is refused rather than silently ignored. There is no
170
+ `[ast]` extra: it declared two packages nothing imported, which do not work
171
+ together at their current releases, for a feature that does not exist.
172
+ - The source distribution ships `corpus/benign`, so the false-positive suite
173
+ runs downstream, and not `corpus/malicious`. The detection suite therefore
174
+ skips from an sdist and says so; clone the repository at the release tag to
175
+ run it.
176
+ - The YAML accepted in configuration is a restricted subset: no anchors,
177
+ aliases or tags.
@@ -0,0 +1,68 @@
1
+ # Contributing
2
+
3
+ ## Getting set up
4
+
5
+ ```bash
6
+ git clone https://github.com/Threx-code/cordon
7
+ cd cordon
8
+ python -m venv .venv && . .venv/bin/activate
9
+ pip install -e ".[dev]"
10
+
11
+ pytest -q
12
+ ruff check src/ tests/
13
+ ruff format --check src/ tests/
14
+ cordon-scanner scan . # the tool scans its own repository
15
+ ```
16
+
17
+ Python 3.11 or newer. There are no runtime dependencies and there will not be
18
+ any: it is what makes the air-gapped story real, and every proposal to add one
19
+ should assume it will be refused.
20
+
21
+ ## What a change needs
22
+
23
+ **A test that fails without it.** For a bug fix, the test should reproduce the
24
+ bug. For a detection change, add a sample to `corpus/` or an inline rule sample.
25
+
26
+ **A reason in the code.** Comments and docstrings here explain *why* a decision
27
+ was made, not what the line does. A change that alters a security property
28
+ should say what it prevents and what it costs.
29
+
30
+ **No new runtime dependency.**
31
+
32
+ **Coverage at or above 85 percent**, which CI enforces.
33
+
34
+ ## Adding a detection rule
35
+
36
+ Rules live in `src/cordon_scanner/rules/builtin/` as YAML and are data, not code:
37
+
38
+ ```bash
39
+ cordon-scanner rules list # what exists
40
+ cordon-scanner rules show RULE.ID # one rule in full
41
+ cordon-scanner rules test # every rule's own samples
42
+ ```
43
+
44
+ Every rule declares at least one positive and one negative sample, and the
45
+ loader refuses a pack without them. A rule that parses, compiles, loads and
46
+ matches nothing is the failure a detection tool cannot see from the inside, so
47
+ the samples are what make an inert rule impossible to ship.
48
+
49
+ `confidence: high` additionally requires a zero baseline over `corpus/benign`.
50
+
51
+ Patterns are validated at load time and refused if they can backtrack
52
+ catastrophically. If yours is rejected, rewrite it rather than working around
53
+ the check: Python's `re` cannot be interrupted mid-match, so nothing downstream
54
+ can bound a pathological pattern.
55
+
56
+ ## Reporting a false positive
57
+
58
+ Open an issue with the smallest file that triggers it and the output of
59
+ `cordon-scanner rules show <RULE.ID>`. False positives are treated as seriously as
60
+ missed detections: a tool people mute is a tool that detects nothing.
61
+
62
+ ## Security issues
63
+
64
+ Do not open a public issue. See [SECURITY.md](SECURITY.md).
65
+
66
+ ## Licence
67
+
68
+ Contributions are accepted under Apache-2.0, matching the project.
@@ -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 Cordon 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,47 @@
1
+ # What goes into the source distribution beyond the package itself.
2
+ #
3
+ # A wheel carries the importable package; an sdist is what a distribution
4
+ # packager, an auditor, or anyone rebuilding from source actually receives. For
5
+ # a security tool that gap matters more than usual: without the tests, nobody
6
+ # downstream can verify that the copy they were handed behaves the way the
7
+ # project claims, and re-running the suite is the only check that does not
8
+ # require trusting this repository.
9
+
10
+ include LICENSE
11
+ include README.md
12
+ include CHANGELOG.md
13
+ include requirements-build.txt
14
+ include SECURITY.md
15
+ include CONTRIBUTING.md
16
+
17
+ recursive-include tests *.py *.yaml *.yml *.json *.toml
18
+
19
+ # The benign corpus, which is ordinary source that must produce nothing above
20
+ # `low`. Shipping it lets a downstream packager run the false-positive suite,
21
+ # which is half of what decides whether this product works.
22
+ #
23
+ # `corpus/malicious` is deliberately not shipped. Those fixtures are inert and
24
+ # point only at reserved domains, but they are the shapes a package index's own
25
+ # malware scanning looks for in an sdist. The detection suite therefore skips
26
+ # from an sdist and says so; clone the repository at the release tag to run it.
27
+ recursive-include corpus/benign *
28
+ recursive-include docs *.md
29
+ recursive-include docs/assets *.svg
30
+ recursive-include action *.yml
31
+
32
+ # The release tooling. Shipped for the same reason the tests are: six tests
33
+ # exercise `generate_sbom.py`, and without it the suite an sdist consumer runs
34
+ # is not the suite this project runs -- it errors on a missing file rather than
35
+ # verifying anything. A packager rebuilding from source also needs it to
36
+ # regenerate the bill of materials for their own build.
37
+ recursive-include scripts *.py
38
+
39
+ recursive-include src/cordon_scanner/rules/builtin *.yaml
40
+ include src/cordon_scanner/py.typed
41
+
42
+ # Never shipped: caches, build output and editor state carry nothing a consumer
43
+ # of the sdist can use, and a stale one is a way to ship a file nobody reviewed.
44
+ global-exclude __pycache__ *.py[cod] .DS_Store
45
+ prune .github
46
+ prune reviews
47
+ prune .venv
@@ -0,0 +1,26 @@
1
+ Cordon
2
+ Copyright 2026 Cordon Contributors
3
+
4
+ This product includes software developed by the Cordon Contributors.
5
+
6
+ Licensed under the Apache License, Version 2.0 (the "License"); you may not use
7
+ this file except in compliance with the License. You may obtain a copy of the
8
+ License at
9
+
10
+ http://www.apache.org/licenses/LICENSE-2.0
11
+
12
+ Unless required by applicable law or agreed to in writing, software distributed
13
+ under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
14
+ CONDITIONS OF ANY KIND, either express or implied. See the License for the
15
+ specific language governing permissions and limitations under the License.
16
+
17
+ -------------------------------------------------------------------------------
18
+ Third-party data
19
+
20
+ The Cordon engine has no third-party runtime dependencies.
21
+
22
+ Rule packs and threat-intelligence databases distributed alongside Cordon may
23
+ incorporate third-party data under separate terms. Every pack declares its own
24
+ `license` and `source` fields, and any pack whose licence is incompatible with
25
+ Apache-2.0 is distributed separately rather than bundled with this
26
+ distribution.