synapse 2.219.0__py311-none-any.whl → 2.221.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 (55) hide show
  1. synapse/data/__init__.py +4 -0
  2. synapse/data/lark/__init__.py +0 -0
  3. synapse/data/lark/imap.lark +8 -0
  4. synapse/exc.py +2 -0
  5. synapse/lib/json.py +6 -5
  6. synapse/lib/layer.py +134 -0
  7. synapse/lib/link.py +49 -50
  8. synapse/lib/parser.py +3 -5
  9. synapse/lib/rstorm.py +65 -2
  10. synapse/lib/snap.py +21 -13
  11. synapse/lib/storm.py +1 -0
  12. synapse/lib/stormhttp.py +10 -10
  13. synapse/lib/stormlib/aha.py +3 -3
  14. synapse/lib/stormlib/auth.py +11 -11
  15. synapse/lib/stormlib/cell.py +1 -1
  16. synapse/lib/stormlib/cortex.py +9 -9
  17. synapse/lib/stormlib/env.py +4 -5
  18. synapse/lib/stormlib/ethereum.py +1 -1
  19. synapse/lib/stormlib/gen.py +3 -3
  20. synapse/lib/stormlib/hex.py +2 -2
  21. synapse/lib/stormlib/imap.py +478 -37
  22. synapse/lib/stormlib/infosec.py +2 -2
  23. synapse/lib/stormlib/iters.py +2 -2
  24. synapse/lib/stormlib/model.py +5 -5
  25. synapse/lib/stormlib/notifications.py +1 -1
  26. synapse/lib/stormlib/oauth.py +2 -2
  27. synapse/lib/stormlib/project.py +3 -3
  28. synapse/lib/stormlib/scrape.py +2 -1
  29. synapse/lib/stormlib/smtp.py +3 -3
  30. synapse/lib/stormlib/stats.py +2 -2
  31. synapse/lib/stormlib/stix.py +2 -2
  32. synapse/lib/stormlib/utils.py +19 -0
  33. synapse/lib/stormlib/vault.py +1 -1
  34. synapse/lib/stormlib/xml.py +2 -2
  35. synapse/lib/stormlib/yaml.py +1 -1
  36. synapse/lib/stormtypes.py +203 -60
  37. synapse/lib/version.py +2 -2
  38. synapse/tests/test_lib_grammar.py +2 -4
  39. synapse/tests/test_lib_json.py +29 -0
  40. synapse/tests/test_lib_layer.py +86 -67
  41. synapse/tests/test_lib_rstorm.py +132 -0
  42. synapse/tests/test_lib_storm.py +11 -1
  43. synapse/tests/test_lib_stormlib_env.py +3 -1
  44. synapse/tests/test_lib_stormlib_imap.py +1307 -230
  45. synapse/tests/test_lib_stormlib_utils.py +10 -0
  46. synapse/tests/test_lib_stormtypes.py +583 -2
  47. synapse/tools/aha/list.py +9 -9
  48. synapse/tools/aha/provision/service.py +2 -2
  49. synapse/utils/stormcov/plugin.py +2 -5
  50. {synapse-2.219.0.dist-info → synapse-2.221.0.dist-info}/METADATA +1 -2
  51. {synapse-2.219.0.dist-info → synapse-2.221.0.dist-info}/RECORD +55 -53
  52. /synapse/{lib → data/lark}/storm.lark +0 -0
  53. {synapse-2.219.0.dist-info → synapse-2.221.0.dist-info}/WHEEL +0 -0
  54. {synapse-2.219.0.dist-info → synapse-2.221.0.dist-info}/licenses/LICENSE +0 -0
  55. {synapse-2.219.0.dist-info → synapse-2.221.0.dist-info}/top_level.txt +0 -0
@@ -896,7 +896,7 @@ class LibModelMigrations(s_stormtypes.Lib, MigrationEditorMixin):
896
896
  'type': {'type': 'function', '_funcname': '_riskHasVulnToVulnerable',
897
897
  'args': (
898
898
  {'name': 'n', 'type': 'node', 'desc': 'The risk:hasvuln node to migrate.'},
899
- {'name': 'nodata', 'type': 'bool', 'default': False,
899
+ {'name': 'nodata', 'type': 'boolean', 'default': False,
900
900
  'desc': 'Do not copy nodedata to the risk:vulnerable node.'},
901
901
  ),
902
902
  'returns': {'type': 'list', 'desc': 'A list of idens for the risk:vulnerable nodes.'}}},
