Skip to content

Commit 2b89f43

Browse files
committed
fix(mxc): authorize curl in inference policy (NVBug 6863783)
Signed-off-by: nv-vankit <[email protected]>
1 parent d1ae20a commit 2b89f43

5 files changed

Lines changed: 21 additions & 8 deletions

File tree

‎crates/openshell-driver-mxc/examples/inference.yaml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,4 @@ network_policies:
2121
access: read-write
2222
enforcement: enforce
2323
binaries:
24-
- path: '__CMD_EXE__'
24+
- path: '__CURL_EXE__'

‎crates/openshell-driver-mxc/examples/run-inference-test.ps1‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ try {
209209
$sharePolicy = $ShareDir.Replace('\', '/')
210210
$policyText = [System.IO.File]::ReadAllText((Join-Path $here "inference.yaml"))
211211
$policyText = $policyText.Replace("__OPENSHELL_DEMO_SHARE__", $sharePolicy)
212-
$policyText = $policyText.Replace("__CMD_EXE__", $cmdExe)
212+
$policyText = $policyText.Replace("__CURL_EXE__", $curlExe)
213213
$policyText = $policyText.Replace("__INFERENCE_HOST__", $apiUri.DnsSafeHost)
214214
$policyText = $policyText.Replace("__INFERENCE_PORT__", [string] $apiUri.Port)
215215
Write-Utf8 $policyUsed $policyText

‎crates/openshell-driver-mxc/src/driver.rs‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2989,7 +2989,8 @@ mod lifecycle_tests {
29892989
.replace("__OLLAMA_PORT__", "11434")
29902990
.replace("__INFERENCE_HOST__", "integrate.api.nvidia.com")
29912991
.replace("__INFERENCE_PORT__", "443")
2992-
.replace("__CMD_EXE__", r"C:\Windows\System32\cmd.exe");
2992+
.replace("__CMD_EXE__", r"C:\Windows\System32\cmd.exe")
2993+
.replace("__CURL_EXE__", r"C:\Windows\System32\curl.exe");
29932994
parse_sandbox_policy(&rendered).expect("parse rendered shipped demo policy")
29942995
}
29952996

‎crates/openshell-driver-mxc/tests/demo_examples.rs‎

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -206,22 +206,31 @@ fn shipped_inference_policies_are_narrow_and_valid_after_rendering() {
206206
"/portable/demo"
207207
};
208208
let fixtures = [
209-
("ollama.yaml", "local_ollama", "127.0.0.1", share),
209+
(
210+
"ollama.yaml",
211+
"local_ollama",
212+
"127.0.0.1",
213+
share,
214+
"__CMD_EXE__",
215+
r"C:\Windows\System32\cmd.exe",
216+
),
210217
(
211218
"inference.yaml",
212219
"nvidia_inference",
213220
"integrate.api.nvidia.com",
214221
share,
222+
"__CURL_EXE__",
223+
r"C:\Windows\System32\curl.exe",
215224
),
216225
];
217-
for (name, rule_name, endpoint, share) in fixtures {
226+
for (name, rule_name, endpoint, share, binary_placeholder, binary_path) in fixtures {
218227
let rendered = read_example(name)
219228
.replace("__OPENSHELL_DEMO_SHARE__", share)
220229
.replace("__OLLAMA_HOST__", "127.0.0.1")
221230
.replace("__OLLAMA_PORT__", "11434")
222231
.replace("__INFERENCE_HOST__", "integrate.api.nvidia.com")
223232
.replace("__INFERENCE_PORT__", "443")
224-
.replace("__CMD_EXE__", r"C:\Windows\System32\cmd.exe");
233+
.replace(binary_placeholder, binary_path);
225234
let policy = parse_sandbox_policy(&rendered)
226235
.unwrap_or_else(|error| panic!("failed to parse rendered {name}: {error}"));
227236
validate_sandbox_policy(&policy)
@@ -241,7 +250,7 @@ fn shipped_inference_policies_are_narrow_and_valid_after_rendering() {
241250
assert_eq!(rule.binaries.len(), 1);
242251
assert_eq!(
243252
rule.binaries[0].path.to_ascii_lowercase(),
244-
r"c:\windows\system32\cmd.exe"
253+
binary_path.to_ascii_lowercase()
245254
);
246255
}
247256
}
@@ -288,6 +297,8 @@ fn shipped_runners_supply_sandbox_scoped_workload_configuration() {
288297
assert!(cloud.contains("--noproxy"));
289298
assert!(cloud.contains("in-process wxc shim"));
290299
assert!(cloud.contains("does not provide MXC or AppContainer isolation"));
300+
assert!(cloud.contains("$policyText.Replace(\"__CURL_EXE__\", $curlExe)"));
301+
assert!(!cloud.contains("$policyText.Replace(\"__CMD_EXE__\", $cmdExe)"));
291302
}
292303

293304
#[cfg(target_os = "windows")]

‎crates/openshell-driver-mxc/tests/wxc_exec_real.rs‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -982,6 +982,7 @@ async fn pc_https_egress_reads_injected_ca_bundle() {
982982
let post_status_path_string = post_status_path.to_string_lossy().into_owned();
983983
let diagnostic_path_string = diagnostic_path.to_string_lossy().into_owned();
984984
let cmd_string = cmd.to_string_lossy().into_owned();
985+
let curl_string = curl.to_string_lossy().into_owned();
985986
// Schannel's revocation lookup targets are intentionally outside this
986987
// test's example.com-only policy. Disable that network lookup while still
987988
// requiring curl to validate the proxy-issued certificate against the
@@ -1036,7 +1037,7 @@ async fn pc_https_egress_reads_injected_ca_bundle() {
10361037
access: "read-only".to_string(),
10371038
..Default::default()
10381039
}],
1039-
binaries: vec![NetworkBinary { path: cmd_string }],
1040+
binaries: vec![NetworkBinary { path: curl_string }],
10401041
},
10411042
)]),
10421043
..Default::default()

0 commit comments

Comments
 (0)