synapse 2.171.0__py311-none-any.whl → 2.172.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.

Files changed (52) hide show
  1. synapse/common.py +20 -0
  2. synapse/cortex.py +86 -4
  3. synapse/lib/agenda.py +13 -7
  4. synapse/lib/ast.py +9 -8
  5. synapse/lib/cache.py +2 -2
  6. synapse/lib/cell.py +5 -0
  7. synapse/lib/coro.py +12 -0
  8. synapse/lib/layer.py +124 -84
  9. synapse/lib/lmdbslab.py +17 -10
  10. synapse/lib/node.py +1 -1
  11. synapse/lib/slabseqn.py +11 -5
  12. synapse/lib/storm.py +7 -71
  13. synapse/lib/stormhttp.py +1 -1
  14. synapse/lib/stormlib/auth.py +19 -0
  15. synapse/lib/stormlib/cell.py +42 -4
  16. synapse/lib/stormlib/compression.py +6 -6
  17. synapse/lib/stormlib/env.py +50 -0
  18. synapse/lib/stormlib/gen.py +1 -1
  19. synapse/lib/stormlib/model.py +1 -1
  20. synapse/lib/stormtypes.py +35 -11
  21. synapse/lib/types.py +6 -6
  22. synapse/lib/version.py +2 -2
  23. synapse/lib/view.py +6 -12
  24. synapse/models/base.py +13 -0
  25. synapse/models/biz.py +14 -0
  26. synapse/models/economic.py +3 -0
  27. synapse/models/inet.py +474 -4
  28. synapse/models/infotech.py +163 -22
  29. synapse/models/orgs.py +17 -0
  30. synapse/models/risk.py +15 -1
  31. synapse/models/transport.py +1 -1
  32. synapse/tests/test_common.py +15 -0
  33. synapse/tests/test_lib_ast.py +2 -1
  34. synapse/tests/test_lib_layer.py +168 -59
  35. synapse/tests/test_lib_lmdbslab.py +13 -0
  36. synapse/tests/test_lib_stormlib_auth.py +22 -0
  37. synapse/tests/test_lib_stormlib_cell.py +47 -0
  38. synapse/tests/test_lib_stormlib_env.py +25 -0
  39. synapse/tests/test_lib_view.py +9 -9
  40. synapse/tests/test_model_base.py +5 -3
  41. synapse/tests/test_model_economic.py +4 -0
  42. synapse/tests/test_model_inet.py +405 -1
  43. synapse/tests/test_model_infotech.py +135 -3
  44. synapse/tests/test_model_orgs.py +6 -0
  45. synapse/tests/test_model_risk.py +8 -0
  46. synapse/tests/test_tools_storm.py +46 -8
  47. synapse/tools/storm.py +14 -6
  48. {synapse-2.171.0.dist-info → synapse-2.172.0.dist-info}/METADATA +1 -1
  49. {synapse-2.171.0.dist-info → synapse-2.172.0.dist-info}/RECORD +52 -50
  50. {synapse-2.171.0.dist-info → synapse-2.172.0.dist-info}/WHEEL +1 -1
  51. {synapse-2.171.0.dist-info → synapse-2.172.0.dist-info}/LICENSE +0 -0
  52. {synapse-2.171.0.dist-info → synapse-2.172.0.dist-info}/top_level.txt +0 -0
@@ -622,12 +622,15 @@ class ItModule(s_module.CoreModule):
622
622
  }),
623
623
  ),
624
624
  'types': (
625
+
625
626
  ('it:hostname', ('str', {'strip': True, 'lower': True}), {
626
- 'doc': 'The name of a host or system.',
627
- }),
627
+ 'doc': 'The name of a host or system.'}),
628
+
629
+
628
630
  ('it:host', ('guid', {}), {
629
- 'doc': 'A GUID that represents a host or system.'
630
- }),
631
+ 'interfaces': ('inet:service:object',),
632
+ 'doc': 'A GUID that represents a host or system.'}),
633
+
631
634
  ('it:log:event:type:taxonomy', ('taxonomy', {}), {
632
635
  'doc': 'A taxonomy of log event types.',
633
636
  'interfaces': ('meta:taxonomy',),
@@ -637,8 +640,12 @@ class ItModule(s_module.CoreModule):
637
640
  'interfaces': ('it:host:activity',),
638
641
  }),
