Skip to content

Commit 90cb011

Browse files
fix: patch llguidance to remove reference to ring crate (#1948)
Fix MVS-2022-374v-6mvc by purging references to `ring` from `Cargo.lock`.
1 parent d7f0291 commit 90cb011

File tree

2 files changed

+64
-0
lines changed

2 files changed

+64
-0
lines changed
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
diff --git a/Cargo.toml b/Cargo.toml
2+
index c23c372..8637592 100644
3+
--- a/Cargo.toml
4+
+++ b/Cargo.toml
5+
@@ -1,23 +1,23 @@
6+
[workspace]
7+
members = [
8+
- "python_ext",
9+
+ # "python_ext",
10+
"parser",
11+
- "sample_parser",
12+
- "json_stats",
13+
+ # "sample_parser",
14+
+ # "json_stats",
15+
"toktrie",
16+
- "toktrie_hf_tokenizers",
17+
- "toktrie_hf_downloader",
18+
- "toktrie_tiktoken",
19+
+ # "toktrie_hf_tokenizers",
20+
+ # "toktrie_hf_downloader",
21+
+ # "toktrie_tiktoken",
22+
]
23+
# just exclude python_ext since it doesn't build without maturin
24+
default-members = [
25+
"parser",
26+
- "sample_parser",
27+
- "json_stats",
28+
+ # "sample_parser",
29+
+ # "json_stats",
30+
"toktrie",
31+
- "toktrie_hf_tokenizers",
32+
- "toktrie_hf_downloader",
33+
- "toktrie_tiktoken",
34+
+ # "toktrie_hf_tokenizers",
35+
+ # "toktrie_hf_downloader",
36+
+ # "toktrie_tiktoken",
37+
]
38+
resolver = "2"
39+
40+
@@ -41,6 +41,6 @@ opt-level = 3
41+
[workspace.dependencies]
42+
toktrie = { path = "toktrie" }
43+
llguidance = { path = "parser" }
44+
-toktrie_hf_tokenizers = { path = "toktrie_hf_tokenizers" }
45+
-toktrie_hf_downloader = { path = "toktrie_hf_downloader" }
46+
-toktrie_tiktoken = { path = "toktrie_tiktoken" }
47+
+# toktrie_hf_tokenizers = { path = "toktrie_hf_tokenizers" }
48+
+# toktrie_hf_downloader = { path = "toktrie_hf_downloader" }
49+
+# toktrie_tiktoken = { path = "toktrie_tiktoken" }

cmake/external/onnxruntime_external_deps.cmake

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,5 +107,20 @@ if(USE_GUIDANCE)
107107
GIT_TAG ${DEP_SHA1_llguidance}
108108
)
109109
onnxruntime_fetchcontent_makeavailable(llguidance)
110+
111+
# HACK: Patch llguidance's `/Cargo.toml` to avoid tripping component governance due to unused `ring` dep.
112+
# `ring` is deprecated in favour of `rust-openssl`.
113+
# `ring` is a transitive dep of several (unused by onnx-rt) libs in `llguidance`.
114+
# We only use the `parser` lib.
115+
# Governance trips on `/Cargo.lock` but that is expected to be regenerated as part of the build,
116+
# dropping the reference to `ring`.
117+
if(NOT EXISTS "${llguidance_SOURCE_DIR}/.onnx-rt-applied-remove-ring-ref-in-cargo-lock")
118+
execute_process(
119+
COMMAND git apply -- "${CMAKE_CURRENT_LIST_DIR}/llguidance/remove-ring-ref-in-cargo-lock.patch"
120+
WORKING_DIRECTORY "${llguidance_SOURCE_DIR}"
121+
COMMAND_ERROR_IS_FATAL ANY
122+
)
123+
file(TOUCH "${llguidance_SOURCE_DIR}/.onnx-rt-applied-remove-ring-ref-in-cargo-lock")
124+
endif()
110125
corrosion_import_crate(MANIFEST_PATH ${llguidance_SOURCE_DIR}/parser/Cargo.toml)
111126
endif()

0 commit comments

Comments
 (0)