fix: route ONNX pb files by content#1029
Conversation
Performance BenchmarksCompared
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: ca7e41601e
ℹ️ 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".
|
|
||
| def _looks_like_onnx_model_candidate_file(path: Path, size: int, header: bytes) -> bool: | ||
| """Run the bounded ONNX parser only for plausible protobuf tag starts.""" | ||
| return _has_onnx_model_tag_start(header) and _looks_like_onnx_model_file(path, size) |
There was a problem hiding this comment.
Parse ONNX candidates without first-byte whitelisting
_looks_like_onnx_model_candidate_file short-circuits on _has_onnx_model_tag_start(header). Protobuf allows unknown/reordered fields, so a valid ONNX ModelProto can legally start with a different tag (e.g., prefixed unknown field). In that case this returns False, routing a malicious .pb as generic protobuf and bypassing ONNX-specific checks (like PythonOp detection).
Useful? React with 👍 / 👎.
ca7e416 to
7a711c2
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 7a711c276a
ℹ️ 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".
|
|
||
| def _looks_like_onnx_model_candidate_file(path: Path, size: int, header: bytes) -> bool: | ||
| """Run the bounded ONNX parser only for plausible protobuf tag starts.""" | ||
| return _has_onnx_model_tag_start(header) and _looks_like_onnx_model_file(path, size) |
There was a problem hiding this comment.
Parse ONNX candidates without first-byte whitelist
_looks_like_onnx_model_candidate_file() only runs the ONNX structural parser when header[0] is in _ONNX_MODEL_TOP_LEVEL_TAG_START_BYTES. Protobuf permits reordered/unknown fields, so valid ModelProto payloads can start with other tags (e.g., unknown-field prefixes or other top-level fields). Those .pb files are then routed as generic protobuf, skipping ONNX-specific checks like PythonOp detection.
Useful? React with 👍 / 👎.
Summary
Validation