Skip to content

Commit e70ee17

Browse files
committed
Add taxonomies for more types (SYN-4338)
1 parent 3e11740 commit e70ee17

14 files changed

+79
-27
lines changed

synapse/models/economic.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,10 @@ def getModelDefs(self):
6363
('econ:fin:exchange', ('guid', {}), {
6464
'doc': 'A financial exchange where securities are traded.'}),
6565

66+
('econ:fin:security:type:taxonomy', ('taxonomy', {}), {
67+
'interfaces': ('meta:taxonomy',),
68+
'doc': 'A hierarchical taxonomy of financial security types.'}),
69+
6670
('econ:fin:security', ('guid', {}), {
6771
'doc': 'A financial security which is typically traded on an exchange.'}),
6872

@@ -73,6 +77,7 @@ def getModelDefs(self):
7377
'doc': 'A sample of the price of a security at a single moment in time'}),
7478

7579
('econ:bank:account:type:taxonomy', ('taxonomy', {}), {
80+
'interfaces': ('meta:taxonomy',),
7681
'doc': 'A bank account type taxonomy.'}),
7782

7883
('econ:bank:account', ('guid', {}), {
@@ -350,6 +355,7 @@ def getModelDefs(self):
350355
'ex': 'usd'}),
351356
)),
352357

358+
('econ:fin:security:type:taxonomy', {}, ()),
353359
('econ:fin:security', {}, (
354360

355361
('exchange', ('econ:fin:exchange', {}), {
@@ -358,8 +364,8 @@ def getModelDefs(self):
358364
('ticker', ('str', {'lower': True, 'strip': True}), {
359365
'doc': 'The identifier for this security within the exchange'}),
360366

361-
('type', ('str', {'lower': True, 'strip': True}), {
362-
'doc': 'A user defined type such as stock, bond, option, future, or forex'}),
367+
('type', ('econ:fin:security:type:taxonomy', {}), {
368+
'doc': 'The type of security.'}),
363369

364370
('price', ('econ:price', {}), {
365371
'doc': 'The last known/available price of the security'}),

synapse/models/inet.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1260,6 +1260,10 @@ def getModelDefs(self):
12601260
'interfaces': ('inet:proto:request',),
12611261
'doc': 'A single HTTP request.'}),
12621262

1263+
('inet:iface:type:taxonomy', ('taxonomy', {}), {
1264+
'interfaces': ('meta:taxonomy',),
1265+
'doc': 'A hierarchical taxonomy of network interface types.'}),
1266+
12631267
('inet:iface', ('guid', {}), {
12641268
'doc': 'A network interface with a set of associated protocol addresses.'
12651269
}),
@@ -2117,6 +2121,7 @@ def getModelDefs(self):
21172121
'doc': 'An array of cookies used to identify this specific session.'}),
21182122
)),
21192123

2124+
('inet:iface:type:taxonomy', {}, ()),
21202125
('inet:iface', {}, (
21212126
('host', ('it:host', {}), {
21222127
'doc': 'The guid of the host the interface is associated with.'}),
@@ -2128,8 +2133,8 @@ def getModelDefs(self):
21282133
('network', ('it:network', {}), {
21292134
'doc': 'The guid of the it:network the interface connected to.'
21302135
}),
2131-
('type', ('str', {'lower': True}), {
2132-
'doc': 'The free-form interface type.'
2136+
('type', ('inet:iface:type:taxonomy', {}), {
2137+
'doc': 'The interface type.'
21332138
}),
21342139
('mac', ('inet:mac', {}), {
21352140
'doc': 'The ethernet (MAC) address of the interface.'

synapse/models/orgs.py

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -160,9 +160,14 @@ def getModelDefs(self):
160160
'deprecated': True,
161161
'doc': 'Deprecated. Please use ou:attendee.',
162162
}),
163+
164+
('ou:contest:type:taxonomy', ('taxonomy', {}), {
165+
'interfaces': ('meta:taxonomy',),
166+
'doc': 'A hierarchical taxonomy of contest types.'}),
167+
163168
('ou:contest', ('guid', {}), {
164-
'doc': 'A competitive event resulting in a ranked set of participants.',
165-
}),
169+
'doc': 'A competitive event resulting in a ranked set of participants.'}),
170+
166171
('ou:contest:result', ('comp', {'fields': (('contest', 'ou:contest'), ('participant', 'ps:contact'))}), {
167172
'doc': 'The results from a single contest participant.',
168173
}),
@@ -235,12 +240,17 @@ def getModelDefs(self):
235240
('ou:id:update', ('guid', {}), {
236241
'doc': 'A status update to an org:id:number.',
237242
}),
243+
244+
('ou:award:type:taxonomy', ('taxonomy', {}), {
245+
'interfaces': ('meta:taxonomy',),
246+
'doc': 'A hierarchical taxonomy of award types.'}),
247+
238248
('ou:award', ('guid', {}), {
239-
'doc': 'An award issued by an organization.',
240-
}),
249+
'doc': 'An award issued by an organization.'}),
250+
241251
('ou:vitals', ('guid', {}), {
242-
'doc': 'Vital statistics about an org for a given time period.',
243-
}),
252+
'doc': 'Vital statistics about an org for a given time period.'}),
253+
244254
('ou:opening', ('guid', {}), {
245255
'doc': 'A job/work opening within an org.'}),
246256

