synapse 2.165.0__py311-none-any.whl → 2.167.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 -10
- synapse/cmds/cortex.py +1 -6
- synapse/common.py +6 -0
- synapse/cortex.py +104 -57
- synapse/datamodel.py +32 -0
- synapse/exc.py +1 -0
- synapse/lib/agenda.py +81 -51
- synapse/lib/aha.py +2 -0
- synapse/lib/ast.py +21 -23
- synapse/lib/base.py +11 -10
- synapse/lib/cell.py +24 -24
- synapse/lib/hive.py +11 -0
- synapse/lib/httpapi.py +1 -0
- synapse/lib/nexus.py +3 -2
- synapse/lib/node.py +4 -2
- synapse/lib/schemas.py +3 -1
- synapse/lib/snap.py +50 -0
- synapse/lib/storm.py +19 -17
- synapse/lib/stormlib/aha.py +370 -17
- synapse/lib/stormlib/auth.py +11 -4
- synapse/lib/stormlib/cache.py +202 -0
- synapse/lib/stormlib/cortex.py +69 -7
- synapse/lib/stormlib/macro.py +11 -18
- synapse/lib/stormlib/spooled.py +109 -0
- synapse/lib/stormlib/stix.py +1 -1
- synapse/lib/stormtypes.py +61 -17
- synapse/lib/trigger.py +10 -12
- synapse/lib/types.py +3 -1
- synapse/lib/version.py +2 -2
- synapse/lib/view.py +16 -3
- synapse/models/base.py +8 -0
- synapse/models/files.py +3 -0
- synapse/models/inet.py +74 -2
- synapse/models/orgs.py +52 -8
- synapse/models/person.py +30 -11
- synapse/models/risk.py +44 -3
- synapse/telepath.py +115 -32
- synapse/tests/files/stormpkg/dotstorm/dotstorm.yaml +3 -0
- synapse/tests/test_cortex.py +79 -8
- synapse/tests/test_datamodel.py +22 -0
- synapse/tests/test_lib_agenda.py +8 -1
- synapse/tests/test_lib_aha.py +19 -6
- synapse/tests/test_lib_cell.py +6 -2
- synapse/tests/test_lib_grammar.py +62 -64
- synapse/tests/test_lib_httpapi.py +1 -1
- synapse/tests/test_lib_rstorm.py +4 -4
- synapse/tests/test_lib_storm.py +98 -7
- synapse/tests/test_lib_stormlib_aha.py +196 -0
- synapse/tests/test_lib_stormlib_cache.py +272 -0
- synapse/tests/test_lib_stormlib_compression.py +12 -12
- synapse/tests/test_lib_stormlib_cortex.py +71 -0
- synapse/tests/test_lib_stormlib_macro.py +94 -0
- synapse/tests/test_lib_stormlib_spooled.py +190 -0
- synapse/tests/test_lib_stormtypes.py +71 -37
- synapse/tests/test_lib_view.py +50 -3
- synapse/tests/test_model_files.py +3 -0
- synapse/tests/test_model_inet.py +67 -0
- synapse/tests/test_model_risk.py +6 -0
- synapse/tests/test_telepath.py +30 -7
- synapse/tests/test_tools_genpkg.py +26 -0
- synapse/tests/test_tools_hiveload.py +1 -0
- synapse/tests/test_tools_hivesave.py +1 -0
- synapse/tests/test_tools_modrole.py +81 -0
- synapse/tests/test_tools_moduser.py +105 -0
- synapse/tests/utils.py +22 -3
- synapse/tools/autodoc.py +1 -1
- synapse/tools/hive/load.py +3 -0
- synapse/tools/hive/save.py +3 -0
- synapse/tools/modrole.py +59 -7
- synapse/tools/moduser.py +78 -10
- {synapse-2.165.0.dist-info → synapse-2.167.0.dist-info}/METADATA +3 -3
- {synapse-2.165.0.dist-info → synapse-2.167.0.dist-info}/RECORD +75 -72
- synapse/lib/provenance.py +0 -111
- synapse/tests/test_lib_provenance.py +0 -37
- {synapse-2.165.0.dist-info → synapse-2.167.0.dist-info}/LICENSE +0 -0
- {synapse-2.165.0.dist-info → synapse-2.167.0.dist-info}/WHEEL +0 -0
- {synapse-2.165.0.dist-info → synapse-2.167.0.dist-info}/top_level.txt +0 -0
synapse/tools/modrole.py
CHANGED
|
@@ -11,15 +11,34 @@ descr = '''
|
|
|
11
11
|
Add or modify a role in a Synapse service.
|
|
12
12
|
'''
|
|
13
13
|
|
|
14
|
+
def printrole(role, outp):
|
|
15
|
+
|
|
16
|
+
outp.printf(f'Role: {role.get("name")} ({role.get("iden")})')
|
|
17
|
+
outp.printf('')
|
|
18
|
+
outp.printf(' Rules:')
|
|
19
|
+
for indx, rule in enumerate(role.get('rules')):
|
|
20
|
+
outp.printf(f' [{str(indx).ljust(3)}] - {s_common.reprauthrule(rule)}')
|
|
21
|
+
|
|
22
|
+
outp.printf('')
|
|
23
|
+
outp.printf(' Gates:')
|
|
24
|
+
for gateiden, gateinfo in role.get('authgates', {}).items():
|
|
25
|
+
outp.printf(f' {gateiden}')
|
|
26
|
+
outp.printf(f' Admin: {gateinfo.get("admin") == True}')
|
|
27
|
+
for indx, rule in enumerate(gateinfo.get('rules', ())):
|
|
28
|
+
outp.printf(f' [{str(indx).ljust(3)}] - {s_common.reprauthrule(rule)}')
|
|
29
|
+
|
|
14
30
|
async def main(argv, outp=s_output.stdout):
|
|
15
31
|
|
|
16
32
|
pars = argparse.ArgumentParser(prog='modrole', description=descr)
|
|
17
33
|
pars.add_argument('--svcurl', default='cell:///vertex/storage', help='The telepath URL of the Synapse service.')
|
|
18
34
|
pars.add_argument('--add', default=False, action='store_true', help='Add the role if they do not already exist.')
|
|
19
35
|
pars.add_argument('--del', dest='delete', default=False, action='store_true', help='Delete the role if it exists.')
|
|
36
|
+
pars.add_argument('--list', default=False, action='store_true',
|
|
37
|
+
help='List existing roles, or rules of a specific role.')
|
|
20
38
|
pars.add_argument('--allow', default=[], action='append', help='A permission string to allow for the role.')
|
|
21
39
|
pars.add_argument('--deny', default=[], action='append', help='A permission string to deny for the role.')
|
|
22
|
-
pars.add_argument('
|
|
40
|
+
pars.add_argument('--gate', default=None, help='The iden of an auth gate to add/del rules on.')
|
|
41
|
+
pars.add_argument('rolename', nargs='?', help='The rolename to add/edit.')
|
|
23
42
|
|
|
24
43
|
opts = pars.parse_args(argv)
|
|
25
44
|
|
|
@@ -31,6 +50,31 @@ async def main(argv, outp=s_output.stdout):
|
|
|
31
50
|
|
|
32
51
|
async with await s_telepath.openurl(opts.svcurl) as cell:
|
|
33
52
|
|
|
53
|
+
if opts.list:
|
|
54
|
+
if opts.rolename:
|
|
55
|
+
role = await cell.getRoleDefByName(opts.rolename)
|
|
56
|
+
if role is None:
|
|
57
|
+
outp.printf(f'ERROR: Role not found: {opts.rolename}')
|
|
58
|
+
return 1
|
|
59
|
+
|
|
60
|
+
printrole(role, outp)
|
|
61
|
+
|
|
62
|
+
else:
|
|
63
|
+
outp.printf('Roles:')
|
|
64
|
+
for role in await cell.getRoleDefs():
|
|
65
|
+
outp.printf(f' {role.get("iden")} - {role.get("name")}')
|
|
66
|
+
|
|
67
|
+
return 0
|
|
68
|
+
elif opts.rolename is None:
|
|
69
|
+
outp.printf(f'ERROR: A rolename argument is required when --list is not specified.')
|
|
70
|
+
return 1
|
|
71
|
+
|
|
72
|
+
if opts.gate:
|
|
73
|
+
gate = await cell.getAuthGate(opts.gate)
|
|
74
|
+
if gate is None:
|
|
75
|
+
outp.printf(f'ERROR: No auth gate found with iden: {opts.gate}')
|
|
76
|
+
return 1
|
|
77
|
+
|
|
34
78
|
role = await cell.getRoleDefByName(opts.rolename)
|
|
35
79
|
if role is not None:
|
|
36
80
|
outp.printf(f'Modifying role: {opts.rolename}')
|
|
@@ -52,15 +96,23 @@ async def main(argv, outp=s_output.stdout):
|
|
|
52
96
|
|
|
53
97
|
for allow in opts.allow:
|
|
54
98
|
perm = allow.lower().split('.')
|
|
55
|
-
|
|
56
|
-
if
|
|
57
|
-
|
|
99
|
+
mesg = f'...adding allow rule: {allow}'
|
|
100
|
+
if opts.gate:
|
|
101
|
+
mesg += f' on gate {opts.gate}'
|
|
102
|
+
|
|
103
|
+
outp.printf(mesg)
|
|
104
|
+
if not await cell.isRoleAllowed(roleiden, perm, gateiden=opts.gate):
|
|
105
|
+
await cell.addRoleRule(roleiden, (True, perm), indx=0, gateiden=opts.gate)
|
|
58
106
|
|
|
59
107
|
for deny in opts.deny:
|
|
60
108
|
perm = deny.lower().split('.')
|
|
61
|
-
|
|
62
|
-
if
|
|
63
|
-
|
|
109
|
+
mesg = f'...adding deny rule: {deny}'
|
|
110
|
+
if opts.gate:
|
|
111
|
+
mesg += f' on gate {opts.gate}'
|
|
112
|
+
|
|
113
|
+
outp.printf(mesg)
|
|
114
|
+
if await cell.isRoleAllowed(roleiden, perm, gateiden=opts.gate):
|
|
115
|
+
await cell.addRoleRule(roleiden, (False, perm), indx=0, gateiden=opts.gate)
|
|
64
116
|
return 0
|
|
65
117
|
|
|
66
118
|
if __name__ == '__main__': # pragma: no cover
|
synapse/tools/moduser.py
CHANGED
|
@@ -9,15 +9,44 @@ import synapse.telepath as s_telepath
|
|
|
9
9
|
import synapse.lib.output as s_output
|
|
10
10
|
|
|
11
11
|
descr = '''
|
|
12
|
-
Add or
|
|
12
|
+
Add, modify, or list users of a Synapse service.
|
|
13
13
|
'''
|
|
14
14
|
|
|
15
|
+
def printuser(user, outp):
|
|
16
|
+
|
|
17
|
+
admin = user.get('admin')
|
|
18
|
+
authtype = user.get('type')
|
|
19
|
+
|
|
20
|
+
outp.printf(f'User: {user.get("name")} ({user.get("iden")})')
|
|
21
|
+
outp.printf('')
|
|
22
|
+
outp.printf(f' Locked: {user.get("locked")}')
|
|
23
|
+
outp.printf(f' Admin: {user.get("admin")}')
|
|
24
|
+
outp.printf(f' Email: {user.get("email")}')
|
|
25
|
+
outp.printf(' Rules:')
|
|
26
|
+
for indx, rule in enumerate(user.get('rules')):
|
|
27
|
+
outp.printf(f' [{str(indx).ljust(3)}] - {s_common.reprauthrule(rule)}')
|
|
28
|
+
|
|
29
|
+
outp.printf('')
|
|
30
|
+
outp.printf(' Roles:')
|
|
31
|
+
for role in user.get('roles'):
|
|
32
|
+
outp.printf(f' {role.get("iden")} - {role.get("name")}')
|
|
33
|
+
|
|
34
|
+
outp.printf('')
|
|
35
|
+
outp.printf(' Gates:')
|
|
36
|
+
for gateiden, gateinfo in user.get('authgates', {}).items():
|
|
37
|
+
outp.printf(f' {gateiden}')
|
|
38
|
+
outp.printf(f' Admin: {gateinfo.get("admin") == True}')
|
|
39
|
+
for indx, rule in enumerate(gateinfo.get('rules', ())):
|
|
40
|
+
outp.printf(f' [{str(indx).ljust(3)}] - {s_common.reprauthrule(rule)}')
|
|
41
|
+
|
|
15
42
|
async def main(argv, outp=s_output.stdout):
|
|
16
43
|
|
|
17
44
|
pars = argparse.ArgumentParser(prog='moduser', description=descr)
|
|
18
45
|
pars.add_argument('--svcurl', default='cell:///vertex/storage', help='The telepath URL of the Synapse service.')
|
|
19
46
|
pars.add_argument('--add', default=False, action='store_true', help='Add the user if they do not already exist.')
|
|
20
47
|
pars.add_argument('--del', dest='delete', default=False, action='store_true', help='Delete the user if they exist.')
|
|
48
|
+
pars.add_argument('--list', default=False, action='store_true',
|
|
49
|
+
help='List existing users of the service, or details of a specific user.')
|
|
21
50
|
pars.add_argument('--admin', choices=('true', 'false'), default=None, help='Set the user admin status.')
|
|
22
51
|
pars.add_argument('--passwd', action='store', type=str, help='A password to set for the user.')
|
|
23
52
|
pars.add_argument('--email', action='store', type=str, help='An email to set for the user.')
|
|
@@ -26,7 +55,8 @@ async def main(argv, outp=s_output.stdout):
|
|
|
26
55
|
pars.add_argument('--revoke', default=[], action='append', help='A role to revoke from the user.')
|
|
27
56
|
pars.add_argument('--allow', default=[], action='append', help='A permission string to allow for the user.')
|
|
28
57
|
pars.add_argument('--deny', default=[], action='append', help='A permission string to deny for the user.')
|
|
29
|
-
pars.add_argument('
|
|
58
|
+
pars.add_argument('--gate', default=None, help='The iden of an auth gate to add/del rules or set admin status on.')
|
|
59
|
+
pars.add_argument('username', nargs='?', help='The username to add/edit or show details.')
|
|
30
60
|
|
|
31
61
|
opts = pars.parse_args(argv)
|
|
32
62
|
|
|
@@ -38,6 +68,32 @@ async def main(argv, outp=s_output.stdout):
|
|
|
38
68
|
|
|
39
69
|
async with await s_telepath.openurl(opts.svcurl) as cell:
|
|
40
70
|
|
|
71
|
+
if opts.list:
|
|
72
|
+
if opts.username:
|
|
73
|
+
user = await cell.getUserDefByName(opts.username)
|
|
74
|
+
if user is None:
|
|
75
|
+
outp.printf(f'ERROR: User not found: {opts.username}')
|
|
76
|
+
return 1
|
|
77
|
+
|
|
78
|
+
printuser(user, outp)
|
|
79
|
+
|
|
80
|
+
else:
|
|
81
|
+
outp.printf('Users:')
|
|
82
|
+
for user in await cell.getUserDefs():
|
|
83
|
+
outp.printf(f' {user.get("name")}')
|
|
84
|
+
|
|
85
|
+
return 0
|
|
86
|
+
|
|
87
|
+
elif opts.username is None:
|
|
88
|
+
outp.printf(f'ERROR: A username argument is required when --list is not specified.')
|
|
89
|
+
return 1
|
|
90
|
+
|
|
91
|
+
if opts.gate:
|
|
92
|
+
gate = await cell.getAuthGate(opts.gate)
|
|
93
|
+
if gate is None:
|
|
94
|
+
outp.printf(f'ERROR: No auth gate found with iden: {opts.gate}')
|
|
95
|
+
return 1
|
|
96
|
+
|
|
41
97
|
grants = []
|
|
42
98
|
revokes = []
|
|
43
99
|
|
|
@@ -80,8 +136,12 @@ async def main(argv, outp=s_output.stdout):
|
|
|
80
136
|
|
|
81
137
|
if opts.admin is not None:
|
|
82
138
|
admin = s_common.yamlloads(opts.admin)
|
|
83
|
-
|
|
84
|
-
|
|
139
|
+
mesg = f'...setting admin: {opts.admin}'
|
|
140
|
+
if opts.gate:
|
|
141
|
+
mesg += f' on gate {opts.gate}'
|
|
142
|
+
|
|
143
|
+
outp.printf(mesg)
|
|
144
|
+
await cell.setUserAdmin(useriden, admin, gateiden=opts.gate)
|
|
85
145
|
|
|
86
146
|
if opts.locked is not None:
|
|
87
147
|
locked = s_common.yamlloads(opts.locked)
|
|
@@ -108,15 +168,23 @@ async def main(argv, outp=s_output.stdout):
|
|
|
108
168
|
|
|
109
169
|
for allow in opts.allow:
|
|
110
170
|
perm = allow.lower().split('.')
|
|
111
|
-
|
|
112
|
-
if
|
|
113
|
-
|
|
171
|
+
mesg = f'...adding allow rule: {allow}'
|
|
172
|
+
if opts.gate:
|
|
173
|
+
mesg += f' on gate {opts.gate}'
|
|
174
|
+
|
|
175
|
+
outp.printf(mesg)
|
|
176
|
+
if not await cell.isUserAllowed(useriden, perm, gateiden=opts.gate):
|
|
177
|
+
await cell.addUserRule(useriden, (True, perm), indx=0, gateiden=opts.gate)
|
|
114
178
|
|
|
115
179
|
for deny in opts.deny:
|
|
116
180
|
perm = deny.lower().split('.')
|
|
117
|
-
|
|
118
|
-
if
|
|
119
|
-
|
|
181
|
+
mesg = f'...adding deny rule: {deny}'
|
|
182
|
+
if opts.gate:
|
|
183
|
+
mesg += f' on gate {opts.gate}'
|
|
184
|
+
|
|
185
|
+
outp.printf(mesg)
|
|
186
|
+
if await cell.isUserAllowed(useriden, perm, gateiden=opts.gate):
|
|
187
|
+
await cell.addUserRule(useriden, (False, perm), indx=0, gateiden=opts.gate)
|
|
120
188
|
return 0
|
|
121
189
|
|
|
122
190
|
if __name__ == '__main__': # pragma: no cover
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: synapse
|
|
3
|
-
Version: 2.
|
|
3
|
+
Version: 2.167.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
|
|
@@ -36,7 +36,7 @@ Requires-Dist: lark ==1.1.9
|
|
|
36
36
|
Requires-Dist: Pygments <2.18.0,>=2.7.4
|
|
37
37
|
Requires-Dist: packaging <24.0,>=20.0
|
|
38
38
|
Requires-Dist: fastjsonschema <2.20.0,>=2.18.0
|
|
39
|
-
Requires-Dist: stix2-validator <4.0.0,>=3.
|
|
39
|
+
Requires-Dist: stix2-validator <4.0.0,>=3.2.0
|
|
40
40
|
Requires-Dist: vcrpy <5.2.0,>=4.3.1
|
|
41
41
|
Requires-Dist: base58 <2.2.0,>=2.1.0
|
|
42
42
|
Requires-Dist: python-bitcoinlib <0.13.0,>=0.11.0
|
|
@@ -46,7 +46,7 @@ Requires-Dist: scalecodec <1.3.0,>=1.0.2
|
|
|
46
46
|
Requires-Dist: cbor2 <5.7.0,>=5.4.1
|
|
47
47
|
Requires-Dist: bech32 ==1.2.0
|
|
48
48
|
Requires-Dist: oauthlib <4.0.0,>=3.2.1
|
|
49
|
-
Requires-Dist: idna <3.
|
|
49
|
+
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
|