-
Notifications
You must be signed in to change notification settings - Fork 1
/
neo4j.init
43 lines (33 loc) · 1.21 KB
/
neo4j.init
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
// Run in cypher-shell -u neo4j
// Cleanup graph.
match (n) detach delete n;
// Initialize configuration for loading RDF into neo4j.
call n10s.graphconfig.init();
call n10s.graphconfig.set( { keepLangTag: true, handleRDFTypes: "LABELS_AND_NODES" });
WITH '
@prefix d3f: <http://d3fend.mitre.org/ontologies/d3fend.owl#> .
@prefix k8s: <urn:k8s:> .
' AS txt
CALL n10s.nsprefixes.addFromText(txt) yield prefix, namespace
RETURN prefix, namespace;
// Ensure resources are unique.
CREATE CONSTRAINT n10s_unique_uri ON (r:Resource)
ASSERT r.uri IS UNIQUE;
// Import d3fend.
// CALL n10s.rdf.import.fetch("https://next.d3fend.mitre.org/ontologies/d3fend.ttl","Turtle");
// Import infrastructure.
// CALL n10s.rdf.import.fetch("https://gist.githubusercontent.com/ioggstream/c3f1394ebf23f27aa0a9771ad1bc06f9/raw/deleteme.ttl", "Turtle");
CALL n10s.rdf.import.fetch("file:///code/d3fend.ttl", "Turtle");
CALL n10s.rdf.import.fetch("file:///code/deleteme.ttl", "Turtle");
// Add labels
match (n)
where
n.`d3f__attack-id` is not null
set n:d3f__OffensiveTechnique ;
match (n)
where
n.`d3f__d3fend-id` is not null
set n:d3f__DefensiveTechnique ;
// Add K8S labels
match (n) -[:rdfs__subClassOf]- ({uri: "urn:k8s:Kind"})
set n:k8s__Kind ;