@@ -912,7 +912,7 @@ class LibModelMigrations(s_stormtypes.Lib, MigrationEditorMixin):
912
912
  'type': {'type': 'function', '_funcname': '_storm_query',
913
913
  'args': (
914
914
  {'name': 'n', 'type': 'node', 'desc': 'The inet:ssl:cert node to migrate.'},
915
- {'name': 'nodata', 'type': 'bool', 'default': False,
915
+ {'name': 'nodata', 'type': 'boolean', 'default': False,
916
916
  'desc': 'Do not copy nodedata to the inet:tls:servercert node.'},
917
917
  ),
918
918
  'returns': {'type': 'node', 'desc': 'The newly created inet:tls:servercert node.'}}},
@@ -1067,7 +1067,7 @@ class LibModelMigrations_0_2_31(s_stormtypes.Lib):
1067
1067
  {'name': 'listNodes', 'desc': 'Yield queued nodes.',
1068
1068
  'type': {'type': 'function', '_funcname': '_methListNodes',
1069
1069
  'args': (
1070
- {'name': 'form', 'type': 'form', 'default': None,
1070
+ {'name': 'form', 'type': 'str', 'default': None,
1071
1071
  'desc': 'Only yield entries matching the specified form.'},
1072
1072
  {'name': 'source', 'type': 'str', 'default': None,
1073
1073
  'desc': 'Only yield entries that were seen by the specified source.'},
@@ -1076,12 +1076,12 @@ class LibModelMigrations_0_2_31(s_stormtypes.Lib):
1076
1076
  {'name': 'size', 'type': 'int', 'default': None,
1077
1077
  'desc': 'Only yield up to this many entries.'},
1078
1078
  ),
1079
- 'returns': {'name': 'Yields', 'type': 'list',
1079
+ 'returns': {'name': 'yields', 'type': 'list',
1080
1080
  'desc': 'A tuple of (offset, form, valu, sources) values for the specified node.', }}},
1081
1081
  {'name': 'printNode', 'desc': 'Print detailed queued node information.',
1082
1082
  'type': {'type': 'function', '_funcname': '_methPrintNode',
1083
1083
  'args': (
1084
- {'name': 'offset', 'type': 'into', 'desc': 'The offset of the queued node to print.'},
1084
+ {'name': 'offset', 'type': 'int', 'desc': 'The offset of the queued node to print.'},
1085
1085
  ),
1086
1086
  'returns': {'type': 'null'}}},
1087
1087
  {'name': 'repairNode', 'desc': 'Repair a queued node.',
@@ -21,7 +21,7 @@ class NotifyLib(s_stormtypes.Lib):
21
21
  {'name': 'size', 'type': 'int', 'desc': 'The max number of notifications to yield.', 'default': None},
22
22
  ),
23
23
  'returns': {
24
- 'name': 'Yields', 'type': 'list',
24
+ 'name': 'yields', 'type': 'list',
25
25
  'desc': 'Yields (useriden, time, mesgtype, msgdata) tuples.'},
26
26
  },
27
27
  },
@@ -210,7 +210,7 @@ class OAuthV2Lib(s_stormtypes.Lib):
210
210
 
211
211
  Add a new provider which uses a custom Storm callback to obtain the client_assertion data. These
212
212
  callbacks are executed as the user who is performing the authorization_code workflow. The Storm
213
- callback must return data in a tuple of ``bool`` and a dictionary containing the assertion in the
213
+ callback must return data in a tuple of ``boolean`` and a dictionary containing the assertion in the
214
214
  key ``token``. Error messages should be in the key ``error``::
215
215
 
216
216
  $iden = $lib.guid(callstormexample, provider, oauth)
@@ -335,7 +335,7 @@ class OAuthV2Lib(s_stormtypes.Lib):
335
335
  'args': (
336
336
  {'name': 'iden', 'type': 'str', 'desc': 'The provider iden.'},
337
337
  ),
338
- 'returns': {'type': 'list', 'desc': 'List of (<bool>, <token/mesg>) for status and data.'},
338
+ 'returns': {'type': 'list', 'desc': 'List of (<boolean>, <token/mesg>) for status and data.'},
339
339
  },
340
340
  },
