Skip to content

fix: keep legal inventory synchronized with upstream updates - #48

Merged
eXPerience83 merged 17 commits into
mainfrom
hotfix/legal-inventory-sync
Aug 1, 2026
Merged

fix: keep legal inventory synchronized with upstream updates#48
eXPerience83 merged 17 commits into
mainfrom
hotfix/legal-inventory-sync

Conversation

@eXPerience83

@eXPerience83 eXPerience83 commented Aug 1, 2026

Copy link
Copy Markdown
Owner

Summary

Repair the main mismatch introduced by merging the legal inventory before the latest upstream version update, and prevent normal automated updates from opening CI-broken pull requests.

  • align GitHub CLI 2.97.0 and mise 2026.7.18 with third_party/inventory.json;
  • update the inventory and exact version-specific repository notices in the same automated runtime-update PR;
  • keep changed legal text visible for human review rather than approving it silently;
  • distinguish automated refreshed_on from human reviewed_on;
  • restrict notice downloads to approved HTTPS hosts and redirects;
  • confine repository notice writes to third_party/;
  • reject duplicate inventory keys before any downloads;
  • add deterministic unit tests for URL derivation, parsing, path containment and duplicate handling;
  • document one automation owner per dependency: Renovate for standard Docker/Actions references, check-upstream.yml for runtime pins, digests, locks and notices.

Bounded behavior

For an existing component, the daily workflow updates its version, derives the new exact reviewed_from URL from the previous version-specific URL, downloads repository-preserved legal documents and commits all resulting changes together. A completely new tool still requires an explicit inventory entry.

This PR remains declarative. It does not add a Docker, shell or package-manager parser.

Validation

  • Python syntax and unittest coverage for the updater contract;
  • deterministic updater --check validation;
  • existing version-pin and legal-inventory validators;
  • full AMD64 image build, smoke tests, bundled-notice checks, SBOMs and Trivy gate.

After this PR merges, Renovate PR #45 should be rebased/retried; its Dockerfile frontend update is not the source of the original failure.

Refs #26

@coderabbitai

coderabbitai Bot commented Aug 1, 2026

Copy link
Copy Markdown

Review Change Stack

Summary by CodeRabbit

  • New Features

    • Added automated validation and refresh of third-party legal inventory records, including reviewed source URLs and legal documents.
    • Inventory updates now verify component versions, required notices, and document availability before completion.
  • Bug Fixes

    • Improved detection of invalid or outdated third-party inventory information.
  • Documentation

    • Documented legal-text review requirements and workflow behavior when notices or URLs cannot be refreshed.
  • Chores

    • Updated GitHub CLI and mise inventory entries and review dates.

Walkthrough

Changes

Third-party inventory automation

Layer / File(s) Summary
Inventory parsing and validation
scripts/update-third-party-inventory.py
The script parses versions.env and inventory JSON, validates version alignment and notice contracts, downloads bounded HTTPS documents, and writes files atomically.
Inventory refresh CLI
scripts/update-third-party-inventory.py
The CLI supports --check and --write modes. Write mode refreshes changed versions, notices, and review dates, then revalidates the inventory.
Workflow and inventory integration
.github/workflows/*.yml, third_party/README.md, third_party/inventory.json
Workflows run inventory validation and updates. Change detection and automation messages include inventory and legal notices. The inventory records updated component versions and review metadata.

Estimated code review effort: 4 (Complex) | ~45 minutes

Possibly related PRs

Possibly related PRs

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description explains the change and validation, but it omits the required Impact, Safety and release checks, and Follow-up sections. Add the required template sections and complete the Impact, Safety and release checks, and Follow-up details.
✅ Passed checks (4 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title clearly summarizes the primary change: synchronizing the legal inventory with upstream updates.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch hotfix/legal-inventory-sync

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 4

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@scripts/update-third-party-inventory.py`:
- Around line 144-153: Validate repository notice paths with the shared
resolve_notice_path helper before use: replace the direct root / "third_party" /
relative joins in both check_inventory and update_inventory with
resolve_notice_path(root, relative, component.get('id', '<unknown>')). Keep the
existing file validation and atomic write behavior unchanged.
- Around line 57-92: Add unit tests for validate_notice_url, derive_notice_url,
and parse_versions, covering HTTPS enforcement, embedded credentials, exactly
one version occurrence, valid derivation, and malformed KEY=VALUE inputs.
Exercise both accepted and rejected cases, asserting the expected validation
failures and parsed or derived values without involving network or file-output
behavior.
- Around line 76-92: Add defense-in-depth host validation inside download_notice
before urllib.request.urlopen, restricting the parsed HTTPS URL hostname to the
approved allowlist such as raw.githubusercontent.com. Reject any URL with a
non-allowlisted hostname through fail, while preserving the existing HTTPS
redirect, size, and empty-content checks.
- Around line 116-206: Extract the shared component and repository-notice shape
validation from check_inventory and update_inventory into a helper, and call it
from both flows before any version processing or downloads. Have the helper
validate version_key, notices, path, and reviewed_from, while tracking seen
version keys so duplicate keys are rejected identically in both paths. Preserve
each function’s existing version-alignment and update behavior.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: c831bad1-514c-4083-8c4f-53af0a2bfd91

📥 Commits

Reviewing files that changed from the base of the PR and between 50523e7 and fa57ad3.

📒 Files selected for processing (5)
  • .github/workflows/build-amd64.yml
  • .github/workflows/check-upstream.yml
  • scripts/update-third-party-inventory.py
  • third_party/README.md
  • third_party/inventory.json
📜 Review details
⏰ Context from checks skipped due to timeout. (1)
  • GitHub Check: build
🧰 Additional context used
📓 Path-based instructions (2)
.github/workflows/**

⚙️ CodeRabbit configuration file

.github/workflows/**: Review GitHub Actions for least-privilege permissions, safe event triggers, untrusted input handling,
accidental publication, tag-channel correctness, secret exposure, reproducible builds, SBOM/provenance
generation and appropriate validation before pushing images.

Files:

  • .github/workflows/build-amd64.yml
  • .github/workflows/check-upstream.yml
**/*.md

