synapse 2.161.0__py311-none-any.whl → 2.162.0__py311-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of synapse might be problematic. Click here for more details.
- synapse/daemon.py +7 -2
- synapse/lib/cell.py +7 -3
- synapse/lib/layer.py +20 -1
- synapse/lib/rstorm.py +16 -0
- synapse/lib/storm.py +17 -1
- synapse/lib/stormlib/stix.py +6 -3
- synapse/lib/stormtypes.py +148 -19
- synapse/lib/version.py +2 -2
- synapse/lib/view.py +15 -2
- synapse/models/inet.py +9 -0
- synapse/models/infotech.py +28 -26
- synapse/models/orgs.py +3 -0
- synapse/models/proj.py +9 -2
- synapse/models/risk.py +32 -0
- synapse/telepath.py +2 -0
- synapse/tests/files/rstorm/testsvc.py +8 -1
- synapse/tests/files/stormpkg/testpkg.yaml +4 -0
- synapse/tests/test_axon.py +4 -4
- synapse/tests/test_cortex.py +6 -6
- synapse/tests/test_daemon.py +19 -0
- synapse/tests/test_lib_ast.py +16 -16
- synapse/tests/test_lib_grammar.py +4 -4
- synapse/tests/test_lib_rstorm.py +38 -2
- synapse/tests/test_lib_storm.py +14 -14
- synapse/tests/test_lib_stormhttp.py +18 -18
- synapse/tests/test_lib_stormlib_auth.py +3 -3
- synapse/tests/test_lib_stormlib_cell.py +1 -1
- synapse/tests/test_lib_stormlib_cortex.py +50 -2
- synapse/tests/test_lib_stormlib_json.py +2 -2
- synapse/tests/test_lib_stormlib_macro.py +1 -1
- synapse/tests/test_lib_stormlib_modelext.py +37 -37
- synapse/tests/test_lib_stormlib_oauth.py +20 -20
- synapse/tests/test_lib_stormlib_stix.py +3 -1
- synapse/tests/test_lib_stormtypes.py +127 -45
- synapse/tests/test_lib_stormwhois.py +1 -1
- synapse/tests/test_lib_trigger.py +11 -11
- synapse/tests/test_lib_view.py +23 -1
- synapse/tests/test_model_crypto.py +1 -1
- synapse/tests/test_model_inet.py +6 -0
- synapse/tests/test_model_orgs.py +2 -1
- synapse/tests/test_model_proj.py +6 -0
- synapse/tests/test_model_risk.py +10 -0
- synapse/tests/test_tools_storm.py +1 -1
- {synapse-2.161.0.dist-info → synapse-2.162.0.dist-info}/METADATA +3 -1
- {synapse-2.161.0.dist-info → synapse-2.162.0.dist-info}/RECORD +48 -48
- {synapse-2.161.0.dist-info → synapse-2.162.0.dist-info}/LICENSE +0 -0
- {synapse-2.161.0.dist-info → synapse-2.162.0.dist-info}/WHEEL +0 -0
- {synapse-2.161.0.dist-info → synapse-2.162.0.dist-info}/top_level.txt +0 -0
synapse/models/infotech.py
CHANGED
|
@@ -1143,10 +1143,11 @@ class ItModule(s_module.CoreModule):
|
|
|
1143
1143
|
('url', ('inet:url', {}), {
|
|
1144
1144
|
'doc': 'The URL that documents the ATT&CK group.',
|
|
1145
1145
|
}),
|
|
1146
|
+
|
|
1146
1147
|
('tag', ('syn:tag', {}), {
|
|
1147
|
-
'
|
|
1148
|
-
'
|
|
1149
|
-
|
|
1148
|
+
'deprecated': True,
|
|
1149
|
+
'doc': 'Deprecated. Please use a risk:threat:tag.'}),
|
|
1150
|
+
|
|
1150
1151
|
('references', ('array', {'type': 'inet:url', 'uniq': True}), {
|
|
1151
1152
|
'doc': 'An array of URLs that document the ATT&CK group.',
|
|
1152
1153
|
}),
|
|
@@ -1171,12 +1172,12 @@ class ItModule(s_module.CoreModule):
|
|
|
1171
1172
|
'disp': {'hint': 'text'},
|
|
1172
1173
|
}),
|
|
1173
1174
|
('url', ('inet:url', {}), {
|
|
1174
|
-
'doc': 'The URL that documents the ATT&CK tactic.',
|
|
1175
|
-
|
|
1175
|
+
'doc': 'The URL that documents the ATT&CK tactic.'}),
|
|
1176
|
+
|
|
1176
1177
|
('tag', ('syn:tag', {}), {
|
|
1177
|
-
'
|
|
1178
|
-
'
|
|
1179
|
-
|
|
1178
|
+
'deprecated': True,
|
|
1179
|
+
'doc': 'Deprecated.'}),
|
|
1180
|
+
|
|
1180
1181
|
('references', ('array', {'type': 'inet:url', 'uniq': True}), {
|
|
1181
1182
|
'doc': 'An array of URLs that document the ATT&CK tactic.',
|
|
1182
1183
|
}),
|
|
@@ -1199,12 +1200,12 @@ class ItModule(s_module.CoreModule):
|
|
|
1199
1200
|
'disp': {'hint': 'text'},
|
|
1200
1201
|
}),
|
|
1201
1202
|
('url', ('inet:url', {}), {
|
|
1202
|
-
'doc': 'The URL that documents the ATT&CK technique.',
|
|
1203
|
-
|
|
1203
|
+
'doc': 'The URL that documents the ATT&CK technique.'}),
|
|
1204
|
+
|
|
1204
1205
|
('tag', ('syn:tag', {}), {
|
|
1205
|
-
'
|
|
1206
|
-
'
|
|
1207
|
-
|
|
1206
|
+
'deprecated': True,
|
|
1207
|
+
'doc': 'Deprecated. Please use ou:technique:tag.'}),
|
|
1208
|
+
|
|
1208
1209
|
('references', ('array', {'type': 'inet:url', 'uniq': True}), {
|
|
1209
1210
|
'doc': 'An array of URLs that document the ATT&CK technique.',
|
|
1210
1211
|
}),
|
|
@@ -1234,12 +1235,12 @@ class ItModule(s_module.CoreModule):
|
|
|
1234
1235
|
'doc': 'If deprecated, this field may contain the current value for the software.',
|
|
1235
1236
|
}),
|
|
1236
1237
|
('url', ('inet:url', {}), {
|
|
1237
|
-
'doc': 'The URL that documents the ATT&CK software.',
|
|
1238
|
-
|
|
1238
|
+
'doc': 'The URL that documents the ATT&CK software.'}),
|
|
1239
|
+
|
|
1239
1240
|
('tag', ('syn:tag', {}), {
|
|
1240
|
-
'
|
|
1241
|
-
'
|
|
1242
|
-
|
|
1241
|
+
'deprecated': True,
|
|
1242
|
+
'doc': 'Deprecated. Please use risk:tool:software:tag.'}),
|
|
1243
|
+
|
|
1243
1244
|
('references', ('array', {'type': 'inet:url', 'uniq': True}), {
|
|
1244
1245
|
'doc': 'An array of URLs that document the ATT&CK software.',
|
|
1245
1246
|
}),
|
|
@@ -1261,12 +1262,12 @@ class ItModule(s_module.CoreModule):
|
|
|
1261
1262
|
'disp': {'hint': 'text'},
|
|
1262
1263
|
}),
|
|
1263
1264
|
('url', ('inet:url', {}), {
|
|
1264
|
-
'doc': 'The URL that documents the ATT&CK mitigation.',
|
|
1265
|
-
|
|
1265
|
+
'doc': 'The URL that documents the ATT&CK mitigation.'}),
|
|
1266
|
+
|
|
1266
1267
|
('tag', ('syn:tag', {}), {
|
|
1267
|
-
'
|
|
1268
|
-
'
|
|
1269
|
-
|
|
1268
|
+
'deprecated': True,
|
|
1269
|
+
'doc': 'Deprecated. Please use risk:mitigation:tag.'}),
|
|
1270
|
+
|
|
1270
1271
|
('references', ('array', {'type': 'inet:url', 'uniq': True}), {
|
|
1271
1272
|
'doc': 'An array of URLs that document the ATT&CK mitigation.',
|
|
1272
1273
|
}),
|
|
@@ -1314,10 +1315,11 @@ class ItModule(s_module.CoreModule):
|
|
|
1314
1315
|
'doc': 'The time that the campaign was created by Mitre.'}),
|
|
1315
1316
|
('updated', ('time', {}), {
|
|
1316
1317
|
'doc': 'The time that the campaign was last updated by Mitre.'}),
|
|
1318
|
+
|
|
1317
1319
|
('tag', ('syn:tag', {}), {
|
|
1318
|
-
'
|
|
1319
|
-
'
|
|
1320
|
-
|
|
1320
|
+
'deprecated': True,
|
|
1321
|
+
'doc': 'Deprecated. Please use ou:campaign:tag.'}),
|
|
1322
|
+
|
|
1321
1323
|
)),
|
|
1322
1324
|
('it:mitre:attack:flow', {}, (
|
|
1323
1325
|
('name', ('str', {}), {
|
synapse/models/orgs.py
CHANGED
|
@@ -346,6 +346,9 @@ class OuModule(s_module.CoreModule):
|
|
|
346
346
|
('name', ('str', {}), {
|
|
347
347
|
'doc': 'The friendly name of the id number type.',
|
|
348
348
|
}),
|
|
349
|
+
('url', ('inet:url', {}), {
|
|
350
|
+
'doc': 'The official URL of the issuer.',
|
|
351
|
+
}),
|
|
349
352
|
)),
|
|
350
353
|
('ou:id:number', {}, (
|
|
351
354
|
('type', ('ou:id:type', {}), {
|
synapse/models/proj.py
CHANGED
|
@@ -52,8 +52,11 @@ class ProjectModule(s_module.CoreModule):
|
|
|
52
52
|
'doc': 'A collection of tickets related to a topic.',
|
|
53
53
|
}),
|
|
54
54
|
('proj:ticket', ('guid', {}), {
|
|
55
|
-
'doc': 'A ticket in a ticketing system.',
|
|
56
|
-
|
|
55
|
+
'doc': 'A ticket in a ticketing system.'}),
|
|
56
|
+
|
|
57
|
+
('proj:project:type:taxonomy', ('taxonomy', {}), {
|
|
58
|
+
'doc': 'A type taxonomy for projects.'}),
|
|
59
|
+
|
|
57
60
|
('proj:sprint', ('guid', {}), {
|
|
58
61
|
'doc': 'A timeboxed period to complete a set amount of work.',
|
|
59
62
|
}),
|
|
@@ -70,11 +73,15 @@ class ProjectModule(s_module.CoreModule):
|
|
|
70
73
|
|
|
71
74
|
'forms': (
|
|
72
75
|
|
|
76
|
+
('proj:project:type:taxonomy', {}, {}),
|
|
73
77
|
('proj:project', {}, (
|
|
74
78
|
|
|
75
79
|
('name', ('str', {'lower': True, 'onespace': True}), {
|
|
76
80
|
'doc': 'The project name.'}),
|
|
77
81
|
|
|
82
|
+
('type', ('proj:project:type:taxonomy', {}), {
|
|
83
|
+
'doc': 'The project type.'}),
|
|
84
|
+
|
|
78
85
|
('desc', ('str', {}), {
|
|
79
86
|
'disp': {'hint': 'text'},
|
|
80
87
|
'doc': 'The project description.'}),
|
synapse/models/risk.py
CHANGED
|
@@ -23,6 +23,15 @@ class CvssV3(s_types.Str):
|
|
|
23
23
|
mesg = exc.get('mesg')
|
|
24
24
|
raise s_exc.BadTypeValu(name=self.name, valu=text, mesg=mesg) from None
|
|
25
25
|
|
|
26
|
+
alertstatus = (
|
|
27
|
+
(0, 'new'),
|
|
28
|
+
(10, 'enrichment'),
|
|
29
|
+
(20, 'todo'),
|
|
30
|
+
(30, 'analysis'),
|
|
31
|
+
(40, 'remediation'),
|
|
32
|
+
(50, 'done'),
|
|
33
|
+
)
|
|
34
|
+
|
|
26
35
|
class RiskModule(s_module.CoreModule):
|
|
27
36
|
|
|
28
37
|
def getModelDefs(self):
|
|
@@ -281,17 +290,31 @@ class RiskModule(s_module.CoreModule):
|
|
|
281
290
|
|
|
282
291
|
)),
|
|
283
292
|
('risk:mitigation', {}, (
|
|
293
|
+
|
|
284
294
|
('vuln', ('risk:vuln', {}), {
|
|
285
295
|
'doc': 'The vulnerability that this mitigation addresses.'}),
|
|
296
|
+
|
|
286
297
|
('name', ('str', {}), {
|
|
287
298
|
'doc': 'A brief name for this risk mitigation.'}),
|
|
299
|
+
|
|
288
300
|
('desc', ('str', {}), {
|
|
289
301
|
'disp': {'hint': 'text'},
|
|
290
302
|
'doc': 'A description of the mitigation approach for the vulnerability.'}),
|
|
303
|
+
|
|
291
304
|
('software', ('it:prod:softver', {}), {
|
|
292
305
|
'doc': 'A software version which implements a fix for the vulnerability.'}),
|
|
306
|
+
|
|
293
307
|
('hardware', ('it:prod:hardware', {}), {
|
|
294
308
|
'doc': 'A hardware version which implements a fix for the vulnerability.'}),
|
|
309
|
+
|
|
310
|
+
('reporter', ('ou:org', {}), {
|
|
311
|
+
'doc': 'The organization reporting on the mitigation.'}),
|
|
312
|
+
|
|
313
|
+
('reporter:name', ('ou:name', {}), {
|
|
314
|
+
'doc': 'The name of the organization reporting on the mitigation.'}),
|
|
315
|
+
|
|
316
|
+
('tag', ('syn:tag', {}), {
|
|
317
|
+
'doc': 'The tag used to annotate nodes which have the mitigation in place.'}),
|
|
295
318
|
)),
|
|
296
319
|
('risk:vulnname', {}, ()),
|
|
297
320
|
('risk:vuln:type:taxonomy', {}, ()),
|
|
@@ -598,6 +621,9 @@ class RiskModule(s_module.CoreModule):
|
|
|
598
621
|
'disp': {'hint': 'text'},
|
|
599
622
|
'doc': 'A free-form description / overview of the alert.'}),
|
|
600
623
|
|
|
624
|
+
('status', ('int', {'enums': alertstatus}), {
|
|
625
|
+
'doc': 'The status of the alert.'}),
|
|
626
|
+
|
|
601
627
|
('benign', ('bool', {}), {
|
|
602
628
|
'doc': 'Set to true if the alert has been confirmed benign. Set to false if malicious.'}),
|
|
603
629
|
|
|
@@ -611,6 +637,12 @@ class RiskModule(s_module.CoreModule):
|
|
|
611
637
|
'ex': 'benign.false_positive',
|
|
612
638
|
'doc': 'A verdict about why the alert is malicious or benign, as a taxonomy entry.'}),
|
|
613
639
|
|
|
640
|
+
('assignee', ('syn:user', {}), {
|
|
641
|
+
'doc': 'The Synapse user who is assigned to investigate the alert.'}),
|
|
642
|
+
|
|
643
|
+
('ext:assignee', ('ps:contact', {}), {
|
|
644
|
+
'doc': 'The alert assignee contact information from an external system.'}),
|
|
645
|
+
|
|
614
646
|
('engine', ('it:prod:softver', {}), {
|
|
615
647
|
'doc': 'The software that generated the alert.'}),
|
|
616
648
|
|
synapse/telepath.py
CHANGED
|
@@ -598,6 +598,7 @@ class Proxy(s_base.Base):
|
|
|
598
598
|
self.tasks = {}
|
|
599
599
|
self.shares = {}
|
|
600
600
|
|
|
601
|
+
self._ahainfo = {}
|
|
601
602
|
self.sharinfo = {}
|
|
602
603
|
self.methinfo = {}
|
|
603
604
|
|
|
@@ -902,6 +903,7 @@ class Proxy(s_base.Base):
|
|
|
902
903
|
raise s_exc.LinkShutDown(mesg=mesg)
|
|
903
904
|
|
|
904
905
|
self.sess = self.synack[1].get('sess')
|
|
906
|
+
self._ahainfo = self.synack[1].get('ahainfo', {})
|
|
905
907
|
self.sharinfo = self.synack[1].get('sharinfo', {})
|
|
906
908
|
self.methinfo = self.sharinfo.get('meths', {})
|
|
907
909
|
|
|
@@ -8,10 +8,17 @@ class TestsvcApi(s_cell.CellApi, s_stormsvc.StormSvc):
|
|
|
8
8
|
{
|
|
9
9
|
'name': 'testsvc',
|
|
10
10
|
'version': (0, 0, 1),
|
|
11
|
+
'onload': '''
|
|
12
|
+
$lib.time.sleep($lib.globals.get(onload_sleep, 0))
|
|
13
|
+
$lib.globals.set(testsvc, testsvc-done)
|
|
14
|
+
''',
|
|
11
15
|
'commands': (
|
|
12
16
|
{
|
|
13
17
|
'name': 'testsvc.test',
|
|
14
|
-
'storm': '
|
|
18
|
+
'storm': '''
|
|
19
|
+
$lib.print($lib.service.get($cmdconf.svciden).test())
|
|
20
|
+
$lib.print($lib.globals.get(testsvc))
|
|
21
|
+
''',
|
|
15
22
|
},
|
|
16
23
|
)
|
|
17
24
|
},
|
synapse/tests/test_axon.py
CHANGED
|
@@ -985,10 +985,10 @@ bar baz",vv
|
|
|
985
985
|
|
|
986
986
|
q = f'''
|
|
987
987
|
$fields = $lib.list(
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
988
|
+
({{'name':'file', 'sha256':$sha256, 'filename':'file'}}),
|
|
989
|
+
({{'name':'zip_password', 'value':'test'}}),
|
|
990
|
+
({{'name':'dict', 'value':({{'foo':'bar'}}) }}),
|
|
991
|
+
({{'name':'bytes', 'value':$bytes}})
|
|
992
992
|
)
|
|
993
993
|
$resp = $lib.inet.http.post("https://127.0.0.1:{port}/api/v1/pushfile",
|
|
994
994
|
fields=$fields, ssl_verify=(0))
|
synapse/tests/test_cortex.py
CHANGED
|
@@ -4028,7 +4028,7 @@ class CortexBasicTest(s_t_utils.SynTest):
|
|
|
4028
4028
|
self.len(1, nodes)
|
|
4029
4029
|
self.eq('baz', nodes[0].ndef[1])
|
|
4030
4030
|
|
|
4031
|
-
q = '$d =
|
|
4031
|
+
q = '$d = ({"field 1": "foo", "field 2": "bar"}) [test:str=$d.\'field 1\']'
|
|
4032
4032
|
nodes = await core.nodes(q)
|
|
4033
4033
|
self.len(1, nodes)
|
|
4034
4034
|
self.eq('foo', nodes[0].ndef[1])
|
|
@@ -4906,7 +4906,7 @@ class CortexBasicTest(s_t_utils.SynTest):
|
|
|
4906
4906
|
pode = podes[0]
|
|
4907
4907
|
self.true(s_node.tagged(pode, '#foo'))
|
|
4908
4908
|
|
|
4909
|
-
nodes = await core.nodes('$d =
|
|
4909
|
+
nodes = await core.nodes('$d = ({"foo": "bar"}) [test:str=yop +#$d.foo]')
|
|
4910
4910
|
self.len(1, nodes)
|
|
4911
4911
|
self.nn(nodes[0].getTag('bar'))
|
|
4912
4912
|
|
|
@@ -4952,7 +4952,7 @@ class CortexBasicTest(s_t_utils.SynTest):
|
|
|
4952
4952
|
pode = podes[0]
|
|
4953
4953
|
self.true(s_node.tagged(pode, '#timetag'))
|
|
4954
4954
|
|
|
4955
|
-
nodes = await core.nodes('$d =
|
|
4955
|
+
nodes = await core.nodes('$d = ({"foo": ""}) [test:str=yop +?#$d.foo +#tag1]')
|
|
4956
4956
|
self.len(1, nodes)
|
|
4957
4957
|
self.none(nodes[0].getTag('foo.*'))
|
|
4958
4958
|
self.nn(nodes[0].getTag('tag1'))
|
|
@@ -4991,7 +4991,7 @@ class CortexBasicTest(s_t_utils.SynTest):
|
|
|
4991
4991
|
self.eq([n.ndef[0] for n in nodes], [*['test:str', 'inet:ipv4'] * 3])
|
|
4992
4992
|
|
|
4993
4993
|
# non-runsafe iteration over a dictionary
|
|
4994
|
-
q = '''$dict
|
|
4994
|
+
q = '''$dict=({"key1": "valu1", "key2": "valu2"}) [(test:str=test1) (test:str=test2)]
|
|
4995
4995
|
for ($key, $valu) in $dict {
|
|
4996
4996
|
[:hehe=$valu]
|
|
4997
4997
|
}
|
|
@@ -5004,14 +5004,14 @@ class CortexBasicTest(s_t_utils.SynTest):
|
|
|
5004
5004
|
self.eq(node.get('hehe'), 'valu2')
|
|
5005
5005
|
|
|
5006
5006
|
# None values don't yield anything
|
|
5007
|
-
q = '''$foo =
|
|
5007
|
+
q = '''$foo = ({})
|
|
5008
5008
|
for $name in $foo.bar { [ test:str=$name ] }
|
|
5009
5009
|
'''
|
|
5010
5010
|
nodes = await core.nodes(q)
|
|
5011
5011
|
self.len(0, nodes)
|
|
5012
5012
|
|
|
5013
5013
|
# Even with a inbound node, zero loop iterations will not yield inbound nodes.
|
|
5014
|
-
q = '''test:str=test1 $foo =
|
|
5014
|
+
q = '''test:str=test1 $foo = ({})
|
|
5015
5015
|
for $name in $foo.bar { [ test:str=$name ] }
|
|
5016
5016
|
'''
|
|
5017
5017
|
nodes = await core.nodes(q)
|
synapse/tests/test_daemon.py
CHANGED
|
@@ -56,6 +56,25 @@ class DaemonTest(s_t_utils.SynTest):
|
|
|
56
56
|
async with await s_telepath.openurl(f'tcp://127.0.0.1:{port}/foo') as foo:
|
|
57
57
|
pass
|
|
58
58
|
|
|
59
|
+
async def test_dmon_ahainfo(self):
|
|
60
|
+
|
|
61
|
+
async with await s_daemon.Daemon.anit() as dmon:
|
|
62
|
+
|
|
63
|
+
host, port = await dmon.listen('tcp://127.0.0.1:0')
|
|
64
|
+
dmon.share('*', Foo())
|
|
65
|
+
|
|
66
|
+
async with await s_telepath.openurl(f'tcp://127.0.0.1:{port}') as proxy:
|
|
67
|
+
self.eq(proxy._ahainfo, {})
|
|
68
|
+
|
|
69
|
+
ahainfo = {'name': 'test.loop.vertex.link'}
|
|
70
|
+
async with await s_daemon.Daemon.anit(ahainfo=ahainfo) as dmon:
|
|
71
|
+
|
|
72
|
+
host, port = await dmon.listen('tcp://127.0.0.1:0')
|
|
73
|
+
dmon.share('*', Foo())
|
|
74
|
+
|
|
75
|
+
async with await s_telepath.openurl(f'tcp://127.0.0.1:{port}') as proxy:
|
|
76
|
+
self.eq(proxy._ahainfo, ahainfo)
|
|
77
|
+
|
|
59
78
|
class SvcApi(s_cell.CellApi, s_stormsvc.StormSvc):
|
|
60
79
|
_storm_svc_name = 'foo'
|
|
61
80
|
_storm_svc_pkgs = ( # type: ignore
|
synapse/tests/test_lib_ast.py
CHANGED
|
@@ -495,7 +495,7 @@ class AstTest(s_test.SynTest):
|
|
|
495
495
|
self.none(await core.callStorm('$foo = $lib.null return($foo.bar.baz)'))
|
|
496
496
|
|
|
497
497
|
q = '''
|
|
498
|
-
$d =
|
|
498
|
+
$d = ({"foo": "bar", "bar": "baz", "baz": "biz"})
|
|
499
499
|
for ($key, $val) in $d {
|
|
500
500
|
[ test:str=$d.$key ]
|
|
501
501
|
}
|
|
@@ -506,7 +506,7 @@ class AstTest(s_test.SynTest):
|
|
|
506
506
|
self.eq(set(['bar', 'baz', 'biz']), reprs)
|
|
507
507
|
|
|
508
508
|
q = '''
|
|
509
|
-
$data =
|
|
509
|
+
$data = ({"foo": ({"bar": ({"woot": "final"}) }) })
|
|
510
510
|
$varkey=woot
|
|
511
511
|
[ test:str=$data.foo.bar.$varkey ]
|
|
512
512
|
'''
|
|
@@ -520,11 +520,11 @@ class AstTest(s_test.SynTest):
|
|
|
520
520
|
|
|
521
521
|
$f = var
|
|
522
522
|
$g = tar
|
|
523
|
-
$de =
|
|
524
|
-
$dd =
|
|
525
|
-
$dc =
|
|
526
|
-
$db =
|
|
527
|
-
$foo =
|
|
523
|
+
$de = ({"car": $f, "zar": $g})
|
|
524
|
+
$dd = ({"mar": $de})
|
|
525
|
+
$dc = ({"bar": $dd})
|
|
526
|
+
$db = ({"var": $dc})
|
|
527
|
+
$foo = ({"woot": $db})
|
|
528
528
|
[ test:str=$foo.woot.var.$bar.mar.$car ]
|
|
529
529
|
'''
|
|
530
530
|
nodes = await core.nodes(q)
|
|
@@ -532,7 +532,7 @@ class AstTest(s_test.SynTest):
|
|
|
532
532
|
self.eq('var', nodes[0].repr())
|
|
533
533
|
|
|
534
534
|
q = '''
|
|
535
|
-
$data =
|
|
535
|
+
$data = ({'vertex project': 'foobar'})
|
|
536
536
|
$"spaced key" = 'vertex project'
|
|
537
537
|
[ test:str = $data.$"spaced key" ]
|
|
538
538
|
'''
|
|
@@ -541,7 +541,7 @@ class AstTest(s_test.SynTest):
|
|
|
541
541
|
self.eq('foobar', nodes[0].repr())
|
|
542
542
|
|
|
543
543
|
q = '''
|
|
544
|
-
$data =
|
|
544
|
+
$data = ({'bar baz': "woot"})
|
|
545
545
|
$'new key' = 'bar baz'
|
|
546
546
|
[ test:str=$data.$'new key' ]
|
|
547
547
|
'''
|
|
@@ -550,9 +550,9 @@ class AstTest(s_test.SynTest):
|
|
|
550
550
|
self.eq('woot', nodes[0].repr())
|
|
551
551
|
|
|
552
552
|
q = '''
|
|
553
|
-
$bottom =
|
|
554
|
-
$subdata =
|
|
555
|
-
$data =
|
|
553
|
+
$bottom = ({"lastkey": "synapse"})
|
|
554
|
+
$subdata = ({'bar baz': $bottom})
|
|
555
|
+
$data = ({"vertex": $subdata})
|
|
556
556
|
$'new key' = 'bar baz'
|
|
557
557
|
$'over key' = vertex
|
|
558
558
|
[ test:str=$data.$'over key'.$"new key".lastkey ]
|
|
@@ -562,7 +562,7 @@ class AstTest(s_test.SynTest):
|
|
|
562
562
|
self.eq('synapse', nodes[0].repr())
|
|
563
563
|
|
|
564
564
|
q = '''
|
|
565
|
-
$data =
|
|
565
|
+
$data = ({"foo": "bar"})
|
|
566
566
|
$key = nope
|
|
567
567
|
[ test:str=$data.$key ]
|
|
568
568
|
'''
|
|
@@ -1850,7 +1850,7 @@ class AstTest(s_test.SynTest):
|
|
|
1850
1850
|
|
|
1851
1851
|
q = '''
|
|
1852
1852
|
$x = asdf
|
|
1853
|
-
$y =
|
|
1853
|
+
$y = ({})
|
|
1854
1854
|
|
|
1855
1855
|
$y.foo = bar
|
|
1856
1856
|
$y."baz faz" = hehe
|
|
@@ -1870,7 +1870,7 @@ class AstTest(s_test.SynTest):
|
|
|
1870
1870
|
self.eq(nodes[5].ndef[1], 'qwer')
|
|
1871
1871
|
|
|
1872
1872
|
# non-runtsafe test
|
|
1873
|
-
q = '''$dict =
|
|
1873
|
+
q = '''$dict = ({})
|
|
1874
1874
|
[(test:str=key1 :hehe=val1) (test:str=key2 :hehe=val2)]
|
|
1875
1875
|
$key=$node.value()
|
|
1876
1876
|
$dict.$key=:hehe
|
|
@@ -2822,7 +2822,7 @@ class AstTest(s_test.SynTest):
|
|
|
2822
2822
|
mesgs = await core.stormlist(q, opts={'vars': {'ret': 'foo'}})
|
|
2823
2823
|
self.stormIsInErr('Cannot find name [squeeeeeee]', mesgs)
|
|
2824
2824
|
|
|
2825
|
-
q = '$ret
|
|
2825
|
+
q = '$ret=({"bar": $ret})'
|
|
2826
2826
|
mesgs = await core.stormlist(q)
|
|
2827
2827
|
self.stormIsInErr('Missing variable: ret', mesgs)
|
|
2828
2828
|
|
|
@@ -119,7 +119,7 @@ Queries = [
|
|
|
119
119
|
'#test.bar -#test <+- *',
|
|
120
120
|
'#test.bar -#test <- *',
|
|
121
121
|
'$bar=5.5.5.5 [ inet:ipv4=$bar ]',
|
|
122
|
-
'$blah =
|
|
122
|
+
'$blah = ({"foo": "vertex.link"}) [ inet:fqdn=$blah.foo ]',
|
|
123
123
|
'($tick, $tock) = .seen',
|
|
124
124
|
'.created',
|
|
125
125
|
'.created<2010',
|
|
@@ -585,7 +585,7 @@ Queries = [
|
|
|
585
585
|
''' [(ou:org=c71cd602f73af5bed208da21012fdf54 :loc=us )]''',
|
|
586
586
|
'function x(y, z) { return ($( $x - $y ) ) }',
|
|
587
587
|
'function echo(arg, arg2=default) { return ($arg) }',
|
|
588
|
-
'$name = asdf $foo =
|
|
588
|
+
'$name = asdf $foo = ({}) $foo.bar = asdf $foo."bar baz" = asdf $foo.$name = asdf',
|
|
589
589
|
'[test:str=a] switch $node.form() { hehe: {[+#baz]} }',
|
|
590
590
|
'[test:str=a] switch $woot { hehe: {[+#baz]} }',
|
|
591
591
|
'[test:str=c] switch $woot { hehe: {[+#baz]} *: {[+#jaz]} }',
|
|
@@ -830,7 +830,7 @@ _ParseResults = [
|
|
|
830
830
|
'Query: [LiftTag: [TagName: [Const: test, Const: bar]], FiltOper: [Const: -, TagCond: [TagMatch: [Const: test]]], PivotIn: [], isjoin=True]',
|
|
831
831
|
'Query: [LiftTag: [TagName: [Const: test, Const: bar]], FiltOper: [Const: -, TagCond: [TagMatch: [Const: test]]], PivotIn: [], isjoin=False]',
|
|
832
832
|
'Query: [SetVarOper: [Const: bar, Const: 5.5.5.5], EditNodeAdd: [FormName: [Const: inet:ipv4], Const: =, VarValue: [Const: bar]]]',
|
|
833
|
-
'Query: [SetVarOper: [Const: blah,
|
|
833
|
+
'Query: [SetVarOper: [Const: blah, DollarExpr: [ExprDict: [Const: foo, Const: vertex.link]]], EditNodeAdd: [FormName: [Const: inet:fqdn], Const: =, VarDeref: [VarValue: [Const: blah], Const: foo]]]',
|
|
834
834
|
"Query: [VarListSetOper: [VarList: ['tick', 'tock'], UnivPropValue: [UnivProp: [Const: .seen]]]]",
|
|
835
835
|
'Query: [LiftProp: [Const: .created]]',
|
|
836
836
|
'Query: [LiftPropBy: [Const: .created, Const: <, Const: 2010]]',
|
|
@@ -1241,7 +1241,7 @@ _ParseResults = [
|
|
|
1241
1241
|
'Query: [EditParens: [EditNodeAdd: [FormName: [Const: ou:org], Const: =, Const: c71cd602f73af5bed208da21012fdf54], EditPropSet: [RelProp: [Const: loc], Const: =, Const: us]]]',
|
|
1242
1242
|
'Query: [Function: [Const: x, FuncArgs: [Const: y, Const: z], Query: [Return: [DollarExpr: [ExprNode: [VarValue: [Const: x], Const: -, VarValue: [Const: y]]]]]]]',
|
|
1243
1243
|
'Query: [Function: [Const: echo, FuncArgs: [Const: arg, CallKwarg: [Const: arg2, Const: default]], Query: [Return: [VarValue: [Const: arg]]]]]',
|
|
1244
|
-
'Query: [SetVarOper: [Const: name, Const: asdf], SetVarOper: [Const: foo,
|
|
1244
|
+
'Query: [SetVarOper: [Const: name, Const: asdf], SetVarOper: [Const: foo, DollarExpr: [ExprDict: []]], SetItemOper: [VarValue: [Const: foo], Const: bar, Const: asdf], SetItemOper: [VarValue: [Const: foo], Const: bar baz, Const: asdf], SetItemOper: [VarValue: [Const: foo], VarValue: [Const: name], Const: asdf]]',
|
|
1245
1245
|
'Query: [EditNodeAdd: [FormName: [Const: test:str], Const: =, Const: a], SwitchCase: [FuncCall: [VarDeref: [VarValue: [Const: node], Const: form], CallArgs: [], CallKwargs: []], CaseEntry: [Const: hehe, SubQuery: [Query: [EditTagAdd: [TagName: [Const: baz]]]]]]]',
|
|
1246
1246
|
'Query: [EditNodeAdd: [FormName: [Const: test:str], Const: =, Const: a], SwitchCase: [VarValue: [Const: woot], CaseEntry: [Const: hehe, SubQuery: [Query: [EditTagAdd: [TagName: [Const: baz]]]]]]]',
|
|
1247
1247
|
'Query: [EditNodeAdd: [FormName: [Const: test:str], Const: =, Const: c], SwitchCase: [VarValue: [Const: woot], CaseEntry: [Const: hehe, SubQuery: [Query: [EditTagAdd: [TagName: [Const: baz]]]]], CaseEntry: [SubQuery: [Query: [EditTagAdd: [TagName: [Const: jaz]]]]]]]',
|
synapse/tests/test_lib_rstorm.py
CHANGED
|
@@ -21,7 +21,7 @@ HI
|
|
|
21
21
|
.. storm-pre:: [ inet:ipv6=0 ]
|
|
22
22
|
.. storm-pkg:: synapse/tests/files/stormpkg/testpkg.yaml
|
|
23
23
|
.. storm:: --hide-props testpkgcmd foo
|
|
24
|
-
.. storm:: --hide-query $lib.print(secret)
|
|
24
|
+
.. storm:: --hide-query $lib.print(secret) $lib.print($lib.globals.get(testpkg))
|
|
25
25
|
.. storm:: --hide-query file:bytes
|
|
26
26
|
.. storm-svc:: synapse.tests.files.rstorm.testsvc.Testsvc test {"secret": "jupiter"}
|
|
27
27
|
.. storm:: testsvc.test
|
|
@@ -44,6 +44,7 @@ HI
|
|
|
44
44
|
::
|
|
45
45
|
|
|
46
46
|
secret
|
|
47
|
+
testpkg-done
|
|
47
48
|
|
|
48
49
|
::
|
|
49
50
|
|
|
@@ -53,6 +54,7 @@ HI
|
|
|
53
54
|
|
|
54
55
|
> testsvc.test
|
|
55
56
|
jupiter
|
|
57
|
+
testsvc-done
|
|
56
58
|
|
|
57
59
|
'''
|
|
58
60
|
|
|
@@ -259,6 +261,17 @@ HI
|
|
|
259
261
|
.. storm-cortex:: path.to.NewpCell
|
|
260
262
|
'''
|
|
261
263
|
|
|
264
|
+
pkg_onload_timeout = '''
|
|
265
|
+
.. storm-cortex:: default
|
|
266
|
+
.. storm-pre:: $lib.globals.set(onload_sleep, 2)
|
|
267
|
+
.. storm-pkg:: synapse/tests/files/stormpkg/testpkg.yaml
|
|
268
|
+
'''
|
|
269
|
+
|
|
270
|
+
svc_onload_timeout = '''
|
|
271
|
+
.. storm-cortex:: default
|
|
272
|
+
.. storm-pre:: $lib.globals.set(onload_sleep, 2)
|
|
273
|
+
.. storm-svc:: synapse.tests.files.rstorm.testsvc.Testsvc test {"secret": "jupiter"}
|
|
274
|
+
'''
|
|
262
275
|
|
|
263
276
|
async def get_rst_text(rstfile):
|
|
264
277
|
async with await s_rstorm.StormRst.anit(rstfile) as rstorm:
|
|
@@ -339,7 +352,7 @@ class RStormLibTest(s_test.SynTest):
|
|
|
339
352
|
self.isin('inet:ipv4=5.6.7.8', text) # one mock at a time
|
|
340
353
|
self.isin('it:dev:str=notjson', text) # one mock at a time
|
|
341
354
|
|
|
342
|
-
# multi
|
|
355
|
+
# multi request in 1 rstorm command
|
|
343
356
|
path = s_common.genpath(dirn, 'http_multi.rst')
|
|
344
357
|
with s_common.genfile(path) as fd:
|
|
345
358
|
fd.write(multi_rst_in_http.encode())
|
|
@@ -496,6 +509,29 @@ class RStormLibTest(s_test.SynTest):
|
|
|
496
509
|
with self.raises(s_exc.NoSuchCtor):
|
|
497
510
|
await get_rst_text(path)
|
|
498
511
|
|
|
512
|
+
# onload failures
|
|
513
|
+
|
|
514
|
+
try:
|
|
515
|
+
oldv = s_rstorm.ONLOAD_TIMEOUT
|
|
516
|
+
s_rstorm.ONLOAD_TIMEOUT = 0.1
|
|
517
|
+
|
|
518
|
+
path = s_common.genpath(dirn, 'pkg_onload_timeout.rst')
|
|
519
|
+
with s_common.genfile(path) as fd:
|
|
520
|
+
fd.write(pkg_onload_timeout.encode())
|
|
521
|
+
with self.raises(s_exc.SynErr) as ectx:
|
|
522
|
+
await get_rst_text(path)
|
|
523
|
+
self.eq('Package onload failed to run for testpkg', ectx.exception.errinfo['mesg'])
|
|
524
|
+
|
|
525
|
+
path = s_common.genpath(dirn, 'svc_onload_timeout.rst')
|
|
526
|
+
with s_common.genfile(path) as fd:
|
|
527
|
+
fd.write(svc_onload_timeout.encode())
|
|
528
|
+
with self.raises(s_exc.SynErr) as ectx:
|
|
529
|
+
await get_rst_text(path)
|
|
530
|
+
self.eq('Package onload failed to run for service test', ectx.exception.errinfo['mesg'])
|
|
531
|
+
|
|
532
|
+
finally:
|
|
533
|
+
s_rstorm.ONLOAD_TIMEOUT = oldv
|
|
534
|
+
|
|
499
535
|
async def test_rstorm_cli(self):
|
|
500
536
|
|
|
501
537
|
with self.getTestDir() as dirn:
|