639
642
  ('it:network', ('guid', {}), {
640
- 'doc': 'A GUID that represents a logical network.'
641
- }),
643
+ 'doc': 'A GUID that represents a logical network.'}),
644
+
645
+ ('it:network:type:taxonomy', ('taxonomy', {}), {
646
+ 'interfaces': ('meta:taxonomy',),
647
+ 'doc': 'A taxonomy of network types.'}),
648
+
642
649
  ('it:domain', ('guid', {}), {
643
650
  'doc': 'A logical boundary of authentication and configuration such as a windows domain.'
644
651
  }),
@@ -902,8 +909,14 @@ class ItModule(s_module.CoreModule):
902
909
  }),
903
910
  ('it:cmd', ('str', {'strip': True}), {
904
911
  'doc': 'A unique command-line string.',
905
- 'ex': 'foo.exe --dostuff bar',
906
- }),
912
+ 'ex': 'foo.exe --dostuff bar'}),
913
+
914
+ ('it:cmd:session', ('guid', {}), {
915
+ 'doc': 'A command line session with multiple commands run over time.'}),
916
+
917
+ ('it:cmd:history', ('guid', {}), {
918
+ 'doc': 'A single command executed within a session.'}),
919
+
907
920
  ('it:query', ('str', {'strip': True}), {
908
921
  'doc': 'A unique query string.',
909
922
  }),
@@ -994,6 +1007,30 @@ class ItModule(s_module.CoreModule):
994
1007
  }),
995
1008
  ('it:sec:c2:config', ('guid', {}), {
996
1009
  'doc': 'An extracted C2 config from an executable.'}),
1010
+
1011
+ ('it:host:tenancy', ('guid', {}), {
1012
+ 'interfaces': ('inet:service:object',),
1013
+ 'doc': 'A time window where a host was a tenant run by another host.'}),
1014
+
1015
+ ('it:software:image:type:taxonomy', ('taxonomy', {}), {
1016
+ 'interfaces': ('meta:taxonomy',),
1017
+ 'doc': 'A taxonomy of software image types.'}),
1018
+
1019
+ ('it:software:image', ('guid', {}), {
1020
+ 'interfaces': ('inet:service:object',),
1021
+ 'doc': 'The base image used to create a container or OS.'}),
1022
+
1023
+ ('it:storage:mount', ('guid', {}), {
1024
+ 'doc': 'A storage volume that has been attached to an image.'}),
1025
+
1026
+ ('it:storage:volume', ('guid', {}), {
1027
+ 'doc': 'A physical or logical storage volume that can be attached to a physical/virtual machine or container.'}),
1028
+
1029
+ ('it:storage:volume:type:taxonomy', ('taxonomy', {}), {
1030
+ 'ex': 'network.smb',
1031
+ 'interfaces': ('meta:taxonomy',),
1032
+ 'doc': 'A taxonomy of storage volume types.',
1033
+ }),
997
1034
  ),
998
1035
  'interfaces': (
999
1036
  ('it:host:activity', {
@@ -1060,11 +1097,11 @@ class ItModule(s_module.CoreModule):
1060
1097
 
1061
1098
  ('manu', ('str', {}), {
1062
1099
  'deprecated': True,
1063
- 'doc': 'Please use :hardware:make.'}),
1100
+ 'doc': 'Please use :hardware::manufacturer:name.'}),
1064
1101
 
1065
1102
  ('model', ('str', {}), {
1066
1103
  'deprecated': True,
1067
- 'doc': 'Please use :hardware:model.'}),
1104
+ 'doc': 'Please use :hardware::model.'}),
1068
1105
 
1069
1106
  ('serial', ('str', {}), {
1070
1107
  'doc': 'The serial number of the host.'}),