@@ -462,12 +472,13 @@ def getModelDefs(self):
462472
'doc': 'The change in population over last period.',
463473
}),
464474
)),
475+
('ou:award:type:taxonomy', {}, ()),
465476
('ou:award', {}, (
466477
('name', ('str', {'lower': True, 'onespace': True}), {
467478
'doc': 'The name of the award.',
468479
'ex': 'Bachelors of Science',
469480
}),
470-
('type', ('str', {'lower': True, 'onespace': True}), {
481+
('type', ('ou:award:type:taxonomy', {}), {
471482
'doc': 'The type of award.',
472483
'ex': 'certification',
473484
}),
@@ -1267,14 +1278,15 @@ def getModelDefs(self):
12671278
'doc': 'List of the roles the person had at the conference event.',
12681279
}),
12691280
)),
1281+
('ou:contest:type:taxonomy', {}, ()),
12701282
('ou:contest', {}, (
12711283
('name', ('str', {'lower': True, 'onespace': True}), {
12721284
'doc': 'The name of the contest.',
12731285
'ex': 'defcon ctf 2020',
12741286
}),
1275-
('type', ('str', {'lower': True, 'onespace': True}), {
1287+
('type', ('ou:contest:type:taxonomy', {}), {
12761288
'doc': 'The type of contest.',
1277-
'ex': 'cyber ctf',
1289+
'ex': 'cyber.ctf',
12781290
}),
12791291
('family', ('str', {'lower': True, 'onespace': True}), {
12801292
'doc': 'A name for a series of recurring contests.',

synapse/models/proj.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,13 +86,18 @@ def getModelDefs(self):
8686
('proj:epic', ('guid', {}), {
8787
'doc': 'A collection of tickets related to a topic.'}),
8888

89+
('proj:ticket:type:taxonomy', ('taxonomy', {}), {
90+
'interfaces': ('meta:taxonomy',),
91+
'doc': 'A hierarchical taxonomy of project ticket types.'}),
92+
8993
('proj:ticket', ('guid', {}), {
9094
'interfaces': ('proj:task',),
9195
'template': {
9296
'task': 'ticket'},
9397
'doc': 'A ticket in a ticketing system.'}),
9498

9599
('proj:project:type:taxonomy', ('taxonomy', {}), {
100+
'interfaces': ('meta:taxonomy',),
96101
'doc': 'A type taxonomy for projects.'}),
97102

98103
('proj:sprint', ('guid', {}), {
@@ -216,6 +221,7 @@ def getModelDefs(self):
216221
'doc': 'The comment the attachment was added to.'}),
217222
)),
218223

224+
('proj:ticket:type:taxonomy', {}, {}),
219225
('proj:ticket', {}, (
220226

221227
('ext:id', ('str', {'strip': True}), {
@@ -243,8 +249,9 @@ def getModelDefs(self):
243249
('sprint', ('proj:sprint', {}), {
244250
'doc': 'The sprint that contains the ticket.'}),
245251

246-
('type', ('str', {'lower': True, 'strip': True}), {
247-
'doc': 'The type of ticket. (eg story / bug)'}),
252+
('type', ('proj:ticket:type:taxonomy', {}), {
253+
'doc': 'The type of ticket.',
254+
'ex': 'bug'}),
248255
)),
249256
),
250257
}),

synapse/models/science.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,14 @@ def getModelDefs(self):
66
return (('sci', {
77
'types': (
88
('sci:hypothesis:type:taxonomy', ('taxonomy', {}), {
9+
'interfaces': ('meta:taxonomy',),
910
'doc': 'A taxonomy of hypothesis types.'}),
1011
('sci:hypothesis', ('guid', {}), {
1112
'doc': 'A hypothesis or theory.'}),
1213

1314
# TODO link experiment to eventual procedure node
1415
('sci:experiment:type:taxonomy', ('taxonomy', {}), {
16+
'interfaces': ('meta:taxonomy',),
1517
'doc': 'A taxonomy of experiment types.'}),
1618
('sci:experiment', ('guid', {}), {
1719
'doc': 'An instance of running an experiment.'}),

synapse/models/telco.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,10 @@ def getModelDefs(self):
183183
'doc': 'The fusion of a MCC/MNC.'
184184
}),
185185

186+
('tel:mob:cell:radio:type:taxonomy', ('taxonomy', {}), {
187+
'interfaces': ('meta:taxonomy',),
188+
'doc': 'A hierarchical taxonomy of cell radio types.'}),
189+
186190
('tel:mob:cell', ('comp', {'fields': (('carrier', 'tel:mob:carrier'),
187191
('lac', ('int', {})),
188192
('cid', ('int', {})))}), {
@@ -312,14 +316,15 @@ def getModelDefs(self):
312316
'doc': 'Location the carrier operates from.'
313317
}),
314318
)),
319+
('tel:mob:cell:radio:type:taxonomy', {}, ()),
315320
('tel:mob:cell', {}, (
316321
('carrier', ('tel:mob:carrier', {}), {'doc': 'Mobile carrier.', 'ro': True, }),
317322
('carrier:mcc', ('tel:mob:mcc', {}), {'doc': 'Mobile Country Code.', 'ro': True, }),
318323
('carrier:mnc', ('tel:mob:mnc', {}), {'doc': 'Mobile Network Code.', 'ro': True, }),
319324
('lac', ('int', {}), {'doc': 'Location Area Code. LTE networks may call this a TAC.',
320325
'ro': True, }),
321326
('cid', ('int', {}), {'doc': 'The Cell ID.', 'ro': True, }),
322-
('radio', ('str', {'lower': 1, 'onespace': 1}), {'doc': 'Cell radio type.'}),
327+
('radio', ('tel:mob:cell:radio:type:taxonomy', {}), {'doc': 'Cell radio type.'}),
323328
('latlong', ('geo:latlong', {}), {'doc': 'Last known location of the cell site.'}),
324329

325330
('loc', ('loc', {}), {

synapse/models/transport.py

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,17 @@ def getModelDefs(self):
1717
('transport:land:license', ('guid', {}), {
1818
'doc': 'A license to operate a land vehicle issued to a contact.'}),
1919

20+
('transport:air:craft:type:taxonomy', ('taxonomy', {}), {
21+
'interfaces': ('meta:taxonomy',),
22+
'doc': 'A hierarchical taxonomy of aircraft types.'}),
23+
2024
('transport:air:craft', ('guid', {}), {
2125
'doc': 'An individual aircraft.'}),
2226

27+
('transport:air:tailnum:type:taxonomy', ('taxonomy', {}), {
28+
'interfaces': ('meta:taxonomy',),
29+
'doc': 'A hierarchical taxonomy of aircraft registration number types.'}),
30+
2331
('transport:air:tailnum', ('str', {'lower': True, 'strip': True, 'regex': '^[a-z0-9-]{2,}$'}), {
2432
'doc': 'An aircraft registration number or military aircraft serial number.',
2533
'ex': 'ff023'}),
@@ -34,6 +42,10 @@ def getModelDefs(self):
3442
('transport:air:flight', ('guid', {}), {
3543
'doc': 'An individual instance of a flight.'}),
3644

45+
('transport:air:occupant:type:taxonomy', ('taxonomy', {}), {
46+
'interfaces': ('meta:taxonomy',),
47+
'doc': 'A hierarchical taxonomy of aircraft occupant types.'}),
48+
3749
('transport:air:occupant', ('guid', {}), {
3850
'doc': 'An occupant of a specific flight.'}),
3951

@@ -104,10 +116,11 @@ def getModelDefs(self):
104116
('owner', ('ps:contact', {}), {
105117
'doc': 'The contact info of the owner of the vehicle.'}),
106118
)),
119+
('transport:air:craft:type:taxonomy', {}, ()),
107120
('transport:air:craft', {}, (
108121
('tailnum', ('transport:air:tailnum', {}), {
109122
'doc': 'The aircraft tail number.'}),
110-
('type', ('str', {'lower': True, 'strip': True}), {
123+
('type', ('transport:air:craft:type:taxonomy', {}), {
111124
'doc': 'The type of aircraft.'}),
112125
('built', ('time', {}), {
113126
'doc': 'The date the aircraft was constructed.'}),
@@ -126,10 +139,11 @@ def getModelDefs(self):
126139
('place', ('geo:place', {}), {
127140
'doc': 'The place where the IATA airport code is assigned.'}),
128141
)),
142+
('transport:air:tailnum:type:taxonomy', {}, ()),
129143
('transport:air:tailnum', {}, (
130144
('loc', ('loc', {}), {
131145
'doc': 'The geopolitical location that the tailnumber is allocated to.'}),
132-
('type', ('str', {'lower': True, 'strip': True}), {
146+
('type', ('transport:air:tailnum:type:taxonomy', {}), {
133147
'doc': 'A type which may be specific to the country prefix.'}),
134148
)),
135149
('transport:air:flightnum', {}, (
@@ -196,8 +210,9 @@ def getModelDefs(self):
196210
('time', ('time', {}), {
197211
'doc': 'The time the telemetry sample was taken.'})
198212
)),
213+
('transport:air:occupant:type:taxonomy', {}, ()),
199214
('transport:air:occupant', {}, (
200-
('type', ('str', {'lower': True}), {
215+
('type', ('transport:air:occupant:type:taxonomy', {}), {
201216
'doc': 'The type of occupant such as pilot, crew or passenger.'}),
202217
('flight', ('transport:air:flight', {}), {
203218
'doc': 'The flight that the occupant was aboard.'}),

synapse/tests/test_model_economic.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ async def test_model_econ(self):
176176

177177
self.len(1, nodes)
178178
self.eq('947183947f2e2c7bdc55264c20670f19', nodes[0].ndef[1])
179-
self.eq('stock', nodes[0].get('type'))
179+
self.eq('stock.', nodes[0].get('type'))
180180
self.eq('nasdaq/tsla', nodes[0].get('ticker'))
181181
self.eq('9999', nodes[0].get('price'))
182182
self.eq(1580515200000, nodes[0].get('time'))

synapse/tests/test_model_inet.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -848,7 +848,7 @@ async def test_iface(self):
848848
self.eq(node.ndef, ('inet:iface', valu))
849849
self.eq(node.get('host'), host)
850850
self.eq(node.get('network'), netw)
851-
self.eq(node.get('type'), 'cool')
851+
self.eq(node.get('type'), 'cool.')
852852
self.eq(node.get('mac'), 'ff:00:ff:00:ff:00')
853853
self.eq(node.get('ip'), (4, 0x01020304))
854854
self.eq(node.get('phone'), '12345678910')

synapse/tests/test_model_orgs.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -581,7 +581,7 @@ async def test_ou_simple(self):
581581
nodes = await core.nodes(f'''[
582582
ou:contest={cont}
583583
:name="defcon ctf 2020"
584-
:type="cyber ctf"
584+
:type=cyber.ctf
585585
:family="defcon ctf"
586586
:start=20200808
587587
:end=20200811
@@ -600,7 +600,7 @@ async def test_ou_simple(self):
600600
]''')
601601
self.len(1, nodes)
602602
self.eq('defcon ctf 2020', nodes[0].get('name'))
603-
self.eq('cyber ctf', nodes[0].get('type'))
603+
self.eq('cyber.ctf.', nodes[0].get('type'))
604604
self.eq('defcon ctf', nodes[0].get('family'))
605605

606606
self.eq(1596844800000, nodes[0].get('start'))

synapse/tests/test_model_person.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ async def test_ps_simple(self):
220220
''')
221221
self.nn(nodes[0].get('org'))
222222
self.eq('bachelors of science', nodes[0].get('name'))
223-
self.eq('degree', nodes[0].get('type'))
223+
self.eq('degree.', nodes[0].get('type'))
224224

225225
opts = {'vars': {'achv': achv}}
226226
nodes = await core.nodes('''[

synapse/tests/test_model_syn.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,7 @@ async def delExtModelConfigs(cortex):
306306
self.isin('inet:client', pprops)
307307

308308
# Test a cmpr that isn't '='
309-
nodes = await core.nodes('syn:form~="test:type"')
309+
nodes = await core.nodes('syn:form~="^test:type"')
310310
self.len(2, nodes)
311311

312312
# Can't add an edge to a runt node

synapse/tests/test_model_telco.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ async def test_telco_simple(self):
7676
self.eq(node.get('lac'), 3)
7777
self.eq(node.get('cid'), 4)
7878
self.eq(node.get('loc'), 'us.ca.la')
79-
self.eq(node.get('radio'), 'pirate')
79+
self.eq(node.get('radio'), 'pirate.')
8080
self.eq(node.get('latlong'), (0.0, 0.0))
8181
self.eq(node.get('place'), place)
8282
self.len(1, await core.nodes('tel:mob:mcc=001'))

synapse/tests/test_model_transport.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ async def test_model_transport(self):
77
async with self.getTestCore() as core:
88

99
craft = (await core.nodes('[ transport:air:craft=* :tailnum=FF023 :type=helicopter :built=202002 :make=boeing :model=747 :serial=1234 :operator=*]'))[0]
10-
self.eq('helicopter', craft.get('type'))
10+
self.eq('helicopter.', craft.get('type'))
1111
self.eq(1580515200000, craft.get('built'))
1212
self.eq('boeing', craft.get('make'))
1313
self.eq('747', craft.get('model'))

0 commit comments

Comments
 (0)