Three non-blocking hardening ideas surfaced while reviewing #1562 id_prefix handling in delete_ontology_terms_by_prefix. None are bugs today: re.escape already prevents the regex-metacharacter risk. These are defense-in-depth for later.
- Restrict
id_prefix to the actual character set ontology prefixes use (alpha, numeric, underscore, hyphen, then a colon) instead of accepting any string.
- Cross-check
id_prefix / source_ontology against OLS or semsql's own registry of known ontology prefixes, instead of only the hand-maintained _ONTOLOGY_ID_PREFIXES dict in nmdc_runtime/site/ops/ontology.py. Would need a live-dependency failure mode considered (what happens on launch if OLS is unreachable).
- No test currently checks
_ONTOLOGY_ID_PREFIXES's actual entries against the four reload_*_ontology_job configs in repository.py — only the mismatch-detection function's logic is tested, with synthetic values. A typo'd dict entry would go uncaught.
Three non-blocking hardening ideas surfaced while reviewing #1562
id_prefixhandling indelete_ontology_terms_by_prefix. None are bugs today:re.escapealready prevents the regex-metacharacter risk. These are defense-in-depth for later.id_prefixto the actual character set ontology prefixes use (alpha, numeric, underscore, hyphen, then a colon) instead of accepting any string.id_prefix/source_ontologyagainst OLS or semsql's own registry of known ontology prefixes, instead of only the hand-maintained_ONTOLOGY_ID_PREFIXESdict innmdc_runtime/site/ops/ontology.py. Would need a live-dependency failure mode considered (what happens on launch if OLS is unreachable)._ONTOLOGY_ID_PREFIXES's actual entries against the fourreload_*_ontology_jobconfigs inrepository.py— only the mismatch-detection function's logic is tested, with synthetic values. A typo'd dict entry would go uncaught.