@@ -1083,7 +1120,67 @@ class ItModule(s_module.CoreModule):
1083
1120
 
1084
1121
  ('keyboard:language', ('lang:language', {}), {
1085
1122
  'doc': 'The primary keyboard input language configured on the host.'}),
1123
+
1124
+ ('image', ('it:software:image', {}), {
1125
+ 'doc': 'The container image or OS image running on the host.'}),
1126
+ )),
1127
+
1128
+ ('it:host:tenancy', {}, (
1129
+
1130
+ ('lessor', ('it:host', {}), {
1131
+ 'doc': 'The host which provides runtime resources to the tenant host.'}),
1132
+
1133
+ ('tenant', ('it:host', {}), {
1134
+ 'doc': 'The host which is run within the resources provided by the lessor.'}),
1135
+
1136
+ )),
1137
+
1138
+ ('it:software:image', {}, (
1139
+
1140
+ ('name', ('str', {'lower': True, 'onespace': True}), {
1141
+ 'doc': 'The name of the image.'}),
1142
+
1143
+ ('type', ('it:software:image:type:taxonomy', {}), {
1144
+ 'doc': 'The type of software image.'}),
1145
+
1146
+ ('published', ('time', {}), {
1147
+ 'doc': 'The time the image was published.'}),
1148
+
1149
+ ('publisher', ('ps:contact', {}), {
1150
+ 'doc': 'The contact information of the org or person who published the image.'}),
1151
+
1152
+ ('parents', ('array', {'type': 'it:software:image'}), {
1153
+ 'doc': 'An array of parent images in precedence order.'}),
1154
+ )),
1155
+
1156
+ ('it:storage:volume:type:taxonomy', {}, ()),
1157
+ ('it:storage:volume', {}, (
1158
+
1159
+ ('id', ('str', {'strip': True}), {
1160
+ 'doc': 'The unique volume ID.'}),
1161
+
1162
+ ('name', ('str', {'lower': True, 'onespace': True}), {
1163
+ 'doc': 'The name of the volume.'}),
1164
+
1165
+ ('type', ('it:storage:volume:type:taxonomy', {}), {
1166
+ 'doc': 'The type of storage volume.'}),
1167
+
1168
+ ('size', ('int', {'min': 0}), {
1169
+ 'doc': 'The size of the volume in bytes.'}),
1086
1170
  )),
1171
+
1172
+ ('it:storage:mount', {}, (
1173
+
1174
+ ('host', ('it:host', {}), {
1175
+ 'doc': 'The host that has mounted the volume.'}),
1176
+
1177
+ ('volume', ('it:storage:volume', {}), {
1178
+ 'doc': 'The volume that the host has mounted.'}),
1179
+
1180
+ ('path', ('file:path', {}), {
1181
+ 'doc': 'The path where the volume is mounted in the host filesystem.'}),
1182
+ )),
1183
+
1087
1184
  ('it:log:event:type:taxonomy', {}, ()),
1088
1185
  ('it:log:event', {}, (
1089
1186
 
@@ -1118,22 +1215,27 @@ class ItModule(s_module.CoreModule):
1118
1215
  'doc': 'The org that operates the given domain.',
1119
1216
  }),
1120
1217
  )),
1218
+ ('it:network:type:taxonomy', {}, ()),
1121
1219
  ('it:network', {}, (
1220
+
1122
1221
  ('name', ('str', {'lower': True, 'onespace': True}), {
1123
- 'doc': 'The name of the network.',
1124
- }),
1222
+ 'doc': 'The name of the network.'}),
1223
+
1125
1224
  ('desc', ('str', {}), {
1126
- 'doc': 'A brief description of the network.',
1127
- }),
1225
+ 'doc': 'A brief description of the network.'}),
1226
+
1227
+ ('type', ('it:network:type:taxonomy', {}), {
1228
+ 'doc': 'The type of network.'}),
1229
+
1128
1230
  ('org', ('ou:org', {}), {
1129
- 'doc': 'The org that owns/operates the network.',
1130
- }),
1231
+ 'doc': 'The org that owns/operates the network.'}),
1232
+
1131
1233
  ('net4', ('inet:net4', {}), {
1132
- 'doc': 'The optional contiguous IPv4 address range of this network.',
1133
- }),
1234
+ 'doc': 'The optional contiguous IPv4 address range of this network.'}),
1235
+
1134
1236
  ('net6', ('inet:net6', {}), {
1135
- 'doc': 'The optional contiguous IPv6 address range of this network.',
1136
- }),
1237
+ 'doc': 'The optional contiguous IPv6 address range of this network.'}),
1238
+
1137
1239
  )),