341
341
  {
@@ -659,12 +659,12 @@ class ProjectSprints(s_stormtypes.Prim):
659
659
  'args': (
660
660
  {'name': 'name', 'type': 'str', 'desc': 'The name (or iden) of the ProjectSprint to get.'},
661
661
  ),
662
- 'returns': {'type': 'proj:sprint', 'desc': 'The `proj:sprint` object', }}},
662
+ 'returns': {'type': 'proj:sprint', 'desc': 'The `proj:sprint` object.', }}},
663
663
  {'name': 'add', 'desc': 'Add a sprint.',
664
664
  'type': {'type': 'function', '_funcname': '_addProjSprint',
665
665
  'args': (
666
666
  {'name': 'name', 'type': 'str', 'desc': 'The name for the new ProjectSprint.'},
667
- {'name': 'period', 'type': 'ival', 'desc': 'The time interval the ProjectSprint runs for',
667
+ {'name': 'period', 'type': 'list', 'desc': 'The time interval the ProjectSprint runs for.',
668
668
  'default': None},
669
669
  ),
670
670
  'returns': {'type': 'proj:sprint', 'desc': 'The newly created `proj:sprint` object', }}},
@@ -673,7 +673,7 @@ class ProjectSprints(s_stormtypes.Prim):
673
673
  'args': (
674
674
  {'name': 'name', 'type': 'str', 'desc': 'The name of the Sprint to delete.'},
675
675
  ),
676
- 'returns': {'type': 'boolean', 'desc': 'True if the ProjectSprint can be found and deleted, otherwise False', }}}
676
+ 'returns': {'type': 'boolean', 'desc': 'True if the ProjectSprint can be found and deleted, otherwise False.', }}}
677
677
  )
678
678
 
679
679
  _storm_typename = 'proj:sprints'
@@ -59,6 +59,7 @@ class LibScrape(s_stormtypes.Lib):
59
59
  genMatches is a generic helper function for constructing scrape interfaces using pure Storm.
60
60
 
61
61
  It accepts the text, a regex pattern, and produce results that can easily be used to create
62
+ nodes.
62
63
 
63
64
  Notes:
64
65
  The pattern must have a named regular expression match for the key ``valu`` using the
@@ -91,7 +92,7 @@ class LibScrape(s_stormtypes.Lib):
91
92
  'desc': 'Regex flags to use (defaults to IGNORECASE).'},
92
93
  ),
93
94
  'returns': {'name': 'yields', 'type': 'list',
94
- 'desc': ''}}}
95
+ 'desc': 'Yields a list of (value, info) tuples scraped from the text.'}}}
95
96
  )
96
97
  _storm_lib_path = ('scrape', )
97
98
 
@@ -90,13 +90,13 @@ class SmtpMessage(s_stormtypes.StormType):
90
90
  'desc': 'The user name to use authenticating to the SMTP server.'},
91
91
  {'name': 'passwd', 'type': 'str', 'default': None,
92
92
  'desc': 'The password to use authenticating to the SMTP server.'},
93
- {'name': 'usetls', 'type': 'bool', 'default': False,
93
+ {'name': 'usetls', 'type': 'boolean', 'default': False,
94
94
  'desc': 'Initiate a TLS connection to the SMTP server.'},
95
- {'name': 'starttls', 'type': 'bool', 'default': False,
95
+ {'name': 'starttls', 'type': 'boolean', 'default': False,
96
96
  'desc': 'Use the STARTTLS directive with the SMTP server.'},
97
97
  {'name': 'timeout', 'type': 'int', 'default': 60,
98
98
  'desc': 'The timeout (in seconds) to wait for message delivery.'},
99
- {'type': 'bool', 'name': 'ssl_verify', 'default': True,
99
+ {'type': 'boolean', 'name': 'ssl_verify', 'default': True,
100
100
  'desc': 'Perform SSL/TLS verification.'},
101
101
  ),
102
102
  'returns': {'type': 'list', 'desc': 'An ($ok, $valu) tuple.'}}},
@@ -190,9 +190,9 @@ class StatTally(s_stormtypes.Prim):
190
190
  'type': {'type': 'function', '_funcname': 'sorted',
191
191
  'args': (
192
192
  {'name': 'byname', 'desc': 'Sort by counter name instead of value.',
193
- 'type': 'bool', 'default': False},
193
+ 'type': 'boolean', 'default': False},
194
194
  {'name': 'reverse', 'desc': 'Sort in descending order instead of ascending order.',
195
- 'type': 'bool', 'default': False},
195
+ 'type': 'boolean', 'default': False},
196
196
  ),
197
197
  'returns': {'type': 'list',
198
198
  'desc': 'List of (counter, value) tuples in sorted order.'}}},
@@ -645,7 +645,7 @@ class LibStix(s_stormtypes.Lib):
645
645
  'args': (
646
646
  {'type': 'dict', 'name': 'bundle', 'desc': 'The STIX bundle to lift nodes from.'},
647
647
  ),
