fix(anatomy): import report reads the id map with get instead of panicking Map indexes (security gate LOW)

This commit is contained in:
bchanot committed 2026-10-22 21:24:04 +02:00
1 parent 82f166450c
commit 6afc1e0a37
1 file changed
+9 -3
+9 -3
View File
@@ -200,8 +200,10 @@ fn text_at<'a>(value: &'a Value, pointer: &str) -> &'a str {
}
fn categories_section(result: &ImportResult) -> String {
let legacy_of: HashMap<&str, &str> = result.legacy_id_map["categories"]
.as_object()
let legacy_of: HashMap<&str, &str> = result
.legacy_id_map
.get("categories")
.and_then(Value::as_object)
.map(|map| {
map.iter()
.filter_map(|(k, v)| Some((v.as_str()?, k.as_str())))
@@ -286,7 +288,11 @@ fn vertebral_section(result: &ImportResult) -> String {
.region_inferences
.iter()
.map(|i| {
let new_id = result.legacy_id_map["annotations"][&i.annotation_id].as_str();
let new_id = result
.legacy_id_map
.get("annotations")
.and_then(|map| map.get(&i.annotation_id))
.and_then(Value::as_str);
vec![
code(Some(new_id.unwrap_or(&i.annotation_id))).into(),
i.label.as_str().into(),