1138
1240
  ('it:account', {}, (
1139
1241
  ('user', ('inet:user', {}), {
@@ -2275,6 +2377,34 @@ class ItModule(s_module.CoreModule):
2275
2377
  }),
2276
2378
  )),
2277
2379
  ('it:cmd', {}, ()),
2380
+ ('it:cmd:session', {}, (
2381
+
2382
+ ('host', ('it:host', {}), {
2383
+ 'doc': 'The host where the command line session was executed.'}),
2384
+
2385
+ ('proc', ('it:exec:proc', {}), {
2386
+ 'doc': 'The process which was interpreting this command line session.'}),
2387
+
2388
+ ('period', ('ival', {}), {
2389
+ 'doc': 'The period over which the command line session was running.'}),
2390
+
2391
+ ('file', ('file:bytes', {}), {
2392
+ 'doc': 'The file containing the command history such as a .bash_history file.'}),
2393
+ )),
2394
+ ('it:cmd:history', {}, (
2395
+
2396
+ ('cmd', ('it:cmd', {}), {
2397
+ 'doc': 'The command that was executed.'}),
2398
+
2399
+ ('session', ('it:cmd:session', {}), {
2400
+ 'doc': 'The session that contains this history entry.'}),
2401
+
2402
+ ('time', ('time', {}), {
2403
+ 'doc': 'The time that the command was executed.'}),
2404
+
2405
+ ('index', ('int', {}), {
2406
+ 'doc': 'Used to order the commands when times are not available.'}),
2407
+ )),
2278
2408
  ('it:exec:proc', {}, (
2279
2409
  ('host', ('it:host', {}), {
2280
2410
  'doc': 'The host that executed the process. May be an actual or a virtual / notional host.',
@@ -2283,9 +2413,12 @@ class ItModule(s_module.CoreModule):
2283
2413
  'doc': 'The file considered the "main" executable for the process. For example, rundll32.exe may be considered the "main" executable for DLLs loaded by that program.',
2284
2414
  }),
2285
2415
  ('cmd', ('it:cmd', {}), {
2286
- 'doc': 'The command string used to launch the process, including any command line parameters.',
2287
2416
  'disp': {'hint': 'text'},
2288
- }),
2417
+ 'doc': 'The command string used to launch the process, including any command line parameters.'}),
2418
+
2419
+ ('cmd:history', ('it:cmd:history', {}), {
2420
+ 'doc': 'The command history entry which caused this process to be run.'}),
2421
+
2289
2422
  ('pid', ('int', {}), {
2290
2423
  'doc': 'The process ID.',
2291
2424
  }),
@@ -2330,16 +2463,24 @@ class ItModule(s_module.CoreModule):
2330
2463
  )),
2331
2464
  ('it:query', {}, ()),
2332
2465
  ('it:exec:query', {}, (
2466
+
2333
2467
  ('text', ('it:query', {}), {
2334
2468
  'doc': 'The query string that was executed.'}),
2469
+
2335
2470
  ('opts', ('data', {}), {
2336
2471
  'doc': 'An opaque JSON object containing query parameters and options.'}),
2472
+
2337
2473
  ('api:url', ('inet:url', {}), {
2338
2474
  'doc': 'The URL of the API endpoint the query was sent to.'}),
2475
+
2339
2476
  ('language', ('str', {'lower': True, 'onespace': True}), {
2340
2477
  'doc': 'The name of the language that the query is expressed in.'}),
2478
+
2341
2479
  ('offset', ('int', {}), {
2342
2480
  'doc': 'The offset of the last record consumed from the query.'}),
2481
+
2482
+ ('synuser', ('syn:user', {}), {
2483
+ 'doc': 'The synapse user who executed the query.'}),
2343
2484
  )),
