synapse 2.224.0__py311-none-any.whl → 2.225.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/axon.py +10 -5
- synapse/lib/cell.py +1 -1
- synapse/lib/const.py +4 -0
- synapse/lib/multislabseqn.py +36 -1
- synapse/lib/nexus.py +67 -8
- synapse/lib/queue.py +4 -1
- synapse/lib/rstorm.py +2 -2
- synapse/lib/schemas.py +11 -1
- synapse/lib/slabseqn.py +28 -0
- synapse/lib/storm.py +5 -1
- synapse/lib/stormhttp.py +7 -1
- synapse/lib/version.py +2 -2
- synapse/models/inet.py +4 -0
- synapse/models/media.py +4 -0
- synapse/models/risk.py +3 -0
- synapse/tests/test_cortex.py +2 -2
- synapse/tests/test_lib_agenda.py +1 -1
- synapse/tests/test_lib_cell.py +1 -1
- synapse/tests/test_lib_certdir.py +1 -1
- synapse/tests/test_lib_httpapi.py +1 -1
- synapse/tests/test_lib_layer.py +1 -1
- synapse/tests/test_lib_multislabseqn.py +22 -0
- synapse/tests/test_lib_nexus.py +42 -1
- synapse/tests/test_lib_slabseqn.py +30 -1
- synapse/tests/test_lib_storm.py +59 -1
- synapse/tests/test_lib_stormhttp.py +16 -0
- synapse/tests/test_lib_stormlib_oauth.py +1 -1
- synapse/tests/test_lib_stormsvc.py +1 -1
- synapse/tests/test_lib_trigger.py +1 -1
- synapse/tests/test_model_inet.py +6 -0
- synapse/tests/test_model_media.py +4 -1
- synapse/tests/test_model_risk.py +2 -0
- synapse/tests/{test_tools_axon2axon.py → test_tools_axon_copy.py} +4 -4
- synapse/tests/{test_tools_pullfile.py → test_tools_axon_get.py} +4 -4
- synapse/tests/{test_tools_pushfile.py → test_tools_axon_put.py} +7 -7
- synapse/tests/{test_tools_csvtool.py → test_tools_cortex_csv.py} +12 -3
- synapse/tests/{test_tools_feed.py → test_tools_cortex_feed.py} +2 -2
- synapse/tests/{test_tools_apikey.py → test_tools_service_apikey.py} +1 -4
- synapse/tests/{test_tools_backup.py → test_tools_service_backup.py} +5 -5
- synapse/tests/{test_tools_demote.py → test_tools_service_demote.py} +1 -1
- synapse/tests/{test_tools_healthcheck.py → test_tools_service_healthcheck.py} +1 -1
- synapse/tests/{test_tools_livebackup.py → test_tools_service_livebackup.py} +1 -1
- synapse/tests/{test_tools_modrole.py → test_tools_service_modrole.py} +1 -1
- synapse/tests/{test_tools_moduser.py → test_tools_service_moduser.py} +1 -1
- synapse/tests/{test_tools_promote.py → test_tools_service_promote.py} +1 -1
- synapse/tests/{test_tools_reload.py → test_tools_service_reload.py} +1 -1
- synapse/tests/{test_tools_shutdown.py → test_tools_service_shutdown.py} +1 -1
- synapse/tests/{test_tools_snapshot.py → test_tools_service_snapshot.py} +1 -1
- synapse/tests/{test_tools_storm.py → test_tools_storm_cli.py} +1 -1
- synapse/tests/{test_tools_pkgs_gendocs.py → test_tools_storm_pkg_doc.py} +12 -3
- synapse/tests/{test_tools_genpkg.py → test_tools_storm_pkg_gen.py} +1 -1
- synapse/tests/{test_tools_autodoc.py → test_tools_utils_autodoc.py} +1 -1
- synapse/tests/test_tools_utils_changelog.py +454 -0
- synapse/tests/{test_tools_easycert.py → test_tools_utils_easycert.py} +48 -46
- synapse/tests/{test_tools_guid.py → test_tools_utils_guid.py} +3 -3
- synapse/tests/{test_tools_json2mpk.py → test_tools_utils_json2mpk.py} +3 -3
- synapse/tests/{test_tools_rstorm.py → test_tools_utils_rstorm.py} +6 -1
- synapse/tests/utils.py +3 -1
- synapse/tools/apikey.py +4 -83
- synapse/tools/autodoc.py +3 -1031
- synapse/tools/axon/copy.py +44 -0
- synapse/tools/axon/get.py +64 -0
- synapse/tools/axon/put.py +122 -0
- synapse/tools/axon2axon.py +3 -36
- synapse/tools/backup.py +6 -176
- synapse/tools/changelog.py +3 -1098
- synapse/tools/cortex/csv.py +236 -0
- synapse/tools/cortex/feed.py +151 -0
- synapse/tools/csvtool.py +3 -227
- synapse/tools/demote.py +4 -40
- synapse/tools/docker/validate.py +3 -3
- synapse/tools/easycert.py +4 -129
- synapse/tools/feed.py +3 -140
- synapse/tools/genpkg.py +3 -307
- synapse/tools/guid.py +7 -6
- synapse/tools/healthcheck.py +3 -101
- synapse/tools/json2mpk.py +6 -38
- synapse/tools/livebackup.py +4 -27
- synapse/tools/modrole.py +3 -108
- synapse/tools/moduser.py +3 -179
- synapse/tools/pkgs/gendocs.py +3 -164
- synapse/tools/promote.py +4 -41
- synapse/tools/pullfile.py +3 -56
- synapse/tools/pushfile.py +3 -114
- synapse/tools/reload.py +4 -61
- synapse/tools/rstorm.py +3 -26
- synapse/tools/service/__init__.py +0 -0
- synapse/tools/service/apikey.py +90 -0
- synapse/tools/service/backup.py +181 -0
- synapse/tools/service/demote.py +47 -0
- synapse/tools/service/healthcheck.py +109 -0
- synapse/tools/service/livebackup.py +34 -0
- synapse/tools/service/modrole.py +116 -0
- synapse/tools/service/moduser.py +184 -0
- synapse/tools/service/promote.py +48 -0
- synapse/tools/service/reload.py +68 -0
- synapse/tools/service/shutdown.py +51 -0
- synapse/tools/service/snapshot.py +64 -0
- synapse/tools/shutdown.py +5 -45
- synapse/tools/snapshot.py +4 -57
- synapse/tools/storm/__init__.py +0 -0
- synapse/tools/storm/__main__.py +5 -0
- synapse/tools/{storm.py → storm/_cli.py} +0 -3
- synapse/tools/storm/pkg/__init__.py +0 -0
- synapse/tools/{pkgs/pandoc_filter.py → storm/pkg/_pandoc_filter.py} +1 -1
- synapse/tools/storm/pkg/doc.py +176 -0
- synapse/tools/storm/pkg/gen.py +315 -0
- synapse/tools/utils/__init__.py +0 -0
- synapse/tools/utils/autodoc.py +1040 -0
- synapse/tools/utils/changelog.py +1124 -0
- synapse/tools/utils/easycert.py +136 -0
- synapse/tools/utils/guid.py +11 -0
- synapse/tools/utils/json2mpk.py +46 -0
- synapse/tools/utils/rstorm.py +35 -0
- {synapse-2.224.0.dist-info → synapse-2.225.0.dist-info}/METADATA +1 -1
- {synapse-2.224.0.dist-info → synapse-2.225.0.dist-info}/RECORD +120 -91
- synapse/tests/test_tools_changelog.py +0 -196
- /synapse/tests/{test_tools_axon.py → test_tools_axon_dump_load.py} +0 -0
- {synapse-2.224.0.dist-info → synapse-2.225.0.dist-info}/WHEEL +0 -0
- {synapse-2.224.0.dist-info → synapse-2.225.0.dist-info}/licenses/LICENSE +0 -0
- {synapse-2.224.0.dist-info → synapse-2.225.0.dist-info}/top_level.txt +0 -0
synapse/tests/test_lib_storm.py
CHANGED
|
@@ -21,7 +21,7 @@ import synapse.lib.stormtypes as s_stormtypes
|
|
|
21
21
|
import synapse.tests.utils as s_t_utils
|
|
22
22
|
from synapse.tests.utils import alist
|
|
23
23
|
|
|
24
|
-
import synapse.tools.backup as s_tools_backup
|
|
24
|
+
import synapse.tools.service.backup as s_tools_backup
|
|
25
25
|
|
|
26
26
|
class StormTest(s_t_utils.SynTest):
|
|
27
27
|
|
|
@@ -4724,6 +4724,64 @@ class StormTest(s_t_utils.SynTest):
|
|
|
4724
4724
|
self.stormIsInWarn('"--end-time" is deprecated and will be removed in v3.0.0.', msgs)
|
|
4725
4725
|
self.len(2, [m for m in msgs if m[0] == 'warn'])
|
|
4726
4726
|
|
|
4727
|
+
async def test_storm_cmd_cmdconf(self):
|
|
4728
|
+
pkgdef = {
|
|
4729
|
+
'name': 'testpkg',
|
|
4730
|
+
'version': '1.0.0',
|
|
4731
|
+
'commands': [
|
|
4732
|
+
{
|
|
4733
|
+
'name': 'getcmdconf',
|
|
4734
|
+
'cmdconf': {
|
|
4735
|
+
'valu': 0,
|
|
4736
|
+
'sub': {
|
|
4737
|
+
'valu': 0,
|
|
4738
|
+
},
|
|
4739
|
+
},
|
|
4740
|
+
'storm': '''
|
|
4741
|
+
$lib.print(`VALU: {$cmdconf.valu}.`)
|
|
4742
|
+
$lib.print(`SUBVALU: {$cmdconf.sub.valu}.`)
|
|
4743
|
+
$cmdconf.valu = ($cmdconf.valu + 1)
|
|
4744
|
+
$cmdconf.sub.valu = ($cmdconf.sub.valu + 1)
|
|
4745
|
+
''',
|
|
4746
|
+
},
|
|
4747
|
+
],
|
|
4748
|
+
}
|
|
4749
|
+
|
|
4750
|
+
async with self.getTestCore() as core:
|
|
4751
|
+
await core.addStormPkg(pkgdef)
|
|
4752
|
+
|
|
4753
|
+
msgs = await core.stormlist('getcmdconf')
|
|
4754
|
+
self.stormHasNoWarnErr(msgs)
|
|
4755
|
+
self.stormIsInPrint('VALU: 0.', msgs)
|
|
4756
|
+
self.stormIsInPrint('SUBVALU: 0.', msgs)
|
|
4757
|
+
|
|
4758
|
+
msgs = await core.stormlist('getcmdconf | getcmdconf')
|
|
4759
|
+
self.stormHasNoWarnErr(msgs)
|
|
4760
|
+
msgs = [k for k in msgs if k[0] == 'print']
|
|
4761
|
+
self.len(4, msgs)
|
|
4762
|
+
self.sorteq(
|
|
4763
|
+
['VALU: 0.', 'VALU: 0.', 'SUBVALU: 0.', 'SUBVALU: 0.'],
|
|
4764
|
+
[msg[1].get('mesg') for msg in msgs]
|
|
4765
|
+
)
|
|
4766
|
+
|
|
4767
|
+
msgs = await core.stormlist('for $i in $lib.range(16) {[test:int=$i]} | getcmdconf')
|
|
4768
|
+
self.stormHasNoWarnErr(msgs)
|
|
4769
|
+
|
|
4770
|
+
self.stormIsInPrint('VALU: 0.', msgs)
|
|
4771
|
+
self.stormIsInPrint('VALU: 1.', msgs)
|
|
4772
|
+
self.stormIsInPrint('VALU: 15.', msgs)
|
|
4773
|
+
self.stormNotInPrint('VALU: 16.', msgs)
|
|
4774
|
+
|
|
4775
|
+
self.stormIsInPrint('SUBVALU: 0.', msgs)
|
|
4776
|
+
self.stormIsInPrint('SUBVALU: 1.', msgs)
|
|
4777
|
+
self.stormIsInPrint('SUBVALU: 15.', msgs)
|
|
4778
|
+
self.stormNotInPrint('SUBVALU: 16.', msgs)
|
|
4779
|
+
|
|
4780
|
+
msgs = await core.stormlist('getcmdconf')
|
|
4781
|
+
self.stormHasNoWarnErr(msgs)
|
|
4782
|
+
self.stormIsInPrint('VALU: 0.', msgs)
|
|
4783
|
+
self.stormIsInPrint('SUBVALU: 0.', msgs)
|
|
4784
|
+
|
|
4727
4785
|
async def test_liftby_edge(self):
|
|
4728
4786
|
async with self.getTestCore() as core:
|
|
4729
4787
|
|
|
@@ -47,6 +47,11 @@ class HttpBadJson(s_httpapi.Handler):
|
|
|
47
47
|
async def get(self):
|
|
48
48
|
self.write(b'{"foo": "bar\x80"}')
|
|
49
49
|
|
|
50
|
+
class HttpGiantHeader(s_httpapi.Handler):
|
|
51
|
+
async def get(self):
|
|
52
|
+
self.set_header('Giant', 'x' * 64_000)
|
|
53
|
+
self.write('test')
|
|
54
|
+
|
|
50
55
|
class StormHttpTest(s_test.SynTest):
|
|
51
56
|
|
|
52
57
|
async def test_storm_http_get(self):
|
|
@@ -60,6 +65,7 @@ class StormHttpTest(s_test.SynTest):
|
|
|
60
65
|
core.addHttpApi('/api/v0/test', s_test.HttpReflector, {'cell': core})
|
|
61
66
|
core.addHttpApi('/api/v0/notjson', HttpNotJson, {'cell': core})
|
|
62
67
|
core.addHttpApi('/api/v0/badjson', HttpBadJson, {'cell': core})
|
|
68
|
+
core.addHttpApi('/api/v0/giantheader', HttpGiantHeader, {'cell': core})
|
|
63
69
|
url = f'https://root:root@127.0.0.1:{port}/api/v0/test'
|
|
64
70
|
status_url = f'https://127.0.0.1:{port}/api/v1/status'
|
|
65
71
|
opts = {'vars': {'url': url, 'port': port, 'status_url': status_url}}
|
|
@@ -273,6 +279,16 @@ class StormHttpTest(s_test.SynTest):
|
|
|
273
279
|
self.isinstance(resp, tuple)
|
|
274
280
|
self.len(0, resp)
|
|
275
281
|
|
|
282
|
+
gianturl = f'https://root:root@127.0.0.1:{port}/api/v0/giantheader'
|
|
283
|
+
giantopts = {'vars': {'url': gianturl}}
|
|
284
|
+
q = '''
|
|
285
|
+
$resp = $lib.inet.http.get($url, ssl_verify=$lib.false)
|
|
286
|
+
return ( $resp )
|
|
287
|
+
'''
|
|
288
|
+
resp = await core.callStorm(q, opts=giantopts)
|
|
289
|
+
self.eq(resp['body'], b'test')
|
|
290
|
+
self.len(64_000, resp['headers'].get('Giant'))
|
|
291
|
+
|
|
276
292
|
async def test_storm_http_inject_ca(self):
|
|
277
293
|
|
|
278
294
|
with self.getTestDir() as dirn:
|
|
@@ -11,7 +11,7 @@ import synapse.lib.coro as s_coro
|
|
|
11
11
|
import synapse.lib.oauth as s_oauth
|
|
12
12
|
import synapse.lib.httpapi as s_httpapi
|
|
13
13
|
import synapse.tests.utils as s_test
|
|
14
|
-
import synapse.tools.backup as s_backup
|
|
14
|
+
import synapse.tools.service.backup as s_backup
|
|
15
15
|
|
|
16
16
|
logger = logging.getLogger(__name__)
|
|
17
17
|
|
synapse/tests/test_model_inet.py
CHANGED
|
@@ -3068,6 +3068,7 @@ class InetModelTest(s_t_utils.SynTest):
|
|
|
3068
3068
|
(inet:service:account=(blackout, account, vertex, slack)
|
|
3069
3069
|
:id=U7RN51U1J
|
|
3070
3070
|
:user=blackout
|
|
3071
|
+
:users=(zeblackout, blackoutalt, zeblackout)
|
|
3071
3072
|
:url=https://vertex.link/users/blackout
|
|
3072
3073
|
:email=blackout@vertex.link
|
|
3073
3074
|
:profile={ gen.ps.contact.email vertex.employee blackout@vertex.link }
|
|
@@ -3099,6 +3100,7 @@ class InetModelTest(s_t_utils.SynTest):
|
|
|
3099
3100
|
self.eq(accounts[0].ndef, ('inet:service:account', s_common.guid(('blackout', 'account', 'vertex', 'slack'))))
|
|
3100
3101
|
self.eq(accounts[0].get('id'), 'U7RN51U1J')
|
|
3101
3102
|
self.eq(accounts[0].get('user'), 'blackout')
|
|
3103
|
+
self.eq(accounts[0].get('users'), ('blackoutalt', 'zeblackout'))
|
|
3102
3104
|
self.eq(accounts[0].get('url'), 'https://vertex.link/users/blackout')
|
|
3103
3105
|
self.eq(accounts[0].get('email'), 'blackout@vertex.link')
|
|
3104
3106
|
self.eq(accounts[0].get('profile'), blckprof.ndef[1])
|
|
@@ -3112,6 +3114,10 @@ class InetModelTest(s_t_utils.SynTest):
|
|
|
3112
3114
|
|
|
3113
3115
|
self.len(1, await core.nodes('inet:service:account:email=visi@vertex.link :parent -> inet:service:account'))
|
|
3114
3116
|
|
|
3117
|
+
nodes = await core.nodes('[ inet:service:account=({"user": "blackoutalt"}) ]')
|
|
3118
|
+
self.len(1, nodes)
|
|
3119
|
+
self.eq(accounts[0].ndef, nodes[0].ndef)
|
|
3120
|
+
|
|
3115
3121
|
q = '''
|
|
3116
3122
|
[ inet:service:group=(developers, group, vertex, slack)
|
|
3117
3123
|
:id=X1234
|
|
@@ -22,6 +22,7 @@ class MediaModelTest(s_t_utils.SynTest):
|
|
|
22
22
|
'file': file0,
|
|
23
23
|
'title': 'Synapse is awesome! ',
|
|
24
24
|
'summary': 'I forget ',
|
|
25
|
+
'body': 'It is Awesome ',
|
|
25
26
|
'published': 0,
|
|
26
27
|
'updated': 0,
|
|
27
28
|
'org': 'verteX',
|
|
@@ -34,7 +35,7 @@ class MediaModelTest(s_t_utils.SynTest):
|
|
|
34
35
|
|
|
35
36
|
q = '''[(media:news=$valu
|
|
36
37
|
:url=$p.url :file=$p.file :title=$p.title
|
|
37
|
-
:summary=$p.summary :published=$p.published :updated=$p.updated
|
|
38
|
+
:summary=$p.summary :body=$p.body :published=$p.published :updated=$p.updated
|
|
38
39
|
:org=$p.org :authors=$p.authors
|
|
39
40
|
:publisher=$p.publisher :publisher:name=$p."publisher:name"
|
|
40
41
|
:rss:feed=$p."rss:feed" :topics=$p.topics
|
|
@@ -49,6 +50,8 @@ class MediaModelTest(s_t_utils.SynTest):
|
|
|
49
50
|
self.eq(node.get('url:fqdn'), 'vertex.link')
|
|
50
51
|
self.eq(node.get('file'), 'sha256:' + file0)
|
|
51
52
|
self.eq(node.get('title'), 'synapse is awesome! ')
|
|
53
|
+
self.eq(node.get('summary'), 'I forget ')
|
|
54
|
+
self.eq(node.get('body'), 'It is Awesome ')
|
|
52
55
|
self.eq(node.get('published'), 0)
|
|
53
56
|
self.eq(node.get('updated'), 0)
|
|
54
57
|
self.eq(node.get('publisher'), publisher)
|
synapse/tests/test_model_risk.py
CHANGED
|
@@ -601,6 +601,7 @@ class RiskModelTest(s_t_utils.SynTest):
|
|
|
601
601
|
risk:mitigation=*
|
|
602
602
|
:vuln=*
|
|
603
603
|
:name=" FooBar "
|
|
604
|
+
:id=" IDa123 "
|
|
604
605
|
:type=foo.bar
|
|
605
606
|
:desc=BazFaz
|
|
606
607
|
:hardware=*
|
|
@@ -613,6 +614,7 @@ class RiskModelTest(s_t_utils.SynTest):
|
|
|
613
614
|
self.eq('BazFaz', nodes[0].props['desc'])
|
|
614
615
|
self.eq('vertex', nodes[0].get('reporter:name'))
|
|
615
616
|
self.eq('foo.bar.', nodes[0].get('type'))
|
|
617
|
+
self.eq('IDa123', nodes[0].get('id'))
|
|
616
618
|
self.nn(nodes[0].get('reporter'))
|
|
617
619
|
self.len(1, await core.nodes('risk:mitigation -> risk:vuln'))
|
|
618
620
|
self.len(1, await core.nodes('risk:mitigation -> it:prod:softver'))
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import synapse.tests.utils as s_test
|
|
2
|
-
import synapse.tools.
|
|
2
|
+
import synapse.tools.axon.copy as s_copy
|
|
3
3
|
|
|
4
4
|
class Axon2AxonTest(s_test.SynTest):
|
|
5
5
|
|
|
@@ -15,7 +15,7 @@ class Axon2AxonTest(s_test.SynTest):
|
|
|
15
15
|
(size, sha256) = await srcaxon.put(b'visi')
|
|
16
16
|
|
|
17
17
|
outp = self.getTestOutp()
|
|
18
|
-
await
|
|
18
|
+
await s_copy.main([srcurl, dsturl], outp=outp)
|
|
19
19
|
self.true(await dstaxon.has(sha256))
|
|
20
20
|
outp.expect('Starting transfer at offset: 0')
|
|
21
21
|
outp.expect('[ 0] - e45bbb7e03acacf4d1cca4c16af1ec0c51d777d10e53ed3155bd3d8deb398f3f (4)')
|
|
@@ -23,11 +23,11 @@ class Axon2AxonTest(s_test.SynTest):
|
|
|
23
23
|
(size, sha256) = await srcaxon.put(b'vertex')
|
|
24
24
|
|
|
25
25
|
outp = self.getTestOutp()
|
|
26
|
-
await
|
|
26
|
+
await s_copy.main([srcurl, dsturl, '--offset', '1'], outp=outp)
|
|
27
27
|
self.true(await dstaxon.has(sha256))
|
|
28
28
|
outp.expect('Starting transfer at offset: 1')
|
|
29
29
|
outp.expect('[ 1] - e1b683e26a3aad218df6aa63afe9cf57fdb5dfaf5eb20cddac14305d67f48a02 (6)')
|
|
30
30
|
|
|
31
31
|
outp = self.getTestOutp()
|
|
32
|
-
self.eq(1, await
|
|
32
|
+
self.eq(1, await s_copy.main([], outp=outp))
|
|
33
33
|
outp.expect('arguments are required:')
|
|
@@ -5,7 +5,7 @@ import pathlib
|
|
|
5
5
|
from unittest import mock
|
|
6
6
|
|
|
7
7
|
import synapse.tests.utils as s_t_utils
|
|
8
|
-
import synapse.tools.
|
|
8
|
+
import synapse.tools.axon.get as s_get
|
|
9
9
|
|
|
10
10
|
class TestPullFile(s_t_utils.SynTest):
|
|
11
11
|
|
|
@@ -30,13 +30,13 @@ class TestPullFile(s_t_utils.SynTest):
|
|
|
30
30
|
with self.getTestDir() as wdir:
|
|
31
31
|
|
|
32
32
|
outp = self.getTestOutp()
|
|
33
|
-
self.eq(0, await
|
|
33
|
+
self.eq(0, await s_get.main(['-a', axonurl,
|
|
34
34
|
'-o', wdir,
|
|
35
35
|
'-l', testhash,
|
|
36
36
|
'-l', nonehash], outp))
|
|
37
37
|
oldcwd = os.getcwd()
|
|
38
38
|
os.chdir(wdir)
|
|
39
|
-
self.eq(0, await
|
|
39
|
+
self.eq(0, await s_get.main(['-a', axonurl,
|
|
40
40
|
'-l', visihash], outp))
|
|
41
41
|
|
|
42
42
|
os.chdir(oldcwd)
|
|
@@ -52,6 +52,6 @@ class TestPullFile(s_t_utils.SynTest):
|
|
|
52
52
|
self.true(outp.expect(f'Fetching {visihash} to file'))
|
|
53
53
|
|
|
54
54
|
with mock.patch('synapse.axon.Axon.get', self._getFail):
|
|
55
|
-
self.eq(0, await
|
|
55
|
+
self.eq(0, await s_get.main(['-a', axonurl,
|
|
56
56
|
'-l', visihash], outp))
|
|
57
57
|
self.isin('Error: Hit Exception', str(outp))
|
|
@@ -3,7 +3,7 @@ import hashlib
|
|
|
3
3
|
|
|
4
4
|
import synapse.common as s_common
|
|
5
5
|
|
|
6
|
-
import synapse.tools.
|
|
6
|
+
import synapse.tools.axon.put as s_put
|
|
7
7
|
|
|
8
8
|
import synapse.tests.utils as s_t_utils
|
|
9
9
|
|
|
@@ -43,7 +43,7 @@ class TestPushFile(s_t_utils.SynTest):
|
|
|
43
43
|
'-t', 'foo.bar,baz.faz',
|
|
44
44
|
visipath]
|
|
45
45
|
|
|
46
|
-
self.eq(0, await
|
|
46
|
+
self.eq(0, await s_put.main(args, outp))
|
|
47
47
|
self.true(outp.expect('Uploaded [visi.txt] to axon'))
|
|
48
48
|
self.true(outp.expect('file: visi.txt (4) added to core'))
|
|
49
49
|
|
|
@@ -51,7 +51,7 @@ class TestPushFile(s_t_utils.SynTest):
|
|
|
51
51
|
self.eq(b'visi', b''.join([buf async for buf in axonprox.get(visihash)]))
|
|
52
52
|
|
|
53
53
|
outp = self.getTestOutp()
|
|
54
|
-
self.eq(0, await
|
|
54
|
+
self.eq(0, await s_put.main(args, outp))
|
|
55
55
|
self.true(outp.expect('Axon already had [visi.txt]'))
|
|
56
56
|
|
|
57
57
|
self.eq(1, await coreprox.count(f'file:bytes={s_common.ehex(visihash)}'))
|
|
@@ -63,7 +63,7 @@ class TestPushFile(s_t_utils.SynTest):
|
|
|
63
63
|
args = ['-a', axonurl, nullpath]
|
|
64
64
|
|
|
65
65
|
outp = self.getTestOutp()
|
|
66
|
-
self.eq(0, await
|
|
66
|
+
self.eq(0, await s_put.main(args, outp))
|
|
67
67
|
self.true(outp.expect(f'filepath does not contain any files: {nullpath}'))
|
|
68
68
|
|
|
69
69
|
self.len(1, await axonprox.wants([nullhash]))
|
|
@@ -77,7 +77,7 @@ class TestPushFile(s_t_utils.SynTest):
|
|
|
77
77
|
'-t', 'empty',
|
|
78
78
|
nullpath]
|
|
79
79
|
|
|
80
|
-
self.eq(0, await
|
|
80
|
+
self.eq(0, await s_put.main(args, outp))
|
|
81
81
|
|
|
82
82
|
self.len(0, await axonprox.wants([nullhash]))
|
|
83
83
|
self.eq(b'', b''.join([buf async for buf in axonprox.get(nullhash)]))
|
|
@@ -100,7 +100,7 @@ class TestPushFile(s_t_utils.SynTest):
|
|
|
100
100
|
'-t', 'beef',
|
|
101
101
|
f'{dirn}/**']
|
|
102
102
|
|
|
103
|
-
self.eq(0, await
|
|
103
|
+
self.eq(0, await s_put.main(args, outp))
|
|
104
104
|
self.true(outp.expect('Uploaded [bar.txt] to axon'))
|
|
105
105
|
self.true(outp.expect('file: bar.txt (3) added to core'))
|
|
106
106
|
|
|
@@ -119,7 +119,7 @@ class TestPushFile(s_t_utils.SynTest):
|
|
|
119
119
|
'-r',
|
|
120
120
|
f'{dirn}/**']
|
|
121
121
|
|
|
122
|
-
self.eq(0, await
|
|
122
|
+
self.eq(0, await s_put.main(args, outp))
|
|
123
123
|
self.true(outp.expect('Uploaded [foo.txt] to axon'))
|
|
124
124
|
self.true(outp.expect('file: foo.txt (3) added to core'))
|
|
125
125
|
|
|
@@ -5,7 +5,7 @@ import synapse.common as s_common
|
|
|
5
5
|
|
|
6
6
|
import synapse.tests.utils as s_t_utils
|
|
7
7
|
|
|
8
|
-
import synapse.tools.
|
|
8
|
+
import synapse.tools.cortex.csv as s_csvtool
|
|
9
9
|
|
|
10
10
|
csvfile = b'''ipv4,fqdn,notes
|
|
11
11
|
1.2.3.4,vertex.link,malware
|
|
@@ -76,7 +76,7 @@ class CsvToolTest(s_t_utils.SynTest):
|
|
|
76
76
|
with mock.patch('synapse.telepath.Proxy._getSynVers', self._getOldSynVers):
|
|
77
77
|
outp = self.getTestOutp()
|
|
78
78
|
await s_csvtool.main(argv, outp=outp)
|
|
79
|
-
outp.expect('Cortex version 0.0.0 is outside of the
|
|
79
|
+
outp.expect('Cortex version 0.0.0 is outside of the synapse.tools.cortex.csv supported range')
|
|
80
80
|
|
|
81
81
|
view = await core.callStorm('$view = $lib.view.get() $fork=$view.fork() return ( $fork.iden )')
|
|
82
82
|
|
|
@@ -107,6 +107,15 @@ class CsvToolTest(s_t_utils.SynTest):
|
|
|
107
107
|
self.eq(0, await s_csvtool.main(argv, outp=outp))
|
|
108
108
|
outp.expect("('err', ('BadSyntax")
|
|
109
109
|
|
|
110
|
+
q = '| |' # raises a err
|
|
111
|
+
with s_common.genfile(stormpath) as fd:
|
|
112
|
+
fd.truncate()
|
|
113
|
+
fd.write(q.encode())
|
|
114
|
+
argv = ['--cortex', url, stormpath, csvpath]
|
|
115
|
+
outp = self.getTestOutp()
|
|
116
|
+
self.eq(0, await s_csvtool.main(argv, outp=outp))
|
|
117
|
+
outp.expect("('err', ('BadSyntax")
|
|
118
|
+
|
|
110
119
|
async def test_csvtool_missingvals(self):
|
|
111
120
|
|
|
112
121
|
async with self.getTestCore() as core:
|
|
@@ -225,7 +234,7 @@ class CsvToolTest(s_t_utils.SynTest):
|
|
|
225
234
|
with mock.patch('synapse.telepath.Proxy._getSynVers', self._getOldSynVers):
|
|
226
235
|
outp = self.getTestOutp()
|
|
227
236
|
await s_csvtool.main(argv, outp=outp)
|
|
228
|
-
outp.expect(f'Cortex version 0.0.0 is outside of the
|
|
237
|
+
outp.expect(f'Cortex version 0.0.0 is outside of the synapse.tools.cortex.csv supported range')
|
|
229
238
|
|
|
230
239
|
view = await core.callStorm('$view = $lib.view.get() $fork=$view.fork() return ( $fork.iden )')
|
|
231
240
|
await core.nodes('[test:int=50]', opts={'view': view})
|
|
@@ -8,7 +8,7 @@ import synapse.common as s_common
|
|
|
8
8
|
import synapse.lib.json as s_json
|
|
9
9
|
import synapse.lib.msgpack as s_msgpack
|
|
10
10
|
|
|
11
|
-
import synapse.tools.feed as s_feed
|
|
11
|
+
import synapse.tools.cortex.feed as s_feed
|
|
12
12
|
|
|
13
13
|
import synapse.tests.utils as s_t_utils
|
|
14
14
|
|
|
@@ -49,7 +49,7 @@ class FeedTest(s_t_utils.SynTest):
|
|
|
49
49
|
|
|
50
50
|
with mock.patch('synapse.telepath.Proxy._getSynVers', self._getOldSynVers):
|
|
51
51
|
await s_feed.main(argv, outp=outp)
|
|
52
|
-
outp.expect(f'Cortex version 0.0.0 is outside of the feed
|
|
52
|
+
outp.expect(f'Cortex version 0.0.0 is outside of the synapse.tools.cortex.feed supported range')
|
|
53
53
|
|
|
54
54
|
async def test_synnodes_offset(self):
|
|
55
55
|
|
|
@@ -1,13 +1,10 @@
|
|
|
1
|
-
import datetime
|
|
2
|
-
|
|
3
|
-
import synapse.exc as s_exc
|
|
4
1
|
import synapse.common as s_common
|
|
5
2
|
|
|
6
3
|
import synapse.lib.time as s_time
|
|
7
4
|
import synapse.lib.output as s_output
|
|
8
5
|
|
|
9
6
|
import synapse.tests.utils as s_test
|
|
10
|
-
import synapse.tools.apikey as s_t_apikey
|
|
7
|
+
import synapse.tools.service.apikey as s_t_apikey
|
|
11
8
|
|
|
12
9
|
async def getApiKeyByName(core, name):
|
|
13
10
|
keys = {k.get('name'): k async for k in core.getApiKeys()}
|
|
@@ -5,7 +5,7 @@ import synapse.lib.lmdbslab as s_lmdbslab
|
|
|
5
5
|
|
|
6
6
|
import synapse.tests.utils as s_t_utils
|
|
7
7
|
|
|
8
|
-
import synapse.tools.backup as s_backup
|
|
8
|
+
import synapse.tools.service.backup as s_backup
|
|
9
9
|
|
|
10
10
|
class BackupTest(s_t_utils.SynTest):
|
|
11
11
|
|
|
@@ -61,7 +61,7 @@ class BackupTest(s_t_utils.SynTest):
|
|
|
61
61
|
|
|
62
62
|
argv = (core.dirn, dirn2)
|
|
63
63
|
|
|
64
|
-
self.eq(0, s_backup.main(argv))
|
|
64
|
+
self.eq(0, await s_backup.main(argv))
|
|
65
65
|
|
|
66
66
|
fpset = self.compare_dirs(core.dirn, dirn2, skipfns={'lock.mdb'}, skipdirs={'tmp'})
|
|
67
67
|
self.false(os.path.exists(s_common.genpath(dirn2, 'tmp')))
|
|
@@ -71,7 +71,7 @@ class BackupTest(s_t_utils.SynTest):
|
|
|
71
71
|
|
|
72
72
|
# Test corner case no-lmdbinfo
|
|
73
73
|
with self.getTestDir() as dirn2:
|
|
74
|
-
with self.getLoggerStream('synapse.tools.backup') as stream:
|
|
74
|
+
with self.getLoggerStream('synapse.tools.service.backup') as stream:
|
|
75
75
|
s_backup.txnbackup({}, core.dirn, dirn2)
|
|
76
76
|
stream.seek(0)
|
|
77
77
|
self.isin('not copied', stream.read())
|
|
@@ -90,7 +90,7 @@ class BackupTest(s_t_utils.SynTest):
|
|
|
90
90
|
'--skipdirs', '**/nodeedits.lmdb', './axon',
|
|
91
91
|
)
|
|
92
92
|
|
|
93
|
-
self.eq(0, s_backup.main(argv))
|
|
93
|
+
self.eq(0, await s_backup.main(argv))
|
|
94
94
|
|
|
95
95
|
skipdirs = {'tmp', 'nodeedits.lmdb', 'axon'}
|
|
96
96
|
fpset = self.compare_dirs(core.dirn, dirn2, skipfns={'lock.mdb'}, skipdirs=skipdirs)
|
|
@@ -110,7 +110,7 @@ class BackupTest(s_t_utils.SynTest):
|
|
|
110
110
|
'--skipdirs', 'layers/*',
|
|
111
111
|
)
|
|
112
112
|
|
|
113
|
-
self.eq(0, s_backup.main(argv))
|
|
113
|
+
self.eq(0, await s_backup.main(argv))
|
|
114
114
|
|
|
115
115
|
fpset = self.compare_dirs(core.dirn, dirn2, skipfns={'lock.mdb'}, skipdirs={'tmp', layriden})
|
|
116
116
|
|
|
@@ -4,7 +4,7 @@ import synapse.common as s_common
|
|
|
4
4
|
|
|
5
5
|
import synapse.lib.output as s_output
|
|
6
6
|
import synapse.tests.utils as s_test
|
|
7
|
-
import synapse.tools.livebackup as s_t_livebackup
|
|
7
|
+
import synapse.tools.service.livebackup as s_t_livebackup
|
|
8
8
|
|
|
9
9
|
class LivebackupTest(s_test.SynTest):
|
|
10
10
|
|
|
@@ -16,7 +16,7 @@ import synapse.telepath as s_telepath
|
|
|
16
16
|
import synapse.lib.coro as s_coro
|
|
17
17
|
import synapse.lib.output as s_output
|
|
18
18
|
import synapse.lib.msgpack as s_msgpack
|
|
19
|
-
import synapse.tools.storm as s_t_storm
|
|
19
|
+
import synapse.tools.storm._cli as s_t_storm
|
|
20
20
|
|
|
21
21
|
def run_cli_till_print(url, evt1):
|
|
22
22
|
'''
|
|
@@ -2,14 +2,15 @@ import io
|
|
|
2
2
|
import os
|
|
3
3
|
import sys
|
|
4
4
|
import json
|
|
5
|
+
import unittest.mock as mock
|
|
5
6
|
|
|
6
7
|
import synapse.exc as s_exc
|
|
7
8
|
import synapse.common as s_common
|
|
8
9
|
|
|
9
10
|
import synapse.tests.utils as s_t_utils
|
|
10
11
|
|
|
11
|
-
import synapse.tools.
|
|
12
|
-
import synapse.tools.
|
|
12
|
+
import synapse.tools.storm.pkg.doc as s_t_gendocs
|
|
13
|
+
import synapse.tools.storm.pkg._pandoc_filter as s_t_pandoc_filter
|
|
13
14
|
|
|
14
15
|
class TestPkgBuildDocs(s_t_utils.SynTest):
|
|
15
16
|
|
|
@@ -18,7 +19,7 @@ class TestPkgBuildDocs(s_t_utils.SynTest):
|
|
|
18
19
|
self.skip('pandoc is not available')
|
|
19
20
|
super().setUp()
|
|
20
21
|
|
|
21
|
-
async def
|
|
22
|
+
async def test_storm_pkg_doc_base(self):
|
|
22
23
|
|
|
23
24
|
with self.getTestDir(mirror='testpkg_build_docs') as dirn:
|
|
24
25
|
testpkgfp = os.path.join(dirn, 'testpkg.yaml')
|
|
@@ -98,3 +99,11 @@ class TestPkgBuildDocs(s_t_utils.SynTest):
|
|
|
98
99
|
outp.expect('ERR: Error running filter')
|
|
99
100
|
finally:
|
|
100
101
|
s_t_gendocs.PANDOC_FILTER = oldv
|
|
102
|
+
|
|
103
|
+
# Pandoc is missing
|
|
104
|
+
def nopandoc(*args, **kwargs):
|
|
105
|
+
return 1
|
|
106
|
+
|
|
107
|
+
with mock.patch('os.system', new=nopandoc):
|
|
108
|
+
argv = [testpkgfp, ]
|
|
109
|
+
self.eq(1, await s_t_gendocs.main(argv))
|