bmsdna-devtools 1.4.0__tar.gz → 1.5.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 (156) hide show
  1. {bmsdna_devtools-1.4.0 → bmsdna_devtools-1.5.0}/PKG-INFO +15 -8
  2. {bmsdna_devtools-1.4.0 → bmsdna_devtools-1.5.0}/README.md +14 -7
  3. {bmsdna_devtools-1.4.0 → bmsdna_devtools-1.5.0}/bmsdna/devtools/deps/__init__.py +2 -1
  4. {bmsdna_devtools-1.4.0 → bmsdna_devtools-1.5.0}/bmsdna/devtools/deps/advisories.py +34 -5
  5. {bmsdna_devtools-1.4.0 → bmsdna_devtools-1.5.0}/bmsdna/devtools/deps/cli.py +18 -10
  6. {bmsdna_devtools-1.4.0 → bmsdna_devtools-1.5.0}/bmsdna/devtools/deps/cooldown.py +4 -2
  7. {bmsdna_devtools-1.4.0 → bmsdna_devtools-1.5.0}/bmsdna/devtools/deps/lockfiles.py +84 -5
  8. {bmsdna_devtools-1.4.0 → bmsdna_devtools-1.5.0}/bmsdna/devtools/deps/osv.py +34 -1
  9. {bmsdna_devtools-1.4.0 → bmsdna_devtools-1.5.0}/bmsdna/devtools/deps/versions.py +56 -9
  10. {bmsdna_devtools-1.4.0 → bmsdna_devtools-1.5.0}/pyproject.toml +1 -1
  11. {bmsdna_devtools-1.4.0 → bmsdna_devtools-1.5.0}/tests/test_deps_advisories.py +61 -0
  12. {bmsdna_devtools-1.4.0 → bmsdna_devtools-1.5.0}/tests/test_deps_lockfiles.py +120 -0
  13. {bmsdna_devtools-1.4.0 → bmsdna_devtools-1.5.0}/tests/test_deps_osv.py +31 -0
  14. {bmsdna_devtools-1.4.0 → bmsdna_devtools-1.5.0}/tests/test_deps_versions.py +32 -0
  15. {bmsdna_devtools-1.4.0 → bmsdna_devtools-1.5.0}/uv.lock +1 -1
  16. {bmsdna_devtools-1.4.0 → bmsdna_devtools-1.5.0}/.github/workflows/auto-release.yml +0 -0
  17. {bmsdna_devtools-1.4.0 → bmsdna_devtools-1.5.0}/.github/workflows/python-publish.yml +0 -0
  18. {bmsdna_devtools-1.4.0 → bmsdna_devtools-1.5.0}/.github/workflows/python-test.yml +0 -0
  19. {bmsdna_devtools-1.4.0 → bmsdna_devtools-1.5.0}/.gitignore +0 -0
  20. {bmsdna_devtools-1.4.0 → bmsdna_devtools-1.5.0}/.python-version +0 -0
  21. {bmsdna_devtools-1.4.0 → bmsdna_devtools-1.5.0}/bmsdna/devtools/__init__.py +0 -0
  22. {bmsdna_devtools-1.4.0 → bmsdna_devtools-1.5.0}/bmsdna/devtools/_api_dump.py +0 -0
  23. {bmsdna_devtools-1.4.0 → bmsdna_devtools-1.5.0}/bmsdna/devtools/ado_auth.py +0 -0
  24. {bmsdna_devtools-1.4.0 → bmsdna_devtools-1.5.0}/bmsdna/devtools/ado_issue.py +0 -0
  25. {bmsdna_devtools-1.4.0 → bmsdna_devtools-1.5.0}/bmsdna/devtools/agent_mentions.py +0 -0
  26. {bmsdna_devtools-1.4.0 → bmsdna_devtools-1.5.0}/bmsdna/devtools/api_usage.py +0 -0
  27. {bmsdna_devtools-1.4.0 → bmsdna_devtools-1.5.0}/bmsdna/devtools/app_service_logs.py +0 -0
  28. {bmsdna_devtools-1.4.0 → bmsdna_devtools-1.5.0}/bmsdna/devtools/azure_arm.py +0 -0
  29. {bmsdna_devtools-1.4.0 → bmsdna_devtools-1.5.0}/bmsdna/devtools/azure_auth.py +0 -0
  30. {bmsdna_devtools-1.4.0 → bmsdna_devtools-1.5.0}/bmsdna/devtools/bdt_config.py +0 -0
  31. {bmsdna_devtools-1.4.0 → bmsdna_devtools-1.5.0}/bmsdna/devtools/business_user.py +0 -0
  32. {bmsdna_devtools-1.4.0 → bmsdna_devtools-1.5.0}/bmsdna/devtools/ci_plan.py +0 -0
  33. {bmsdna_devtools-1.4.0 → bmsdna_devtools-1.5.0}/bmsdna/devtools/ci_plan_env.py +0 -0
  34. {bmsdna_devtools-1.4.0 → bmsdna_devtools-1.5.0}/bmsdna/devtools/cleanup_scan.py +0 -0
  35. {bmsdna_devtools-1.4.0 → bmsdna_devtools-1.5.0}/bmsdna/devtools/cli.py +0 -0
  36. {bmsdna_devtools-1.4.0 → bmsdna_devtools-1.5.0}/bmsdna/devtools/cli_tools.py +0 -0
  37. {bmsdna_devtools-1.4.0 → bmsdna_devtools-1.5.0}/bmsdna/devtools/commit.py +0 -0
  38. {bmsdna_devtools-1.4.0 → bmsdna_devtools-1.5.0}/bmsdna/devtools/dead_code.py +0 -0
  39. {bmsdna_devtools-1.4.0 → bmsdna_devtools-1.5.0}/bmsdna/devtools/env_config.py +0 -0
  40. {bmsdna_devtools-1.4.0 → bmsdna_devtools-1.5.0}/bmsdna/devtools/env_files.py +0 -0
  41. {bmsdna_devtools-1.4.0 → bmsdna_devtools-1.5.0}/bmsdna/devtools/find_injection.py +0 -0
  42. {bmsdna_devtools-1.4.0 → bmsdna_devtools-1.5.0}/bmsdna/devtools/find_repo.py +0 -0
  43. {bmsdna_devtools-1.4.0 → bmsdna_devtools-1.5.0}/bmsdna/devtools/gh_args.py +0 -0
  44. {bmsdna_devtools-1.4.0 → bmsdna_devtools-1.5.0}/bmsdna/devtools/gh_issue.py +0 -0
  45. {bmsdna_devtools-1.4.0 → bmsdna_devtools-1.5.0}/bmsdna/devtools/gh_pr.py +0 -0
  46. {bmsdna_devtools-1.4.0 → bmsdna_devtools-1.5.0}/bmsdna/devtools/github_api.py +0 -0
  47. {bmsdna_devtools-1.4.0 → bmsdna_devtools-1.5.0}/bmsdna/devtools/gitrepo.py +0 -0
  48. {bmsdna_devtools-1.4.0 → bmsdna_devtools-1.5.0}/bmsdna/devtools/injection_frontend.py +0 -0
  49. {bmsdna_devtools-1.4.0 → bmsdna_devtools-1.5.0}/bmsdna/devtools/injection_python.py +0 -0
  50. {bmsdna_devtools-1.4.0 → bmsdna_devtools-1.5.0}/bmsdna/devtools/issue_do.py +0 -0
  51. {bmsdna_devtools-1.4.0 → bmsdna_devtools-1.5.0}/bmsdna/devtools/issue_show.py +0 -0
  52. {bmsdna_devtools-1.4.0 → bmsdna_devtools-1.5.0}/bmsdna/devtools/issue_watch.py +0 -0
  53. {bmsdna_devtools-1.4.0 → bmsdna_devtools-1.5.0}/bmsdna/devtools/lint.py +0 -0
  54. {bmsdna_devtools-1.4.0 → bmsdna_devtools-1.5.0}/bmsdna/devtools/lint_findings.py +0 -0
  55. {bmsdna_devtools-1.4.0 → bmsdna_devtools-1.5.0}/bmsdna/devtools/lint_models.py +0 -0
  56. {bmsdna_devtools-1.4.0 → bmsdna_devtools-1.5.0}/bmsdna/devtools/lint_sql.py +0 -0
  57. {bmsdna_devtools-1.4.0 → bmsdna_devtools-1.5.0}/bmsdna/devtools/lint_sql_files.py +0 -0
  58. {bmsdna_devtools-1.4.0 → bmsdna_devtools-1.5.0}/bmsdna/devtools/lint_tooling.py +0 -0
  59. {bmsdna_devtools-1.4.0 → bmsdna_devtools-1.5.0}/bmsdna/devtools/lint_typescript.py +0 -0
  60. {bmsdna_devtools-1.4.0 → bmsdna_devtools-1.5.0}/bmsdna/devtools/logs.py +0 -0
  61. {bmsdna_devtools-1.4.0 → bmsdna_devtools-1.5.0}/bmsdna/devtools/pr_build.py +0 -0
  62. {bmsdna_devtools-1.4.0 → bmsdna_devtools-1.5.0}/bmsdna/devtools/pr_cancel.py +0 -0
  63. {bmsdna_devtools-1.4.0 → bmsdna_devtools-1.5.0}/bmsdna/devtools/pr_choice.py +0 -0
  64. {bmsdna_devtools-1.4.0 → bmsdna_devtools-1.5.0}/bmsdna/devtools/pr_create_args.py +0 -0
  65. {bmsdna_devtools-1.4.0 → bmsdna_devtools-1.5.0}/bmsdna/devtools/pr_drift.py +0 -0
  66. {bmsdna_devtools-1.4.0 → bmsdna_devtools-1.5.0}/bmsdna/devtools/pr_info.py +0 -0
  67. {bmsdna_devtools-1.4.0 → bmsdna_devtools-1.5.0}/bmsdna/devtools/pr_issue_link.py +0 -0
  68. {bmsdna_devtools-1.4.0 → bmsdna_devtools-1.5.0}/bmsdna/devtools/pr_labels.py +0 -0
  69. {bmsdna_devtools-1.4.0 → bmsdna_devtools-1.5.0}/bmsdna/devtools/pr_list.py +0 -0
  70. {bmsdna_devtools-1.4.0 → bmsdna_devtools-1.5.0}/bmsdna/devtools/pr_markdown.py +0 -0
  71. {bmsdna_devtools-1.4.0 → bmsdna_devtools-1.5.0}/bmsdna/devtools/pr_merge_defaults.py +0 -0
  72. {bmsdna_devtools-1.4.0 → bmsdna_devtools-1.5.0}/bmsdna/devtools/pr_ref.py +0 -0
  73. {bmsdna_devtools-1.4.0 → bmsdna_devtools-1.5.0}/bmsdna/devtools/pull.py +0 -0
  74. {bmsdna_devtools-1.4.0 → bmsdna_devtools-1.5.0}/bmsdna/devtools/testdb.py +0 -0
  75. {bmsdna_devtools-1.4.0 → bmsdna_devtools-1.5.0}/bmsdna/devtools/translate.py +0 -0
  76. {bmsdna_devtools-1.4.0 → bmsdna_devtools-1.5.0}/bmsdna/devtools/usage/__init__.py +0 -0
  77. {bmsdna_devtools-1.4.0 → bmsdna_devtools-1.5.0}/bmsdna/devtools/usage/cli.py +0 -0
  78. {bmsdna_devtools-1.4.0 → bmsdna_devtools-1.5.0}/bmsdna/devtools/usage/pipeline.py +0 -0
  79. {bmsdna_devtools-1.4.0 → bmsdna_devtools-1.5.0}/bmsdna/devtools/usage/pricing.py +0 -0
  80. {bmsdna_devtools-1.4.0 → bmsdna_devtools-1.5.0}/bmsdna/devtools/usage/report.py +0 -0
  81. {bmsdna_devtools-1.4.0 → bmsdna_devtools-1.5.0}/bmsdna/devtools/usage/sql/00_schema.sql +0 -0
  82. {bmsdna_devtools-1.4.0 → bmsdna_devtools-1.5.0}/bmsdna/devtools/usage/sql/01_ingest_claude.sql +0 -0
  83. {bmsdna_devtools-1.4.0 → bmsdna_devtools-1.5.0}/bmsdna/devtools/usage/sql/01_ingest_codex.sql +0 -0
  84. {bmsdna_devtools-1.4.0 → bmsdna_devtools-1.5.0}/bmsdna/devtools/usage/sql/02_messages.sql +0 -0
  85. {bmsdna_devtools-1.4.0 → bmsdna_devtools-1.5.0}/bmsdna/devtools/usage/sql/03_markers.sql +0 -0
  86. {bmsdna_devtools-1.4.0 → bmsdna_devtools-1.5.0}/bmsdna/devtools/usage/sql/04_facts.sql +0 -0
  87. {bmsdna_devtools-1.4.0 → bmsdna_devtools-1.5.0}/bmsdna/devtools/usage/sql/05_views.sql +0 -0
  88. {bmsdna_devtools-1.4.0 → bmsdna_devtools-1.5.0}/bmsdna/devtools/worktree.py +0 -0
  89. {bmsdna_devtools-1.4.0 → bmsdna_devtools-1.5.0}/justfile +0 -0
  90. {bmsdna_devtools-1.4.0 → bmsdna_devtools-1.5.0}/prek.toml +0 -0
  91. {bmsdna_devtools-1.4.0 → bmsdna_devtools-1.5.0}/skills/bmsdna-devtools/SKILL.md +0 -0
  92. {bmsdna_devtools-1.4.0 → bmsdna_devtools-1.5.0}/tests/conftest.py +0 -0
  93. {bmsdna_devtools-1.4.0 → bmsdna_devtools-1.5.0}/tests/fake_github.py +0 -0
  94. {bmsdna_devtools-1.4.0 → bmsdna_devtools-1.5.0}/tests/test_ado_auth.py +0 -0
  95. {bmsdna_devtools-1.4.0 → bmsdna_devtools-1.5.0}/tests/test_ado_issue.py +0 -0
  96. {bmsdna_devtools-1.4.0 → bmsdna_devtools-1.5.0}/tests/test_ado_issue_flow.py +0 -0
  97. {bmsdna_devtools-1.4.0 → bmsdna_devtools-1.5.0}/tests/test_agent_mentions.py +0 -0
  98. {bmsdna_devtools-1.4.0 → bmsdna_devtools-1.5.0}/tests/test_api_usage.py +0 -0
  99. {bmsdna_devtools-1.4.0 → bmsdna_devtools-1.5.0}/tests/test_app_service_logs.py +0 -0
  100. {bmsdna_devtools-1.4.0 → bmsdna_devtools-1.5.0}/tests/test_azure_arm.py +0 -0
  101. {bmsdna_devtools-1.4.0 → bmsdna_devtools-1.5.0}/tests/test_bdt_config.py +0 -0
  102. {bmsdna_devtools-1.4.0 → bmsdna_devtools-1.5.0}/tests/test_business_user.py +0 -0
  103. {bmsdna_devtools-1.4.0 → bmsdna_devtools-1.5.0}/tests/test_ci_plan.py +0 -0
  104. {bmsdna_devtools-1.4.0 → bmsdna_devtools-1.5.0}/tests/test_ci_plan_env.py +0 -0
  105. {bmsdna_devtools-1.4.0 → bmsdna_devtools-1.5.0}/tests/test_cleanup_scan.py +0 -0
  106. {bmsdna_devtools-1.4.0 → bmsdna_devtools-1.5.0}/tests/test_cli_cleanup.py +0 -0
  107. {bmsdna_devtools-1.4.0 → bmsdna_devtools-1.5.0}/tests/test_cli_commit.py +0 -0
  108. {bmsdna_devtools-1.4.0 → bmsdna_devtools-1.5.0}/tests/test_cli_deps.py +0 -0
  109. {bmsdna_devtools-1.4.0 → bmsdna_devtools-1.5.0}/tests/test_cli_issue.py +0 -0
  110. {bmsdna_devtools-1.4.0 → bmsdna_devtools-1.5.0}/tests/test_cli_pr_create.py +0 -0
  111. {bmsdna_devtools-1.4.0 → bmsdna_devtools-1.5.0}/tests/test_cli_pr_id.py +0 -0
  112. {bmsdna_devtools-1.4.0 → bmsdna_devtools-1.5.0}/tests/test_cli_pull.py +0 -0
  113. {bmsdna_devtools-1.4.0 → bmsdna_devtools-1.5.0}/tests/test_cli_tools.py +0 -0
  114. {bmsdna_devtools-1.4.0 → bmsdna_devtools-1.5.0}/tests/test_cli_version.py +0 -0
  115. {bmsdna_devtools-1.4.0 → bmsdna_devtools-1.5.0}/tests/test_commit.py +0 -0
  116. {bmsdna_devtools-1.4.0 → bmsdna_devtools-1.5.0}/tests/test_deps_cooldown.py +0 -0
  117. {bmsdna_devtools-1.4.0 → bmsdna_devtools-1.5.0}/tests/test_env_config.py +0 -0
  118. {bmsdna_devtools-1.4.0 → bmsdna_devtools-1.5.0}/tests/test_env_files.py +0 -0
  119. {bmsdna_devtools-1.4.0 → bmsdna_devtools-1.5.0}/tests/test_find_injection.py +0 -0
  120. {bmsdna_devtools-1.4.0 → bmsdna_devtools-1.5.0}/tests/test_find_repo.py +0 -0
  121. {bmsdna_devtools-1.4.0 → bmsdna_devtools-1.5.0}/tests/test_gh_issue.py +0 -0
  122. {bmsdna_devtools-1.4.0 → bmsdna_devtools-1.5.0}/tests/test_gh_pr.py +0 -0
  123. {bmsdna_devtools-1.4.0 → bmsdna_devtools-1.5.0}/tests/test_github_api.py +0 -0
  124. {bmsdna_devtools-1.4.0 → bmsdna_devtools-1.5.0}/tests/test_gitrepo.py +0 -0
  125. {bmsdna_devtools-1.4.0 → bmsdna_devtools-1.5.0}/tests/test_issue_do.py +0 -0
  126. {bmsdna_devtools-1.4.0 → bmsdna_devtools-1.5.0}/tests/test_issue_for_me.py +0 -0
  127. {bmsdna_devtools-1.4.0 → bmsdna_devtools-1.5.0}/tests/test_issue_show.py +0 -0
  128. {bmsdna_devtools-1.4.0 → bmsdna_devtools-1.5.0}/tests/test_issue_watch.py +0 -0
  129. {bmsdna_devtools-1.4.0 → bmsdna_devtools-1.5.0}/tests/test_lint.py +0 -0
  130. {bmsdna_devtools-1.4.0 → bmsdna_devtools-1.5.0}/tests/test_lint_models.py +0 -0
  131. {bmsdna_devtools-1.4.0 → bmsdna_devtools-1.5.0}/tests/test_lint_sql.py +0 -0
  132. {bmsdna_devtools-1.4.0 → bmsdna_devtools-1.5.0}/tests/test_lint_sql_files.py +0 -0
  133. {bmsdna_devtools-1.4.0 → bmsdna_devtools-1.5.0}/tests/test_lint_tooling.py +0 -0
  134. {bmsdna_devtools-1.4.0 → bmsdna_devtools-1.5.0}/tests/test_lint_typescript.py +0 -0
  135. {bmsdna_devtools-1.4.0 → bmsdna_devtools-1.5.0}/tests/test_logs.py +0 -0
  136. {bmsdna_devtools-1.4.0 → bmsdna_devtools-1.5.0}/tests/test_pr_build.py +0 -0
  137. {bmsdna_devtools-1.4.0 → bmsdna_devtools-1.5.0}/tests/test_pr_build_create_options.py +0 -0
  138. {bmsdna_devtools-1.4.0 → bmsdna_devtools-1.5.0}/tests/test_pr_build_flow.py +0 -0
  139. {bmsdna_devtools-1.4.0 → bmsdna_devtools-1.5.0}/tests/test_pr_cancel_build.py +0 -0
  140. {bmsdna_devtools-1.4.0 → bmsdna_devtools-1.5.0}/tests/test_pr_choice.py +0 -0
  141. {bmsdna_devtools-1.4.0 → bmsdna_devtools-1.5.0}/tests/test_pr_create_args.py +0 -0
  142. {bmsdna_devtools-1.4.0 → bmsdna_devtools-1.5.0}/tests/test_pr_description_not_truncated.py +0 -0
  143. {bmsdna_devtools-1.4.0 → bmsdna_devtools-1.5.0}/tests/test_pr_drift.py +0 -0
  144. {bmsdna_devtools-1.4.0 → bmsdna_devtools-1.5.0}/tests/test_pr_info.py +0 -0
  145. {bmsdna_devtools-1.4.0 → bmsdna_devtools-1.5.0}/tests/test_pr_issue_link.py +0 -0
  146. {bmsdna_devtools-1.4.0 → bmsdna_devtools-1.5.0}/tests/test_pr_labels.py +0 -0
  147. {bmsdna_devtools-1.4.0 → bmsdna_devtools-1.5.0}/tests/test_pr_list.py +0 -0
  148. {bmsdna_devtools-1.4.0 → bmsdna_devtools-1.5.0}/tests/test_pr_markdown.py +0 -0
  149. {bmsdna_devtools-1.4.0 → bmsdna_devtools-1.5.0}/tests/test_pr_merge_defaults.py +0 -0
  150. {bmsdna_devtools-1.4.0 → bmsdna_devtools-1.5.0}/tests/test_pull.py +0 -0
  151. {bmsdna_devtools-1.4.0 → bmsdna_devtools-1.5.0}/tests/test_testdb.py +0 -0
  152. {bmsdna_devtools-1.4.0 → bmsdna_devtools-1.5.0}/tests/test_translate.py +0 -0
  153. {bmsdna_devtools-1.4.0 → bmsdna_devtools-1.5.0}/tests/test_usage.py +0 -0
  154. {bmsdna_devtools-1.4.0 → bmsdna_devtools-1.5.0}/tests/test_wait_timeout.py +0 -0
  155. {bmsdna_devtools-1.4.0 → bmsdna_devtools-1.5.0}/tests/test_worktree_clean.py +0 -0
  156. {bmsdna_devtools-1.4.0 → bmsdna_devtools-1.5.0}/tests/test_worktree_create.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: bmsdna-devtools