2344
2485
  ('it:exec:thread', {}, (
2345
2486
  ('proc', ('it:exec:proc', {}), {
synapse/models/orgs.py CHANGED
@@ -560,6 +560,9 @@ class OuModule(s_module.CoreModule):
560
560
 
561
561
  ('mitre:attack:campaign', ('it:mitre:attack:campaign', {}), {
562
562
  'doc': 'A mapping to a MITRE ATT&CK campaign if applicable.'}),
563
+
564
+ ('ext:id', ('str', {'strip': True}), {
565
+ 'doc': 'An external identifier for the campaign.'}),
563
566
  )),
564
567
  ('ou:conflict', {}, (
565
568
  ('name', ('str', {'onespace': True}), {
@@ -594,23 +597,34 @@ class OuModule(s_module.CoreModule):
594
597
  'doc': 'Title or designation for the contributed personnel.'}),
595
598
  )),
596
599
  ('ou:technique', {}, (
600
+
597
601
  ('name', ('str', {'lower': True, 'onespace': True}), {
598
602
  'doc': 'The normalized name of the technique.'}),
603
+
599
604
  ('type', ('ou:technique:taxonomy', {}), {
600
605
  'doc': 'The taxonomy classification of the technique.'}),
606
+
601
607
  ('sophistication', ('meta:sophistication', {}), {
602
608
  'doc': 'The assessed sophistication of the technique.'}),
609
+
603
610
  ('desc', ('str', {}), {
604
611
  'disp': {'hint': 'text'},
605
612
  'doc': 'A description of the technique.'}),
613
+
606
614
  ('tag', ('syn:tag', {}), {
607
615
  'doc': 'The tag used to annotate nodes where the technique was employed.'}),
616
+
608
617
  ('mitre:attack:technique', ('it:mitre:attack:technique', {}), {
609
618
  'doc': 'A mapping to a MITRE ATT&CK technique if applicable.'}),
619
+
610
620
  ('reporter', ('ou:org', {}), {
611
621
  'doc': 'The organization reporting on the technique.'}),
622
+
612
623
  ('reporter:name', ('ou:name', {}), {
613
624
  'doc': 'The name of the organization reporting on the technique.'}),
625
+
626
+ ('ext:id', ('str', {'strip': True}), {
627
+ 'doc': 'An external identifier for the technique.'}),
614
628
  )),
615
629
  ('ou:technique:taxonomy', {}, ()),
616
630
  ('ou:orgtype', {}, ()),
@@ -699,6 +713,9 @@ class OuModule(s_module.CoreModule):
699
713
 
700
714
  ('tag', ('syn:tag', {}), {
701
715
  'doc': 'A base tag used to encode assessments made by the organization.'}),
716
+
717
+ ('ext:id', ('str', {'strip': True}), {
718
+ 'doc': 'An external identifier for the organization.'}),
702
719
  )),
703
720
  ('ou:team', {}, (
704
721
  ('org', ('ou:org', {}), {}),
synapse/models/risk.py CHANGED
@@ -278,6 +278,9 @@ class RiskModule(s_module.CoreModule):
278
278
 
279
279
  ('mitre:attack:group', ('it:mitre:attack:group', {}), {
280
280
  'doc': 'A mapping to a MITRE ATT&CK group if applicable.'}),
281
+
282
+ ('ext:id', ('str', {'strip': True}), {
283
+ 'doc': 'An external identifier for the threat.'}),
281
284
  )),
282
285
  ('risk:availability', {}, {}),
283
286
  ('risk:tool:software:taxonomy', {}, ()),