648
- 'returns': {'name': 'Yields', 'type': 'node', 'desc': 'Yields nodes'}
648
+ 'returns': {'name': 'yields', 'type': 'node', 'desc': 'Yields nodes.'}
649
649
  }
650
650
  },
651
651
  )
@@ -856,7 +856,7 @@ class LibStixImport(s_stormtypes.Lib):
856
856
  {'type': 'dict', 'name': 'bundle', 'desc': 'The STIX bundle to ingest.'},
857
857
  {'type': 'dict', 'name': 'config', 'default': None, 'desc': 'An optional STIX ingest configuration.'},
858
858
  ),
859
- 'returns': {'name': 'Yields', 'type': 'node', 'desc': 'Yields nodes'}
859
+ 'returns': {'name': 'yields', 'type': 'node', 'desc': 'Yields nodes.'}
860
860
  },
861
861
  },
862
862
  )
@@ -1,3 +1,5 @@
1
+ import synapse.common as s_common
2
+
1
3
  import synapse.lib.stormtypes as s_stormtypes
2
4
 
3
5
  @s_stormtypes.registry.registerLib
@@ -6,6 +8,17 @@ class LibUtils(s_stormtypes.Lib):
6
8
  A Storm library for working with utility functions.
7
9
  '''
8
10
  _storm_locals = (
11
+ {'name': 'buid',
12
+ 'desc': '''
13
+ Calculate a buid from the provided valu.
14
+ ''',
15
+ 'type': {'type': 'function', '_funcname': '_buid',
16
+ 'args': (
17
+ {'name': 'valu', 'type': 'any',
18
+ 'desc': 'The value to calculate the buid from.'},
19
+ ),
20
+ 'returns': {'type': 'bytes', 'desc': 'The calculated buid.'},
21
+ }},
9
22
  {'name': 'todo',
10
23
  'desc': '''
11
24
  Create a todo tuple of (name, args, kwargs).
@@ -26,9 +39,15 @@ class LibUtils(s_stormtypes.Lib):
26
39
 
27
40
  def getObjLocals(self):
28
41
  return {
42
+ 'buid': self._buid,
29
43
  'todo': self._todo,
30
44
  }
31
45
 
46
+ @s_stormtypes.stormfunc(readonly=True)
47
+ async def _buid(self, valu):
48
+ valu = await s_stormtypes.toprim(valu)
49
+ return s_common.buid(valu)
50
+
32
51
  @s_stormtypes.stormfunc(readonly=True)
33
52
  async def _todo(self, _todoname, *args, **kwargs):
34
53
  _todoname = await s_stormtypes.tostr(_todoname)
@@ -365,7 +365,7 @@ class LibVault(s_stormtypes.Lib):
365
365
  {'name': 'list', 'desc': 'List vaults accessible to the current user.',
366
366
  'type': {'type': 'function', '_funcname': '_listVaults',
367
367
  'args': (),
368
- 'returns': {'type': 'list', 'desc': 'Yields vaults.'}}},
368
+ 'returns': {'name': 'yields', 'type': 'list', 'desc': 'Yields vaults.'}}},
369
369
  {'name': 'print', 'desc': 'Print the details of the specified vault.',
370
370
  'type': {'type': 'function', '_funcname': '_storm_query',
371
371
  'args': (
@@ -20,8 +20,8 @@ class XmlElement(s_stormtypes.Prim):
20
20
  'type': {'type': 'function', '_funcname': 'find',
21
21
  'args': (
22
22
  {'name': 'name', 'type': 'str', 'desc': 'The name of the XML tag.'},
23
- {'name': 'nested', 'type': 'bool', 'default': True,
24
- 'desc': 'Set to ``(false)`` to only find direct children.'},
23
+ {'name': 'nested', 'type': 'boolean', 'default': True,
24
+ 'desc': 'Set to ``(false)`` to only find direct children.'},
25
25
  ),
26
26
  'returns': {'type': 'generator', 'desc': 'A generator which yields xml:elements.'}}},
27
27
 
@@ -15,7 +15,7 @@ class LibYaml(s_stormtypes.Lib):
15
15
  {'name': 'save', 'desc': 'Encode data as a YAML string.',
16
16
  'type': {'type': 'function', '_funcname': 'save',
17
17
  'args': (
18
- {'name': 'valu', 'type': 'object', 'desc': 'The object to encode.'},
18
+ {'name': 'valu', 'type': 'prim', 'desc': 'The object to encode.'},
19
19
  {'name': 'sort_keys', 'type': 'boolean', 'desc': 'Sort object keys.', 'default': True},
20
20
  ),
21
21
  'returns': {'type': 'str', 'desc': 'A YAML string.'}}},