rdflib
rdflib copied to clipboard
Fix/1369 custom resolver
Fixes #1369
Proposed Changes
This adds a new Resolver framework, and updates the JSON-LD parser to use it.
As a result, implementors have much more control over which URLs referenced in JSON-LD documents will be resolved.
This PR implements a default-deny approach to URL resolution, which will need explaining in release notes and documentation. Implementors can revert to the old behaviour via environment variable if they are happy with the risks.
This also provides a base for future extensibility, e.g. caching or using locally-held copies of external resources.
No tests or documentation yet, but all existing tests pass when using the new PermissiveResolver.
Hi @alexdutton I am watching this PR with interest - I think it's a great idea to have "everything" available to RDFlib users, and, if scary, off by default - so look forward to you bringing it out of draft.
Just a couple of questions:
- Has this work of yours been motivated by the JSON-LD parser & serializer now being in RDFlib core?
- Do you have your own code like this in action already, just not in RDFlib?
- Can you please add some notes to the top of the new file
rdflib/resolver.pyto explains what it's doing, perhaps something likerdflib/compare.py(though doesn't have to be as long!) This just helps with people and file browsing
Hi @nicholascar
- I didn't realise the JSON-LD support had been moved into core when I first realised this was an issue, but still saw the fix as being in core as that's where the resolution behaviour was.
- No, I don't have similar code elsewhere. This was precipitated by needing to implement a Linked Data Notifications inbox for the COAR Notify initiative, which involves receiving JSON-LD documents to a publicly accessible HTTP endpoint.
- Yep, I'll do that now :-)
@alexdutton this PR is still in draft. Are you planning on taking it out of draft soon so we can review it formally?
This is a critical vulnerability. Will this be fixed in 6.3 release? Do we have a date for it?
This is a critical vulnerability. Will this be fixed in 6.3 release? Do we have a date for it?
The plan is to fix in in 6.3, but sadly I have very little time to work on this. I will be having some days off work later this month and I hope to finish it then.