synapse 2.202.0__py311-none-any.whl → 2.203.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 +4 -4
- synapse/cmds/cortex.py +4 -6
- synapse/cmds/hive.py +10 -10
- synapse/common.py +17 -58
- synapse/cortex.py +6 -6
- synapse/data/__init__.py +3 -2
- synapse/data/iana.uris.mpk +1 -0
- synapse/lib/autodoc.py +3 -3
- synapse/lib/cli.py +2 -2
- synapse/lib/config.py +2 -2
- synapse/lib/encoding.py +4 -3
- synapse/lib/httpapi.py +7 -11
- synapse/lib/json.py +224 -0
- synapse/lib/lmdbslab.py +1 -1
- synapse/lib/oauth.py +176 -54
- synapse/lib/rstorm.py +18 -14
- synapse/lib/schemas.py +87 -1
- synapse/lib/scrape.py +35 -13
- synapse/lib/snap.py +2 -1
- synapse/lib/storm.py +2 -2
- synapse/lib/stormhttp.py +11 -13
- synapse/lib/stormlib/aha.py +4 -4
- synapse/lib/stormlib/auth.py +1 -1
- synapse/lib/stormlib/cache.py +2 -2
- synapse/lib/stormlib/cortex.py +5 -5
- synapse/lib/stormlib/graph.py +1 -1
- synapse/lib/stormlib/imap.py +1 -1
- synapse/lib/stormlib/json.py +8 -11
- synapse/lib/stormlib/model.py +1 -1
- synapse/lib/stormlib/notifications.py +2 -2
- synapse/lib/stormlib/oauth.py +105 -2
- synapse/lib/stormlib/stats.py +4 -0
- synapse/lib/stormlib/stix.py +3 -4
- synapse/lib/stormlib/vault.py +6 -6
- synapse/lib/stormlib/xml.py +2 -2
- synapse/lib/stormtypes.py +19 -28
- synapse/lib/structlog.py +3 -3
- synapse/lib/types.py +2 -1
- synapse/lib/version.py +2 -2
- synapse/lib/view.py +7 -3
- synapse/models/base.py +51 -2
- synapse/telepath.py +5 -3
- synapse/tests/files/__init__.py +0 -1
- synapse/tests/test_axon.py +1 -1
- synapse/tests/test_cmds_cortex.py +3 -2
- synapse/tests/test_cmds_hive.py +4 -4
- synapse/tests/test_common.py +29 -19
- synapse/tests/test_cortex.py +5 -5
- synapse/tests/test_lib_ast.py +3 -3
- synapse/tests/test_lib_autodoc.py +5 -5
- synapse/tests/test_lib_base.py +1 -1
- synapse/tests/test_lib_cell.py +16 -10
- synapse/tests/test_lib_config.py +2 -2
- synapse/tests/test_lib_encoding.py +2 -2
- synapse/tests/test_lib_grammar.py +64 -64
- synapse/tests/test_lib_httpapi.py +13 -13
- synapse/tests/test_lib_json.py +219 -0
- synapse/tests/test_lib_multislabseqn.py +2 -1
- synapse/tests/test_lib_node.py +2 -2
- synapse/tests/test_lib_scrape.py +50 -0
- synapse/tests/test_lib_storm.py +6 -6
- synapse/tests/test_lib_stormhttp.py +4 -4
- synapse/tests/test_lib_stormlib_auth.py +3 -2
- synapse/tests/test_lib_stormlib_cortex.py +10 -12
- synapse/tests/test_lib_stormlib_infosec.py +2 -3
- synapse/tests/test_lib_stormlib_json.py +18 -21
- synapse/tests/test_lib_stormlib_log.py +1 -1
- synapse/tests/test_lib_stormlib_oauth.py +603 -1
- synapse/tests/test_lib_stormlib_stats.py +13 -3
- synapse/tests/test_lib_stormlib_stix.py +5 -5
- synapse/tests/test_lib_stormtypes.py +4 -4
- synapse/tests/test_lib_structlog.py +5 -6
- synapse/tests/test_lib_view.py +8 -0
- synapse/tests/test_model_base.py +32 -0
- synapse/tests/test_model_infotech.py +2 -2
- synapse/tests/test_telepath.py +0 -1
- synapse/tests/test_tools_cryo_cat.py +4 -3
- synapse/tests/test_tools_docker_validate.py +4 -2
- synapse/tests/test_tools_feed.py +30 -2
- synapse/tests/test_tools_genpkg.py +1 -1
- synapse/tests/test_tools_healthcheck.py +8 -7
- synapse/tests/test_utils.py +2 -2
- synapse/tests/utils.py +3 -3
- synapse/tools/autodoc.py +3 -3
- synapse/tools/changelog.py +2 -2
- synapse/tools/cryo/cat.py +3 -3
- synapse/tools/csvtool.py +2 -3
- synapse/tools/docker/validate.py +5 -5
- synapse/tools/feed.py +2 -1
- synapse/tools/genpkg.py +3 -2
- synapse/tools/healthcheck.py +2 -3
- synapse/tools/json2mpk.py +2 -2
- synapse/utils/getrefs.py +6 -6
- synapse/vendor/cpython/lib/json.py +35 -0
- synapse/vendor/cpython/lib/test/test_json.py +22 -0
- {synapse-2.202.0.dist-info → synapse-2.203.0.dist-info}/METADATA +2 -1
- {synapse-2.202.0.dist-info → synapse-2.203.0.dist-info}/RECORD +100 -95
- {synapse-2.202.0.dist-info → synapse-2.203.0.dist-info}/WHEEL +1 -1
- {synapse-2.202.0.dist-info → synapse-2.203.0.dist-info}/LICENSE +0 -0
- {synapse-2.202.0.dist-info → synapse-2.203.0.dist-info}/top_level.txt +0 -0
synapse/tools/genpkg.py
CHANGED
|
@@ -12,6 +12,7 @@ import synapse.exc as s_exc
|
|
|
12
12
|
import synapse.common as s_common
|
|
13
13
|
import synapse.telepath as s_telepath
|
|
14
14
|
|
|
15
|
+
import synapse.lib.json as s_json
|
|
15
16
|
import synapse.lib.output as s_output
|
|
16
17
|
import synapse.lib.certdir as s_certdir
|
|
17
18
|
import synapse.lib.dyndeps as s_dyndeps
|
|
@@ -224,7 +225,7 @@ def loadPkgProto(path, opticdir=None, no_docs=False, readonly=False):
|
|
|
224
225
|
s_schemas.reqValidPkgdef(pkgdef)
|
|
225
226
|
|
|
226
227
|
# Ensure the package is json safe and tuplify it.
|
|
227
|
-
|
|
228
|
+
s_json.reqjsonsafe(pkgdef, strict=True)
|
|
228
229
|
pkgdef = s_common.tuplify(pkgdef)
|
|
229
230
|
return pkgdef
|
|
230
231
|
|
|
@@ -286,7 +287,7 @@ async def main(argv, outp=s_output.stdout):
|
|
|
286
287
|
return 1
|
|
287
288
|
|
|
288
289
|
if opts.save:
|
|
289
|
-
|
|
290
|
+
s_json.jssave(pkgdef, opts.save)
|
|
290
291
|
|
|
291
292
|
if opts.push:
|
|
292
293
|
|
synapse/tools/healthcheck.py
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import sys
|
|
2
|
-
import json
|
|
3
2
|
import socket
|
|
4
3
|
import asyncio
|
|
5
4
|
|
|
@@ -8,13 +7,13 @@ import synapse.common as s_common
|
|
|
8
7
|
import synapse.telepath as s_telepath
|
|
9
8
|
|
|
10
9
|
import synapse.lib.cmd as s_cmd
|
|
10
|
+
import synapse.lib.json as s_json
|
|
11
11
|
import synapse.lib.output as s_output
|
|
12
12
|
import synapse.lib.health as s_health
|
|
13
13
|
import synapse.lib.urlhelp as s_urlhelp
|
|
14
14
|
|
|
15
15
|
def serialize(ret):
|
|
16
|
-
|
|
17
|
-
return s
|
|
16
|
+
return s_json.dumps(ret).decode()
|
|
18
17
|
|
|
19
18
|
def format_component(e, mesg: str) -> dict:
|
|
20
19
|
d = {
|
synapse/tools/json2mpk.py
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import os
|
|
2
2
|
import sys
|
|
3
|
-
import json
|
|
4
3
|
import argparse
|
|
5
4
|
|
|
5
|
+
import synapse.lib.json as s_json
|
|
6
6
|
import synapse.lib.output as s_output
|
|
7
7
|
import synapse.lib.msgpack as s_msgpack
|
|
8
8
|
|
|
@@ -37,7 +37,7 @@ def main(argv, outp=None):
|
|
|
37
37
|
with open(path, 'r', encoding='utf8') as fd:
|
|
38
38
|
with open(newp, 'wb') as pk:
|
|
39
39
|
for line in fd:
|
|
40
|
-
item =
|
|
40
|
+
item = s_json.loads(line)
|
|
41
41
|
pk.write(s_msgpack.en(item))
|
|
42
42
|
|
|
43
43
|
if opts.rm:
|
synapse/utils/getrefs.py
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import sys
|
|
2
|
-
import json
|
|
3
2
|
import urllib
|
|
4
3
|
import asyncio
|
|
5
4
|
import logging
|
|
@@ -12,6 +11,7 @@ import synapse.exc as s_exc
|
|
|
12
11
|
import synapse.data as s_data
|
|
13
12
|
import synapse.common as s_common
|
|
14
13
|
|
|
14
|
+
import synapse.lib.json as s_json
|
|
15
15
|
import synapse.lib.config as s_config
|
|
16
16
|
|
|
17
17
|
logger = logging.getLogger(__name__)
|
|
@@ -47,7 +47,7 @@ async def _download_refs_handler(uri):
|
|
|
47
47
|
if filepath.exists():
|
|
48
48
|
logger.info(f'Schema {uri} already exists in local cache, skipping.')
|
|
49
49
|
with filepath.open() as fp:
|
|
50
|
-
return
|
|
50
|
+
return s_json.load(fp)
|
|
51
51
|
|
|
52
52
|
# Create parent directory structure if it doesn't already exist
|
|
53
53
|
filepath.parent.mkdir(parents=True, exist_ok=True)
|
|
@@ -59,11 +59,11 @@ async def _download_refs_handler(uri):
|
|
|
59
59
|
resp.raise_for_status()
|
|
60
60
|
buf = await resp.read()
|
|
61
61
|
|
|
62
|
-
data =
|
|
62
|
+
data = s_json.loads(buf)
|
|
63
63
|
|
|
64
64
|
# Save the json schema to disk
|
|
65
|
-
with filepath.open('
|
|
66
|
-
|
|
65
|
+
with filepath.open('wb') as fp:
|
|
66
|
+
s_json.dump(data, fp, indent=True)
|
|
67
67
|
|
|
68
68
|
# Return the schema to satisfy fastjsonschema
|
|
69
69
|
return data
|
|
@@ -78,7 +78,7 @@ def download_refs(schema):
|
|
|
78
78
|
|
|
79
79
|
def main(argv):
|
|
80
80
|
with argv.schema.open() as fp:
|
|
81
|
-
schema =
|
|
81
|
+
schema = s_json.load(fp)
|
|
82
82
|
|
|
83
83
|
download_refs(schema)
|
|
84
84
|
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
##############################################################################
|
|
2
|
+
# Taken from the cpython 3.11 source branch after the 3.11.10 release.
|
|
3
|
+
##############################################################################
|
|
4
|
+
import codecs
|
|
5
|
+
|
|
6
|
+
# vendored from:
|
|
7
|
+
# https://github.com/python/cpython/blob/v3.11.10/Lib/json/__init__.py#L244-L271
|
|
8
|
+
def detect_encoding(b):
|
|
9
|
+
bstartswith = b.startswith
|
|
10
|
+
if bstartswith((codecs.BOM_UTF32_BE, codecs.BOM_UTF32_LE)):
|
|
11
|
+
return 'utf-32'
|
|
12
|
+
if bstartswith((codecs.BOM_UTF16_BE, codecs.BOM_UTF16_LE)):
|
|
13
|
+
return 'utf-16'
|
|
14
|
+
if bstartswith(codecs.BOM_UTF8):
|
|
15
|
+
return 'utf-8-sig'
|
|
16
|
+
|
|
17
|
+
if len(b) >= 4:
|
|
18
|
+
if not b[0]:
|
|
19
|
+
# 00 00 -- -- - utf-32-be
|
|
20
|
+
# 00 XX -- -- - utf-16-be
|
|
21
|
+
return 'utf-16-be' if b[1] else 'utf-32-be'
|
|
22
|
+
if not b[1]:
|
|
23
|
+
# XX 00 00 00 - utf-32-le
|
|
24
|
+
# XX 00 00 XX - utf-16-le
|
|
25
|
+
# XX 00 XX -- - utf-16-le
|
|
26
|
+
return 'utf-16-le' if b[2] or b[3] else 'utf-32-le'
|
|
27
|
+
elif len(b) == 2:
|
|
28
|
+
if not b[0]:
|
|
29
|
+
# 00 XX - utf-16-be
|
|
30
|
+
return 'utf-16-be'
|
|
31
|
+
if not b[1]:
|
|
32
|
+
# XX 00 - utf-16-le
|
|
33
|
+
return 'utf-16-le'
|
|
34
|
+
# default
|
|
35
|
+
return 'utf-8'
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
# From the python source, tests/test_json/test_unicode.py does not have a
|
|
2
|
+
# direct test for detect_encoding. It instead tests the various encoding
|
|
3
|
+
# schemes in test_bytes_decode, which uses the detection in json.loads().
|
|
4
|
+
# Since there is not a standalone test to vendor, we have written a simple
|
|
5
|
+
# test on its own.
|
|
6
|
+
|
|
7
|
+
import synapse.vendor.cpython.lib.json as v_json
|
|
8
|
+
|
|
9
|
+
import synapse.vendor.utils as s_v_utils
|
|
10
|
+
|
|
11
|
+
class JsonVendorTest(s_v_utils.VendorTest):
|
|
12
|
+
def test_json_detect_encoding(self):
|
|
13
|
+
|
|
14
|
+
ENCODINGS = (
|
|
15
|
+
'utf-8', 'utf-8-sig',
|
|
16
|
+
'utf-16', 'utf-16-le', 'utf-16-be',
|
|
17
|
+
'utf-32', 'utf-32-le', 'utf-32-be',
|
|
18
|
+
)
|
|
19
|
+
|
|
20
|
+
for encoding in ENCODINGS:
|
|
21
|
+
self.assertEqual(encoding, v_json.detect_encoding('a'.encode(encoding)))
|
|
22
|
+
self.assertEqual(encoding, v_json.detect_encoding('ab'.encode(encoding)))
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.2
|
|
2
2
|
Name: synapse
|
|
3
|
-
Version: 2.
|
|
3
|
+
Version: 2.203.0
|
|
4
4
|
Summary: Synapse Intelligence Analysis Framework
|
|
5
5
|
Author-email: The Vertex Project LLC <root@vertex.link>
|
|
6
6
|
License: Apache License 2.0
|
|
@@ -50,6 +50,7 @@ Requires-Dist: idna<3.8,>=3.6
|
|
|
50
50
|
Requires-Dist: python-dateutil<3.0,>=2.8
|
|
51
51
|
Requires-Dist: pytz<2024.1,>=2023.3
|
|
52
52
|
Requires-Dist: beautifulsoup4[html5lib]<5.0,>=4.11.1
|
|
53
|
+
Requires-Dist: orjson<4.0,>=3.10.15
|
|
53
54
|
Provides-Extra: dev
|
|
54
55
|
Requires-Dist: pytest<8.0.0,>=7.2.0; extra == "dev"
|
|
55
56
|
Requires-Dist: autopep8<3.0.0,>=2.0.4; extra == "dev"
|