⚙️ CodeRabbit configuration file

**/*.md: Check that documentation matches the implemented behavior and clearly distinguishes experimental edge builds
from stable releases. Flag outdated versions, unsafe deployment guidance and claims not proven by CI or testing.

Files:

  • third_party/README.md
🪛 ast-grep (0.45.0)
scripts/update-third-party-inventory.py

[warning] 79-79: Request-controlled URL passed to urlopen; validate against an allowlist to prevent SSRF.
Context: urllib.request.urlopen(request, timeout=30)
Note: [CWE-918] Server-Side Request Forgery (SSRF).

(urlopen-unsanitized-data)


[info] 111-111: use jsonify instead of json.dumps for JSON output
Context: json.dumps(data, indent=2, ensure_ascii=False)
Note: [CWE-116] Improper Encoding or Escaping of Output.

(use-jsonify)

🪛 Ruff (0.16.0)
scripts/update-third-party-inventory.py

[warning] 22-22: Avoid specifying long messages outside the exception class

(TRY003)


[error] 78-78: Audit URL open for permitted schemes. Allowing use of file: or custom schemes is often unexpected.

(S310)


[error] 80-80: Audit URL open for permitted schemes. Allowing use of file: or custom schemes is often unexpected.

(S310)


[warning] 116-116: Too many branches (13 > 12)

(PLR0912)


[warning] 156-156: Too many branches (14 > 12)

(PLR0912)

🔇 Additional comments (7)
scripts/update-third-party-inventory.py (2)

20-113: LGTM!


116-243: LGTM on the remaining check/update/CLI logic. The write-then-revalidate flow in main() (Lines 232-234) correctly re-reads the file from disk before revalidating, and update_inventory defers all disk writes until after every notice download succeeds, so a mid-loop failure cannot leave a partial commit.

.github/workflows/build-amd64.yml (1)

31-32: LGTM!

.github/workflows/check-upstream.yml (2)

265-287: LGTM!


305-305: LGTM!

third_party/inventory.json (1)

3-3: LGTM!

Also applies to: 44-51, 76-83

third_party/README.md (1)

30-31: 📐 Maintainability & Code Quality

Daily cadence matches the workflow schedule.

on.schedule.cron: "17 5 * * *" schedules the upstream workflow daily at 05:17 UTC.

Comment thread scripts/update-third-party-inventory.py Outdated
Comment thread scripts/update-third-party-inventory.py
Comment thread scripts/update-third-party-inventory.py
Comment thread scripts/update-third-party-inventory.py

@eXPerience83 eXPerience83 left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed the bounded actionable feedback on the current HEAD:

  • added deterministic unit tests for parsing, version-specific URL validation/derivation, approved hosts, path containment and duplicate keys;
  • restricted both initial downloads and redirects to the explicit raw.githubusercontent.com allowlist;
  • confined repository notice writes to third_party/;
  • reject duplicate version_key entries before any download;
  • separated automated refreshed_on from human reviewed_on.

The larger helper-extraction refactor was intentionally not added: the concrete behavior gap identified by the review is fixed and tested, while restructuring both validation paths would expand this hotfix without changing its contract.

@eXPerience83
eXPerience83 merged commit 7437827 into main Aug 1, 2026
2 checks passed

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 508b609ebb

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

for path, content in pending_files:
atomic_write_bytes(path, content)

inventory["refreshed_on"] = datetime.now(timezone.utc).date().isoformat()

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Preserve the refresh date across identical reruns

When an automation PR remains open past UTC midnight, check-upstream.yml resets the local automation branch to main and processes the same still-unmerged version change again. This line then produces a different tree solely because the date changed, so the tree comparison in .github/workflows/check-upstream.yml lines 289-295 cannot reuse the existing remote commit and instead force-pushes and dispatches another build every day. Preserve the candidate's original refresh date or otherwise make repeated generation deterministic when the versions and notices are unchanged.

Useful? React with 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant