forked from sepses/cyber-kg-converter
-
Notifications
You must be signed in to change notification settings - Fork 0
/
example-queries.txt
201 lines (144 loc) · 5.55 KB
/
example-queries.txt
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
# Endpoint: https://sepses.ifs.tuwien.ac.at/sparql
#
# Recent CVEs
#
PREFIX cve: <http://w3id.org/sepses/vocab/ref/cve#>
PREFIX dct: <http://purl.org/dc/terms/>
SELECT ?cveId ?modified
WHERE {
?cve cve:id ?cveId .
?cve dct:modified ?modified .
}
ORDER BY DESC(?modified)
# XML-based updates are phased out since Oct 16 - currently updating the mappings to JSON
#
# Look up CPE by product name
#
PREFIX cve: <http://w3id.org/sepses/vocab/ref/cve#>
SELECT ?cpeId
WHERE {
?cve cve:hasCPE ?cpeId
.
FILTER(regex(str(?cpeId), "cpeoapplemac_os_x" ))
}
#ORDER BY DESC(?cpeId)
#
# List vulnerabilities (i.e., CVEs) for a given product (i.e., CPE).
#
#
# hasCPE is based on vulnerable product in CVE
#
# Complex logical rules could be used to specify combinations - data is there, but queries become complex (could be materialized..)
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX asset: <http://w3id.org/sepses/vocab/bgk/assetKnowledge#>
PREFIX cve: <http://w3id.org/sepses/vocab/ref/cve#>
PREFIX cpe: <http://w3id.org/sepses/vocab/ref/cpe#>
PREFIX cvss: <http://w3id.org/sepses/vocab/ref/cvss#>
PREFIX cwe: <http://w3id.org/sepses/vocab/ref/cwe#>
PREFIX dct: <http://purl.org/dc/terms/>
SELECT ?cveId ?issued ?modified
WHERE {
?cve cve:hasCPE <http://w3id.org/sepses/resource/cpe/cpeoapplemac_os_x10.14.1> .
?cve cve:id ?cveId.
?cve dct:issued ?issued.
?cve dct:modified ?modified.
}
# Limitation: Only CVEs that match this specific version here
# wildcards not considered yet - currently adapting the ETL process to account for CPE specifications of affected versions
#
# List all CVSS scores for all the vulnerabilities (CVEs) for a given product (CPE).
#
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX asset: <http://w3id.org/sepses/vocab/bgk/assetKnowledge#>
PREFIX cve: <http://w3id.org/sepses/vocab/ref/cve#>
PREFIX cpe: <http://w3id.org/sepses/vocab/ref/cpe#>
PREFIX cvss: <http://w3id.org/sepses/vocab/ref/cvss#>
PREFIX cwe: <http://w3id.org/sepses/vocab/ref/cwe#>
SELECT ?cveId ?confImpact ?integrImpact ?availImpact ?cvssScore
WHERE {
?cve cve:hasCPE <http://w3id.org/sepses/resource/cpe/cpeoapplemac_os_x10.14.1> .
?cve cve:id ?cveId.
?cve cve:hasCVSS2BaseMetric ?cvss2.
?cvss2 cvss:confidentialityImpact ?confImpact.
?cvss2 cvss:integrityImpact ?integrImpact.
?cvss2 cvss:availabilityImpact ?availImpact.
?cvss2 cvss:baseScore ?cvssScore.
}
#
# Look into information on underlying weaknesses (CWE)
#
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX asset: <http://w3id.org/sepses/vocab/bgk/assetKnowledge#>
PREFIX cve: <http://w3id.org/sepses/vocab/ref/cve#>
PREFIX cpe: <http://w3id.org/sepses/vocab/ref/cpe#>
PREFIX cvss: <http://w3id.org/sepses/vocab/ref/cvss#>
PREFIX cwe: <http://w3id.org/sepses/vocab/ref/cwe#>
SELECT ?cveId ?cwe
WHERE {
?cve cve:hasCPE <http://w3id.org/sepses/resource/cpe/cpeoapplemac_os_x10.14.1> .
?cve cve:id ?cveId.
?cve cve:hasCWE ?cwe.
}
# need to uncheck "Strict checking of void variables" for the following to work
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX asset: <http://w3id.org/sepses/vocab/bgk/assetKnowledge#>
PREFIX cve: <http://w3id.org/sepses/vocab/ref/cve#>
PREFIX cpe: <http://w3id.org/sepses/vocab/ref/cpe#>
PREFIX cvss: <http://w3id.org/sepses/vocab/ref/cvss#>
PREFIX cwe: <http://w3id.org/sepses/vocab/ref/cwe#>
PREFIX dct: <http://purl.org/dc/terms/>
SELECT ?name ?status ?description
WHERE {
BIND(IRI("http://w3id.org/sepses/resource/cwe/CWE-125") AS ?cwe).
?cwe dct:description ?description.
?cwe cwe:name ?name.
?cwe cwe:status ?status.
?cwe dct:description ?description.
}
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX asset: <http://w3id.org/sepses/vocab/bgk/assetKnowledge#>
PREFIX cve: <http://w3id.org/sepses/vocab/ref/cve#>
PREFIX cpe: <http://w3id.org/sepses/vocab/ref/cpe#>
PREFIX cvss: <http://w3id.org/sepses/vocab/ref/cvss#>
PREFIX cwe: <http://w3id.org/sepses/vocab/ref/cwe#>
#
# Putting it all together..
#
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX asset: <http://w3id.org/sepses/vocab/bgk/assetKnowledge#>
PREFIX cve: <http://w3id.org/sepses/vocab/ref/cve#>
PREFIX cpe: <http://w3id.org/sepses/vocab/ref/cpe#>
PREFIX cvss: <http://w3id.org/sepses/vocab/ref/cvss#>
PREFIX cwe: <http://w3id.org/sepses/vocab/ref/cwe#>
SELECT DISTINCT ?cveId ?confImpact ?cvssScore ?commonConsequence ?consequenceImpact ?capec
WHERE {
?cve cve:hasCPE <http://w3id.org/sepses/resource/cpe/cpeoapplemac_os_x10.14.1> .
?cve cve:id ?cveId.
?cve cve:hasCVSS2BaseMetric ?cvss2.
?cvss2 cvss:confidentialityImpact ?confImpact.
?cvss2 cvss:baseScore ?cvssScore.
?cve cve:hasCWE ?cwe.
?cwe cwe:hasCommonConsequence ?commonConsequence.
?cwe cwe:hasCAPEC ?capec.
?commonConsequence cwe:consequenceImpact ?consequenceImpact
} ORDER BY (?cveId)
#
# What mitigations are available (via CWE -> CAPEC)
#
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX asset: <http://w3id.org/sepses/vocab/bgk/assetKnowledge#>
PREFIX cve: <http://w3id.org/sepses/vocab/ref/cve#>
PREFIX cpe: <http://w3id.org/sepses/vocab/ref/cpe#>
PREFIX cvss: <http://w3id.org/sepses/vocab/ref/cvss#>
PREFIX cwe: <http://w3id.org/sepses/vocab/ref/cwe#>
PREFIX capec: <http://w3id.org/sepses/vocab/ref/capec#>
SELECT DISTINCT ?cveId ?cweName ?capecName ?mitigation
WHERE {
?cve cve:hasCPE <http://w3id.org/sepses/resource/cpe/cpeoapplemac_os_x10.14.1> .
?cve cve:id ?cveId.
?cve cve:hasCWE ?cwe.
?cwe cwe:name ?cweName.
?cwe cwe:hasCAPEC ?capec.
?capec capec:name ?capecName.
?capec capec:mitigation ?mitigation .
} ORDER BY (?cveId)