Run the import-ontology transform client-side; delete the /transform endpoint - #344
Open
namedgraph wants to merge 2 commits into
Open
Run the import-ontology transform client-side; delete the /transform endpoint#344namedgraph wants to merge 2 commits into
namedgraph wants to merge 2 commits into
Conversation
…endpoint Move the "Import ontology" CONSTRUCT transform off the server, removing the last bespoke server-side fetch/SSRF surface (pen-test LNK-002) after /add and /generate. - Browser: the import-ontology submit handler fetches the construct-constructors query (sp:text), runs it in-browser over the ?uri=-proxied dct:source via a bundled SPARQL engine (Comunica, lazily loaded on first use), and GSP-appends the Turtle result to the local sd:name target -- structurally identical to the add/clone flow (ldh:transform-query-response / ldh:transform-construct-response). - CLI: import-ontology.sh no longer POSTs to /transform; it fetches the query, transforms the source locally with Jena arq, and POSTs the result to the graph. - Delete Transform.java, its Dispatcher locator, and the /transform HTTP tests. - Remove the now-unreachable generic form-clone-data RDF/POST submit template (its only caller was the transform variant's xsl:next-match). Bundle SPARQLTransform.js (thin wrapper) + comunica-browser.js (engine), loaded in the $load-sparql-builder block. CHANGELOG updated. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
import-ontology.sh pulls sp:text with a `sparql` SELECT over the fetched query document, emitted as SPARQL Results XML and read with `xmllint --xpath string(//literal)` to recover the exact multi-line query -- the XML parser decodes entities and preserves newlines, so no serialization regex or manual unescaping. Both the extraction and the transform run through `sparql`. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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.
Summary
Moves the "Import ontology" CONSTRUCT transform off the server on both the browser and CLI paths, so the
/transformendpoint is deleted. This removes the last bespoke server-side fetch/SSRF surface (pen-test LNK-002) after/addand/generatewere moved client-side, and completes the "until a client-side SPARQL engine lands" caveat from the graph-writes work.Changes
Browser — client-orchestrated transform
The import-ontology submit handler (
modal.xsl) now mirrors the add/clone flow, with an in-browser CONSTRUCT inserted:construct-constructorsquery, extractssp:text, runs it in-browser over the?uri=-proxieddct:source, and GSP-appends the Turtle result to the localsd:nametarget.ldh:transform-query-response/ldh:transform-construct-responseparallelldh:add-data-source-response.Client-side SPARQL engine (bundled, lazy)
comunica-browser.js(Comunica, prebuilt browser bundle) alongsidethree.min.jsetc.SPARQLTransform.jsexposesLinkedDataHub.construct(engineSrc, sourceURL, queryString) → Promise<Turtle>and lazily loads the 2.2 MB engine bundle on first use — nothing heavy loads on ordinary pages. Loaded in the$load-sparql-builderblock.CLI — symmetric local transform
bin/admin/ontologies/import-ontology.shno longer POSTs to/transform. It fetches the query, runs the CONSTRUCT locally via Jenaarq, and POSTs the result to the target graph. (Requiresarq+perlon$PATH.)Removals
Transform.java, itsDispatcherlocator, and the 4/transformHTTP tests.form-clone-dataRDF/POST submit template (its only caller was the transform variant'sxsl:next-match).Implemented but not yet exercised in a browser/stack (no runtime in the authoring environment). Confirmed here: both stylesheets XML-well-formed, CLI passes
bash -n, no lingeringTransformrefs, Java change is a trivial locator+import removal. Needs in-browser confirmation of:ixsl:call(...) => ixsl:then(...)bridge — awaiting a plain JS-library promise from Saxon-JS. Documented contract, but no precedent in this codebase.engine.query()→resultToString(result, 'text/turtle')→ stream read); the wrapper has an async-iterable fallback but verify.mvn -Pstandalone clean package(SEF compile) and a live Import ontology run (e.g. SKOS).🤖 Generated with Claude Code