Skip to content

Commit e48e797

Browse files
authored
Merge pull request #306 from theobarrague/main
Ajout des relations opposées dans relationships/definition.json
2 parents 4e011f2 + 1bf9f93 commit e48e797

4 files changed

Lines changed: 74 additions & 27 deletions

File tree

relationships/definition.json

Lines changed: 53 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -43,15 +43,17 @@
4343
"misp",
4444
"stix-1.1"
4545
],
46-
"name": "connected-to"
46+
"name": "connected-to",
47+
"opposite": "connected-from"
4748
},
4849
{
4950
"description": "The referenced source is connected from the target object.",
5051
"format": [
5152
"misp",
5253
"stix-1.1"
5354
],
54-
"name": "connected-from"
55+
"name": "connected-from",
56+
"opposite": "connected-to"
5557
},
5658
{
5759
"description": "The referenced source is containing the target object.",
@@ -60,15 +62,17 @@
6062
"stix-1.1",
6163
"alfred"
6264
],
63-
"name": "contains"
65+
"name": "contains",
66+
"opposite": "contained-by"
6467
},
6568
{
6669
"description": "The referenced source is contained by the target object.",
6770
"format": [
6871
"misp",
6972
"stix-1.1"
7073
],
71-
"name": "contained-by"
74+
"name": "contained-by",
75+
"opposite": "contains"
7276
},
7377
{
7478
"description": "The referenced source is contained within the target object.",
@@ -84,31 +88,35 @@
8488
"misp",
8589
"stix-1.1"
8690
],
87-
"name": "characterized-by"
91+
"name": "characterized-by",
92+
"opposite": "characterizes"
8893
},
8994
{
9095
"description": "The referenced source is characterizing the target object.",
9196
"format": [
9297
"misp",
9398
"stix-1.1"
9499
],
95-
"name": "characterizes"
100+
"name": "characterizes",
101+
"opposite": "characterized-by"
96102
},
97103
{
98104
"description": "The referenced source has queried the target object.",
99105
"format": [
100106
"misp",
101107
"stix-1.1"
102108
],
103-
"name": "properties-queried"
109+
"name": "properties-queried",
110+
"opposite": "properties-queried-by"
104111
},
105112
{
106113
"description": "The referenced source is queried by the target object.",
107114
"format": [
108115
"misp",
109116
"stix-1.1"
110117
],
111-
"name": "properties-queried-by"
118+
"name": "properties-queried-by",
119+
"opposite": "properties-queried"
112120
},
113121
{
114122
"description": "The referenced source is extracted from the target object.",
@@ -124,15 +132,17 @@
124132
"misp",
125133
"stix-1.1"
126134
],
127-
"name": "supra-domain-of"
135+
"name": "supra-domain-of",
136+
"opposite": "sub-domain-of"
128137
},
129138
{
130139
"description": "The referenced source is a sub domain of the target object.",
131140
"format": [
132141
"misp",
133142
"stix-1.1"
134143
],
135-
"name": "sub-domain-of"
144+
"name": "sub-domain-of",
145+
"opposite": "supra-domain-of"
136146
},
137147
{
138148
"description": "The referenced source has dropped the target object.",
@@ -156,15 +166,17 @@
156166
"misp",
157167
"stix-1.1"
158168
],
159-
"name": "downloaded"
169+
"name": "downloaded",
170+
"opposite": "downloaded-from"
160171
},
161172
{
162173
"description": "The referenced source has been downloaded from the target object.",
163174
"format": [
164175
"misp",
165176
"stix-1.1"
166177
],
167-
"name": "downloaded-from"
178+
"name": "downloaded-from",
179+
"opposite": "downloaded"
168180
},
169181
{
170182
"description": "The referenced source is resolved to the target object.",
@@ -197,7 +209,8 @@
197209
"stix-2.0",
198210
"alfred"
199211
],
200-
"name": "uses"
212+
"name": "uses",
213+
"opposite": "used-by"
201214
},
202215
{
203216
"description": "This relationship describes that the source object indicates the target object.",
@@ -251,14 +264,16 @@
251264
"format": [
252265
"misp"
253266
],
254-
"name": "authored-by"
267+
"name": "authored-by",
268+
"opposite": "is-author-of"
255269
},
256270
{
257271
"description": "This relationship describes an object being author by someone.",
258272
"format": [
259273
"misp"
260274
],
261-
"name": "is-author-of"
275+
"name": "is-author-of",
276+
"opposite": "authored-by"
262277
},
263278
{
264279
"description": "This relationship describes the location (of any type) of a specific object.",
@@ -272,14 +287,16 @@
272287
"format": [
273288
"misp"
274289
],
275-
"name": "included-in"
290+
"name": "included-in",
291+
"opposite": "includes"
276292
},
277293
{
278294
"description": "This relationship describes an object that includes an other object.",
279295
"format": [
280296
"misp"
281297
],
282-
"name": "includes"
298+
"name": "includes",
299+
"opposite": "included-in"
283300
},
284301
{
285302
"description": "This relationship describes an object analysed by another object.",
@@ -382,14 +399,16 @@
382399
"format": [
383400
"misp"
384401
],
385-
"name": "followed-by"
402+
"name": "followed-by",
403+
"opposite": "preceding-by"
386404
},
387405
{
388406
"description": "This relationship describes an object which is preceded by another object. This can be used when a time reference is missing but a sequence is known.",
389407
"format": [
390408
"misp"
391409
],
392-
"name": "preceding-by"
410+
"name": "preceding-by",
411+
"opposite": "followed-by"
393412
},
394413
{
395414
"description": "This relationship describes an object which triggers another object.",
@@ -438,7 +457,8 @@
438457
"format": [
439458
"cert-eu"
440459
],
441-
"name": "used-by"
460+
"name": "used-by",
461+
"opposite": "uses"
442462
},
443463
{
444464
"description": "This relationship describes an object which is affiliated with another object.",
@@ -741,14 +761,16 @@
741761
"format": [
742762
"alfred"
743763
],
744-
"name": "downloads"
764+
"name": "downloads",
765+
"opposite": "downloads-from"
745766
},
746767
{
747768
"description": "Represents the semantic link of malware being downloaded from a location.",
748769
"format": [
749770
"alfred"
750771
],
751-
"name": "downloads-from"
772+
"name": "downloads-from",
773+
"opposite": "downloads"
752774
},
753775
{
754776
"description": "Represents the semantic link of an alert generated from a signature.",
@@ -840,14 +862,16 @@
840862
"format": [
841863
"alfred"
842864
],
843-
"name": "registered"
865+
"name": "registered",
866+
"opposite": "registered-to"
844867
},
845868
{
846869
"description": "Represents the semantic link of something being registered to.",
847870
"format": [
848871
"alfred"
849872
],
850-
"name": "registered-to"
873+
"name": "registered-to",
874+
"opposite": "registered"
851875
},
852876
{
853877
"description": "Represents the semantic link between HBS Comms and communication addresses.",
@@ -1107,14 +1131,16 @@
11071131
"format": [
11081132
"misp"
11091133
],
1110-
"name": "leaks"
1134+
"name": "leaks",
1135+
"opposite": "leaked-by"
11111136
},
11121137
{
11131138
"description": "leaked-by",
11141139
"format": [
11151140
"misp"
11161141
],
1117-
"name": "leaked-by"
1142+
"name": "leaked-by",
1143+
"opposite": "leaks"
11181144
},
11191145
{
11201146
"description": "doxed-by",
@@ -1125,4 +1151,4 @@
11251151
}
11261152
],
11271153
"version": 22
1128-
}
1154+
}

schema_relationships.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@
1919
"items": {
2020
"type": "string"
2121
}
22+
},
23+
"opposite": {
24+
"type": "string"
2225
}
2326
},
2427
"required": [

tools/validate_opposites.sh

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#!/bin/bash
2+
3+
opposites=$(cat relationships/definition.json | grep '"opposite"' | cut -d ':' -f 2 | tr -d ' ' | tr -d '"')
4+
5+
for opposite in $opposites
6+
do
7+
cat relationships/definition.json | grep '"name": "'$opposite'"' >/dev/null 2>&1
8+
res=$?
9+
if [ "$res" -eq 1 ]
10+
then
11+
echo "'$opposite' not found"
12+
exit 1
13+
fi
14+
done
15+
16+
echo "OK, all opposites seem to point to existing relationships"
17+
exit 0

validate_all.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ do
3131
done
3232

3333
jsonschema -i relationships/definition.json schema_relationships.json
34+
./tools/validate_opposites.sh
3435

3536
./unique_uuid.py
3637

0 commit comments

Comments
 (0)