Skip to content

[DO NOT MERGE] Copy of #2737 - #2769

Draft
Xiaoyu Z (xiaoyu-work) wants to merge 2 commits into
mainfrom
shared-cache-integrity-hardening
Draft

Xiaoyu Z (xiaoyu-work) wants to merge 2 commits into
mainfrom
shared-cache-integrity-hardening

Conversation

@xiaoyu-work

Copy link
Copy Markdown
Member

Describe your changes

Independent copy of #2737: Harden shared cache downloads and pin the Miniconda installer.

Copies Iyanuoluwa007/Olive:shared-cache-integrity-hardening to the same branch name in microsoft/Olive, preserving the original commits. The original PR remains unchanged.

Validation: the copied branch head matches the source PR head. Tests and lintrunner -a were not run for this copy-only operation; the existing code has not been revalidated.

Checklist before requesting a review

  • Add unit tests for this change.
  • Make sure all tests can pass.
  • Update documents if necessary.
  • Lint and apply fixes to your code by running lintrunner -a
  • Is this a user-facing change? If yes, give a description of this change to be included in the release notes.

(Optional) Issue link

Source PR: #2737.

- Reject shared cache blobs whose names resolve outside of the local output
  directory (for example names containing ".." segments or absolute paths)
  instead of writing them wherever the path points.
- Widen the output model id derived from the run config hash from 8 to 16
  hex characters so cache entries are much harder to collide with.
- Download a pinned Miniconda release in the Qualcomm python env setup
  scripts and verify its published SHA-256 before running it, instead of
  executing the moving "latest" installer unchecked.

Addresses #2674
cache_model kept absolute model paths for non-HF models, so an ONNX model at
/tmp/model.onnx was uploaded as <id>/model/model//tmp/model.onnx and its
cached config pointed at the producer machine path. The new download
containment check rejects those names. Upload any local model file or folder
under its name instead, so blob names and the cached config are relative to
the cached model folder, and add an upload/download round-trip test.
Comment thread test/test_cache.py
blob.name = "model_id/model/additional_files/sub/config.json"

# execute
self.shared_cache._download_blob_list(
Comment thread test/test_cache.py

# execute and assert
with pytest.raises(ValueError, match="resolves outside of the output directory"):
self.shared_cache._download_blob_list([blob], "model_id/model/model", tmp_path / "output")

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.

3 participants