synapse 2.222.0__py311-none-any.whl → 2.224.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/common.py +2 -2
- synapse/cortex.py +159 -31
- synapse/cryotank.py +1 -1
- synapse/datamodel.py +1 -1
- synapse/lib/ast.py +5 -3
- synapse/lib/layer.py +6 -6
- synapse/lib/nexus.py +1 -1
- synapse/lib/schemas.py +2 -0
- synapse/lib/snap.py +15 -9
- synapse/lib/storm.py +35 -191
- synapse/lib/stormlib/auth.py +1 -1
- synapse/lib/stormlib/imap.py +12 -4
- synapse/lib/stormlib/mime.py +15 -5
- synapse/lib/stormlib/pkg.py +598 -0
- synapse/lib/stormlib/task.py +114 -0
- synapse/lib/stormtypes.py +43 -175
- synapse/lib/trigger.py +16 -14
- synapse/lib/version.py +2 -2
- synapse/lib/view.py +17 -14
- synapse/models/files.py +1 -1
- synapse/models/inet.py +25 -0
- synapse/models/proj.py +3 -0
- synapse/models/risk.py +6 -0
- synapse/models/syn.py +8 -0
- synapse/tests/test_common.py +4 -0
- synapse/tests/test_cortex.py +52 -1
- synapse/tests/test_lib_aha.py +68 -53
- synapse/tests/test_lib_ast.py +3 -0
- synapse/tests/test_lib_cell.py +12 -12
- synapse/tests/test_lib_storm.py +128 -248
- synapse/tests/test_lib_stormlib_imap.py +14 -0
- synapse/tests/test_lib_stormlib_mime.py +24 -0
- synapse/tests/test_lib_stormlib_pkg.py +456 -0
- synapse/tests/test_lib_stormlib_task.py +98 -0
- synapse/tests/test_lib_stormtypes.py +12 -100
- synapse/tests/test_lib_trigger.py +66 -3
- synapse/tests/test_lib_view.py +53 -0
- synapse/tests/test_model_files.py +11 -0
- synapse/tests/test_model_inet.py +23 -0
- synapse/tests/test_model_proj.py +3 -1
- synapse/tests/test_model_risk.py +10 -0
- synapse/tests/test_model_syn.py +54 -2
- synapse/tools/cryo/cat.py +2 -1
- synapse/tools/cryo/list.py +2 -0
- {synapse-2.222.0.dist-info → synapse-2.224.0.dist-info}/METADATA +1 -1
- {synapse-2.222.0.dist-info → synapse-2.224.0.dist-info}/RECORD +49 -45
- {synapse-2.222.0.dist-info → synapse-2.224.0.dist-info}/WHEEL +0 -0
- {synapse-2.222.0.dist-info → synapse-2.224.0.dist-info}/licenses/LICENSE +0 -0
- {synapse-2.222.0.dist-info → synapse-2.224.0.dist-info}/top_level.txt +0 -0
synapse/tests/test_lib_storm.py
CHANGED
|
@@ -1220,33 +1220,6 @@ class StormTest(s_t_utils.SynTest):
|
|
|
1220
1220
|
''')
|
|
1221
1221
|
self.eq(email, 'visi@vertex.link')
|
|
1222
1222
|
|
|
1223
|
-
pkg0 = {'name': 'hehe', 'version': '1.2.3'}
|
|
1224
|
-
await core.addStormPkg(pkg0)
|
|
1225
|
-
self.eq('1.2.3', await core.callStorm('return($lib.pkg.get(hehe).version)'))
|
|
1226
|
-
|
|
1227
|
-
self.eq(None, await core.callStorm('return($lib.pkg.get(nopkg))'))
|
|
1228
|
-
|
|
1229
|
-
pkg1 = {'name': 'haha', 'version': '1.2.3'}
|
|
1230
|
-
await core.addStormPkg(pkg1)
|
|
1231
|
-
msgs = await core.stormlist('pkg.list')
|
|
1232
|
-
self.stormIsInPrint('haha', msgs)
|
|
1233
|
-
self.stormIsInPrint('hehe', msgs)
|
|
1234
|
-
|
|
1235
|
-
self.true(await core.callStorm('return($lib.pkg.has(haha))'))
|
|
1236
|
-
|
|
1237
|
-
await core.delStormPkg('haha')
|
|
1238
|
-
self.none(await core.callStorm('return($lib.pkg.get(haha))'))
|
|
1239
|
-
self.false(await core.callStorm('return($lib.pkg.has(haha))'))
|
|
1240
|
-
|
|
1241
|
-
msgs = await core.stormlist('pkg.list --verbose')
|
|
1242
|
-
self.stormIsInPrint('not available', msgs)
|
|
1243
|
-
|
|
1244
|
-
pkg2 = {'name': 'hoho', 'version': '4.5.6', 'build': {'time': 1732017600000}}
|
|
1245
|
-
await core.addStormPkg(pkg2)
|
|
1246
|
-
self.eq('4.5.6', await core.callStorm('return($lib.pkg.get(hoho).version)'))
|
|
1247
|
-
msgs = await core.stormlist('pkg.list --verbose')
|
|
1248
|
-
self.stormIsInPrint('2024-11-19 12:00:00', msgs)
|
|
1249
|
-
|
|
1250
1223
|
# test for $lib.queue.gen()
|
|
1251
1224
|
self.eq(0, await core.callStorm('return($lib.queue.gen(woot).size())'))
|
|
1252
1225
|
# and again to test *not* creating it...
|
|
@@ -1575,161 +1548,6 @@ class StormTest(s_t_utils.SynTest):
|
|
|
1575
1548
|
nodes = [x for x in msgs if x[0] == 'node']
|
|
1576
1549
|
self.len(0, nodes)
|
|
1577
1550
|
|
|
1578
|
-
pkgdef = {
|
|
1579
|
-
'name': 'foobar',
|
|
1580
|
-
'version': '1.2.3',
|
|
1581
|
-
}
|
|
1582
|
-
|
|
1583
|
-
await core.addStormPkg(pkgdef)
|
|
1584
|
-
|
|
1585
|
-
deps = await core.callStorm('return($lib.pkg.deps($pkgdef))', opts={'vars': {'pkgdef': pkgdef}})
|
|
1586
|
-
self.eq({
|
|
1587
|
-
'requires': (),
|
|
1588
|
-
'conflicts': (),
|
|
1589
|
-
}, deps)
|
|
1590
|
-
|
|
1591
|
-
pkgdef = {
|
|
1592
|
-
'name': 'bazfaz',
|
|
1593
|
-
'version': '2.2.2',
|
|
1594
|
-
'depends': {
|
|
1595
|
-
'conflicts': (
|
|
1596
|
-
{'name': 'foobar'},
|
|
1597
|
-
),
|
|
1598
|
-
}
|
|
1599
|
-
}
|
|
1600
|
-
|
|
1601
|
-
with self.raises(s_exc.StormPkgConflicts):
|
|
1602
|
-
await core.addStormPkg(pkgdef)
|
|
1603
|
-
|
|
1604
|
-
deps = await core.callStorm('return($lib.pkg.deps($pkgdef))', opts={'vars': {'pkgdef': pkgdef}})
|
|
1605
|
-
self.eq({
|
|
1606
|
-
'requires': (),
|
|
1607
|
-
'conflicts': (
|
|
1608
|
-
{'name': 'foobar', 'version': None, 'desc': None, 'ok': False, 'actual': '1.2.3'},
|
|
1609
|
-
)
|
|
1610
|
-
}, deps)
|
|
1611
|
-
|
|
1612
|
-
pkgdef = {
|
|
1613
|
-
'name': 'bazfaz',
|
|
1614
|
-
'version': '2.2.2',
|
|
1615
|
-
'depends': {
|
|
1616
|
-
'conflicts': (
|
|
1617
|
-
{'name': 'foobar', 'version': '>=1.0.0', 'desc': 'foo'},
|
|
1618
|
-
),
|
|
1619
|
-
}
|
|
1620
|
-
}
|
|
1621
|
-
|
|
1622
|
-
with self.raises(s_exc.StormPkgConflicts):
|
|
1623
|
-
await core.addStormPkg(pkgdef)
|
|
1624
|
-
|
|
1625
|
-
deps = await core.callStorm('return($lib.pkg.deps($pkgdef))', opts={'vars': {'pkgdef': pkgdef}})
|
|
1626
|
-
self.eq({
|
|
1627
|
-
'requires': (),
|
|
1628
|
-
'conflicts': (
|
|
1629
|
-
{'name': 'foobar', 'version': '>=1.0.0', 'desc': 'foo', 'ok': False, 'actual': '1.2.3'},
|
|
1630
|
-
)
|
|
1631
|
-
}, deps)
|
|
1632
|
-
|
|
1633
|
-
pkgdef = {
|
|
1634
|
-
'name': 'bazfaz',
|
|
1635
|
-
'version': '2.2.2',
|
|
1636
|
-
'depends': {
|
|
1637
|
-
'requires': (
|
|
1638
|
-
{'name': 'foobar', 'version': '>=2.0.0,<3.0.0'},
|
|
1639
|
-
),
|
|
1640
|
-
}
|
|
1641
|
-
}
|
|
1642
|
-
|
|
1643
|
-
with self.getAsyncLoggerStream('synapse.cortex', 'bazfaz requirement') as stream:
|
|
1644
|
-
await core.addStormPkg(pkgdef)
|
|
1645
|
-
self.true(await stream.wait(timeout=1))
|
|
1646
|
-
|
|
1647
|
-
pkgdef = {
|
|
1648
|
-
'name': 'bazfaz',
|
|
1649
|
-
'version': '2.2.2',
|
|
1650
|
-
'depends': {
|
|
1651
|
-
'requires': (
|
|
1652
|
-
{'name': 'foobar', 'version': '>=2.0.0,<3.0.0', 'optional': True},
|
|
1653
|
-
),
|
|
1654
|
-
}
|
|
1655
|
-
}
|
|
1656
|
-
|
|
1657
|
-
with self.getAsyncLoggerStream('synapse.cortex', 'bazfaz optional requirement') as stream:
|
|
1658
|
-
await core.addStormPkg(pkgdef)
|
|
1659
|
-
self.true(await stream.wait(timeout=1))
|
|
1660
|
-
|
|
1661
|
-
deps = await core.callStorm('return($lib.pkg.deps($pkgdef))', opts={'vars': {'pkgdef': pkgdef}})
|
|
1662
|
-
self.eq({
|
|
1663
|
-
'requires': (
|
|
1664
|
-
{'name': 'foobar', 'version': '>=2.0.0,<3.0.0', 'desc': None,
|
|
1665
|
-
'ok': False, 'actual': '1.2.3', 'optional': True},
|
|
1666
|
-
),
|
|
1667
|
-
'conflicts': ()
|
|
1668
|
-
}, deps)
|
|
1669
|
-
|
|
1670
|
-
pkgdef = {
|
|
1671
|
-
'name': 'lolzlolz',
|
|
1672
|
-
'version': '1.2.3',
|
|
1673
|
-
}
|
|
1674
|
-
|
|
1675
|
-
await core.addStormPkg(pkgdef)
|
|
1676
|
-
|
|
1677
|
-
deps = await core.callStorm('return($lib.pkg.deps($pkgdef))', opts={'vars': {'pkgdef': pkgdef}})
|
|
1678
|
-
self.eq({
|
|
1679
|
-
'requires': (),
|
|
1680
|
-
'conflicts': (),
|
|
1681
|
-
}, deps)
|
|
1682
|
-
|
|
1683
|
-
pkgdef = {
|
|
1684
|
-
'name': 'bazfaz',
|
|
1685
|
-
'version': '2.2.2',
|
|
1686
|
-
'depends': {
|
|
1687
|
-
'requires': (
|
|
1688
|
-
{'name': 'lolzlolz', 'version': '>=1.0.0,<2.0.0', 'desc': 'lol'},
|
|
1689
|
-
),
|
|
1690
|
-
'conflicts': (
|
|
1691
|
-
{'name': 'foobar', 'version': '>=3.0.0'},
|
|
1692
|
-
),
|
|
1693
|
-
}
|
|
1694
|
-
}
|
|
1695
|
-
|
|
1696
|
-
await core.addStormPkg(pkgdef)
|
|
1697
|
-
|
|
1698
|
-
deps = await core.callStorm('return($lib.pkg.deps($pkgdef))', opts={'vars': {'pkgdef': pkgdef}})
|
|
1699
|
-
self.eq({
|
|
1700
|
-
'requires': (
|
|
1701
|
-
{'name': 'lolzlolz', 'version': '>=1.0.0,<2.0.0', 'desc': 'lol', 'ok': True, 'actual': '1.2.3'},
|
|
1702
|
-
),
|
|
1703
|
-
'conflicts': (
|
|
1704
|
-
{'name': 'foobar', 'version': '>=3.0.0', 'desc': None, 'ok': True, 'actual': '1.2.3'},
|
|
1705
|
-
)
|
|
1706
|
-
}, deps)
|
|
1707
|
-
|
|
1708
|
-
pkgdef = {
|
|
1709
|
-
'name': 'zoinkszoinks',
|
|
1710
|
-
'version': '2.2.2',
|
|
1711
|
-
'depends': {
|
|
1712
|
-
'requires': (
|
|
1713
|
-
{'name': 'newpnewp', 'version': '1.2.3'},
|
|
1714
|
-
),
|
|
1715
|
-
'conflicts': (
|
|
1716
|
-
{'name': 'newpnewp'},
|
|
1717
|
-
),
|
|
1718
|
-
}
|
|
1719
|
-
}
|
|
1720
|
-
|
|
1721
|
-
await core.addStormPkg(pkgdef)
|
|
1722
|
-
|
|
1723
|
-
deps = await core.callStorm('return($lib.pkg.deps($pkgdef))', opts={'vars': {'pkgdef': pkgdef}})
|
|
1724
|
-
self.eq({
|
|
1725
|
-
'requires': (
|
|
1726
|
-
{'name': 'newpnewp', 'version': '1.2.3', 'desc': None, 'ok': False, 'actual': None},
|
|
1727
|
-
),
|
|
1728
|
-
'conflicts': (
|
|
1729
|
-
{'name': 'newpnewp', 'version': None, 'desc': None, 'ok': True, 'actual': None},
|
|
1730
|
-
)
|
|
1731
|
-
}, deps)
|
|
1732
|
-
|
|
1733
1551
|
# force old-cron behavior which lacks a view
|
|
1734
1552
|
await core.nodes('cron.add --hourly 03 { inet:ipv4 }')
|
|
1735
1553
|
for (iden, cron) in core.agenda.list():
|
|
@@ -2980,72 +2798,6 @@ class StormTest(s_t_utils.SynTest):
|
|
|
2980
2798
|
with self.raises(s_exc.NoSuchVar):
|
|
2981
2799
|
await core.callStorm('$foo = 10 $foo = $lib.undef return($foo)')
|
|
2982
2800
|
|
|
2983
|
-
async def test_storm_pkg_load(self):
|
|
2984
|
-
cont = s_common.guid()
|
|
2985
|
-
pkg = {
|
|
2986
|
-
'name': 'testload',
|
|
2987
|
-
'version': '0.3.0',
|
|
2988
|
-
'modules': (
|
|
2989
|
-
{
|
|
2990
|
-
'name': 'testload',
|
|
2991
|
-
'storm': 'function x() { return((0)) }',
|
|
2992
|
-
},
|
|
2993
|
-
),
|
|
2994
|
-
'onload': f'[ ps:contact={cont} ] $lib.print(teststring) $lib.warn(testwarn, key=valu) return($path.vars.newp)'
|
|
2995
|
-
}
|
|
2996
|
-
class PkgHandler(s_httpapi.Handler):
|
|
2997
|
-
|
|
2998
|
-
async def get(self, name):
|
|
2999
|
-
assert self.request.headers.get('X-Synapse-Version') == s_version.verstring
|
|
3000
|
-
|
|
3001
|
-
if name == 'notok':
|
|
3002
|
-
self.sendRestErr('FooBar', 'baz faz')
|
|
3003
|
-
return
|
|
3004
|
-
|
|
3005
|
-
self.sendRestRetn(pkg)
|
|
3006
|
-
|
|
3007
|
-
class PkgHandlerRaw(s_httpapi.Handler):
|
|
3008
|
-
async def get(self, name):
|
|
3009
|
-
assert self.request.headers.get('X-Synapse-Version') == s_version.verstring
|
|
3010
|
-
|
|
3011
|
-
self.set_header('Content-Type', 'application/json')
|
|
3012
|
-
return self.write(pkg)
|
|
3013
|
-
|
|
3014
|
-
async with self.getTestCore() as core:
|
|
3015
|
-
core.addHttpApi('/api/v1/pkgtest/(.*)', PkgHandler, {'cell': core})
|
|
3016
|
-
core.addHttpApi('/api/v1/pkgtestraw/(.*)', PkgHandlerRaw, {'cell': core})
|
|
3017
|
-
port = (await core.addHttpsPort(0, host='127.0.0.1'))[1]
|
|
3018
|
-
|
|
3019
|
-
msgs = await core.stormlist(f'pkg.load --ssl-noverify https://127.0.0.1:{port}/api/v1/newp/newp')
|
|
3020
|
-
self.stormIsInWarn('pkg.load got HTTP code: 404', msgs)
|
|
3021
|
-
|
|
3022
|
-
msgs = await core.stormlist(f'pkg.load --ssl-noverify https://127.0.0.1:{port}/api/v1/pkgtest/notok')
|
|
3023
|
-
self.stormIsInWarn('pkg.load got JSON error: FooBar', msgs)
|
|
3024
|
-
|
|
3025
|
-
# onload will on fire once. all other pkg.load events will effectively bounce
|
|
3026
|
-
# because the pkg hasn't changed so no loading occurs
|
|
3027
|
-
waiter = core.waiter(1, 'core:pkg:onload:complete')
|
|
3028
|
-
|
|
3029
|
-
with self.getAsyncLoggerStream('synapse.cortex') as stream:
|
|
3030
|
-
msgs = await core.stormlist(f'pkg.load --ssl-noverify https://127.0.0.1:{port}/api/v1/pkgtest/yep')
|
|
3031
|
-
self.stormIsInPrint('testload @0.3.0', msgs)
|
|
3032
|
-
|
|
3033
|
-
msgs = await core.stormlist(f'pkg.load --ssl-noverify --raw https://127.0.0.1:{port}/api/v1/pkgtestraw/yep')
|
|
3034
|
-
self.stormIsInPrint('testload @0.3.0', msgs)
|
|
3035
|
-
|
|
3036
|
-
stream.seek(0)
|
|
3037
|
-
buf = stream.read()
|
|
3038
|
-
self.isin("testload onload output: teststring", buf)
|
|
3039
|
-
self.isin("testload onload output: testwarn", buf)
|
|
3040
|
-
self.isin("No var with name: newp", buf)
|
|
3041
|
-
self.len(1, await core.nodes(f'ps:contact={cont}'))
|
|
3042
|
-
|
|
3043
|
-
evnts = await waiter.wait(timeout=4)
|
|
3044
|
-
exp = [
|
|
3045
|
-
('core:pkg:onload:complete', {'pkg': 'testload'})
|
|
3046
|
-
]
|
|
3047
|
-
self.eq(exp, evnts)
|
|
3048
|
-
|
|
3049
2801
|
async def test_storm_pkg_onload_active(self):
|
|
3050
2802
|
pkg = {
|
|
3051
2803
|
'name': 'testload',
|
|
@@ -3294,6 +3046,37 @@ class StormTest(s_t_utils.SynTest):
|
|
|
3294
3046
|
await stream.wait(timeout=10)
|
|
3295
3047
|
self.eq(8, await core.getStormPkgVar('testload', 'testload:version'))
|
|
3296
3048
|
|
|
3049
|
+
# init that advances the version
|
|
3050
|
+
|
|
3051
|
+
pkg['version'] = '0.7.0'
|
|
3052
|
+
pkg['inits']['versions'].extend([
|
|
3053
|
+
{
|
|
3054
|
+
'version': 9,
|
|
3055
|
+
'name': 'init09',
|
|
3056
|
+
'query': '''
|
|
3057
|
+
$lib.globals.set(init09, $lib.time.now())
|
|
3058
|
+
$lib.pkg.vars(testload)."testload:version" = (10)
|
|
3059
|
+
''',
|
|
3060
|
+
},
|
|
3061
|
+
{
|
|
3062
|
+
'version': 10,
|
|
3063
|
+
'name': 'init10',
|
|
3064
|
+
'query': '$lib.globals.set(init10, $lib.time.now())',
|
|
3065
|
+
},
|
|
3066
|
+
{
|
|
3067
|
+
'version': 11,
|
|
3068
|
+
'name': 'init11',
|
|
3069
|
+
'query': '$lib.globals.set(init11, $lib.time.now())',
|
|
3070
|
+
},
|
|
3071
|
+
])
|
|
3072
|
+
|
|
3073
|
+
await loadPkg(core, pkg)
|
|
3074
|
+
|
|
3075
|
+
self.eq(11, await core.getStormPkgVar('testload', 'testload:version'))
|
|
3076
|
+
self.nn(await core.getStormVar('init09'))
|
|
3077
|
+
self.none(await core.getStormVar('init10'))
|
|
3078
|
+
self.nn(await core.getStormVar('init11'))
|
|
3079
|
+
|
|
3297
3080
|
async def test_storm_tree(self):
|
|
3298
3081
|
|
|
3299
3082
|
async with self.getTestCore() as core:
|
|
@@ -4844,6 +4627,103 @@ class StormTest(s_t_utils.SynTest):
|
|
|
4844
4627
|
self.stormIsInPrint('$lib.bytes.hashset`` has been deprecated and will be removed in version v3.0.0', msgs)
|
|
4845
4628
|
self.stormIsInPrint('Use the corresponding ``$lib.axon`` function.', msgs)
|
|
4846
4629
|
|
|
4630
|
+
async def test_storm_cmd_deprecations(self):
|
|
4631
|
+
|
|
4632
|
+
async with self.getTestCore() as core:
|
|
4633
|
+
|
|
4634
|
+
deprpkg = {
|
|
4635
|
+
'name': 'testdepr',
|
|
4636
|
+
'version': '0.0.1',
|
|
4637
|
+
'synapse_version': '>=2.8.0,<3.0.0',
|
|
4638
|
+
'commands': (
|
|
4639
|
+
{
|
|
4640
|
+
'name': 'deprmesg',
|
|
4641
|
+
'descr': 'deprecated command',
|
|
4642
|
+
'deprecated': {'eolvers': 'v3.0.0', 'mesg': 'Please use something else.'},
|
|
4643
|
+
'storm': '[ inet:ipv4=1.2.3.4 ]',
|
|
4644
|
+
},
|
|
4645
|
+
{
|
|
4646
|
+
'name': 'deprnomesg',
|
|
4647
|
+
'descr': 'deprecated command',
|
|
4648
|
+
'deprecated': {'eoldate': '2099-01-01'},
|
|
4649
|
+
'storm': '[ inet:ipv4=1.2.3.4 ]',
|
|
4650
|
+
},
|
|
4651
|
+
{
|
|
4652
|
+
'name': 'deprargs',
|
|
4653
|
+
'descr': 'deprecated command',
|
|
4654
|
+
'storm': '[ inet:ipv4=1.2.3.4 ]',
|
|
4655
|
+
'cmdargs': (
|
|
4656
|
+
('--start-time', {
|
|
4657
|
+
'type': 'time',
|
|
4658
|
+
'deprecated': {'eolvers': 'v3.0.0', 'mesg': 'Use --period instead.'},
|
|
4659
|
+
}),
|
|
4660
|
+
('--end-time', {
|
|
4661
|
+
'type': 'time',
|
|
4662
|
+
'deprecated': {'eolvers': 'v3.0.0'},
|
|
4663
|
+
}),
|
|
4664
|
+
('--period', {
|
|
4665
|
+
'type': 'time',
|
|
4666
|
+
}),
|
|
4667
|
+
),
|
|
4668
|
+
},
|
|
4669
|
+
),
|
|
4670
|
+
}
|
|
4671
|
+
|
|
4672
|
+
self.none(await core.addStormPkg(deprpkg))
|
|
4673
|
+
|
|
4674
|
+
# Deprecation message shows up in command help
|
|
4675
|
+
deprmesg = '"deprmesg" is deprecated: Please use something else.'
|
|
4676
|
+
msgs = await core.stormlist('deprmesg -h')
|
|
4677
|
+
self.stormIsInPrint(f'Deprecated: {deprmesg}', msgs)
|
|
4678
|
+
self.stormHasNoWarnErr(msgs)
|
|
4679
|
+
|
|
4680
|
+
# Deprecation message shows up in command execution as warning
|
|
4681
|
+
msgs = await core.stormlist('deprmesg')
|
|
4682
|
+
self.stormIsInWarn(deprmesg, msgs)
|
|
4683
|
+
|
|
4684
|
+
# Deprecation message shows up in command help (with no message specified)
|
|
4685
|
+
deprmesg = '"deprnomesg" is deprecated and will be removed on 2099-01-01.'
|
|
4686
|
+
msgs = await core.stormlist('deprnomesg -h')
|
|
4687
|
+
self.stormIsInPrint(f'Deprecated: {deprmesg}', msgs)
|
|
4688
|
+
self.stormHasNoWarnErr(msgs)
|
|
4689
|
+
|
|
4690
|
+
# Deprecation message shows up in command execution as warning (with no message specified)
|
|
4691
|
+
msgs = await core.stormlist('deprnomesg')
|
|
4692
|
+
self.stormIsInWarn(deprmesg, msgs)
|
|
4693
|
+
|
|
4694
|
+
# Deprecation message shows up in help for command args
|
|
4695
|
+
msgs = await core.stormlist('deprargs -h')
|
|
4696
|
+
self.stormIsInPrint(' Deprecated: "--start-time" is deprecated: Use --period instead.', msgs)
|
|
4697
|
+
self.stormIsInPrint(' Deprecated: "--end-time" is deprecated and will be removed in v3.0.0.', msgs)
|
|
4698
|
+
self.stormHasNoWarnErr(msgs)
|
|
4699
|
+
|
|
4700
|
+
# Deprecation message doesn't show up in command execution when not using deprecated args
|
|
4701
|
+
msgs = await core.stormlist('deprargs')
|
|
4702
|
+
self.stormHasNoWarnErr(msgs)
|
|
4703
|
+
|
|
4704
|
+
# Deprecation message shows up in command execution as warning
|
|
4705
|
+
msgs = await core.stormlist('deprargs --start-time now')
|
|
4706
|
+
self.stormIsInWarn('"--start-time" is deprecated: Use --period instead.', msgs)
|
|
4707
|
+
self.stormNotInWarn('"--end-time" is deprecated and will be removed in v3.0.0.', msgs)
|
|
4708
|
+
|
|
4709
|
+
msgs = await core.stormlist('deprargs --end-time now')
|
|
4710
|
+
self.stormNotInWarn('"--start-time" is deprecated: Use --period instead.', msgs)
|
|
4711
|
+
self.stormIsInWarn('"--end-time" is deprecated and will be removed in v3.0.0.', msgs)
|
|
4712
|
+
|
|
4713
|
+
msgs = await core.stormlist('deprargs --start-time now --end-time now')
|
|
4714
|
+
self.stormIsInWarn('"--start-time" is deprecated: Use --period instead.', msgs)
|
|
4715
|
+
self.stormIsInWarn('"--end-time" is deprecated and will be removed in v3.0.0.', msgs)
|
|
4716
|
+
|
|
4717
|
+
# Deprecation message only appears once per runtime
|
|
4718
|
+
msgs = await core.stormlist('[ inet:ipv4=10.0.0.0/28 ] | deprmesg')
|
|
4719
|
+
self.stormIsInWarn('"deprmesg" is deprecated: Please use something else.', msgs)
|
|
4720
|
+
self.len(1, [m for m in msgs if m[0] == 'warn'])
|
|
4721
|
+
|
|
4722
|
+
msgs = await core.stormlist('[ inet:ipv4=10.0.0.0/28 ] | deprargs --start-time now --end-time now')
|
|
4723
|
+
self.stormIsInWarn('"--start-time" is deprecated: Use --period instead.', msgs)
|
|
4724
|
+
self.stormIsInWarn('"--end-time" is deprecated and will be removed in v3.0.0.', msgs)
|
|
4725
|
+
self.len(2, [m for m in msgs if m[0] == 'warn'])
|
|
4726
|
+
|
|
4847
4727
|
async def test_liftby_edge(self):
|
|
4848
4728
|
async with self.getTestCore() as core:
|
|
4849
4729
|
|
|
@@ -445,6 +445,8 @@ class ImapTest(s_test.SynTest):
|
|
|
445
445
|
|
|
446
446
|
while not link.isfini:
|
|
447
447
|
mesg = await link.rx()
|
|
448
|
+
if mesg is None:
|
|
449
|
+
break
|
|
448
450
|
|
|
449
451
|
# Receive commands from client
|
|
450
452
|
command = mesg.get('command')
|
|
@@ -854,6 +856,8 @@ class ImapTest(s_test.SynTest):
|
|
|
854
856
|
self.stormIsInErr('Cannot process EXPUNGE command.', mesgs)
|
|
855
857
|
|
|
856
858
|
imap = await s_link.connect('127.0.0.1', port, linkcls=s_imap.IMAPClient)
|
|
859
|
+
core.onfini(imap)
|
|
860
|
+
|
|
857
861
|
await imap.login('user01@vertex.link', 'spaces lol')
|
|
858
862
|
await imap.select('INBOX')
|
|
859
863
|
self.eq(
|
|
@@ -868,6 +872,8 @@ class ImapTest(s_test.SynTest):
|
|
|
868
872
|
|
|
869
873
|
# Normal response
|
|
870
874
|
imap = await s_link.connect('127.0.0.1', port, linkcls=s_imap.IMAPClient)
|
|
875
|
+
core.onfini(imap)
|
|
876
|
+
|
|
871
877
|
await imap.login(user, 'pass00')
|
|
872
878
|
await imap.select('INBOX')
|
|
873
879
|
ret = await imap.uid_fetch('1', '(RFC822 BODY[HEADER])')
|
|
@@ -884,6 +890,8 @@ class ImapTest(s_test.SynTest):
|
|
|
884
890
|
|
|
885
891
|
# Normal response
|
|
886
892
|
imap = await s_link.connect('127.0.0.1', port, linkcls=s_imap.IMAPClient)
|
|
893
|
+
core.onfini(imap)
|
|
894
|
+
|
|
887
895
|
await imap.login(user, 'pass00')
|
|
888
896
|
self.eq(
|
|
889
897
|
await imap.logout(),
|
|
@@ -897,6 +905,8 @@ class ImapTest(s_test.SynTest):
|
|
|
897
905
|
|
|
898
906
|
with mock.patch.object(IMAPServer, 'logout', logout_no):
|
|
899
907
|
imap = await s_link.connect('127.0.0.1', port, linkcls=s_imap.IMAPClient)
|
|
908
|
+
core.onfini(imap)
|
|
909
|
+
|
|
900
910
|
await imap.login(user, 'pass00')
|
|
901
911
|
self.eq(
|
|
902
912
|
await imap.logout(),
|
|
@@ -910,6 +920,8 @@ class ImapTest(s_test.SynTest):
|
|
|
910
920
|
|
|
911
921
|
with mock.patch.object(IMAPServer, 'logout', logout_nobye):
|
|
912
922
|
imap = await s_link.connect('127.0.0.1', port, linkcls=s_imap.IMAPClient)
|
|
923
|
+
core.onfini(imap)
|
|
924
|
+
|
|
913
925
|
await imap.login(user, 'pass00')
|
|
914
926
|
self.eq(
|
|
915
927
|
await imap.logout(),
|
|
@@ -932,6 +944,8 @@ class ImapTest(s_test.SynTest):
|
|
|
932
944
|
|
|
933
945
|
# Check command validation
|
|
934
946
|
imap = await s_link.connect('127.0.0.1', port, linkcls=s_imap.IMAPClient)
|
|
947
|
+
core.onfini(imap)
|
|
948
|
+
|
|
935
949
|
with self.raises(s_exc.ImapError) as exc:
|
|
936
950
|
tag = imap._genTag()
|
|
937
951
|
await imap._command(tag, 'NEWP')
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import synapse.lib.stormlib.mime as s_mime
|
|
2
|
+
|
|
1
3
|
import synapse.tests.utils as s_test
|
|
2
4
|
|
|
3
5
|
html00 = '''
|
|
@@ -35,20 +37,42 @@ class StormlibMimeTest(s_test.SynTest):
|
|
|
35
37
|
|
|
36
38
|
async def test_stormlib_mime_html(self):
|
|
37
39
|
|
|
40
|
+
# this is mostly for coverage because it looks like code coverage doesn't work for code executed under semafork()
|
|
41
|
+
self.eq('html5lib includes this\na title\nhello there\nother text', s_mime.htmlToText(html00))
|
|
42
|
+
self.eq('html5lib includes this|a title|hello there|other text', s_mime.htmlToText(html00, separator='|'))
|
|
43
|
+
self.eq(' foo ', s_mime.htmlToText('<div> <p> foo </p> </div>', separator='', strip=False))
|
|
44
|
+
|
|
38
45
|
async with self.getTestCore() as core:
|
|
39
46
|
|
|
40
47
|
opts = {'vars': {'html': html00}}
|
|
41
48
|
ret = await core.callStorm('return($lib.mime.html.totext($html))', opts=opts)
|
|
42
49
|
self.eq('html5lib includes this\na title\nhello there\nother text', ret)
|
|
43
50
|
|
|
51
|
+
ret = await core.callStorm('return($lib.mime.html.totext($html, separator="|"))', opts=opts)
|
|
52
|
+
self.eq('html5lib includes this|a title|hello there|other text', ret)
|
|
53
|
+
|
|
44
54
|
opts = {'vars': {'html': html01}}
|
|
45
55
|
ret = await core.callStorm('return($lib.mime.html.totext($html))', opts=opts)
|
|
46
56
|
self.eq('a bad tag\nanother bad tag\nmore text\nfor fun', ret)
|
|
47
57
|
|
|
58
|
+
ret = await core.callStorm('return($lib.mime.html.totext($html, separator=", "))', opts=opts)
|
|
59
|
+
self.eq('a bad tag, another bad tag, more text, for fun', ret)
|
|
60
|
+
|
|
61
|
+
ret = await core.callStorm('return($lib.mime.html.totext($html, separator=(null), strip=(false)))', opts=opts)
|
|
62
|
+
self.eq('\n \n \n \n a bad tag\n \n \n \n another bad tag\n \n more text\n \n \n\nfor fun\n', ret)
|
|
63
|
+
|
|
48
64
|
opts = {'vars': {'html': '<div></div>'}}
|
|
49
65
|
ret = await core.callStorm('return($lib.mime.html.totext($html))', opts=opts)
|
|
50
66
|
self.eq('', ret)
|
|
51
67
|
|
|
68
|
+
opts = {'vars': {'html': '<div> </div>'}}
|
|
69
|
+
ret = await core.callStorm('return($lib.mime.html.totext($html, strip=(false)))', opts=opts)
|
|
70
|
+
self.eq(' ', ret)
|
|
71
|
+
|
|
72
|
+
opts = {'vars': {'html': '<div> <p> foo </p> </div>'}}
|
|
73
|
+
ret = await core.callStorm('return($lib.mime.html.totext($html, separator=(null), strip=(false)))', opts=opts)
|
|
74
|
+
self.eq(' foo ', ret)
|
|
75
|
+
|
|
52
76
|
opts = {'vars': {'html': '...'}}
|
|
53
77
|
ret = await core.callStorm('return($lib.mime.html.totext($html))', opts=opts)
|
|
54
78
|
self.eq('...', ret)
|