3
- Version: 1.4.0
3
+ Version: 1.5.0
4
4
  Summary: Shared Azure DevOps / GitHub / git / Azure Monitor developer tooling for BMS projects
5
5
  Requires-Python: >=3.14
6
6
  Requires-Dist: azure-identity>=1.19.0
@@ -1313,9 +1313,12 @@ used is reported as `api-route-baseline-stale`, so the list can only shrink.
1313
1313
  ## `bdt deps affected` / `bdt deps advisories` / `bdt deps cooldown`
1314
1314
 
1315
1315
  Security incidents and supply chain attacks (bmsuisse/devtools#113): which locked dependencies are touched? All
1316
- commands only read: they never edit a file, a lock or an environment. They cover `uv.lock` (PyPI), `bun.lock` (npm) and
1317
- Gradle (Maven: `gradle.lockfile` and the version catalog `gradle/libs.versions.toml`) below each `--path` (default: the
1318
- current directory; `node_modules`, virtualenvs, `.git`, `.gradle` and `.worktrees` are skipped).
1316
+ commands only read: they never edit a file, a lock or an environment. They cover `uv.lock` (PyPI), `bun.lock` (npm),
1317
+ Gradle (Maven: `gradle.lockfile` and the version catalog `gradle/libs.versions.toml`), `Cargo.lock` (crates.io) and NuGet's
1318
+ `packages.lock.json` below each `--path` (default: the current directory; `node_modules`, virtualenvs, `.git`, `.gradle`,
1319
+ Rust `target` and `.worktrees` are skipped). Cargo and NuGet are read from the lockfile only: the version ranges live in
1320
+ `Cargo.toml` / the project files, so a `blocked` status (fix outside the declared range) is not computed for them. A NuGet
1321
+ project needs `RestorePackagesWithLockFile` to have a `packages.lock.json`.
1319
1322
  Git, path, alias and workspace sources, and Gradle entries without an exact version in the catalog (managed by a BOM, or a
1320
1323
  range), can't be matched against an advisory: they are listed as `unsupported`, never skipped. A catalog lists the direct
1321
1324
  dependencies only; transitive ones need Gradle dependency locking (`gradle.lockfile`).
@@ -1325,6 +1328,7 @@ bdt deps affected lodash --version-spec "<4.17.21" --path ~/projects/CCMT2 --pat
1325
1328
  bdt deps advisories --path . # OSV lookup of every locked version, one status per affected package
1326
1329
  bdt deps advisories --json # machine-readable
1327
1330
  bdt deps cooldown --ecosystem Maven --base origin/dev # CI: no Gradle version added or changed within the cooldown
1331
+ bdt deps cooldown --ecosystem NuGet --base origin/main # same for packages.lock.json; Cargo >= 1.100 enforces it itself
1328
1332
  ```
1329
1333
 
1330
1334
  `affected PACKAGE` lists the locked versions of one package (PyPI names are normalised, npm names exact; `--ecosystem`
@@ -1333,9 +1337,12 @@ none matches, 1 a locked version matches, 2 setup error (no lockfile, unreadable
1333
1337
  git/path/alias source of that name could not be matched).
1334
1338
 
1335
1339
  `cooldown` answers "is a locked version younger than the dependency cooldown?" (`--cooldown-days`, default 5). uv
1336
- (`exclude-newer`) and bun (`minimumReleaseAge`) enforce the cooldown while resolving; Gradle has no such setting and
1337
- pins exact versions, so this is its check. The release time is the upload time of the POM (`Last-Modified`) on Maven
1338
- Central, Google Maven or the Gradle plugin portal. `--base REV` looks only at versions the file does not have at `REV`
1340
+ (`exclude-newer`), bun (`minimumReleaseAge`) and Cargo >= 1.100 (`[registry] global-min-publish-age = "5 days"` in
1341
+ `.cargo/config.toml`) enforce the cooldown while resolving; Gradle has no such setting and NuGet's (`minPublishAgeHours`
1342
+ per source in `nuget.config`) does not gate a pinned restore, so this is their check. It also works for a Cargo project
1343
+ on an older toolchain. The release time is the upload time of the POM (`Last-Modified`) on Maven Central,
1344
+ Google Maven or the Gradle plugin portal, `created_at` on crates.io, and `published` on nuget.org (an unlisted package,
1345
+ which nuget.org dates 1900, counts as unknown). `--base REV` looks only at versions the file does not have at `REV`
1339
1346
  (use the target branch in CI, so an old pin never fails a later pull request); without it every locked version is looked
1340
1347
  up. `--exempt NAME` (repeatable, `group:artifact` for Maven) lets one package through: the per-invocation exception for a
1341
1348
  security fix younger than the cooldown, as for uv and bun. Exit 0 none inside the cooldown (or all exempt), 1 a version
@@ -1357,7 +1364,7 @@ cooldown exception flow (`references/audit.md`) acts on it:
1357
1364
 
1358
1365
  The target version is the lowest one the advisory data shows to be outside every affected range of the urgent
1359
1366
  advisories (all of them when none is urgent), never "latest". Lower-severity advisories that need a newer version stay open until a normal bump, and the finding names them. `next:` lines give the per-invocation commands. Unsupported sources are listed but don't change the exit code. The fix's age
1360
- comes from the registry (PyPI: youngest file; npm: `time[version]`); `--cooldown-days` (default 5) is the project's
1367
+ comes from the registry (PyPI: youngest file; npm: `time[version]`; crates.io and NuGet: the release date above); `--cooldown-days` (default 5) is the project's
1361
1368
  cooldown. Compatibility with the parents' ranges of a *transitive* dependency isn't known here: re-run after the bump.
1362
1369
 
1363
1370
  It fails closed: OSV, KEV or an advisory record that can't be read is reported as `incomplete` with exit 3, never as
@@ -1294,9 +1294,12 @@ used is reported as `api-route-baseline-stale`, so the list can only shrink.
1294
1294
  ## `bdt deps affected` / `bdt deps advisories` / `bdt deps cooldown`
1295
1295
 
1296
1296
  Security incidents and supply chain attacks (bmsuisse/devtools#113): which locked dependencies are touched? All
1297
- commands only read: they never edit a file, a lock or an environment. They cover `uv.lock` (PyPI), `bun.lock` (npm) and
1298
- Gradle (Maven: `gradle.lockfile` and the version catalog `gradle/libs.versions.toml`) below each `--path` (default: the
1299
- current directory; `node_modules`, virtualenvs, `.git`, `.gradle` and `.worktrees` are skipped).
1297
+ commands only read: they never edit a file, a lock or an environment. They cover `uv.lock` (PyPI), `bun.lock` (npm),
1298
+ Gradle (Maven: `gradle.lockfile` and the version catalog `gradle/libs.versions.toml`), `Cargo.lock` (crates.io) and NuGet's
1299
+ `packages.lock.json` below each `--path` (default: the current directory; `node_modules`, virtualenvs, `.git`, `.gradle`,
1300
+ Rust `target` and `.worktrees` are skipped). Cargo and NuGet are read from the lockfile only: the version ranges live in
1301
+ `Cargo.toml` / the project files, so a `blocked` status (fix outside the declared range) is not computed for them. A NuGet
1302
+ project needs `RestorePackagesWithLockFile` to have a `packages.lock.json`.
1300
1303
  Git, path, alias and workspace sources, and Gradle entries without an exact version in the catalog (managed by a BOM, or a
1301
1304
  range), can't be matched against an advisory: they are listed as `unsupported`, never skipped. A catalog lists the direct
1302
1305
  dependencies only; transitive ones need Gradle dependency locking (`gradle.lockfile`).
@@ -1306,6 +1309,7 @@ bdt deps affected lodash --version-spec "<4.17.21" --path ~/projects/CCMT2 --pat
1306
1309
  bdt deps advisories --path . # OSV lookup of every locked version, one status per affected package
1307
1310
  bdt deps advisories --json # machine-readable
1308
1311
  bdt deps cooldown --ecosystem Maven --base origin/dev # CI: no Gradle version added or changed within the cooldown
1312
+ bdt deps cooldown --ecosystem NuGet --base origin/main # same for packages.lock.json; Cargo >= 1.100 enforces it itself
1309
1313
  ```
1310
1314
 
1311
1315
  `affected PACKAGE` lists the locked versions of one package (PyPI names are normalised, npm names exact; `--ecosystem`
@@ -1314,9 +1318,12 @@ none matches, 1 a locked version matches, 2 setup error (no lockfile, unreadable
1314
1318
  git/path/alias source of that name could not be matched).
1315
1319
 
1316
1320
  `cooldown` answers "is a locked version younger than the dependency cooldown?" (`--cooldown-days`, default 5). uv
1317
- (`exclude-newer`) and bun (`minimumReleaseAge`) enforce the cooldown while resolving; Gradle has no such setting and
1318
- pins exact versions, so this is its check. The release time is the upload time of the POM (`Last-Modified`) on Maven
1319
- Central, Google Maven or the Gradle plugin portal. `--base REV` looks only at versions the file does not have at `REV`
1321
+ (`exclude-newer`), bun (`minimumReleaseAge`) and Cargo >= 1.100 (`[registry] global-min-publish-age = "5 days"` in
1322
+ `.cargo/config.toml`) enforce the cooldown while resolving; Gradle has no such setting and NuGet's (`minPublishAgeHours`
1323
+ per source in `nuget.config`) does not gate a pinned restore, so this is their check. It also works for a Cargo project
1324
+ on an older toolchain. The release time is the upload time of the POM (`Last-Modified`) on Maven Central,
1325
+ Google Maven or the Gradle plugin portal, `created_at` on crates.io, and `published` on nuget.org (an unlisted package,
1326
+ which nuget.org dates 1900, counts as unknown). `--base REV` looks only at versions the file does not have at `REV`
1320
1327
  (use the target branch in CI, so an old pin never fails a later pull request); without it every locked version is looked
1321
1328
  up. `--exempt NAME` (repeatable, `group:artifact` for Maven) lets one package through: the per-invocation exception for a
1322
1329
  security fix younger than the cooldown, as for uv and bun. Exit 0 none inside the cooldown (or all exempt), 1 a version
@@ -1338,7 +1345,7 @@ cooldown exception flow (`references/audit.md`) acts on it:
1338
1345
 
1339
1346
  The target version is the lowest one the advisory data shows to be outside every affected range of the urgent
1340
1347
  advisories (all of them when none is urgent), never "latest". Lower-severity advisories that need a newer version stay open until a normal bump, and the finding names them. `next:` lines give the per-invocation commands. Unsupported sources are listed but don't change the exit code. The fix's age
1341
- comes from the registry (PyPI: youngest file; npm: `time[version]`); `--cooldown-days` (default 5) is the project's
1348
+ comes from the registry (PyPI: youngest file; npm: `time[version]`; crates.io and NuGet: the release date above); `--cooldown-days` (default 5) is the project's
1342
1349
  cooldown. Compatibility with the parents' ranges of a *transitive* dependency isn't known here: re-run after the bump.
1343
1350
 
1344
1351
  It fails closed: OSV, KEV or an advisory record that can't be read is reported as `incomplete` with exit 3, never as
@@ -1,6 +1,7 @@
1
1
  """`bdt deps`: which locked dependencies a security advisory or supply chain incident touches (bmsuisse/devtools#113).
2
2
 
3
- - `lockfiles` -- read `uv.lock` (PyPI) and `bun.lock` (npm) into one shape
3
+ - `lockfiles` -- read `uv.lock` (PyPI), `bun.lock` (npm), Gradle (Maven), `Cargo.lock` (crates.io) and
4
+ `packages.lock.json` (NuGet) into one shape
4
5
  - `versions` -- version parsing, comparison and range matching per ecosystem
5
6
  - `osv` -- OSV / CISA KEV / registry timestamp client (the only network code)
6
7
  - `advisories` -- turns OSV records into a per-package status; pure logic, no I/O
@@ -18,14 +18,16 @@ known here; re-run after the bump to confirm the locked version moved.
18
18
 
19
19
  from __future__ import annotations
20
20
 
21
+ import shlex
21
22
  from collections.abc import Callable, Iterable
22
23
  from dataclasses import dataclass, field
23
24
  from datetime import datetime
24
- from typing import Any, Literal
25
+ from typing import Any, Literal, cast
25
26
 
26
27
  from bmsdna.devtools.deps.lockfiles import LockedPackage, LockfileContent, Unsupported
27
28
  from bmsdna.devtools.deps.osv import AdvisorySource, DataError, PackageQuery
28
29
  from bmsdna.devtools.deps.versions import (
30
+ ECOSYSTEMS,
29
31
  Ecosystem,
30
32
  SemVer,
31
33
  VersionError,
@@ -74,7 +76,9 @@ def parse_vuln(raw: dict[str, Any]) -> Vuln:
74
76
  for aff in raw.get("affected", []):
75
77
  package = aff.get("package") or {}
76
78
  eco = package.get("ecosystem", "")
77
- name = normalize_name("PyPI", package.get("name", "")) if eco == "PyPI" else package.get("name", "")
79
+ name = package.get("name", "")
80
+ if eco in ECOSYSTEMS:
81
+ name = normalize_name(cast("Ecosystem", eco), name)
78
82
  ranges = tuple((r.get("type", ""), tuple(r.get("events", []))) for r in aff.get("ranges", []))
79
83
  entries.append(AffectedEntry(eco, name, ranges, frozenset(aff.get("versions", []))))
80
84
  scores = tuple(
@@ -138,7 +142,7 @@ FixState = Literal["fixed", "no-fix", "unknown"]
138
142
 
139
143
  def _event_version(ecosystem: Ecosystem, text: str) -> Any:
140
144
  if text == "0":
141
- return SemVer(0, 0, 0) if ecosystem == "npm" else parse_version(ecosystem, "0")
145
+ return SemVer(0, 0, 0) if ecosystem in ("npm", "crates.io") else parse_version(ecosystem, "0")
142
146
  return parse_version(ecosystem, text)
143
147
 
144
148
 
@@ -148,7 +152,8 @@ def fix_for(vuln: Vuln, ecosystem: Ecosystem, name: str, version: str) -> tuple[
148
152
  locked = parse_version(ecosystem, version)
149
153
  except VersionError as exc:
150
154
  return "unknown", None, str(exc)
151
- entries = [a for a in vuln.affected if a.ecosystem == ecosystem and a.name == name]
155
+ wanted = normalize_name(ecosystem, name)
156
+ entries = [a for a in vuln.affected if a.ecosystem == ecosystem and normalize_name(ecosystem, a.name) == wanted]
152
157
  if not entries:
153
158
  return "unknown", None, "the advisory has no affected entry for this package"
154
159
  fixed: list[tuple[Any, str]] = []
@@ -283,7 +288,7 @@ def _commands(finding: Finding) -> list[str]:
283
288
  if finding.status not in ("exempt-eligible", "bump") or not target:
284
289
  return []
285
290
  project = pkg.lockfile.parent.parent if pkg.lockfile.parent.name == "gradle" else pkg.lockfile.parent
286
- where = f"cd {project}"
291
+ where = f"cd {shlex.quote(str(project))}"
287
292
  if pkg.ecosystem == "Maven":
288
293
  step = f"{where} && set {pkg.name} to {target} in the Gradle version catalog (gradle/libs.versions.toml)" + (
289
294
  ", then `./gradlew dependencies --write-locks`" if pkg.lockfile.name == "gradle.lockfile" else ""
@@ -294,6 +299,30 @@ def _commands(finding: Finding) -> list[str]:
294
299
  step,
295
300
  f"{where} && bdt deps cooldown --exempt {pkg.name} # Gradle has no cooldown setting: pass the exception here",
296
301
  ]
302
+ if pkg.ecosystem == "crates.io":
303
+ step = f"{where} && cargo update {pkg.name}@{pkg.version} --precise {target}"
304
+ if finding.status == "bump":
305
+ return [step]
306
+ # Cargo >= 1.100 enforces `registry.global-min-publish-age`; the exception is per invocation and, once the
307
+ # version is in Cargo.lock, the lockfile keeps it (versions already locked bypass the age check). The override
308
+ # covers the whole resolve, not just this crate, hence the check of what else the lockfile picked up.
309
+ return [
310
+ f"{where} && CARGO_RESOLVER_INCOMPATIBLE_PUBLISH_AGE=allow cargo update {pkg.name}@{pkg.version} --precise {target}",
311
+ f"{where} && bdt deps cooldown --ecosystem crates.io --base HEAD --exempt {pkg.name}"
312
+ " # the override applies to the whole resolve: no other version the lockfile picked up may be inside the cooldown",
313
+ ]
314
+ if pkg.ecosystem == "NuGet":
315
+ step = (
316
+ f"{where} && dotnet add package {pkg.name} --version {target}"
317
+ if pkg.direct
318
+ else f"{where} && add {pkg.name} {target} as a direct PackageReference (or a central pin)"
319
+ ) + ", then `dotnet restore --force-evaluate` (rewrites packages.lock.json)"
320
+ if finding.status == "bump":
321
+ return [step]
322
+ return [
323
+ step,
324
+ f"{where} && bdt deps cooldown --exempt {pkg.name} # NuGet has no cooldown setting: pass the exception here",
325
+ ]
297
326
  if pkg.ecosystem == "PyPI":
298
327
  if finding.status == "bump":
299
328
  return [f"{where} && uv lock --upgrade-package {pkg.name} && uv sync"]
@@ -25,14 +25,14 @@ from bmsdna.devtools.deps.versions import ECOSYSTEMS, VersionError, normalize_na
25
25
 
26
26
  deps_app = typer.Typer(
27
27
  name="deps",
28
- help="Which locked dependencies (uv.lock, bun.lock, Gradle) a security advisory or supply chain incident touches",
28
+ help="Which locked dependencies (uv.lock, bun.lock, Gradle, Cargo.lock, NuGet) a security advisory or supply chain incident touches",
29
29
  )
30
30
 
31
31
  PathOption = Annotated[
32
32
  list[Path] | None,
33
33
  typer.Option(
34
34
  "--path",
35
- help="Directory (or lockfile) to scan, repeatable; every uv.lock, bun.lock, gradle.lockfile and gradle/*.versions.toml below it. Default: the current directory.",
35
+ help="Directory (or lockfile) to scan, repeatable; every uv.lock, bun.lock, gradle.lockfile, gradle/*.versions.toml, Cargo.lock and packages.lock.json below it. Default: the current directory.",
36
36
  ),
37
37
  ]
38
38
  EXIT_FOUND, EXIT_SETUP, EXIT_INCOMPLETE = 1, 2, 3
@@ -47,7 +47,10 @@ def _read_all(paths: list[Path] | None) -> list[LockfileContent]:
47
47
  try:
48
48
  lockfiles = find_lockfiles(roots)
49
49
  if not lockfiles:
50
- typer.echo("bdt deps: no uv.lock, bun.lock, gradle.lockfile or Gradle version catalog found", err=True)
50
+ typer.echo(
51
+ "bdt deps: no uv.lock, bun.lock, gradle.lockfile, Gradle version catalog, Cargo.lock or packages.lock.json found",
52
+ err=True,
53
+ )
51
54
  raise typer.Exit(EXIT_SETUP)
52
55
  return [read_lockfile(p) for p in lockfiles]
53
56
  except LockfileError as exc:
@@ -57,7 +60,9 @@ def _read_all(paths: list[Path] | None) -> list[LockfileContent]:
57
60
 
58
61
  @deps_app.command("affected")
59
62
  def affected(
60
- package: Annotated[str, typer.Argument(help="Package name (PyPI names are normalised, npm names are exact)")],
63
+ package: Annotated[
64
+ str, typer.Argument(help="Package name (PyPI/crates.io/NuGet names are normalised, npm names are exact)")
65
+ ],
61
66
  version_spec: Annotated[
62
67
  str | None,
63
68
  typer.Option(
@@ -66,7 +71,8 @@ def affected(
66
71
  ),
67
72
  ] = None,
68
73
  ecosystem: Annotated[
69
- str | None, typer.Option("--ecosystem", help="PyPI, npm or Maven (Gradle). Default: all.")
74
+ str | None,
75
+ typer.Option("--ecosystem", help="PyPI, npm, Maven (Gradle), crates.io (Cargo) or NuGet. Default: all."),
70
76
  ] = None,
71
77
  path: PathOption = None,
72
78
  ) -> None:
@@ -139,7 +145,7 @@ def advisories(
139
145
  ] = DEFAULT_COOLDOWN_DAYS,
140
146
  as_json: Annotated[bool, typer.Option("--json", help="Machine-readable output.")] = False,
141
147
  ) -> None:
142
- """OSV advisories for every locked PyPI/npm/Maven version below --path, with a status each (malicious, needs-triage, no-fix,
148
+ """OSV advisories for every locked PyPI/npm/Maven/crates.io/NuGet version below --path, with a status each (malicious, needs-triage, no-fix,
143
149
  blocked, exempt-eligible, bump, informational; see the maintenance skill, audit.md). Fails closed: if OSV, the CISA KEV
144
150
  feed or a record can't be read the exit code is 3 and nothing is reported as clean. Exit 0 no affected locked version,
145
151
  1 affected, 2 setup error, 3 incomplete. Never edits anything; other lockfile sources are listed as unsupported."""
@@ -186,7 +192,8 @@ def cooldown(
186
192
  exempt: Annotated[
187
193
  list[str] | None,
188
194
  typer.Option(
189
- "--exempt", help="Package (exact name, `group:artifact` for Maven) allowed inside the cooldown. Repeatable."
195
+ "--exempt",
196
+ help="Package (name as locked, `group:artifact` for Maven) allowed inside the cooldown. Repeatable.",
190
197
  ),
191
198
  ] = None,
192
199
  base: Annotated[
@@ -197,11 +204,12 @@ def cooldown(
197
204
  ),
198
205
  ] = None,
199
206
  ecosystem: Annotated[
200
- str | None, typer.Option("--ecosystem", help="PyPI, npm or Maven (Gradle). Default: all.")
207
+ str | None,
208
+ typer.Option("--ecosystem", help="PyPI, npm, Maven (Gradle), crates.io (Cargo) or NuGet. Default: all."),
201
209
  ] = None,
202
210
  ) -> None:
203
- """Locked versions younger than the dependency cooldown. uv and bun enforce it while resolving; Gradle can't, so this is
204
- its check (`--ecosystem Maven --base origin/dev`). Exit 0 none inside the cooldown (or all exempt), 1 a version inside
211
+ """Locked versions younger than the dependency cooldown. uv and bun enforce it while resolving; Cargo >= 1.100 does too
212
+ (`registry.global-min-publish-age`); Gradle and NuGet can't, so this is their check (`--ecosystem Maven --base origin/dev`). Exit 0 none inside the cooldown (or all exempt), 1 a version inside
205
213
  it, 2 setup error, 3 a release time could not be read. Versions without a public release time are listed, not failed."""
206
214
  if ecosystem and ecosystem not in ECOSYSTEMS:
207
215
  typer.echo(f"bdt deps: --ecosystem must be one of {', '.join(ECOSYSTEMS)}", err=True)
@@ -1,7 +1,9 @@
1
1
  """`bdt deps cooldown`: is a locked or pinned version younger than the dependency cooldown?
2
2
 
3
- uv (`exclude-newer`) and bun (`minimumReleaseAge`) enforce the cooldown while resolving. Gradle has no such setting and
4
- catalogs pin exact versions, so for Maven the cooldown is checked here, against the version a branch adds or changes.
3
+ uv (`exclude-newer`), bun (`minimumReleaseAge`) and Cargo >= 1.100 (`registry.global-min-publish-age`) enforce the cooldown
4
+ while resolving. Gradle has no such setting and NuGet's does not gate a pinned restore, so for Maven and NuGet the cooldown
5
+ is checked here, against the version a branch adds or changes (it also works for any other locked version, e.g. Cargo
6
+ projects on an older toolchain).
5
7
  """
6
8
 
7
9
  from __future__ import annotations
@@ -1,4 +1,5 @@
1
- """Read `uv.lock` (PyPI), `bun.lock` (npm), `gradle.lockfile` and Gradle version catalogs (Maven) into `LockedPackage`s.
1
+ """Read `uv.lock` (PyPI), `bun.lock` (npm), `gradle.lockfile` and Gradle version catalogs (Maven), `Cargo.lock` (crates.io)
2
+ and `packages.lock.json` (NuGet) into `LockedPackage`s.
2
3
 
3
4
  Only registry packages are returned; git, path, editable and workspace sources (and Gradle versions a catalog does not pin)
4
5
  are reported as `Unsupported` so a scan never claims to have looked at a dependency it can't match against an advisory.
@@ -17,8 +18,16 @@ from typing import Any, cast
17
18
 
18
19
  from bmsdna.devtools.deps.versions import Ecosystem, normalize_name
19
20
 
20
- LOCKFILE_NAMES = {"uv.lock": "PyPI", "bun.lock": "npm", "gradle.lockfile": "Maven"}
21
- _SKIP_DIRS = frozenset({"node_modules", ".venv", "venv", ".git", ".worktrees", "__pycache__", ".tox", ".gradle"})
21
+ LOCKFILE_NAMES = {
22
+ "uv.lock": "PyPI",
23
+ "bun.lock": "npm",
24
+ "gradle.lockfile": "Maven",
25
+ "Cargo.lock": "crates.io",
26
+ "packages.lock.json": "NuGet",
27
+ }
28
+ _SKIP_DIRS = frozenset(
29
+ {"node_modules", ".venv", "venv", ".git", ".worktrees", "__pycache__", ".tox", ".gradle", "target"}
30
+ )
22
31
 
23
32
 
24
33
  def is_lockfile(path: Path) -> bool:
@@ -56,8 +65,8 @@ class LockfileContent:
56
65
 
57
66
 
58
67
  def find_lockfiles(roots: Iterable[Path]) -> list[Path]:
59
- """Every `uv.lock` / `bun.lock` / `gradle.lockfile` / `gradle/*.versions.toml` below the roots; `node_modules`,
60
- virtualenvs, `.git`, `.gradle` and `.worktrees` are not entered (a root that itself lives inside one is still scanned)."""
68
+ """Every `uv.lock` / `bun.lock` / `gradle.lockfile` / `gradle/*.versions.toml` / `Cargo.lock` / `packages.lock.json`
69
+ below the roots; `node_modules`, virtualenvs, `.git`, `.gradle`, Rust `target` and `.worktrees` are not entered (a root that itself lives inside one is still scanned)."""
61
70
  found: list[Path] = []
62
71
  errors: list[str] = []
63
72
  for root in roots:
@@ -81,6 +90,10 @@ def read_lockfile(path: Path, text: str | None = None) -> LockfileContent:
81
90
  return read_uv_lock(path, text)
82
91
  if path.name == "gradle.lockfile":
83
92
  return read_gradle_lockfile(path, text)
93
+ if path.name == "Cargo.lock":
94
+ return read_cargo_lock(path, text)
95
+ if path.name == "packages.lock.json":
96
+ return read_nuget_lock(path, text)
84
97
  if path.name.endswith(".versions.toml"):
85
98
  return read_gradle_catalog(path, text)
86
99
  return read_bun_lock(path, text)
@@ -297,3 +310,69 @@ def read_gradle_lockfile(path: Path, text: str | None = None) -> LockfileContent
297
310
  seen.add((name, version))
298
311
  content.packages.append(LockedPackage("Maven", name, version, name in direct, path))
299
312
  return content
313
+
314
+
315
+ # ── Cargo.lock ───────────────────────────────────────────────────────────────────────────────────────────────────
316
+
317
+ _CRATES_IO_SOURCES = ("registry+https://github.com/rust-lang/crates.io-index", "sparse+https://index.crates.io/")
318
+
319
+
320
+ def read_cargo_lock(path: Path, text: str | None = None) -> LockfileContent:
321
+ """`Cargo.lock`: every package from crates.io. Direct = listed as a dependency by a workspace member (a package with
322
+ no `source`); the version ranges live in `Cargo.toml`, so `declared` stays empty."""
323
+ data = tomllib.loads(text if text is not None else path.read_text(encoding="utf-8"))
324
+ packages = data.get("package")
325
+ if not isinstance(packages, list) or not packages:
326
+ raise ValueError("no [[package]] entries: not a Cargo lockfile")
327
+ direct: set[tuple[str, str | None]] = set()
328
+ for pkg in packages:
329
+ if "source" not in pkg:
330
+ for dep in pkg.get("dependencies", []): # "name", "name version" or "name version (source)"
331
+ name, _, rest = dep.partition(" ")
332
+ direct.add((name, rest.split(" ")[0] or None))
333
+ content = LockfileContent(path, "crates.io")
334
+ seen: set[tuple[str, str]] = set()
335
+ for pkg in packages:
336
+ source = pkg.get("source")
337
+ if source is None: # a workspace member or path dependency: the project's own code
338
+ continue
339
+ name, version = pkg["name"], pkg["version"]
340
+ if not source.startswith(_CRATES_IO_SOURCES):
341
+ kind = source.partition("+")[0]
342
+ reason = "git source" if kind == "git" else f"{kind} source other than crates.io"
343
+ content.unsupported.append(Unsupported(path, f"{name} {version}", reason))
344
+ continue
345
+ if (name, version) in seen:
346
+ continue
347
+ seen.add((name, version))
348
+ is_direct = (name, version) in direct or (name, None) in direct
349
+ content.packages.append(LockedPackage("crates.io", name, version, is_direct, path))
350
+ return content
351
+
352
+
353
+ # ── packages.lock.json (NuGet) ───────────────────────────────────────────────────────────────────────────────────
354
+
355
+
356
+ def read_nuget_lock(path: Path, text: str | None = None) -> LockfileContent:
357
+ """`packages.lock.json` (`RestorePackagesWithLockFile`): one table per target framework. Direct = `type: Direct`;
358
+ project references are the solution's own code and skipped. The requested range is NuGet interval notation, which is
359
+ not evaluated, so `declared` stays empty."""
360
+ data = json.loads(text if text is not None else path.read_text(encoding="utf-8"))
361
+ frameworks = data.get("dependencies") if isinstance(data, dict) else None
362
+ if not isinstance(frameworks, dict):
363
+ raise ValueError('no "dependencies" object: not a NuGet lockfile')
364
+ content = LockfileContent(path, "NuGet")
365
+ found: dict[tuple[str, str], bool] = {}
366
+ for framework in frameworks.values():
367
+ for name, entry in framework.items():
368
+ if entry.get("type") == "Project":
369
+ continue
370
+ version = entry.get("resolved")
371
+ if not version:
372
+ content.unsupported.append(Unsupported(path, name, "no resolved version in the lockfile"))
373
+ continue
374
+ found[(name, version)] = found.get((name, version), False) or entry.get("type") == "Direct"
375
+ content.packages.extend(
376
+ LockedPackage("NuGet", name, version, direct, path) for (name, version), direct in found.items()
377
+ )
378
+ return content
@@ -20,6 +20,11 @@ OSV_URL = "https://api.osv.dev"
20
20
  KEV_URL = "https://www.cisa.gov/sites/default/files/feeds/known_exploited_vulnerabilities.json"
21
21
  PYPI_URL = "https://pypi.org/pypi"
22
22
  NPM_URL = "https://registry.npmjs.org"
23
+ CRATES_URL = "https://crates.io/api/v1/crates"
24
+ CRATES_USER_AGENT = (
25
+ "bdt (bmsuisse devtools; https://github.com/bmsuisse/devtools)" # crates.io rejects clients without one
26
+ )
27
+ NUGET_URL = "https://api.nuget.org/v3/registration5-gz-semver2"
23
28
  # Where a Gradle dependency can live, in lookup order: the first repository that has the POM gives the release time.
24
29
  MAVEN_REPOS = (
25
30
  "https://repo1.maven.org/maven2",
@@ -161,9 +166,33 @@ class OsvClient:
161
166
  raise DataError(f"{url} unreachable: {last}")
162
167
  return None
163
168
 
169
+ def _crates_release_time(self, name: str, version: str) -> datetime | None:
170
+ """`created_at` of the version on crates.io."""
171
+ url = f"{CRATES_URL}/{quote(name)}/{quote(version)}"
172
+ data = self._request("GET", url, allow_404=True, headers={"User-Agent": CRATES_USER_AGENT})
173
+ if data is None:
174
+ return None
175
+ try:
176
+ return _parse_time(data["version"]["created_at"])
177
+ except (KeyError, TypeError, ValueError) as exc:
178
+ raise DataError(f"{url} has no readable created_at") from exc
179
+
180
+ def _nuget_release_time(self, name: str, version: str) -> datetime | None:
181
+ """`published` of the version's registration leaf on nuget.org (ids and versions are lower-cased there)."""
182
+ url = f"{NUGET_URL}/{quote(name.lower())}/{quote(version.lower())}.json"
183
+ data = self._request("GET", url, allow_404=True)
184
+ if data is None:
185
+ return None
186
+ try:
187
+ published = _parse_time(data["published"])
188
+ except (KeyError, TypeError, ValueError) as exc:
189
+ raise DataError(f"{url} has no readable published date") from exc
190
+ # nuget.org reports 1900-01-01 for an unlisted package: its real date is unknown, not 125 years old
191
+ return None if published.year < 2000 else published
192
+
164
193
  def release_time(self, ecosystem: Ecosystem, name: str, version: str) -> datetime | None:
165
194
  """When the version was published: the youngest file for PyPI (uv gates per file), `time[version]` for npm
166
- (bun's source), the POM's `Last-Modified` for Maven. None when the registry doesn't know it (private package)."""
195
+ (bun's source), `created_at` for crates.io, `published` for NuGet, the POM's `Last-Modified` for Maven. None when the registry doesn't know it (private package)."""
167
196
  if ecosystem == "Maven":
168
197
  return self._maven_release_time(name, version)
169
198
  if ecosystem == "PyPI":
@@ -171,6 +200,10 @@ class OsvClient:
171
200
  files = (data or {}).get("urls") or []
172
201
  times = [f["upload_time_iso_8601"] for f in files if f.get("upload_time_iso_8601")]
173
202
  return max(_parse_time(t) for t in times) if times else None
203
+ if ecosystem == "crates.io":
204
+ return self._crates_release_time(name, version)
205
+ if ecosystem == "NuGet":
206
+ return self._nuget_release_time(name, version)
174
207
  if name not in self._npm_times:
175
208
  data = self._request("GET", f"{NPM_URL}/{quote(name, safe='@')}", allow_404=True)
176
209
  self._npm_times[name] = (data or {}).get("time") or {}
@@ -1,4 +1,5 @@
1
- """Version parsing and matching for the supported ecosystems: PyPI (PEP 440), npm (semver) and Maven (Gradle).
1
+ """Version parsing and matching for the supported ecosystems: PyPI (PEP 440), npm and crates.io (semver), Maven (Gradle)
2
+ and NuGet.
2
3
 
3
4
  A `spec` is a comma/space separated list of comparators (`<4.17.21`, `>=1.0,<2`, `==1.2.3`); declared npm ranges from a
4
5
  `package.json` (`^4`, `~1.2`, `1.x`, `>=1 <3 || ^5`) go through `npm_range_satisfied`.
@@ -14,8 +15,8 @@ from typing import Literal, cast
14
15
  from packaging.specifiers import InvalidSpecifier, SpecifierSet
15
16
  from packaging.version import InvalidVersion, Version
16
17
 
17
- Ecosystem = Literal["PyPI", "npm", "Maven"]
18
- ECOSYSTEMS: tuple[Ecosystem, ...] = ("PyPI", "npm", "Maven")
18
+ Ecosystem = Literal["PyPI", "npm", "Maven", "crates.io", "NuGet"] # OSV's ecosystem names
19
+ ECOSYSTEMS: tuple[Ecosystem, ...] = ("PyPI", "npm", "Maven", "crates.io", "NuGet")
19
20
 
20
21
 
21
22
  class VersionError(ValueError):
@@ -64,6 +65,45 @@ def parse_semver(text: str) -> SemVer:
64
65
  return SemVer(int(major), int(minor), int(patch), prerelease)
65
66
 
66
67
 
68
+ # NuGet: 1 to 4 numeric parts (`1.2.3.4`, a missing part is 0), optional `-prerelease` (compared like semver, case
69
+ # insensitive), `+metadata` ignored.
70
+ _NUGET_RE = re.compile(r"^v?(\d+)(?:\.(\d+))?(?:\.(\d+))?(?:\.(\d+))?(?:-([0-9A-Za-z.-]+))?(?:\+[0-9A-Za-z.-]+)?$")
71
+
72
+
73
+ @total_ordering
74
+ @dataclass(frozen=True, slots=True)
75
+ class NuGetVersion:
76
+ parts: tuple[int, int, int, int]
77
+ prerelease: tuple[int | str, ...] = ()
78
+
79
+ def _key(self) -> tuple:
80
+ pre = (
81
+ (1,)
82
+ if not self.prerelease
83
+ else (0, tuple((0, p, "") if isinstance(p, int) else (1, 0, p) for p in self.prerelease))
84
+ )
85
+ return (self.parts, pre)
86
+
87
+ def __lt__(self, other: object) -> bool:
88
+ if not isinstance(other, NuGetVersion):
89
+ return NotImplemented
90
+ return self._key() < other._key()
91
+
92
+ def __str__(self) -> str:
93
+ pre = "-" + ".".join(map(str, self.prerelease)) if self.prerelease else ""
94
+ return ".".join(map(str, self.parts)) + pre
95
+
96
+
97
+ def parse_nuget(text: str) -> NuGetVersion:
98
+ match = _NUGET_RE.match(text.strip())
99
+ if not match:
100
+ raise VersionError(f"not a NuGet version: {text!r}")
101
+ *numbers, pre = match.groups()
102
+ prerelease = tuple(int(p) if p.isdigit() else p.lower() for p in pre.split(".")) if pre else ()
103
+ padded = [int(n) if n else 0 for n in numbers]
104
+ return NuGetVersion((padded[0], padded[1], padded[2], padded[3]), prerelease)
105
+
106
+
67
107
  # Maven's ComparableVersion (the Maven 3 algorithm): a version is a nested list, a hyphen or a digit/letter change opens a
68
108
  # sublist, trailing "null" items (0, "", "ga", "final", "release") are dropped. `1.0` == `1.0.0`, `1.0-alpha-1` < `1.0-rc1`
69
109
  # < `1.0` < `1.0-sp1` < `1.0-1` < `1.0.1`.
@@ -209,7 +249,7 @@ def parse_maven(text: str) -> MavenVersion:
209
249
  return MavenVersion(cast("tuple[object, ...]", _maven_freeze(("l", root))), text, tuple(root))
210
250
 
211
251
 
212
- def parse_version(ecosystem: Ecosystem, text: str) -> Version | SemVer | MavenVersion:
252
+ def parse_version(ecosystem: Ecosystem, text: str) -> Version | SemVer | MavenVersion | NuGetVersion:
213
253
  if ecosystem == "PyPI":
214
254
  try:
215
255
  return Version(text.strip())
@@ -217,12 +257,19 @@ def parse_version(ecosystem: Ecosystem, text: str) -> Version | SemVer | MavenVe
217
257
  raise VersionError(f"not a PEP 440 version: {text!r}") from exc
218
258
  if ecosystem == "Maven":
219
259
  return parse_maven(text)
220
- return parse_semver(text)
260
+ if ecosystem == "NuGet":
261
+ return parse_nuget(text)
262
+ return parse_semver(text) # npm and crates.io
221
263
 
222
264
 
223
265
  def normalize_name(ecosystem: Ecosystem, name: str) -> str:
224
- """PEP 503 for PyPI (`Foo_Bar.baz` == `foo-bar-baz`); npm names are case-sensitive and compared as they are."""
225
- return re.sub(r"[-_.]+", "-", name).lower() if ecosystem == "PyPI" else name
266
+ """PEP 503 for PyPI (`Foo_Bar.baz` == `foo-bar-baz`); crates.io ignores case and `-`/`_`, NuGet ids ignore case;
267
+ npm and Maven names are case-sensitive and compared as they are."""
268
+ if ecosystem == "PyPI":
269
+ return re.sub(r"[-_.]+", "-", name).lower()
270
+ if ecosystem == "crates.io":
271
+ return name.replace("_", "-").lower()
272
+ return name.lower() if ecosystem == "NuGet" else name
226
273
 
227
274
 
228
275
  _COMPARATOR_RE = re.compile(r"^(<=|>=|==|!=|<|>|=)\s*(\S+)$")
@@ -361,8 +408,8 @@ def _names_prerelease_of(comparator: str, version: SemVer) -> bool:
361
408
 
362
409
 
363
410
  def declared_range_satisfied(ecosystem: Ecosystem, declared: str, version: str) -> bool:
364
- if ecosystem == "Maven": # Gradle catalogs pin exact versions: nothing declared is a range we could evaluate
365
- raise VersionError(f"Maven version ranges are not evaluated: {declared!r}")
411
+ if ecosystem in ("Maven", "crates.io", "NuGet"): # exact pins, or ranges whose syntax is not evaluated here
412
+ raise VersionError(f"{ecosystem} version ranges are not evaluated: {declared!r}")
366
413
  return (
367
414
  pypi_specifier_satisfied(declared, version) if ecosystem == "PyPI" else npm_range_satisfied(declared, version)
368
415
  )
@@ -10,7 +10,7 @@ packages = ["bmsdna"]
10
10
 
11
11
  [project]
12
12
  name = "bmsdna-devtools"
13
- version = "1.4.0"
13
+ version = "1.5.0"
14
14
  description = "Shared Azure DevOps / GitHub / git / Azure Monitor developer tooling for BMS projects"
15
15
  readme = "README.md"
16
16
  requires-python = ">=3.14" # pgdevkit>=0.7.1 requires 3.14; was >=3.11 before adding it as a dependency