Conversation
Two defects on the legacy route that attaches datasets to a scenario: - The list hook was named validate_dataset, but DRF calls validate_<field> and the field is `datasets`, so the empty-list and duplicate-name rules never ran (#2508). Renamed. - insert_dataset_query and dataset_exists_query (extracted unchanged from their callers first, so the tests could run the statement text against an in-memory rdflib graph) put the label and the address between quotes. The label is a table's title, editable by its owner; an external address is checked only for its prefix. The tests showed a quote in either writing 7 triples instead of 5, the extra two being the payload's own. Both are now Literal(...).n3(). The predicates and closed-shape properties of #2509 are unchanged on purpose: fixing them changes the data representation and needs the retire-or-fix decision plus a production count first. Closes #2508 Refs #2509 Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #2508. Fixes part 4 of #2509 (the injection); the rest of #2509 is deliberately left open.
#2508: the list validation never ran
DRF calls
validate_<field name>. The field isdatasets, and the hook wasvalidate_dataset. So an empty list and duplicate names were accepted. The hook is now renamed tovalidate_datasets.#2509 part 4: SPARQL injection
add_datasets_to_scenariobuilt itsINSERT DATAwith an f-string, pasting two user-controlled values between quotes:Any logged-in user can create a bundle, and so own one. A quote in either value closed the literal and turned the rest into triples in the OEKG. The new tests showed it on develop: a crafted label wrote 7 triples instead of 5, and the two extra were the payload's own.
The two query builders were first extracted unchanged (
insert_dataset_query,dataset_exists_query), so the tests can run the statement text against an in-memory rdflib graph with no Fuseki needed. Both values are now written asLiteral(...).n3(). The identifiers are server-minted uuids, and the OEO terms are constants.Deliberately not in this PR
The rest of #2509 changes what the route writes, so it needs WF-06's retire-or-fix decision, plus a count of the affected triples on production:
RO_0002233/4vsOEO_00020437/6);has_iri/has_keyvs the closed shape;Tests
8 new tests in
api/tests/test_manage_datasets.py: 3 for the list rules, 5 for the escaping (quote in the label, quote in the address, newline and backslash, the ASK, a plain link).python manage.py test api oekg factsheet: 407 tests, green locally (105 skipped: no Fuseki). One subprocess test needed a rerun under the default settings, because of the isolated test DB.🤖 Generated with Claude Code