bmsdna-devtools 0.56.0__tar.gz → 0.57.1__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.
- {bmsdna_devtools-0.56.0 → bmsdna_devtools-0.57.1}/PKG-INFO +28 -9
- {bmsdna_devtools-0.56.0 → bmsdna_devtools-0.57.1}/README.md +27 -8
- {bmsdna_devtools-0.56.0 → bmsdna_devtools-0.57.1}/bmsdna/devtools/cli.py +11 -3
- {bmsdna_devtools-0.56.0 → bmsdna_devtools-0.57.1}/bmsdna/devtools/deps/advisories.py +12 -1
- {bmsdna_devtools-0.56.0 → bmsdna_devtools-0.57.1}/bmsdna/devtools/deps/cli.py +83 -6
- bmsdna_devtools-0.57.1/bmsdna/devtools/deps/cooldown.py +83 -0
- {bmsdna_devtools-0.56.0 → bmsdna_devtools-0.57.1}/bmsdna/devtools/deps/lockfiles.py +104 -15
- {bmsdna_devtools-0.56.0 → bmsdna_devtools-0.57.1}/bmsdna/devtools/deps/osv.py +42 -1
- {bmsdna_devtools-0.56.0 → bmsdna_devtools-0.57.1}/bmsdna/devtools/deps/versions.py +154 -5
- {bmsdna_devtools-0.56.0 → bmsdna_devtools-0.57.1}/bmsdna/devtools/find_repo.py +102 -20
- {bmsdna_devtools-0.56.0 → bmsdna_devtools-0.57.1}/pyproject.toml +1 -1
- {bmsdna_devtools-0.56.0 → bmsdna_devtools-0.57.1}/skills/bmsdna-devtools/SKILL.md +4 -3
- {bmsdna_devtools-0.56.0 → bmsdna_devtools-0.57.1}/tests/test_cli_deps.py +90 -0
- bmsdna_devtools-0.57.1/tests/test_deps_cooldown.py +90 -0
- {bmsdna_devtools-0.56.0 → bmsdna_devtools-0.57.1}/tests/test_deps_lockfiles.py +88 -0
- {bmsdna_devtools-0.56.0 → bmsdna_devtools-0.57.1}/tests/test_deps_osv.py +31 -2
- {bmsdna_devtools-0.56.0 → bmsdna_devtools-0.57.1}/tests/test_deps_versions.py +29 -0
- {bmsdna_devtools-0.56.0 → bmsdna_devtools-0.57.1}/tests/test_find_repo.py +134 -2
- {bmsdna_devtools-0.56.0 → bmsdna_devtools-0.57.1}/uv.lock +1 -1
- {bmsdna_devtools-0.56.0 → bmsdna_devtools-0.57.1}/.github/workflows/auto-release.yml +0 -0
- {bmsdna_devtools-0.56.0 → bmsdna_devtools-0.57.1}/.github/workflows/python-publish.yml +0 -0
- {bmsdna_devtools-0.56.0 → bmsdna_devtools-0.57.1}/.github/workflows/python-test.yml +0 -0
- {bmsdna_devtools-0.56.0 → bmsdna_devtools-0.57.1}/.gitignore +0 -0
- {bmsdna_devtools-0.56.0 → bmsdna_devtools-0.57.1}/.python-version +0 -0
- {bmsdna_devtools-0.56.0 → bmsdna_devtools-0.57.1}/bmsdna/devtools/__init__.py +0 -0
- {bmsdna_devtools-0.56.0 → bmsdna_devtools-0.57.1}/bmsdna/devtools/_api_dump.py +0 -0
- {bmsdna_devtools-0.56.0 → bmsdna_devtools-0.57.1}/bmsdna/devtools/ado_auth.py +0 -0
- {bmsdna_devtools-0.56.0 → bmsdna_devtools-0.57.1}/bmsdna/devtools/ado_issue.py +0 -0
- {bmsdna_devtools-0.56.0 → bmsdna_devtools-0.57.1}/bmsdna/devtools/agent_mentions.py +0 -0
- {bmsdna_devtools-0.56.0 → bmsdna_devtools-0.57.1}/bmsdna/devtools/api_usage.py +0 -0
- {bmsdna_devtools-0.56.0 → bmsdna_devtools-0.57.1}/bmsdna/devtools/app_service_logs.py +0 -0
- {bmsdna_devtools-0.56.0 → bmsdna_devtools-0.57.1}/bmsdna/devtools/azure_arm.py +0 -0
- {bmsdna_devtools-0.56.0 → bmsdna_devtools-0.57.1}/bmsdna/devtools/azure_auth.py +0 -0
- {bmsdna_devtools-0.56.0 → bmsdna_devtools-0.57.1}/bmsdna/devtools/bdt_config.py +0 -0
- {bmsdna_devtools-0.56.0 → bmsdna_devtools-0.57.1}/bmsdna/devtools/business_user.py +0 -0
- {bmsdna_devtools-0.56.0 → bmsdna_devtools-0.57.1}/bmsdna/devtools/ci_plan.py +0 -0
- {bmsdna_devtools-0.56.0 → bmsdna_devtools-0.57.1}/bmsdna/devtools/ci_plan_env.py +0 -0
- {bmsdna_devtools-0.56.0 → bmsdna_devtools-0.57.1}/bmsdna/devtools/cli_tools.py +0 -0
- {bmsdna_devtools-0.56.0 → bmsdna_devtools-0.57.1}/bmsdna/devtools/commit.py +0 -0
- {bmsdna_devtools-0.56.0 → bmsdna_devtools-0.57.1}/bmsdna/devtools/dead_code.py +0 -0
- {bmsdna_devtools-0.56.0 → bmsdna_devtools-0.57.1}/bmsdna/devtools/deps/__init__.py +0 -0
- {bmsdna_devtools-0.56.0 → bmsdna_devtools-0.57.1}/bmsdna/devtools/env_config.py +0 -0
- {bmsdna_devtools-0.56.0 → bmsdna_devtools-0.57.1}/bmsdna/devtools/env_files.py +0 -0
- {bmsdna_devtools-0.56.0 → bmsdna_devtools-0.57.1}/bmsdna/devtools/find_injection.py +0 -0
- {bmsdna_devtools-0.56.0 → bmsdna_devtools-0.57.1}/bmsdna/devtools/gh_args.py +0 -0
- {bmsdna_devtools-0.56.0 → bmsdna_devtools-0.57.1}/bmsdna/devtools/gh_issue.py +0 -0
- {bmsdna_devtools-0.56.0 → bmsdna_devtools-0.57.1}/bmsdna/devtools/gh_pr.py +0 -0
- {bmsdna_devtools-0.56.0 → bmsdna_devtools-0.57.1}/bmsdna/devtools/github_api.py +0 -0
- {bmsdna_devtools-0.56.0 → bmsdna_devtools-0.57.1}/bmsdna/devtools/gitrepo.py +0 -0
- {bmsdna_devtools-0.56.0 → bmsdna_devtools-0.57.1}/bmsdna/devtools/injection_frontend.py +0 -0
- {bmsdna_devtools-0.56.0 → bmsdna_devtools-0.57.1}/bmsdna/devtools/injection_python.py +0 -0
- {bmsdna_devtools-0.56.0 → bmsdna_devtools-0.57.1}/bmsdna/devtools/issue_do.py +0 -0
- {bmsdna_devtools-0.56.0 → bmsdna_devtools-0.57.1}/bmsdna/devtools/issue_show.py +0 -0
- {bmsdna_devtools-0.56.0 → bmsdna_devtools-0.57.1}/bmsdna/devtools/issue_watch.py +0 -0
- {bmsdna_devtools-0.56.0 → bmsdna_devtools-0.57.1}/bmsdna/devtools/lint.py +0 -0
- {bmsdna_devtools-0.56.0 → bmsdna_devtools-0.57.1}/bmsdna/devtools/lint_findings.py +0 -0
- {bmsdna_devtools-0.56.0 → bmsdna_devtools-0.57.1}/bmsdna/devtools/lint_models.py +0 -0
- {bmsdna_devtools-0.56.0 → bmsdna_devtools-0.57.1}/bmsdna/devtools/lint_sql.py +0 -0
- {bmsdna_devtools-0.56.0 → bmsdna_devtools-0.57.1}/bmsdna/devtools/lint_sql_files.py +0 -0
- {bmsdna_devtools-0.56.0 → bmsdna_devtools-0.57.1}/bmsdna/devtools/lint_tooling.py +0 -0
- {bmsdna_devtools-0.56.0 → bmsdna_devtools-0.57.1}/bmsdna/devtools/lint_typescript.py +0 -0
- {bmsdna_devtools-0.56.0 → bmsdna_devtools-0.57.1}/bmsdna/devtools/logs.py +0 -0
- {bmsdna_devtools-0.56.0 → bmsdna_devtools-0.57.1}/bmsdna/devtools/pr_build.py +0 -0
- {bmsdna_devtools-0.56.0 → bmsdna_devtools-0.57.1}/bmsdna/devtools/pr_cancel.py +0 -0
- {bmsdna_devtools-0.56.0 → bmsdna_devtools-0.57.1}/bmsdna/devtools/pr_choice.py +0 -0
- {bmsdna_devtools-0.56.0 → bmsdna_devtools-0.57.1}/bmsdna/devtools/pr_create_args.py +0 -0
- {bmsdna_devtools-0.56.0 → bmsdna_devtools-0.57.1}/bmsdna/devtools/pr_drift.py +0 -0
- {bmsdna_devtools-0.56.0 → bmsdna_devtools-0.57.1}/bmsdna/devtools/pr_info.py +0 -0
- {bmsdna_devtools-0.56.0 → bmsdna_devtools-0.57.1}/bmsdna/devtools/pr_issue_link.py +0 -0
- {bmsdna_devtools-0.56.0 → bmsdna_devtools-0.57.1}/bmsdna/devtools/pr_labels.py +0 -0
- {bmsdna_devtools-0.56.0 → bmsdna_devtools-0.57.1}/bmsdna/devtools/pr_markdown.py +0 -0
- {bmsdna_devtools-0.56.0 → bmsdna_devtools-0.57.1}/bmsdna/devtools/pr_merge_defaults.py +0 -0
- {bmsdna_devtools-0.56.0 → bmsdna_devtools-0.57.1}/bmsdna/devtools/pr_ref.py +0 -0
- {bmsdna_devtools-0.56.0 → bmsdna_devtools-0.57.1}/bmsdna/devtools/pull.py +0 -0
- {bmsdna_devtools-0.56.0 → bmsdna_devtools-0.57.1}/bmsdna/devtools/testdb.py +0 -0
- {bmsdna_devtools-0.56.0 → bmsdna_devtools-0.57.1}/bmsdna/devtools/translate.py +0 -0
- {bmsdna_devtools-0.56.0 → bmsdna_devtools-0.57.1}/bmsdna/devtools/usage/__init__.py +0 -0
- {bmsdna_devtools-0.56.0 → bmsdna_devtools-0.57.1}/bmsdna/devtools/usage/cli.py +0 -0
- {bmsdna_devtools-0.56.0 → bmsdna_devtools-0.57.1}/bmsdna/devtools/usage/pipeline.py +0 -0
- {bmsdna_devtools-0.56.0 → bmsdna_devtools-0.57.1}/bmsdna/devtools/usage/pricing.py +0 -0
- {bmsdna_devtools-0.56.0 → bmsdna_devtools-0.57.1}/bmsdna/devtools/usage/report.py +0 -0
- {bmsdna_devtools-0.56.0 → bmsdna_devtools-0.57.1}/bmsdna/devtools/usage/sql/00_schema.sql +0 -0
- {bmsdna_devtools-0.56.0 → bmsdna_devtools-0.57.1}/bmsdna/devtools/usage/sql/01_ingest_claude.sql +0 -0
- {bmsdna_devtools-0.56.0 → bmsdna_devtools-0.57.1}/bmsdna/devtools/usage/sql/01_ingest_codex.sql +0 -0
- {bmsdna_devtools-0.56.0 → bmsdna_devtools-0.57.1}/bmsdna/devtools/usage/sql/02_messages.sql +0 -0
- {bmsdna_devtools-0.56.0 → bmsdna_devtools-0.57.1}/bmsdna/devtools/usage/sql/03_markers.sql +0 -0
- {bmsdna_devtools-0.56.0 → bmsdna_devtools-0.57.1}/bmsdna/devtools/usage/sql/04_facts.sql +0 -0
- {bmsdna_devtools-0.56.0 → bmsdna_devtools-0.57.1}/bmsdna/devtools/usage/sql/05_views.sql +0 -0
- {bmsdna_devtools-0.56.0 → bmsdna_devtools-0.57.1}/bmsdna/devtools/worktree.py +0 -0
- {bmsdna_devtools-0.56.0 → bmsdna_devtools-0.57.1}/justfile +0 -0
- {bmsdna_devtools-0.56.0 → bmsdna_devtools-0.57.1}/tests/conftest.py +0 -0
- {bmsdna_devtools-0.56.0 → bmsdna_devtools-0.57.1}/tests/fake_github.py +0 -0
- {bmsdna_devtools-0.56.0 → bmsdna_devtools-0.57.1}/tests/test_ado_auth.py +0 -0
- {bmsdna_devtools-0.56.0 → bmsdna_devtools-0.57.1}/tests/test_ado_issue.py +0 -0
- {bmsdna_devtools-0.56.0 → bmsdna_devtools-0.57.1}/tests/test_ado_issue_flow.py +0 -0
- {bmsdna_devtools-0.56.0 → bmsdna_devtools-0.57.1}/tests/test_agent_mentions.py +0 -0
- {bmsdna_devtools-0.56.0 → bmsdna_devtools-0.57.1}/tests/test_api_usage.py +0 -0
- {bmsdna_devtools-0.56.0 → bmsdna_devtools-0.57.1}/tests/test_app_service_logs.py +0 -0
- {bmsdna_devtools-0.56.0 → bmsdna_devtools-0.57.1}/tests/test_azure_arm.py +0 -0
- {bmsdna_devtools-0.56.0 → bmsdna_devtools-0.57.1}/tests/test_bdt_config.py +0 -0
- {bmsdna_devtools-0.56.0 → bmsdna_devtools-0.57.1}/tests/test_business_user.py +0 -0
- {bmsdna_devtools-0.56.0 → bmsdna_devtools-0.57.1}/tests/test_ci_plan.py +0 -0
- {bmsdna_devtools-0.56.0 → bmsdna_devtools-0.57.1}/tests/test_ci_plan_env.py +0 -0
- {bmsdna_devtools-0.56.0 → bmsdna_devtools-0.57.1}/tests/test_cli_cleanup.py +0 -0
- {bmsdna_devtools-0.56.0 → bmsdna_devtools-0.57.1}/tests/test_cli_commit.py +0 -0
- {bmsdna_devtools-0.56.0 → bmsdna_devtools-0.57.1}/tests/test_cli_issue.py +0 -0
- {bmsdna_devtools-0.56.0 → bmsdna_devtools-0.57.1}/tests/test_cli_pr_create.py +0 -0
- {bmsdna_devtools-0.56.0 → bmsdna_devtools-0.57.1}/tests/test_cli_pr_id.py +0 -0
- {bmsdna_devtools-0.56.0 → bmsdna_devtools-0.57.1}/tests/test_cli_pull.py +0 -0
- {bmsdna_devtools-0.56.0 → bmsdna_devtools-0.57.1}/tests/test_cli_tools.py +0 -0
- {bmsdna_devtools-0.56.0 → bmsdna_devtools-0.57.1}/tests/test_cli_version.py +0 -0
- {bmsdna_devtools-0.56.0 → bmsdna_devtools-0.57.1}/tests/test_commit.py +0 -0
- {bmsdna_devtools-0.56.0 → bmsdna_devtools-0.57.1}/tests/test_deps_advisories.py +0 -0
- {bmsdna_devtools-0.56.0 → bmsdna_devtools-0.57.1}/tests/test_env_config.py +0 -0
- {bmsdna_devtools-0.56.0 → bmsdna_devtools-0.57.1}/tests/test_env_files.py +0 -0
- {bmsdna_devtools-0.56.0 → bmsdna_devtools-0.57.1}/tests/test_find_injection.py +0 -0
- {bmsdna_devtools-0.56.0 → bmsdna_devtools-0.57.1}/tests/test_gh_issue.py +0 -0
- {bmsdna_devtools-0.56.0 → bmsdna_devtools-0.57.1}/tests/test_gh_pr.py +0 -0
- {bmsdna_devtools-0.56.0 → bmsdna_devtools-0.57.1}/tests/test_github_api.py +0 -0
- {bmsdna_devtools-0.56.0 → bmsdna_devtools-0.57.1}/tests/test_gitrepo.py +0 -0
- {bmsdna_devtools-0.56.0 → bmsdna_devtools-0.57.1}/tests/test_issue_do.py +0 -0
- {bmsdna_devtools-0.56.0 → bmsdna_devtools-0.57.1}/tests/test_issue_for_me.py +0 -0
- {bmsdna_devtools-0.56.0 → bmsdna_devtools-0.57.1}/tests/test_issue_show.py +0 -0
- {bmsdna_devtools-0.56.0 → bmsdna_devtools-0.57.1}/tests/test_issue_watch.py +0 -0
- {bmsdna_devtools-0.56.0 → bmsdna_devtools-0.57.1}/tests/test_lint.py +0 -0
- {bmsdna_devtools-0.56.0 → bmsdna_devtools-0.57.1}/tests/test_lint_models.py +0 -0
- {bmsdna_devtools-0.56.0 → bmsdna_devtools-0.57.1}/tests/test_lint_sql.py +0 -0
- {bmsdna_devtools-0.56.0 → bmsdna_devtools-0.57.1}/tests/test_lint_sql_files.py +0 -0
- {bmsdna_devtools-0.56.0 → bmsdna_devtools-0.57.1}/tests/test_lint_tooling.py +0 -0
- {bmsdna_devtools-0.56.0 → bmsdna_devtools-0.57.1}/tests/test_lint_typescript.py +0 -0
- {bmsdna_devtools-0.56.0 → bmsdna_devtools-0.57.1}/tests/test_logs.py +0 -0
- {bmsdna_devtools-0.56.0 → bmsdna_devtools-0.57.1}/tests/test_pr_build.py +0 -0
- {bmsdna_devtools-0.56.0 → bmsdna_devtools-0.57.1}/tests/test_pr_build_create_options.py +0 -0
- {bmsdna_devtools-0.56.0 → bmsdna_devtools-0.57.1}/tests/test_pr_build_flow.py +0 -0
- {bmsdna_devtools-0.56.0 → bmsdna_devtools-0.57.1}/tests/test_pr_cancel_build.py +0 -0
- {bmsdna_devtools-0.56.0 → bmsdna_devtools-0.57.1}/tests/test_pr_choice.py +0 -0
- {bmsdna_devtools-0.56.0 → bmsdna_devtools-0.57.1}/tests/test_pr_create_args.py +0 -0
- {bmsdna_devtools-0.56.0 → bmsdna_devtools-0.57.1}/tests/test_pr_description_not_truncated.py +0 -0
- {bmsdna_devtools-0.56.0 → bmsdna_devtools-0.57.1}/tests/test_pr_drift.py +0 -0
- {bmsdna_devtools-0.56.0 → bmsdna_devtools-0.57.1}/tests/test_pr_info.py +0 -0
- {bmsdna_devtools-0.56.0 → bmsdna_devtools-0.57.1}/tests/test_pr_issue_link.py +0 -0
- {bmsdna_devtools-0.56.0 → bmsdna_devtools-0.57.1}/tests/test_pr_labels.py +0 -0
- {bmsdna_devtools-0.56.0 → bmsdna_devtools-0.57.1}/tests/test_pr_markdown.py +0 -0
- {bmsdna_devtools-0.56.0 → bmsdna_devtools-0.57.1}/tests/test_pr_merge_defaults.py +0 -0
- {bmsdna_devtools-0.56.0 → bmsdna_devtools-0.57.1}/tests/test_pull.py +0 -0
- {bmsdna_devtools-0.56.0 → bmsdna_devtools-0.57.1}/tests/test_testdb.py +0 -0
- {bmsdna_devtools-0.56.0 → bmsdna_devtools-0.57.1}/tests/test_translate.py +0 -0
- {bmsdna_devtools-0.56.0 → bmsdna_devtools-0.57.1}/tests/test_usage.py +0 -0
- {bmsdna_devtools-0.56.0 → bmsdna_devtools-0.57.1}/tests/test_wait_timeout.py +0 -0
- {bmsdna_devtools-0.56.0 → bmsdna_devtools-0.57.1}/tests/test_worktree_clean.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: bmsdna-devtools
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.57.1
|
|
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
|
|
@@ -709,7 +709,7 @@ those orgs are searched.
|
|
|
709
709
|
## `bdt list-repo`
|
|
710
710
|
|
|
711
711
|
```bash
|
|
712
|
-
bdt list-repo [--root ~/projects] [--org MYORG] [--github-org MYORG] [--local] [--fast] [--json] [--pat PAT]
|
|
712
|
+
bdt list-repo [--root ~/projects] [--org MYORG] [--github-org MYORG] [--local] [--no-local] [--fast] [--json] [--pat PAT]
|
|
713
713
|
```
|
|
714
714
|
|
|
715
715
|
The browse counterpart to `bdt find-repo`: lists **every** repo of the Azure DevOps org and/or GitHub org
|
|
@@ -730,8 +730,14 @@ configured, or with `--local`, it lists the clones under the work dir instead (t
|
|
|
730
730
|
(about 15 s for ~400 Azure DevOps repos). `--fast` skips them: GitHub then shows only its last push date,
|
|
731
731
|
Azure DevOps repos no commit and no description. Repos without commits, or whose commits can't be read, have empty fields.
|
|
732
732
|
- **`--json`:** prints an array of objects for scripts instead of the aligned text, with full (untruncated) values:
|
|
733
|
-
`project`, `name`, `source` (`ado`/`github`), `
|
|
734
|
-
`
|
|
733
|
+
`project`, `name`, `source` (`ado`/`github`), `git_url` (to clone), `web_url` (to open in the browser),
|
|
734
|
+
`location`, `last_commit_id`, `last_commit_date` (ISO 8601), `last_commit_author`, `description`.
|
|
735
|
+
Both URLs are always there; local clones have `name` instead of `project`/`source`, and their `git_url` is the clone's
|
|
736
|
+
`origin` (`web_url` is "" for a host other than GitHub / Azure DevOps).
|
|
737
|
+
- **Local clones:** `location` is the path of your clone of that repo under the work dir (found by matching each
|
|
738
|
+
clone's `origin` URL, whether it was cloned via https or ssh), or `null` if it isn't cloned. `--no-local` skips that
|
|
739
|
+
lookup and leaves `location` out of the JSON entirely; the aligned text never shows it. `--local` and `--no-local`
|
|
740
|
+
contradict each other, and `--no-local` needs an org to list.
|
|
735
741
|
|
|
736
742
|
## `bdt cleanup worktrees` / `bdt cleanup orphaned-dbs` / `bdt cleanup db` / `bdt cleanup worktree`
|
|
737
743
|
|
|
@@ -1256,17 +1262,21 @@ catch-all, service-to-service endpoints and an external API folder.
|
|
|
1256
1262
|
then on only *new* unused routes fail -- and a baseline line whose route has since been deleted, excluded or
|
|
1257
1263
|
used is reported as `api-route-baseline-stale`, so the list can only shrink.
|
|
1258
1264
|
|
|
1259
|
-
## `bdt deps affected` / `bdt deps advisories`
|
|
1265
|
+
## `bdt deps affected` / `bdt deps advisories` / `bdt deps cooldown`
|
|
1260
1266
|
|
|
1261
|
-
Security incidents and supply chain attacks (bmsuisse/devtools#113): which locked dependencies are touched?
|
|
1262
|
-
commands only read: they never edit a file, a lock or an environment. They cover `uv.lock` (PyPI)
|
|
1263
|
-
|
|
1264
|
-
|
|
1267
|
+
Security incidents and supply chain attacks (bmsuisse/devtools#113): which locked dependencies are touched? All
|
|
1268
|
+
commands only read: they never edit a file, a lock or an environment. They cover `uv.lock` (PyPI), `bun.lock` (npm) and
|
|
1269
|
+
Gradle (Maven: `gradle.lockfile` and the version catalog `gradle/libs.versions.toml`) below each `--path` (default: the
|
|
1270
|
+
current directory; `node_modules`, virtualenvs, `.git`, `.gradle` and `.worktrees` are skipped).
|
|
1271
|
+
Git, path, alias and workspace sources, and Gradle entries without an exact version in the catalog (managed by a BOM, or a
|
|
1272
|
+
range), can't be matched against an advisory: they are listed as `unsupported`, never skipped. A catalog lists the direct
|
|
1273
|
+
dependencies only; transitive ones need Gradle dependency locking (`gradle.lockfile`).
|
|
1265
1274
|
|
|
1266
1275
|
```bash
|
|
1267
1276
|
bdt deps affected lodash --version-spec "<4.17.21" --path ~/projects/CCMT2 --path ~/projects/OneSales
|
|
1268
1277
|
bdt deps advisories --path . # OSV lookup of every locked version, one status per affected package
|
|
1269
1278
|
bdt deps advisories --json # machine-readable
|
|
1279
|
+
bdt deps cooldown --ecosystem Maven --base origin/dev # CI: no Gradle version added or changed within the cooldown
|
|
1270
1280
|
```
|
|
1271
1281
|
|
|
1272
1282
|
`affected PACKAGE` lists the locked versions of one package (PyPI names are normalised, npm names exact; `--ecosystem`
|
|
@@ -1274,6 +1284,15 @@ narrows) and marks those matching `--version-spec` (comparators such as `<4.17.2
|
|
|
1274
1284
|
none matches, 1 a locked version matches, 2 setup error (no lockfile, unreadable lockfile, bad spec), 3 incomplete (a
|
|
1275
1285
|
git/path/alias source of that name could not be matched).
|
|
1276
1286
|
|
|
1287
|
+
`cooldown` answers "is a locked version younger than the dependency cooldown?" (`--cooldown-days`, default 5). uv
|
|
1288
|
+
(`exclude-newer`) and bun (`minimumReleaseAge`) enforce the cooldown while resolving; Gradle has no such setting and
|
|
1289
|
+
pins exact versions, so this is its check. The release time is the upload time of the POM (`Last-Modified`) on Maven
|
|
1290
|
+
Central, Google Maven or the Gradle plugin portal. `--base REV` looks only at versions the file does not have at `REV`
|
|
1291
|
+
(use the target branch in CI, so an old pin never fails a later pull request); without it every locked version is looked
|
|
1292
|
+
up. `--exempt NAME` (repeatable, `group:artifact` for Maven) lets one package through: the per-invocation exception for a
|
|
1293
|
+
security fix younger than the cooldown, as for uv and bun. Exit 0 none inside the cooldown (or all exempt), 1 a version
|
|
1294
|
+
inside it, 2 setup error, 3 a release time could not be read; a version without a public release time is listed, not failed.
|
|
1295
|
+
|
|
1277
1296
|
`advisories` queries [OSV](https://osv.dev) (GHSA, PYSEC and the OpenSSF `MAL-` malicious-package advisories) and the
|
|
1278
1297
|
CISA KEV feed, groups aliases (GHSA = PYSEC = CVE) and reports per locked package one status. The maintenance skill's
|
|
1279
1298
|
cooldown exception flow (`references/audit.md`) acts on it:
|
|
@@ -690,7 +690,7 @@ those orgs are searched.
|
|
|
690
690
|
## `bdt list-repo`
|
|
691
691
|
|
|
692
692
|
```bash
|
|
693
|
-
bdt list-repo [--root ~/projects] [--org MYORG] [--github-org MYORG] [--local] [--fast] [--json] [--pat PAT]
|
|
693
|
+
bdt list-repo [--root ~/projects] [--org MYORG] [--github-org MYORG] [--local] [--no-local] [--fast] [--json] [--pat PAT]
|
|
694
694
|
```
|
|
695
695
|
|
|
696
696
|
The browse counterpart to `bdt find-repo`: lists **every** repo of the Azure DevOps org and/or GitHub org
|
|
@@ -711,8 +711,14 @@ configured, or with `--local`, it lists the clones under the work dir instead (t
|
|
|
711
711
|
(about 15 s for ~400 Azure DevOps repos). `--fast` skips them: GitHub then shows only its last push date,
|
|
712
712
|
Azure DevOps repos no commit and no description. Repos without commits, or whose commits can't be read, have empty fields.
|
|
713
713
|
- **`--json`:** prints an array of objects for scripts instead of the aligned text, with full (untruncated) values:
|
|
714
|
-
`project`, `name`, `source` (`ado`/`github`), `
|
|
715
|
-
`
|
|
714
|
+
`project`, `name`, `source` (`ado`/`github`), `git_url` (to clone), `web_url` (to open in the browser),
|
|
715
|
+
`location`, `last_commit_id`, `last_commit_date` (ISO 8601), `last_commit_author`, `description`.
|
|
716
|
+
Both URLs are always there; local clones have `name` instead of `project`/`source`, and their `git_url` is the clone's
|
|
717
|
+
`origin` (`web_url` is "" for a host other than GitHub / Azure DevOps).
|
|
718
|
+
- **Local clones:** `location` is the path of your clone of that repo under the work dir (found by matching each
|
|
719
|
+
clone's `origin` URL, whether it was cloned via https or ssh), or `null` if it isn't cloned. `--no-local` skips that
|
|
720
|
+
lookup and leaves `location` out of the JSON entirely; the aligned text never shows it. `--local` and `--no-local`
|
|
721
|
+
contradict each other, and `--no-local` needs an org to list.
|
|
716
722
|
|
|
717
723
|
## `bdt cleanup worktrees` / `bdt cleanup orphaned-dbs` / `bdt cleanup db` / `bdt cleanup worktree`
|
|
718
724
|
|
|
@@ -1237,17 +1243,21 @@ catch-all, service-to-service endpoints and an external API folder.
|
|
|
1237
1243
|
then on only *new* unused routes fail -- and a baseline line whose route has since been deleted, excluded or
|
|
1238
1244
|
used is reported as `api-route-baseline-stale`, so the list can only shrink.
|
|
1239
1245
|
|
|
1240
|
-
## `bdt deps affected` / `bdt deps advisories`
|
|
1246
|
+
## `bdt deps affected` / `bdt deps advisories` / `bdt deps cooldown`
|
|
1241
1247
|
|
|
1242
|
-
Security incidents and supply chain attacks (bmsuisse/devtools#113): which locked dependencies are touched?
|
|
1243
|
-
commands only read: they never edit a file, a lock or an environment. They cover `uv.lock` (PyPI)
|
|
1244
|
-
|
|
1245
|
-
|
|
1248
|
+
Security incidents and supply chain attacks (bmsuisse/devtools#113): which locked dependencies are touched? All
|
|
1249
|
+
commands only read: they never edit a file, a lock or an environment. They cover `uv.lock` (PyPI), `bun.lock` (npm) and
|
|
1250
|
+
Gradle (Maven: `gradle.lockfile` and the version catalog `gradle/libs.versions.toml`) below each `--path` (default: the
|
|
1251
|
+
current directory; `node_modules`, virtualenvs, `.git`, `.gradle` and `.worktrees` are skipped).
|
|
1252
|
+
Git, path, alias and workspace sources, and Gradle entries without an exact version in the catalog (managed by a BOM, or a
|
|
1253
|
+
range), can't be matched against an advisory: they are listed as `unsupported`, never skipped. A catalog lists the direct
|
|
1254
|
+
dependencies only; transitive ones need Gradle dependency locking (`gradle.lockfile`).
|
|
1246
1255
|
|
|
1247
1256
|
```bash
|
|
1248
1257
|
bdt deps affected lodash --version-spec "<4.17.21" --path ~/projects/CCMT2 --path ~/projects/OneSales
|
|
1249
1258
|
bdt deps advisories --path . # OSV lookup of every locked version, one status per affected package
|
|
1250
1259
|
bdt deps advisories --json # machine-readable
|
|
1260
|
+
bdt deps cooldown --ecosystem Maven --base origin/dev # CI: no Gradle version added or changed within the cooldown
|
|
1251
1261
|
```
|
|
1252
1262
|
|
|
1253
1263
|
`affected PACKAGE` lists the locked versions of one package (PyPI names are normalised, npm names exact; `--ecosystem`
|
|
@@ -1255,6 +1265,15 @@ narrows) and marks those matching `--version-spec` (comparators such as `<4.17.2
|
|
|
1255
1265
|
none matches, 1 a locked version matches, 2 setup error (no lockfile, unreadable lockfile, bad spec), 3 incomplete (a
|
|
1256
1266
|
git/path/alias source of that name could not be matched).
|
|
1257
1267
|
|
|
1268
|
+
`cooldown` answers "is a locked version younger than the dependency cooldown?" (`--cooldown-days`, default 5). uv
|
|
1269
|
+
(`exclude-newer`) and bun (`minimumReleaseAge`) enforce the cooldown while resolving; Gradle has no such setting and
|
|
1270
|
+
pins exact versions, so this is its check. The release time is the upload time of the POM (`Last-Modified`) on Maven
|
|
1271
|
+
Central, Google Maven or the Gradle plugin portal. `--base REV` looks only at versions the file does not have at `REV`
|
|
1272
|
+
(use the target branch in CI, so an old pin never fails a later pull request); without it every locked version is looked
|
|
1273
|
+
up. `--exempt NAME` (repeatable, `group:artifact` for Maven) lets one package through: the per-invocation exception for a
|
|
1274
|
+
security fix younger than the cooldown, as for uv and bun. Exit 0 none inside the cooldown (or all exempt), 1 a version
|
|
1275
|
+
inside it, 2 setup error, 3 a release time could not be read; a version without a public release time is listed, not failed.
|
|
1276
|
+
|
|
1258
1277
|
`advisories` queries [OSV](https://osv.dev) (GHSA, PYSEC and the OpenSSF `MAL-` malicious-package advisories) and the
|
|
1259
1278
|
CISA KEV feed, groups aliases (GHSA = PYSEC = CVE) and reports per locked package one status. The maintenance skill's
|
|
1260
1279
|
cooldown exception flow (`references/audit.md`) acts on it:
|
|
@@ -2008,7 +2008,12 @@ def list_repo_cmd(
|
|
|
2008
2008
|
github_org: str | None = typer.Option(
|
|
2009
2009
|
None, "--github-org", envvar=["GITHUB_ORG", "BMS_GITHUB_ORG"], help="GitHub org to list"
|
|
2010
2010
|
),
|
|
2011
|
-
local: bool = typer.Option(False, "--local", help="List the local clones under --root even if an org is configured"),
|
|
2011
|
+
local: bool = typer.Option(False, "--local", help="List only the local clones under --root, even if an org is configured"),
|
|
2012
|
+
no_local: bool = typer.Option(
|
|
2013
|
+
False,
|
|
2014
|
+
"--no-local",
|
|
2015
|
+
help="Don't look for local clones of the listed repos: --json then has no `location` (otherwise the clone's path, or null if not cloned)",
|
|
2016
|
+
),
|
|
2012
2017
|
fast: bool = typer.Option(
|
|
2013
2018
|
False,
|
|
2014
2019
|
"--fast",
|
|
@@ -2029,9 +2034,12 @@ def list_repo_cmd(
|
|
|
2029
2034
|
as `find-repo`); with no org configured, or with --local, the clones under the work dir.
|
|
2030
2035
|
GitHub supplies its own description. Azure DevOps and local repos have none, so the first sentence of
|
|
2031
2036
|
the README stands in. The commit is the newest one of the default branch on GitHub / Azure DevOps and of
|
|
2032
|
-
any branch in a local clone. --json gives the same data as an array of objects, with full ids and dates
|
|
2037
|
+
any branch in a local clone. --json gives the same data as an array of objects, with full ids and dates, the
|
|
2038
|
+
git and browser URL, and the path of the local clone (see --no-local).
|
|
2033
2039
|
"""
|
|
2034
|
-
find_repo_mod.run_list(
|
|
2040
|
+
find_repo_mod.run_list(
|
|
2041
|
+
root=root, org=org, github_org=github_org, local=local, no_local=no_local, fast=fast, as_json=as_json, pat=pat
|
|
2042
|
+
)
|
|
2035
2043
|
|
|
2036
2044
|
|
|
2037
2045
|
@cleanup_app.command("worktrees")
|
|
@@ -287,7 +287,18 @@ def _commands(finding: Finding) -> list[str]:
|
|
|
287
287
|
pkg, target = finding.package, finding.target
|
|
288
288
|
if finding.status not in ("exempt-eligible", "bump") or not target:
|
|
289
289
|
return []
|
|
290
|
-
|
|
290
|
+
project = pkg.lockfile.parent.parent if pkg.lockfile.parent.name == "gradle" else pkg.lockfile.parent
|
|
291
|
+
where = f"cd {project}"
|
|
292
|
+
if pkg.ecosystem == "Maven":
|
|
293
|
+
step = f"{where} && set {pkg.name} to {target} in the Gradle version catalog (gradle/libs.versions.toml)" + (
|
|
294
|
+
", then `./gradlew dependencies --write-locks`" if pkg.lockfile.name == "gradle.lockfile" else ""
|
|
295
|
+
)
|
|
296
|
+
if finding.status == "bump":
|
|
297
|
+
return [step]
|
|
298
|
+
return [
|
|
299
|
+
step,
|
|
300
|
+
f"{where} && bdt deps cooldown --exempt {pkg.name} # Gradle has no cooldown setting: pass the exception here",
|
|
301
|
+
]
|
|
291
302
|
if pkg.ecosystem == "PyPI":
|
|
292
303
|
if finding.status == "bump":
|
|
293
304
|
return [f"{where} && uv lock --upgrade-package {pkg.name} && uv sync"]
|
|
@@ -11,20 +11,21 @@ from typing import Annotated
|
|
|
11
11
|
import typer
|
|
12
12
|
|
|
13
13
|
from .advisories import DEFAULT_COOLDOWN_DAYS, ScanResult, scan
|
|
14
|
-
from .
|
|
14
|
+
from .cooldown import CooldownResult, changed_packages, check
|
|
15
|
+
from .lockfiles import LockedPackage, LockfileContent, LockfileError, Unsupported, find_lockfiles, read_lockfile
|
|
15
16
|
from .osv import DataError, OsvClient
|
|
16
17
|
from .versions import ECOSYSTEMS, VersionError, normalize_name, spec_matches
|
|
17
18
|
|
|
18
19
|
deps_app = typer.Typer(
|
|
19
20
|
name="deps",
|
|
20
|
-
help="Which locked dependencies (uv.lock, bun.lock) a security advisory or supply chain incident touches",
|
|
21
|
+
help="Which locked dependencies (uv.lock, bun.lock, Gradle) a security advisory or supply chain incident touches",
|
|
21
22
|
)
|
|
22
23
|
|
|
23
24
|
PathOption = Annotated[
|
|
24
25
|
list[Path] | None,
|
|
25
26
|
typer.Option(
|
|
26
27
|
"--path",
|
|
27
|
-
help="Directory (or lockfile) to scan, repeatable; every uv.lock
|
|
28
|
+
help="Directory (or lockfile) to scan, repeatable; every uv.lock, bun.lock, gradle.lockfile and gradle/*.versions.toml below it. Default: the current directory.",
|
|
28
29
|
),
|
|
29
30
|
]
|
|
30
31
|
EXIT_FOUND, EXIT_SETUP, EXIT_INCOMPLETE = 1, 2, 3
|
|
@@ -39,7 +40,7 @@ def _read_all(paths: list[Path] | None) -> list[LockfileContent]:
|
|
|
39
40
|
try:
|
|
40
41
|
lockfiles = find_lockfiles(roots)
|
|
41
42
|
if not lockfiles:
|
|
42
|
-
typer.echo("bdt deps: no uv.lock
|
|
43
|
+
typer.echo("bdt deps: no uv.lock, bun.lock, gradle.lockfile or Gradle version catalog found", err=True)
|
|
43
44
|
raise typer.Exit(EXIT_SETUP)
|
|
44
45
|
return [read_lockfile(p) for p in lockfiles]
|
|
45
46
|
except LockfileError as exc:
|
|
@@ -57,7 +58,9 @@ def affected(
|
|
|
57
58
|
help='Affected versions, comparators like "<4.17.21" or ">=1.0,<2" (comma = and). Default: any version.',
|
|
58
59
|
),
|
|
59
60
|
] = None,
|
|
60
|
-
ecosystem: Annotated[
|
|
61
|
+
ecosystem: Annotated[
|
|
62
|
+
str | None, typer.Option("--ecosystem", help="PyPI, npm or Maven (Gradle). Default: all.")
|
|
63
|
+
] = None,
|
|
61
64
|
path: PathOption = None,
|
|
62
65
|
) -> None:
|
|
63
66
|
"""Locked versions of PACKAGE in every lockfile below --path. Exit 0 none matches, 1 a locked version matches,
|
|
@@ -131,7 +134,7 @@ def advisories(
|
|
|
131
134
|
] = DEFAULT_COOLDOWN_DAYS,
|
|
132
135
|
as_json: Annotated[bool, typer.Option("--json", help="Machine-readable output.")] = False,
|
|
133
136
|
) -> None:
|
|
134
|
-
"""OSV advisories for every locked PyPI/npm version below --path, with a status each (malicious, needs-triage, no-fix,
|
|
137
|
+
"""OSV advisories for every locked PyPI/npm/Maven version below --path, with a status each (malicious, needs-triage, no-fix,
|
|
135
138
|
blocked, exempt-eligible, bump, informational; see the maintenance skill, audit.md). Fails closed: if OSV, the CISA KEV
|
|
136
139
|
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,
|
|
137
140
|
1 affected, 2 setup error, 3 incomplete. Never edits anything; other lockfile sources are listed as unsupported."""
|
|
@@ -149,3 +152,77 @@ def advisories(
|
|
|
149
152
|
if result.incomplete:
|
|
150
153
|
raise typer.Exit(EXIT_INCOMPLETE)
|
|
151
154
|
raise typer.Exit(EXIT_FOUND if result.findings else 0)
|
|
155
|
+
|
|
156
|
+
|
|
157
|
+
def _render_cooldown(result: CooldownResult, cooldown_days: float) -> str:
|
|
158
|
+
lines = [
|
|
159
|
+
f"INSIDE {item.package.lockfile}: {item.package.name} {item.package.version} released {item.released:%Y-%m-%d %H:%M} UTC, {item.age_days} days old (cooldown {cooldown_days:g})"
|
|
160
|
+
for item in result.young
|
|
161
|
+
]
|
|
162
|
+
lines += [
|
|
163
|
+
f"exempt {item.package.lockfile}: {item.package.name} {item.package.version} is {item.age_days} days old"
|
|
164
|
+
for item in result.exempt
|
|
165
|
+
]
|
|
166
|
+
lines += [
|
|
167
|
+
f"unknown {pkg.lockfile}: {pkg.name} {pkg.version}: no public release time (private or unlisted)"
|
|
168
|
+
for pkg in result.unknown
|
|
169
|
+
]
|
|
170
|
+
lines += [f"[unsupported] {item.name}: {item.reason} {item.lockfile}" for item in result.unsupported]
|
|
171
|
+
lines += [f"[incomplete] {reason}" for reason in result.incomplete]
|
|
172
|
+
return "\n".join(lines)
|
|
173
|
+
|
|
174
|
+
|
|
175
|
+
@deps_app.command("cooldown")
|
|
176
|
+
def cooldown(
|
|
177
|
+
path: PathOption = None,
|
|
178
|
+
cooldown_days: Annotated[
|
|
179
|
+
float, typer.Option("--cooldown-days", help="The project's dependency cooldown (see the maintenance skill).")
|
|
180
|
+
] = DEFAULT_COOLDOWN_DAYS,
|
|
181
|
+
exempt: Annotated[
|
|
182
|
+
list[str] | None,
|
|
183
|
+
typer.Option(
|
|
184
|
+
"--exempt", help="Package (exact name, `group:artifact` for Maven) allowed inside the cooldown. Repeatable."
|
|
185
|
+
),
|
|
186
|
+
] = None,
|
|
187
|
+
base: Annotated[
|
|
188
|
+
str | None,
|
|
189
|
+
typer.Option(
|
|
190
|
+
"--base",
|
|
191
|
+
help="Only check versions that are not in the same file at this git revision (CI: origin/<target branch>). Without it every locked version is looked up.",
|
|
192
|
+
),
|
|
193
|
+
] = None,
|
|
194
|
+
ecosystem: Annotated[
|
|
195
|
+
str | None, typer.Option("--ecosystem", help="PyPI, npm or Maven (Gradle). Default: all.")
|
|
196
|
+
] = None,
|
|
197
|
+
) -> None:
|
|
198
|
+
"""Locked versions younger than the dependency cooldown. uv and bun enforce it while resolving; Gradle can't, so this is
|
|
199
|
+
its check (`--ecosystem Maven --base origin/dev`). Exit 0 none inside the cooldown (or all exempt), 1 a version inside
|
|
200
|
+
it, 2 setup error, 3 a release time could not be read. Versions without a public release time are listed, not failed."""
|
|
201
|
+
if ecosystem and ecosystem not in ECOSYSTEMS:
|
|
202
|
+
typer.echo(f"bdt deps: --ecosystem must be one of {', '.join(ECOSYSTEMS)}", err=True)
|
|
203
|
+
raise typer.Exit(EXIT_SETUP)
|
|
204
|
+
contents = [c for c in _read_all(path) if not ecosystem or c.ecosystem == ecosystem]
|
|
205
|
+
packages: list[LockedPackage] = []
|
|
206
|
+
unsupported: list[Unsupported] = []
|
|
207
|
+
try:
|
|
208
|
+
for content in contents:
|
|
209
|
+
packages.extend(changed_packages(content, base) if base else content.packages)
|
|
210
|
+
unsupported.extend(content.unsupported)
|
|
211
|
+
except LockfileError as exc:
|
|
212
|
+
typer.echo(f"bdt deps: {exc}", err=True)
|
|
213
|
+
raise typer.Exit(EXIT_SETUP) from exc
|
|
214
|
+
exempt_names = frozenset(exempt or ())
|
|
215
|
+
result = check(
|
|
216
|
+
packages, OsvClient().release_time, cooldown_days=cooldown_days, exempt=exempt_names, now=datetime.now(UTC)
|
|
217
|
+
)
|
|
218
|
+
result.unsupported = unsupported
|
|
219
|
+
report = _render_cooldown(result, cooldown_days)
|
|
220
|
+
if not result.young and not result.incomplete:
|
|
221
|
+
summary = (
|
|
222
|
+
f"bdt deps: none of the {result.checked} checked versions is inside the {cooldown_days:g}-day cooldown"
|
|
223
|
+
)
|
|
224
|
+
report = f"{report}\n{summary}" if report else summary
|
|
225
|
+
typer.echo(report)
|
|
226
|
+
if result.incomplete:
|
|
227
|
+
raise typer.Exit(EXIT_INCOMPLETE)
|
|
228
|
+
raise typer.Exit(EXIT_FOUND if result.young else 0)
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
"""`bdt deps cooldown`: is a locked or pinned version younger than the dependency cooldown?
|
|
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.
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
from __future__ import annotations
|
|
8
|
+
|
|
9
|
+
import subprocess
|
|
10
|
+
from collections.abc import Callable, Iterable
|
|
11
|
+
from dataclasses import dataclass, field
|
|
12
|
+
from datetime import datetime
|
|
13
|
+
|
|
14
|
+
from .lockfiles import LockedPackage, LockfileContent, LockfileError, Unsupported, read_lockfile
|
|
15
|
+
from .osv import DataError
|
|
16
|
+
from .versions import Ecosystem, normalize_name
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
@dataclass(frozen=True, slots=True)
|
|
20
|
+
class Young:
|
|
21
|
+
package: LockedPackage
|
|
22
|
+
released: datetime
|
|
23
|
+
age_days: float
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
@dataclass(slots=True)
|
|
27
|
+
class CooldownResult:
|
|
28
|
+
young: list[Young] = field(default_factory=list)
|
|
29
|
+
exempt: list[Young] = field(default_factory=list)
|
|
30
|
+
unknown: list[LockedPackage] = field(default_factory=list) # release time not known (private or unlisted package)
|
|
31
|
+
unsupported: list[Unsupported] = field(default_factory=list) # entries that could not be matched, never skipped
|
|
32
|
+
incomplete: list[str] = field(default_factory=list)
|
|
33
|
+
checked: int = 0
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
def changed_packages(content: LockfileContent, base: str) -> list[LockedPackage]:
|
|
37
|
+
"""The packages of `content` that are not in the same file at git revision `base` (all of them for a new file)."""
|
|
38
|
+
try:
|
|
39
|
+
shown = subprocess.run(
|
|
40
|
+
["git", "show", f"{base}:./{content.lockfile.name}"],
|
|
41
|
+
cwd=content.lockfile.parent,
|
|
42
|
+
capture_output=True,
|
|
43
|
+
text=True,
|
|
44
|
+
check=False,
|
|
45
|
+
)
|
|
46
|
+
except OSError as exc:
|
|
47
|
+
raise LockfileError(f"cannot run git: {exc}") from exc
|
|
48
|
+
if shown.returncode != 0:
|
|
49
|
+
if "does not exist" in shown.stderr or "exists on disk, but not in" in shown.stderr:
|
|
50
|
+
return list(content.packages)
|
|
51
|
+
raise LockfileError(f"{content.lockfile}: cannot read it at {base}: {shown.stderr.strip()}")
|
|
52
|
+
before = {(p.name, p.version) for p in read_lockfile(content.lockfile, shown.stdout).packages}
|
|
53
|
+
return [p for p in content.packages if (p.name, p.version) not in before]
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
def check(
|
|
57
|
+
packages: Iterable[LockedPackage],
|
|
58
|
+
release_time: Callable[[Ecosystem, str, str], datetime | None],
|
|
59
|
+
*,
|
|
60
|
+
cooldown_days: float,
|
|
61
|
+
exempt: frozenset[str],
|
|
62
|
+
now: datetime,
|
|
63
|
+
) -> CooldownResult:
|
|
64
|
+
result = CooldownResult()
|
|
65
|
+
for pkg in packages:
|
|
66
|
+
result.checked += 1
|
|
67
|
+
try:
|
|
68
|
+
released = release_time(pkg.ecosystem, pkg.name, pkg.version)
|
|
69
|
+
except DataError as exc:
|
|
70
|
+
result.incomplete.append(f"release time of {pkg.name} {pkg.version} unavailable: {exc}")
|
|
71
|
+
continue
|
|
72
|
+
if released is None:
|
|
73
|
+
result.unknown.append(pkg)
|
|
74
|
+
continue
|
|
75
|
+
age = round((now - released).total_seconds() / 86400, 1)
|
|
76
|
+
if age >= cooldown_days:
|
|
77
|
+
continue
|
|
78
|
+
item = Young(pkg, released, age)
|
|
79
|
+
if normalize_name(pkg.ecosystem, pkg.name) in exempt or pkg.name in exempt:
|
|
80
|
+
result.exempt.append(item)
|
|
81
|
+
else:
|
|
82
|
+
result.young.append(item)
|
|
83
|
+
return result
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
"""Read `uv.lock` (PyPI)
|
|
1
|
+
"""Read `uv.lock` (PyPI), `bun.lock` (npm), `gradle.lockfile` and Gradle version catalogs (Maven) into `LockedPackage`s.
|
|
2
2
|
|
|
3
|
-
Only registry packages are returned; git, path, editable and workspace sources
|
|
4
|
-
scan never claims to have looked at a dependency it can't match against an advisory.
|
|
3
|
+
Only registry packages are returned; git, path, editable and workspace sources (and Gradle versions a catalog does not pin)
|
|
4
|
+
are reported as `Unsupported` so a scan never claims to have looked at a dependency it can't match against an advisory.
|
|
5
5
|
"""
|
|
6
6
|
|
|
7
7
|
from __future__ import annotations
|
|
@@ -17,8 +17,13 @@ from typing import Any, cast
|
|
|
17
17
|
|
|
18
18
|
from .versions import Ecosystem, normalize_name
|
|
19
19
|
|
|
20
|
-
LOCKFILE_NAMES = {"uv.lock": "PyPI", "bun.lock": "npm"}
|
|
21
|
-
_SKIP_DIRS = frozenset({"node_modules", ".venv", "venv", ".git", ".worktrees", "__pycache__", ".tox"})
|
|
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"})
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
def is_lockfile(path: Path) -> bool:
|
|
25
|
+
"""A lockfile by name, or a Gradle version catalog (`gradle/*.versions.toml`: the pins of a project without locking)."""
|
|
26
|
+
return path.name in LOCKFILE_NAMES or (path.name.endswith(".versions.toml") and path.parent.name == "gradle")
|
|
22
27
|
|
|
23
28
|
|
|
24
29
|
class LockfileError(ValueError):
|
|
@@ -51,27 +56,34 @@ class LockfileContent:
|
|
|
51
56
|
|
|
52
57
|
|
|
53
58
|
def find_lockfiles(roots: Iterable[Path]) -> list[Path]:
|
|
54
|
-
"""Every `uv.lock` / `bun.lock` below the roots; `node_modules`,
|
|
55
|
-
(a root that itself lives inside one is still scanned)."""
|
|
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)."""
|
|
56
61
|
found: list[Path] = []
|
|
57
62
|
errors: list[str] = []
|
|
58
63
|
for root in roots:
|
|
59
|
-
if root.is_file() and root
|
|
64
|
+
if root.is_file() and is_lockfile(root):
|
|
60
65
|
found.append(root)
|
|
61
66
|
continue
|
|
62
67
|
for dirpath, dirnames, filenames in os.walk(
|
|
63
68
|
root, onerror=lambda exc: errors.append(f"{exc.filename}: {exc.strerror}")
|
|
64
69
|
):
|
|
65
70
|
dirnames[:] = sorted(d for d in dirnames if d not in _SKIP_DIRS)
|
|
66
|
-
found.extend(Path(dirpath) / name for name in sorted(filenames) if
|
|
71
|
+
found.extend(Path(dirpath) / name for name in sorted(filenames) if is_lockfile(Path(dirpath) / name))
|
|
67
72
|
if errors: # an unreadable directory may hide a lockfile: the scan is incomplete, not clean
|
|
68
73
|
raise LockfileError(f"cannot read directory ({'; '.join(errors)})")
|
|
69
74
|
return sorted(dict.fromkeys(p.resolve() for p in found))
|
|
70
75
|
|
|
71
76
|
|
|
72
|
-
def read_lockfile(path: Path) -> LockfileContent:
|
|
77
|
+
def read_lockfile(path: Path, text: str | None = None) -> LockfileContent:
|
|
78
|
+
"""Parse the lockfile at `path`; `text` is its content when it was not read from disk (an older git revision)."""
|
|
73
79
|
try:
|
|
74
|
-
|
|
80
|
+
if path.name == "uv.lock":
|
|
81
|
+
return read_uv_lock(path, text)
|
|
82
|
+
if path.name == "gradle.lockfile":
|
|
83
|
+
return read_gradle_lockfile(path, text)
|
|
84
|
+
if path.name.endswith(".versions.toml"):
|
|
85
|
+
return read_gradle_catalog(path, text)
|
|
86
|
+
return read_bun_lock(path, text)
|
|
75
87
|
except (
|
|
76
88
|
OSError,
|
|
77
89
|
tomllib.TOMLDecodeError,
|
|
@@ -86,8 +98,8 @@ def read_lockfile(path: Path) -> LockfileContent:
|
|
|
86
98
|
# ── uv.lock ──────────────────────────────────────────────────────────────────────────────────────────────────────
|
|
87
99
|
|
|
88
100
|
|
|
89
|
-
def read_uv_lock(path: Path) -> LockfileContent:
|
|
90
|
-
data = tomllib.loads(path.read_text(encoding="utf-8"))
|
|
101
|
+
def read_uv_lock(path: Path, text: str | None = None) -> LockfileContent:
|
|
102
|
+
data = tomllib.loads(text if text is not None else path.read_text(encoding="utf-8"))
|
|
91
103
|
if not isinstance(data.get("package"), list) or not data["package"]:
|
|
92
104
|
raise ValueError("no [[package]] entries: not a uv lockfile")
|
|
93
105
|
content = LockfileContent(path, "PyPI")
|
|
@@ -159,8 +171,8 @@ def loads_jsonc(text: str) -> object:
|
|
|
159
171
|
return json.loads(cleaned)
|
|
160
172
|
|
|
161
173
|
|
|
162
|
-
def read_bun_lock(path: Path) -> LockfileContent:
|
|
163
|
-
data = loads_jsonc(path.read_text(encoding="utf-8"))
|
|
174
|
+
def read_bun_lock(path: Path, text: str | None = None) -> LockfileContent:
|
|
175
|
+
data = loads_jsonc(text if text is not None else path.read_text(encoding="utf-8"))
|
|
164
176
|
if (
|
|
165
177
|
not isinstance(data, dict)
|
|
166
178
|
or not isinstance(data.get("packages"), dict)
|
|
@@ -208,3 +220,80 @@ def read_bun_lock(path: Path) -> LockfileContent:
|
|
|
208
220
|
)
|
|
209
221
|
)
|
|
210
222
|
return content
|
|
223
|
+
|
|
224
|
+
|
|
225
|
+
# ── Gradle: gradle.lockfile and version catalogs ─────────────────────────────────────────────────────────────────
|
|
226
|
+
|
|
227
|
+
_GRADLE_RANGE_RE = re.compile(r"^[\[(]|[\])]$|\+$|^latest\.")
|
|
228
|
+
|
|
229
|
+
|
|
230
|
+
def _catalog_version(spec: object, versions: dict[str, Any]) -> tuple[str | None, str]:
|
|
231
|
+
"""The exact version a catalog entry pins, or None and the reason it can't be matched."""
|
|
232
|
+
if isinstance(spec, dict):
|
|
233
|
+
table = cast("dict[str, Any]", spec)
|
|
234
|
+
if "ref" in table:
|
|
235
|
+
return _catalog_version(versions.get(table["ref"]), versions)
|
|
236
|
+
spec = table.get("strictly") or table.get("require") or table.get("prefer")
|
|
237
|
+
if not isinstance(spec, str) or not spec:
|
|
238
|
+
return (None, "no version in the catalog (managed by a BOM or platform, or by the build script)")
|
|
239
|
+
if _GRADLE_RANGE_RE.search(spec):
|
|
240
|
+
return (None, f"version {spec!r} is a range or dynamic selector, not an exact version")
|
|
241
|
+
return spec, ""
|
|
242
|
+
|
|
243
|
+
|
|
244
|
+
def read_gradle_catalog(path: Path, text: str | None = None) -> LockfileContent:
|
|
245
|
+
"""`gradle/libs.versions.toml`: libraries and plugins with their pinned versions. Direct dependencies only (transitive
|
|
246
|
+
ones need Gradle dependency locking); entries without a version are `Unsupported`."""
|
|
247
|
+
data = tomllib.loads(text if text is not None else path.read_text(encoding="utf-8"))
|
|
248
|
+
if not isinstance(data.get("libraries"), dict) and not isinstance(data.get("plugins"), dict):
|
|
249
|
+
raise ValueError("no [libraries] or [plugins] table: not a Gradle version catalog")
|
|
250
|
+
versions = cast("dict[str, Any]", data.get("versions") or {})
|
|
251
|
+
content = LockfileContent(path, "Maven")
|
|
252
|
+
seen: set[tuple[str, str]] = set()
|
|
253
|
+
|
|
254
|
+
def add(name: str, spec: object) -> None:
|
|
255
|
+
version, reason = _catalog_version(spec, versions)
|
|
256
|
+
if version is None:
|
|
257
|
+
content.unsupported.append(Unsupported(path, name, reason))
|
|
258
|
+
elif (name, version) not in seen:
|
|
259
|
+
seen.add((name, version))
|
|
260
|
+
content.packages.append(LockedPackage("Maven", name, version, True, path))
|
|
261
|
+
|
|
262
|
+
for entry in (data.get("libraries") or {}).values():
|
|
263
|
+
if isinstance(entry, str):
|
|
264
|
+
parts = entry.split(":")
|
|
265
|
+
name, spec = ":".join(parts[:2]), (parts[2] if len(parts) > 2 else None)
|
|
266
|
+
else:
|
|
267
|
+
module = entry.get("module") or f"{entry.get('group', '')}:{entry.get('name', '')}"
|
|
268
|
+
name, spec = module, entry.get("version")
|
|
269
|
+
if name.count(":") != 1 or not all(name.split(":")):
|
|
270
|
+
raise ValueError(f"cannot read library coordinates {name!r}")
|
|
271
|
+
add(name, spec)
|
|
272
|
+
for entry in (data.get("plugins") or {}).values():
|
|
273
|
+
if isinstance(entry, str):
|
|
274
|
+
plugin_id, _, spec = entry.partition(":")
|
|
275
|
+
else:
|
|
276
|
+
plugin_id, spec = entry["id"], entry.get("version")
|
|
277
|
+
add(f"{plugin_id}:{plugin_id}.gradle.plugin", spec) # the plugin marker artifact
|
|
278
|
+
return content
|
|
279
|
+
|
|
280
|
+
|
|
281
|
+
def read_gradle_lockfile(path: Path, text: str | None = None) -> LockfileContent:
|
|
282
|
+
"""`gradle.lockfile` (dependency locking): one `group:artifact:version=configuration,...` line per resolved module."""
|
|
283
|
+
direct: set[str] = set()
|
|
284
|
+
for catalog in (path.parent / "gradle").glob("*.versions.toml") if (path.parent / "gradle").is_dir() else ():
|
|
285
|
+
direct.update(p.name for p in read_gradle_catalog(catalog).packages)
|
|
286
|
+
content = LockfileContent(path, "Maven")
|
|
287
|
+
seen: set[tuple[str, str]] = set()
|
|
288
|
+
for raw in (text if text is not None else path.read_text(encoding="utf-8")).splitlines():
|
|
289
|
+
line = raw.strip()
|
|
290
|
+
if not line or line.startswith("#") or line.startswith("empty="):
|
|
291
|
+
continue
|
|
292
|
+
coordinates = line.partition("=")[0].split(":")
|
|
293
|
+
if len(coordinates) != 3 or not all(coordinates):
|
|
294
|
+
raise ValueError(f"cannot read line {line!r}")
|
|
295
|
+
name, version = ":".join(coordinates[:2]), coordinates[2]
|
|
296
|
+
if (name, version) not in seen:
|
|
297
|
+
seen.add((name, version))
|
|
298
|
+
content.packages.append(LockedPackage("Maven", name, version, name in direct, path))
|
|
299
|
+
return content
|
|
@@ -7,6 +7,7 @@ from __future__ import annotations
|
|
|
7
7
|
import time
|
|
8
8
|
from collections.abc import Iterator, Sequence
|
|
9
9
|
from datetime import UTC, datetime
|
|
10
|
+
from email.utils import parsedate_to_datetime
|
|
10
11
|
from typing import Any, Protocol, cast
|
|
11
12
|
from urllib.parse import quote
|
|
12
13
|
|
|
@@ -19,6 +20,12 @@ OSV_URL = "https://api.osv.dev"
|
|
|
19
20
|
KEV_URL = "https://www.cisa.gov/sites/default/files/feeds/known_exploited_vulnerabilities.json"
|
|
20
21
|
PYPI_URL = "https://pypi.org/pypi"
|
|
21
22
|
NPM_URL = "https://registry.npmjs.org"
|
|
23
|
+
# Where a Gradle dependency can live, in lookup order: the first repository that has the POM gives the release time.
|
|
24
|
+
MAVEN_REPOS = (
|
|
25
|
+
"https://repo1.maven.org/maven2",
|
|
26
|
+
"https://dl.google.com/dl/android/maven2",
|
|
27
|
+
"https://plugins.gradle.org/m2",
|
|
28
|
+
)
|
|
22
29
|
BATCH_SIZE = 500
|
|
23
30
|
MAX_PAGES = 100 # backstop: OSV pages hold up to 1000 advisories, no package has anywhere near that many
|
|
24
31
|
RETRY_ATTEMPTS = 3
|
|
@@ -122,9 +129,43 @@ class OsvClient:
|
|
|
122
129
|
except (KeyError, TypeError) as exc:
|
|
123
130
|
raise DataError("CISA KEV feed has an unexpected shape") from exc
|
|
124
131
|
|
|
132
|
+
def _maven_release_time(self, name: str, version: str) -> datetime | None:
|
|
133
|
+
"""`Last-Modified` of the POM in the first Maven repository that has it (the upload time of the release)."""
|
|
134
|
+
group, _, artifact = name.partition(":")
|
|
135
|
+
path = f"{group.replace('.', '/')}/{artifact}/{version}/{artifact}-{version}.pom"
|
|
136
|
+
for repo in MAVEN_REPOS:
|
|
137
|
+
url = f"{repo}/{path}"
|
|
138
|
+
last: Exception | None = None
|
|
139
|
+
for attempt in range(RETRY_ATTEMPTS):
|
|
140
|
+
try:
|
|
141
|
+
response = self._session.head(url, timeout=HTTP_TIMEOUT_SECS, allow_redirects=True)
|
|
142
|
+
except requests.RequestException as exc:
|
|
143
|
+
last = exc
|
|
144
|
+
else:
|
|
145
|
+
if response.status_code == 404:
|
|
146
|
+
break # not in this repository: try the next one
|
|
147
|
+
if response.status_code in (429, 500, 502, 503, 504):
|
|
148
|
+
last = DataError(f"HTTP {response.status_code} from {url}")
|
|
149
|
+
elif not response.ok:
|
|
150
|
+
raise DataError(f"HTTP {response.status_code} from {url}")
|
|
151
|
+
else:
|
|
152
|
+
stamp = response.headers.get("Last-Modified")
|
|
153
|
+
if not stamp: # the POM exists, so its age is unreadable data, not "unknown"
|
|
154
|
+
raise DataError(f"{url} has no Last-Modified header")
|
|
155
|
+
try:
|
|
156
|
+
return parsedate_to_datetime(stamp).astimezone(UTC)
|
|
157
|
+
except (TypeError, ValueError) as exc:
|
|
158
|
+
raise DataError(f"{url} has an unreadable Last-Modified header {stamp!r}") from exc
|
|
159
|
+
time.sleep(RETRY_BACKOFF_SECS * (attempt + 1))
|
|
160
|
+
else:
|
|
161
|
+
raise DataError(f"{url} unreachable: {last}")
|
|
162
|
+
return None
|
|
163
|
+
|
|
125
164
|
def release_time(self, ecosystem: Ecosystem, name: str, version: str) -> datetime | None:
|
|
126
165
|
"""When the version was published: the youngest file for PyPI (uv gates per file), `time[version]` for npm
|
|
127
|
-
(bun's source). None when the registry doesn't know it (private package)."""
|
|
166
|
+
(bun's source), the POM's `Last-Modified` for Maven. None when the registry doesn't know it (private package)."""
|
|
167
|
+
if ecosystem == "Maven":
|
|
168
|
+
return self._maven_release_time(name, version)
|
|
128
169
|
if ecosystem == "PyPI":
|
|
129
170
|
data = self._request("GET", f"{PYPI_URL}/{quote(name)}/{quote(version)}/json", allow_404=True)
|
|
130
171
|
files = (data or {}).get("urls") or []
|