@@ -978,7 +981,13 @@ class RiskModule(s_module.CoreModule):
978
981
  'doc': 'The URL where the leaked information was made publicly available.'}),
979
982
 
980
983
  ('size:bytes', ('int', {'min': 0}), {
981
- 'doc': 'The approximate uncompressed size of the total data leaked.'}),
984
+ 'doc': 'The total size of the leaked data in bytes.'}),
985
+
986
+ ('size:count', ('int', {'min': 0}), {
987
+ 'doc': 'The number of files included in the leaked data.'}),
988
+
989
+ ('size:percent', ('int', {'min': 0, 'max': 100}), {
990
+ 'doc': 'The total percent of the data leaked.'}),
982
991
 
983
992
  )),
984
993
 
@@ -1037,6 +1046,11 @@ class RiskModule(s_module.CoreModule):
1037
1046
  ('demanded:payment:currency', ('econ:currency', {}), {
1038
1047
  'doc': 'The currency in which payment was demanded.'}),
1039
1048
 
1049
+ ('paid:price', ('econ:price', {}), {
1050
+ 'doc': 'The total price paid by the target of the extortion.'}),
1051
+
1052
+ ('payments', ('array', {'type': 'econ:acct:payment', 'sorted': True, 'uniq': True}), {
1053
+ 'doc': 'Payments made from the target to the attacker.'}),
1040
1054
  )),
1041
1055
  ('risk:technique:masquerade', {}, (
1042
1056
  ('node', ('ndef', {}), {
@@ -24,7 +24,7 @@ class TransportModule(s_module.CoreModule):
24
24
  'doc': 'An aircraft registration number or military aircraft serial number.',
25
25
  'ex': 'ff023'}),
26
26
 
27
- ('transport:air:flightnum', ('str', {'lower': True, 'strip': True, 'replace': ((' ', ''),), 'regex': '^[a-z]{2}[0-9]{1,4}$'}), {
27
+ ('transport:air:flightnum', ('str', {'lower': True, 'strip': True, 'replace': ((' ', ''),), 'regex': '^[a-z0-9]{3,6}$'}), {
28
28
  'doc': 'A commercial flight designator including airline and serial.',
29
29
  'ex': 'ua2437'}),
30
30
 
@@ -438,3 +438,18 @@ class CommonTest(s_t_utils.SynTest):
438
438
  await footask
439
439
 
440
440
  self.eq(123, await s_common.wait_for(footask, timeout=-1))
441
+
442
+ def test_trim_text(self):
443
+ tvs = (
444
+ ('Hello world!', 'Hello world!'),
445
+ ('Hello world 123', 'Hello world 123'),
446
+ ('Hello world 1234', 'Hello world 1234'),
447
+ ('Hello world 12345', 'Hello world 1...'),
448
+ ('Hello world 1234 5678', 'Hello world 1...'),
449
+ ('HelloXworldY1234Z5678', 'HelloXworldY1...'),
450
+ )
451
+ n = 16
452
+ for iv, ev in tvs:
453
+ v = s_common.trimText(iv, n=n)
454
+ self.le(len(v), n)
455
+ self.eq(v, ev)
@@ -1190,8 +1190,9 @@ class AstTest(s_test.SynTest):
1190
1190
  with self.raises(s_exc.BadTypeValu):
1191
1191
  await core.nodes('ou:org:alias=visiacme [ :name={} ]')
1192
1192
 
1193
- with self.raises(s_exc.BadTypeValu):
1193
+ with self.raises(s_exc.BadTypeValu) as cm:
1194
1194
  await core.nodes('ou:org:alias=visiacme [ :name={[it:dev:str=hehe it:dev:str=haha]} ]')
1195
+ self.eq(cm.exception.get('text'), '[it:dev:str=hehe it:dev:str=haha]')
1195
1196
 
1196
1197
  with self.raises(s_exc.BadTypeValu):
1197
1198
  await core.nodes('ou:org:alias=visiacme [ :industries={[inet:ipv4=1.2.3.0/24]} ]')