Skip to content

Harden id_prefix validation in the ontology reload jobs (defense-in-depth, not a bug) #1600

Description

@turbomam

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.

  1. Restrict id_prefix to the actual character set ontology prefixes use (alpha, numeric, underscore, hyphen, then a colon) instead of accepting any string.
  2. 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).
  3. 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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions