Skip to content

Commit 380275b

Browse files
invisig0thCisphyx
andauthored
Visi model 20250331 (#4216)
Co-authored-by: Cisphyx <[email protected]>
1 parent ce4c7be commit 380275b

7 files changed

+40
-2
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
desc: Added ``it:network:dns:resolvers`` to track DNS resolvers for a network.
3+
prs: []
4+
type: model
5+
...
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
desc: Added ``tel:mob:tadig`` and ``tel:mob:carrier:tadig`` to track GSM carrier TADIG codes.
3+
prs: []
4+
type: model
5+
...

synapse/models/inet.py

+9-1
Original file line numberDiff line numberDiff line change
@@ -108,12 +108,20 @@ def postTypeInit(self):
108108
s_types.Str.postTypeInit(self)
109109
self.setNormFunc(str, self._normPyStr)
110110

111+
self.defport = self.opts.get('defport', None)
112+
self.defproto = self.opts.get('defproto', 'tcp')
113+
111114
def _getPort(self, valu):
115+
112116
parts = valu.split(':', 1)
113117
if len(parts) == 2:
114118
valu, port = parts
115119
port = self.modl.type('inet:port').norm(port)[0]
116120
return valu, port, f':{port}'
121+
122+
if self.defport:
123+
return valu, self.defport, f':{self.defport}'
124+
117125
return valu, None, ''
118126

119127
def _normPyStr(self, valu):
@@ -123,7 +131,7 @@ def _normPyStr(self, valu):
123131
# no protos use case sensitivity yet...
124132
valu = valu.lower()
125133

126-
proto = 'tcp'
134+
proto = self.defproto
127135
parts = valu.split('://', 1)
128136
if len(parts) == 2:
129137
proto, valu = parts

synapse/models/infotech.py

+5
Original file line numberDiff line numberDiff line change
@@ -1296,6 +1296,11 @@ def getModelDefs(self):
12961296
('net6', ('inet:net6', {}), {
12971297
'doc': 'The optional contiguous IPv6 address range of this network.'}),
12981298

1299+
('dns:resolvers', ('array', {'type': 'inet:server',
1300+
'typeopts': {'defport': 53, 'defproto': 'udp'},
1301+
'sorted': True, 'uniq': True}), {
1302+
'doc': 'An array of DNS servers configured to resolve requests for hosts on the network.'})
1303+
12991304
)),
13001305
('it:account', {}, (
13011306
('user', ('inet:user', {}), {

synapse/models/telco.py

+10
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,11 @@ def getModelDefs(self):
193193
'doc': 'A mobile cell site which a phone may connect to.'
194194
}),
195195

196+
# TODO - eventually break out ISO-3 country code into a sub
197+
# https://en.wikipedia.org/wiki/TADIG_code
198+
('tel:mob:tadig', ('str', {'regex': '^[A-Z0-9]{5}$', 'strip': True}), {
199+
'doc': 'A Transferred Account Data Interchange Group number issued to a GSM carrier.'}),
200+
196201
),
197202

198203
'forms': (
@@ -322,6 +327,9 @@ def getModelDefs(self):
322327
('loc', ('loc', {}), {
323328
'doc': 'Location the carrier operates from.'
324329
}),
330+
331+
('tadig', ('tel:mob:tadig', {}), {
332+
'doc': 'The TADIG code issued to the carrier.'}),
325333
)),
326334
('tel:mob:cell', {}, (
327335
('carrier', ('tel:mob:carrier', {}), {'doc': 'Mobile carrier.', 'ro': True, }),
@@ -340,6 +348,8 @@ def getModelDefs(self):
340348
'doc': 'The place associated with the latlong property.'}),
341349
)),
342350

351+
('tel:mob:tadig', {}, ()),
352+
343353
('tel:mob:telem', {}, (
344354

345355
('time', ('time', {}), {}),

synapse/tests/test_model_infotech.py

+2
Original file line numberDiff line numberDiff line change
@@ -398,6 +398,7 @@ async def test_infotech_basics(self):
398398
:net6="fe80::0/64"
399399
:org={ gen.ou.org "Vertex Project" }
400400
:type=virtual.sdn
401+
:dns:resolvers=(1.2.3.4, tcp://1.2.3.4:99)
401402
]
402403
'''
403404
nodes = await core.nodes(q)
@@ -408,6 +409,7 @@ async def test_infotech_basics(self):
408409
self.eq(nodes[0].get('net4'), (167837696, 167903231))
409410
self.eq(nodes[0].get('net6'), ('fe80::', 'fe80::ffff:ffff:ffff:ffff'))
410411
self.eq(nodes[0].get('type'), 'virtual.sdn.')
412+
self.eq(nodes[0].get('dns:resolvers'), ('tcp://1.2.3.4:99', 'udp://1.2.3.4:53'))
411413

412414
nodes = await core.nodes('''[
413415
it:sec:stix:indicator=*

synapse/tests/test_model_telco.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -56,14 +56,17 @@ async def test_telco_simple(self):
5656
self.eq(node.ndef, ('tel:mob:mcc', '611'))
5757
self.eq(node.get('loc'), 'gn')
5858

59-
nodes = await core.nodes('[(tel:mob:carrier=(001, 02) :org=$org :loc=us)]', opts={'vars': {'org': oguid}})
59+
nodes = await core.nodes('[(tel:mob:carrier=(001, 02) :org=$org :loc=us :tadig=USAVX )]', opts={'vars': {'org': oguid}})
6060
self.len(1, nodes)
6161
node = nodes[0]
6262
self.eq(node.ndef, ('tel:mob:carrier', ('001', '02')))
6363
self.eq(node.get('mcc'), '001')
6464
self.eq(node.get('mnc'), '02')
6565
self.eq(node.get('org'), oguid)
6666
self.eq(node.get('loc'), 'us')
67+
self.eq(node.get('tadig'), 'USAVX')
68+
69+
self.len(1, await core.nodes('tel:mob:carrier -> tel:mob:tadig'))
6770

6871
q = '[(tel:mob:cell=((001, 02), 3, 4) :radio="Pirate " :place=$place :loc=us.ca.la :latlong=(0, 0))]'
6972
nodes = await core.nodes(q, opts={'vars': {'place': place}})

0 commit comments

Comments
 (0)