Skip to content

Validate Cargo.lock input to the MxcDependencies feed seed pipeline - #1924

Open
Elliot (theelliotm) wants to merge 3 commits into
mainfrom
user/emichlin/seed-feed-input-validation
Open

Elliot (theelliotm) wants to merge 3 commits into
mainfrom
user/emichlin/seed-feed-input-validation

Conversation

@theelliotm

@theelliotm Elliot (theelliotm) commented Dec 3, 2026 •

Copy link
Copy Markdown
Contributor

📖 Description

The seed pipeline turns each crates.io entry in a PR's Cargo.lock into feed request URLs. It now checks those entries first, and also checks the PR number it is given.

The script only seeds packages from crates.io. Each name must follow crates.io naming rules and each version must be valid semver. If any entry fails, the script lists all of them and stops before sending a request. In that list, ## is printed as #\x23 so Azure Pipelines doesn't treat a value as a logging command. Names and versions are percent-encoded in URLs; for valid crates the URLs are unchanged. Fetching the feed's config.json now has a timeout and a clear error, and one crate failing no longer crashes the whole run.

In the pipeline, prNumber must be a number and is passed through an environment variable instead of being pasted into the script. The checkout no longer keeps git credentials, since the only later git command fetches from the public GitHub repo.

New offline tests in test_seed_feed.py run in the dependency-feed-check job.

Limitation: packages from git or other registries are skipped, not reported as errors.

🔗 References

  • Docs: docs/development/build-and-test/pull-requests.md, docs/development/build-and-test/ci-validation-infrastructure.md.

🔍 Validation

  • python -m unittest test_seed_feed (from .azure-pipelines/scripts, Windows and Ubuntu): passed, 6 tests. The ##vso[ test fails without the fix.
  • The real src/Cargo.lock passes validation, and the script produces the same 690 index and download URLs as before.
  • Not run: the Azure DevOps seed pipeline itself (needs shine-oss access).

✅ Checklist

  • Signed the Contributor License Agreement
  • Linked to an issue
  • For features or changes requiring a spec: linked the issue with maintainer-applied feature-accepted
  • For implementation: linked the required approved and merged design/API spec, or explained why no spec is required
  • Feature issue remains open unless this PR completes all agreed implementation, validation, and documentation
  • Updated documentation (if applicable)
  • Updated Copilot instructions (if build, architecture, or conventions changed)
  • If this PR changes Cargo.lock, the dependency-feed-check check passes (see pull request builds)

📋 Issue Type

  • Bug fix
  • Feature
  • Task

Elliot (theelliotm) and others added 2 commits December 3, 2026 15:46
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 83e19dbb-1bf5-41ad-80f0-47fe416d8093
Copilot AI max review requested due to automatic review settings December 3, 2026 23:55
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
There may be pipelines that require an authorized user to comment /azp run to run.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

PR-controlled names or versions can still inject active Azure Pipelines logging commands through validation diagnostics, allowing pipeline variables to be set before validation fails.

2 open issues
What changed in this PR

Hardens MXC’s MxcDependencies feed-seeding pipeline against untrusted pull request input.

Changes:

  • Validates crates.io package names and versions before requests and encodes URL segments.
  • Secures PR-number handling, removes persisted checkout credentials, and improves request failures.
  • Adds offline tests to dependency-feed-check and updates contributor guidance.
File Description
docs/​development/​build-and-test/​pull-requests.md Documents seed validation behavior.
docs/​development/​build-and-test/​ci-validation-infrastructure.md Records the new offline test step.
.github/​workflows/​Dependency.Feed.Check.Job.yml Runs seed-script tests.
.azure-pipelines/​Update.Feed.Dependencies.yml Validates PR numbers and removes persisted credentials.
.azure-pipelines/​scripts/​test_seed_feed.py Adds validation, URL, and failure tests.
.azure-pipelines/​scripts/​seed_feed.py Validates lockfile input and hardens feed requests.

Review effort: Max

Comment thread .azure-pipelines/scripts/seed_feed.py Resolved
Comment thread .azure-pipelines/scripts/seed_feed.py Resolved
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 83e19dbb-1bf5-41ad-80f0-47fe416d8093
Copilot AI max review requested due to automatic review settings December 5, 2026 00:09
@theelliotm
Elliot (theelliotm) marked this pull request as ready for review December 5, 2026 00:09
@theelliotm
Elliot (theelliotm) requested a review from a team as a code owner December 5, 2026 00:09

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

Unsanitized TOML diagnostics can trigger injected Azure Pipelines logging commands even when validation fails.

1 open issue
2 resolved since last review

Review effort: Max

try:
crates = _read_locked_crates()
except ValueError as error:
print(error)

This branch has not been deployed

No deployments
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.

2 participants