synapse 2.164.0__py311-none-any.whl → 2.166.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 +3 -3
- synapse/cmds/cortex.py +1 -6
- synapse/common.py +7 -1
- synapse/cortex.py +145 -192
- synapse/datamodel.py +36 -1
- synapse/lib/agenda.py +87 -97
- synapse/lib/aha.py +51 -0
- synapse/lib/ast.py +22 -23
- synapse/lib/base.py +0 -6
- synapse/lib/boss.py +3 -0
- synapse/lib/cell.py +70 -39
- synapse/lib/certdir.py +9 -0
- synapse/lib/hiveauth.py +65 -12
- synapse/lib/httpapi.py +1 -0
- synapse/lib/modelrev.py +121 -33
- synapse/lib/modules.py +1 -0
- synapse/lib/nexus.py +64 -26
- synapse/lib/parser.py +2 -0
- synapse/lib/schemas.py +14 -0
- synapse/lib/snap.py +50 -4
- synapse/lib/storm.lark +4 -3
- synapse/lib/storm.py +96 -22
- synapse/lib/storm_format.py +1 -0
- synapse/lib/stormlib/aha.py +7 -1
- synapse/lib/stormlib/auth.py +13 -5
- synapse/lib/stormlib/cache.py +202 -0
- synapse/lib/stormlib/cortex.py +147 -8
- synapse/lib/stormlib/gen.py +53 -6
- synapse/lib/stormlib/math.py +1 -1
- synapse/lib/stormlib/model.py +11 -1
- synapse/lib/stormlib/spooled.py +109 -0
- synapse/lib/stormlib/vault.py +1 -1
- synapse/lib/stormtypes.py +113 -17
- synapse/lib/trigger.py +36 -47
- synapse/lib/types.py +29 -2
- synapse/lib/version.py +2 -2
- synapse/lib/view.py +80 -53
- synapse/models/economic.py +174 -5
- synapse/models/files.py +2 -0
- synapse/models/inet.py +77 -2
- synapse/models/infotech.py +12 -12
- synapse/models/orgs.py +72 -21
- synapse/models/person.py +40 -11
- synapse/models/risk.py +78 -24
- synapse/models/science.py +102 -0
- synapse/telepath.py +117 -35
- synapse/tests/test_cortex.py +84 -158
- synapse/tests/test_datamodel.py +22 -0
- synapse/tests/test_lib_agenda.py +52 -96
- synapse/tests/test_lib_aha.py +126 -4
- synapse/tests/test_lib_ast.py +412 -6
- synapse/tests/test_lib_cell.py +24 -8
- synapse/tests/test_lib_certdir.py +32 -0
- synapse/tests/test_lib_grammar.py +9 -1
- synapse/tests/test_lib_httpapi.py +0 -1
- synapse/tests/test_lib_jupyter.py +0 -1
- synapse/tests/test_lib_modelrev.py +41 -0
- synapse/tests/test_lib_nexus.py +38 -0
- synapse/tests/test_lib_storm.py +95 -5
- synapse/tests/test_lib_stormlib_cache.py +272 -0
- synapse/tests/test_lib_stormlib_cortex.py +71 -0
- synapse/tests/test_lib_stormlib_gen.py +37 -2
- synapse/tests/test_lib_stormlib_model.py +2 -0
- synapse/tests/test_lib_stormlib_spooled.py +190 -0
- synapse/tests/test_lib_stormlib_vault.py +12 -3
- synapse/tests/test_lib_stormsvc.py +0 -10
- synapse/tests/test_lib_stormtypes.py +60 -8
- synapse/tests/test_lib_trigger.py +20 -2
- synapse/tests/test_lib_types.py +17 -1
- synapse/tests/test_model_economic.py +114 -0
- synapse/tests/test_model_files.py +2 -0
- synapse/tests/test_model_inet.py +73 -1
- synapse/tests/test_model_infotech.py +2 -2
- synapse/tests/test_model_orgs.py +10 -1
- synapse/tests/test_model_risk.py +30 -2
- synapse/tests/test_model_science.py +59 -0
- synapse/tests/test_model_syn.py +0 -1
- synapse/tests/test_telepath.py +30 -7
- synapse/tests/test_tools_modrole.py +81 -0
- synapse/tests/test_tools_moduser.py +105 -0
- synapse/tools/modrole.py +59 -7
- synapse/tools/moduser.py +78 -10
- {synapse-2.164.0.dist-info → synapse-2.166.0.dist-info}/METADATA +2 -2
- {synapse-2.164.0.dist-info → synapse-2.166.0.dist-info}/RECORD +87 -83
- {synapse-2.164.0.dist-info → synapse-2.166.0.dist-info}/WHEEL +1 -1
- synapse/lib/provenance.py +0 -111
- synapse/tests/test_lib_provenance.py +0 -37
- {synapse-2.164.0.dist-info → synapse-2.166.0.dist-info}/LICENSE +0 -0
- {synapse-2.164.0.dist-info → synapse-2.166.0.dist-info}/top_level.txt +0 -0
synapse/lib/provenance.py
DELETED
|
@@ -1,111 +0,0 @@
|
|
|
1
|
-
import hashlib
|
|
2
|
-
import logging
|
|
3
|
-
import pathlib
|
|
4
|
-
import contextlib
|
|
5
|
-
|
|
6
|
-
import synapse.exc as s_exc
|
|
7
|
-
|
|
8
|
-
import synapse.common as s_common
|
|
9
|
-
|
|
10
|
-
import synapse.lib.base as s_base
|
|
11
|
-
import synapse.lib.task as s_task
|
|
12
|
-
import synapse.lib.const as s_const
|
|
13
|
-
import synapse.lib.msgpack as s_msgpack
|
|
14
|
-
import synapse.lib.lmdbslab as s_lmdbslab
|
|
15
|
-
import synapse.lib.slabseqn as s_slabseqn
|
|
16
|
-
|
|
17
|
-
logger = logging.getLogger(__name__)
|
|
18
|
-
|
|
19
|
-
ProvenanceEnabled = True
|
|
20
|
-
ProvenanceStackLimit = 256
|
|
21
|
-
|
|
22
|
-
class _ProvStack:
|
|
23
|
-
def __init__(self):
|
|
24
|
-
# We start with a dummy frame so we don't have to special case an empty stack
|
|
25
|
-
self.provs = [None] # A stack of the provenance info
|
|
26
|
-
self.idens = [(None, True)] # A stack of the iden/written tupls for the prov stack ending in this frame
|
|
27
|
-
|
|
28
|
-
def __len__(self):
|
|
29
|
-
return len(self.provs)
|
|
30
|
-
|
|
31
|
-
def get(self):
|
|
32
|
-
'''
|
|
33
|
-
Returns:
|
|
34
|
-
iden, whether that iden has been written, the provstack info
|
|
35
|
-
'''
|
|
36
|
-
# We add an empty dict for future expansion/info
|
|
37
|
-
iden, written = self.idens[-1]
|
|
38
|
-
return iden, written, ({}, self.provs[1:])
|
|
39
|
-
|
|
40
|
-
def setiden(self, identupl):
|
|
41
|
-
self.idens[-1] = identupl
|
|
42
|
-
|
|
43
|
-
def push(self, typ, **info):
|
|
44
|
-
tuplinfo = tuple((k, info[k]) for k in sorted(info.keys()))
|
|
45
|
-
self.provs.append((typ, tuplinfo))
|
|
46
|
-
self.idens.append((None, True))
|
|
47
|
-
|
|
48
|
-
def pop(self):
|
|
49
|
-
self.provs.pop()
|
|
50
|
-
self.idens.pop()
|
|
51
|
-
|
|
52
|
-
def copy(self):
|
|
53
|
-
newstack = _ProvStack()
|
|
54
|
-
newstack.provs = self.provs[:]
|
|
55
|
-
newstack.idens = self.idens[:]
|
|
56
|
-
return newstack
|
|
57
|
-
|
|
58
|
-
s_task.vardefault('provstack', lambda: _ProvStack())
|
|
59
|
-
|
|
60
|
-
@contextlib.contextmanager
|
|
61
|
-
def claim(typ, **info):
|
|
62
|
-
'''
|
|
63
|
-
Add an entry to the provenance stack for the duration of the context
|
|
64
|
-
'''
|
|
65
|
-
stack = s_task.varget('provstack')
|
|
66
|
-
if len(stack) > ProvenanceStackLimit:
|
|
67
|
-
baseframe = stack.provs[1]
|
|
68
|
-
recent_frames = stack.provs[-6:]
|
|
69
|
-
raise s_exc.RecursionLimitHit(mesg='Hit provenance claim recursion limit',
|
|
70
|
-
type=typ, info=info, baseframe=baseframe, recent_frames=recent_frames)
|
|
71
|
-
|
|
72
|
-
if not ProvenanceEnabled:
|
|
73
|
-
info = {}
|
|
74
|
-
|
|
75
|
-
stack.push(typ, **info)
|
|
76
|
-
|
|
77
|
-
try:
|
|
78
|
-
yield
|
|
79
|
-
finally:
|
|
80
|
-
stack.pop()
|
|
81
|
-
|
|
82
|
-
def reset():
|
|
83
|
-
'''
|
|
84
|
-
Reset the stack to its initial state
|
|
85
|
-
|
|
86
|
-
For testing purposes
|
|
87
|
-
'''
|
|
88
|
-
s_task.varset('provstack', _ProvStack())
|
|
89
|
-
|
|
90
|
-
def dupstack(newtask):
|
|
91
|
-
'''
|
|
92
|
-
Duplicate the current provenance stack onto another task
|
|
93
|
-
'''
|
|
94
|
-
stack = s_task.varget('provstack')
|
|
95
|
-
s_task.varset('provstack', stack.copy(), newtask)
|
|
96
|
-
|
|
97
|
-
def get():
|
|
98
|
-
'''
|
|
99
|
-
Returns:
|
|
100
|
-
A tuple of (stack iden (or None if not set), the current provenance stack)
|
|
101
|
-
'''
|
|
102
|
-
stack = s_task.varget('provstack')
|
|
103
|
-
return stack.get()
|
|
104
|
-
|
|
105
|
-
def setiden(iden, waswritten):
|
|
106
|
-
'''
|
|
107
|
-
Sets the cached stack iden, waswritten for the current provenance stack. We use waswritten to cache whether we've
|
|
108
|
-
written the stack and so we can tell the snap whether to fire a prov:new event
|
|
109
|
-
'''
|
|
110
|
-
stack = s_task.varget('provstack')
|
|
111
|
-
stack.setiden((iden, waswritten))
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import hashlib
|
|
2
|
-
import unittest.mock as mock
|
|
3
|
-
|
|
4
|
-
import synapse.exc as s_exc
|
|
5
|
-
import synapse.common as s_common
|
|
6
|
-
|
|
7
|
-
import synapse.lib.msgpack as s_msgpack
|
|
8
|
-
import synapse.lib.provenance as s_provenance
|
|
9
|
-
|
|
10
|
-
import synapse.tests.utils as s_t_utils
|
|
11
|
-
from synapse.tests.utils import alist
|
|
12
|
-
|
|
13
|
-
class ProvenanceTest(s_t_utils.SynTest):
|
|
14
|
-
|
|
15
|
-
async def test_prov(self):
|
|
16
|
-
|
|
17
|
-
s_provenance.reset()
|
|
18
|
-
|
|
19
|
-
async with self.getTestCore() as real, real.getLocalProxy() as core:
|
|
20
|
-
|
|
21
|
-
# Force recursion exception to be thrown
|
|
22
|
-
|
|
23
|
-
with mock.patch.object(s_provenance, 'ProvenanceStackLimit', 10):
|
|
24
|
-
q = '.created ' + '| uniq' * 20
|
|
25
|
-
with self.raises(s_exc.RecursionLimitHit) as cm:
|
|
26
|
-
await real.nodes(q)
|
|
27
|
-
|
|
28
|
-
self.eq(cm.exception.get('type'), 'stormcmd')
|
|
29
|
-
self.eq(cm.exception.get('info'), {'name': 'uniq'})
|
|
30
|
-
baseframe = cm.exception.get('baseframe')
|
|
31
|
-
name, args = baseframe
|
|
32
|
-
self.eq(name, 'storm')
|
|
33
|
-
self.eq(args[0], ('q', q))
|
|
34
|
-
recent_frames = cm.exception.get('recent_frames')
|
|
35
|
-
self.len(6, recent_frames)
|
|
36
|
-
for frame in recent_frames:
|
|
37
|
-
self.eq(frame, ('stormcmd', (('name', 'uniq'),)))
|
|
File without changes
|
|
File without changes
|