MCPcopy Create free account
hub / github.com/NVIDIA/OpenShell / validate_env_entries

Function validate_env_entries

crates/openshell-server/src/grpc/validation.rs:262–273  ·  view source on GitHub ↗
(
    map: &std::collections::HashMap<String, String>,
    field_name: &str,
)

Source from the content-addressed store, hash-verified

260const MAX_ENV_SERIALIZED_SIZE: usize = 256 * 1024; // 256 KiB
261
262fn validate_env_entries(
263 map: &std::collections::HashMap<String, String>,
264 field_name: &str,
265) -> Result<(), Status> {
266 let total_size: usize = map.iter().map(|(k, v)| k.len() + v.len()).sum();
267 if total_size > MAX_ENV_SERIALIZED_SIZE {
268 return Err(Status::invalid_argument(format!(
269 "{field_name} total size exceeds {MAX_ENV_SERIALIZED_SIZE} byte limit ({total_size} bytes)"
270 )));
271 }
272 validate_env_entries_inner(map, field_name, &[])
273}
274
275fn validate_exec_env_entries(
276 map: &std::collections::HashMap<String, String>,

Callers 1

validate_sandbox_specFunction · 0.85

Calls 2

lenMethod · 0.80

Tested by

no test coverage detected