D3FEND JSON ontology file does not load properly into Blazegraph, but TTL file does
Closed this issue · 4 comments
Hello! I am fairly new to SPARQL and D3FEND. I have been playing around with putting D3FEND into a SPARQL engine so that I can run queries. I noticed that the D3FEND TTL file https://d3fend.mitre.org/ontologies/d3fend.ttl
loads properly into Blazegraph. However, when I try to upload https://d3fend.mitre.org/ontologies/d3fend.json
, I get this Java error:
ERROR: INSERT-WITH-BODY: baseURI=http://127.0.0.1:9999/blazegraph/namespace/kb/sparql, Content-Type=application/sparql-results+json, context-uri=[]
java.util.concurrent.ExecutionException: org.openrdf.rio.RDFParseException: Found unexpected object in top level @context field
at java.util.concurrent.FutureTask.report(FutureTask.java:122)
at java.util.concurrent.FutureTask.get(FutureTask.java:192)
at com.bigdata.rdf.sail.webapp.BigdataServlet.submitApiTask(BigdataServlet.java:294)
at com.bigdata.rdf.sail.webapp.InsertServlet.doPostWithBody(InsertServlet.java:206)
at com.bigdata.rdf.sail.webapp.InsertServlet.doPost(InsertServlet.java:122)
at com.bigdata.rdf.sail.webapp.RESTServlet.doPost(RESTServlet.java:308)
at com.bigdata.rdf.sail.webapp.MultiTenancyServlet.doPost(MultiTenancyServlet.java:195)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:707)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:790)
at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:865)
at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:535)
at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:146)
at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:548)
at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:132)
at org.eclipse.jetty.server.handler.ScopedHandler.nextHandle(ScopedHandler.java:257)
at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:1595)
at org.eclipse.jetty.server.handler.ScopedHandler.nextHandle(ScopedHandler.java:255)
at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1340)
at org.eclipse.jetty.server.handler.ScopedHandler.nextScope(ScopedHandler.java:203)
at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:473)
at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:1564)
at org.eclipse.jetty.server.handler.ScopedHandler.nextScope(ScopedHandler.java:201)
at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1242)
at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:144)
at org.eclipse.jetty.server.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:220)
at org.eclipse.jetty.server.handler.HandlerCollection.handle(HandlerCollection.java:126)
at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:132)
at org.eclipse.jetty.rewrite.handler.RewriteHandler.handle(RewriteHandler.java:335)
at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:132)
at org.eclipse.jetty.server.Server.handle(Server.java:503)
at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:364)
at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:260)
at org.eclipse.jetty.io.AbstractConnection$ReadCallback.succeeded(AbstractConnection.java:305)
at org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:103)
at org.eclipse.jetty.io.ChannelEndPoint$2.run(ChannelEndPoint.java:118)
at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.runTask(EatWhatYouKill.java:333)
at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.doProduce(EatWhatYouKill.java:310)
at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.tryProduce(EatWhatYouKill.java:168)
at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.run(EatWhatYouKill.java:126)
at org.eclipse.jetty.util.thread.ReservedThreadExecutor$ReservedThread.run(ReservedThreadExecutor.java:366)
at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:765)
at org.eclipse.jetty.util.thread.QueuedThreadPool$2.run(QueuedThreadPool.java:683)
at java.lang.Thread.run(Thread.java:748)
Caused by: org.openrdf.rio.RDFParseException: Found unexpected object in top level @context field
at com.bigdata.rdf.rio.json.BigdataSPARQLResultsJSONParserForConstruct.parse(BigdataSPARQLResultsJSONParserForConstruct.java:75)
at com.bigdata.rdf.sail.webapp.InsertServlet$InsertWithBodyTask.call(InsertServlet.java:308)
at com.bigdata.rdf.sail.webapp.InsertServlet$InsertWithBodyTask.call(InsertServlet.java:229)
at com.bigdata.rdf.task.ApiTaskForIndexManager.call(ApiTaskForIndexManager.java:68)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
... 1 more
Caused by: org.openrdf.query.resultio.QueryResultParseException: Found unexpected object in top level @context field
at com.bigdata.rdf.rio.json.SPARQLJSONParserBase.parseQueryResultInternal(SPARQLJSONParserBase.java:354)
at com.bigdata.rdf.rio.json.SPARQLJSONParserBase.parseQueryResult(SPARQLJSONParserBase.java:125)
at com.bigdata.rdf.rio.json.BigdataSPARQLResultsJSONParserForConstruct.parse(BigdataSPARQLResultsJSONParserForConstruct.java:73)
... 7 more
Hey! Nice to meet you. Thanks for reporting this. I'm not on the D3FEND team, but I can help you out. I can reproduce the bug in Blazegraph with parsing this JSON-LD. It is due to the extension not being jsonld. The way RIO is parsing it is based on the file extension, so to explicitly nudge it toward parsing JSON-LD it needs the right file extension. Try again after renaming the file to d3fend.jsonld.
I renamed d3fend.json
to d3fend.jsonld
and tried uploading it into Blazegraph, but I got an error.
Screenshot of part of the error:
This is the error message. I removed a lot of the text in the middle that I think is just a dump of the file contents:
ERROR: SPARQL-UPDATE: updateStr={
"@context": {
"d3f": "http://d3fend.mitre.org/ontologies/d3fend.owl#",
"dbr": "http://dbpedia.org/resource/",
"dc": "http://purl.org/dc/elements/1.1/",
"dcterms": "http://purl.org/dc/terms/",
"owl": "http://www.w3.org/2002/07/owl#",
"rdf": "http://www.w3.org/1999/02/22-rdf-syntax-ns#",
"rdfs": "http://www.w3.org/2000/01/rdf-schema#",
"skos": "http://www.w3.org/2004/02/skos/core#",
"xml": "http://www.w3.org/XML/1998/namespace",
"xsd": "http://www.w3.org/2001/XMLSchema#"
},
[ I'm omitting what I think this is a dump of the entire file ]
{
"@id": "d3f:T1590.002",
"@type": "owl:Class",
"d3f:attack-id": "T1590.002",
"d3f:definition": "Adversaries may gather information about the victim's DNS that can be used during targeting. DNS information may include a variety of details, including registered name servers as well as records that outline addressing for a target’s subdomains, mail servers, and other hosts. DNS, MX, TXT, and SPF records may also reveal the use of third party cloud and SaaS providers, such as Office 365, G Suite, Salesforce, or Zendesk.(Citation: Sean Metcalf Twitter DNS Records)",
"rdfs:label": "DNS",
"rdfs:subClassOf": {
"@id": "d3f:T1590"
}
}
]
}
java.util.concurrent.ExecutionException: org.openrdf.query.MalformedQueryException: Encountered " "{" "{ "" at line 1, column 1.
Was expecting one of:
";" ...
"base" ...
"prefix" ...
"drop entailments" ...
"create entailments" ...
"enable entailments" ...
"disable entailments" ...
"load" ...
"clear" ...
"drop" ...
"add" ...
"move" ...
"copy" ...
"create" ...
"insert" ...
"delete" ...
"with" ...
at java.util.concurrent.FutureTask.report(FutureTask.java:122)
at java.util.concurrent.FutureTask.get(FutureTask.java:192)
at com.bigdata.rdf.sail.webapp.BigdataServlet.submitApiTask(BigdataServlet.java:294)
at com.bigdata.rdf.sail.webapp.QueryServlet.doSparqlUpdate(QueryServlet.java:460)
at com.bigdata.rdf.sail.webapp.QueryServlet.doPost(QueryServlet.java:241)
at com.bigdata.rdf.sail.webapp.RESTServlet.doPost(RESTServlet.java:269)
at com.bigdata.rdf.sail.webapp.MultiTenancyServlet.doPost(MultiTenancyServlet.java:195)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:707)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:790)
at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:865)
at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:535)
at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:146)
at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:548)
at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:132)
at org.eclipse.jetty.server.handler.ScopedHandler.nextHandle(ScopedHandler.java:257)
at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:1595)
at org.eclipse.jetty.server.handler.ScopedHandler.nextHandle(ScopedHandler.java:255)
at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1340)
at org.eclipse.jetty.server.handler.ScopedHandler.nextScope(ScopedHandler.java:203)
at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:473)
at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:1564)
at org.eclipse.jetty.server.handler.ScopedHandler.nextScope(ScopedHandler.java:201)
at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1242)
at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:144)
at org.eclipse.jetty.server.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:220)
at org.eclipse.jetty.server.handler.HandlerCollection.handle(HandlerCollection.java:126)
at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:132)
at org.eclipse.jetty.rewrite.handler.RewriteHandler.handle(RewriteHandler.java:335)
at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:132)
at org.eclipse.jetty.server.Server.handle(Server.java:503)
at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:364)
at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:260)
at org.eclipse.jetty.io.AbstractConnection$ReadCallback.succeeded(AbstractConnection.java:305)
at org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:103)
at org.eclipse.jetty.io.ChannelEndPoint$2.run(ChannelEndPoint.java:118)
at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.runTask(EatWhatYouKill.java:333)
at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.doProduce(EatWhatYouKill.java:310)
at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.tryProduce(EatWhatYouKill.java:168)
at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.run(EatWhatYouKill.java:126)
at org.eclipse.jetty.util.thread.ReservedThreadExecutor$ReservedThread.run(ReservedThreadExecutor.java:366)
at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:765)
at org.eclipse.jetty.util.thread.QueuedThreadPool$2.run(QueuedThreadPool.java:683)
at java.lang.Thread.run(Thread.java:748)
Caused by: org.openrdf.query.MalformedQueryException: Encountered " "{" "{ "" at line 1, column 1.
Was expecting one of:
";" ...
"base" ...
"prefix" ...
"drop entailments" ...
"create entailments" ...
"enable entailments" ...
"disable entailments" ...
"load" ...
"clear" ...
"drop" ...
"add" ...
"move" ...
"copy" ...
"create" ...
"insert" ...
"delete" ...
"with" ...
at com.bigdata.rdf.sail.sparql.Bigdata2ASTSPARQLParser.parseUpdate2(Bigdata2ASTSPARQLParser.java:305)
at com.bigdata.rdf.sail.webapp.QueryServlet$SparqlUpdateTask.call(QueryServlet.java:533)
at com.bigdata.rdf.sail.webapp.QueryServlet$SparqlUpdateTask.call(QueryServlet.java:472)
at com.bigdata.rdf.task.ApiTaskForIndexManager.call(ApiTaskForIndexManager.java:68)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
... 1 more
Caused by: com.bigdata.rdf.sail.sparql.ast.ParseException: Encountered " "{" "{ "" at line 1, column 1.
Was expecting one of:
";" ...
"base" ...
"prefix" ...
"drop entailments" ...
"create entailments" ...
"enable entailments" ...
"disable entailments" ...
"load" ...
"clear" ...
"drop" ...
"add" ...
"move" ...
"copy" ...
"create" ...
"insert" ...
"delete" ...
"with" ...
at com.bigdata.rdf.sail.sparql.ast.SyntaxTreeBuilder.generateParseException(SyntaxTreeBuilder.java:9718)
at com.bigdata.rdf.sail.sparql.ast.SyntaxTreeBuilder.jj_consume_token(SyntaxTreeBuilder.java:9585)
at com.bigdata.rdf.sail.sparql.ast.SyntaxTreeBuilder.UpdateSequence(SyntaxTreeBuilder.java:126)
at com.bigdata.rdf.sail.sparql.ast.SyntaxTreeBuilder.parseUpdateSequence(SyntaxTreeBuilder.java:49)
at com.bigdata.rdf.sail.sparql.Bigdata2ASTSPARQLParser.parseUpdate2(Bigdata2ASTSPARQLParser.java:186)
... 7 more
I think this is a Blazegraph specific issue -- it's not under active development anymore, but you can try raising the issue here: https://github.com/blazegraph/database/issues
The JSON passes our parsing tests: https://github.com/d3fend/d3fend-ontology/blob/develop/Makefile#L364
If there are alternate tests to propose please let us know.