synapse 2.154.1__py311-none-any.whl → 2.156.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 (74) hide show
  1. synapse/cmds/cortex.py +2 -14
  2. synapse/common.py +13 -36
  3. synapse/cortex.py +15 -508
  4. synapse/lib/ast.py +215 -22
  5. synapse/lib/cell.py +35 -8
  6. synapse/lib/certdir.py +11 -0
  7. synapse/lib/cmdr.py +0 -5
  8. synapse/lib/gis.py +2 -2
  9. synapse/lib/httpapi.py +14 -43
  10. synapse/lib/layer.py +64 -201
  11. synapse/lib/lmdbslab.py +11 -0
  12. synapse/lib/node.py +1 -3
  13. synapse/lib/parser.py +10 -0
  14. synapse/lib/slabseqn.py +2 -1
  15. synapse/lib/snap.py +121 -21
  16. synapse/lib/spooled.py +9 -0
  17. synapse/lib/storm.lark +23 -6
  18. synapse/lib/storm.py +16 -339
  19. synapse/lib/storm_format.py +5 -0
  20. synapse/lib/stormhttp.py +10 -1
  21. synapse/lib/stormlib/gen.py +1 -2
  22. synapse/lib/stormlib/gis.py +41 -0
  23. synapse/lib/stormlib/graph.py +2 -1
  24. synapse/lib/stormlib/stats.py +21 -2
  25. synapse/lib/stormlib/storm.py +16 -1
  26. synapse/lib/stormtypes.py +244 -16
  27. synapse/lib/types.py +16 -2
  28. synapse/lib/version.py +2 -2
  29. synapse/lib/view.py +118 -25
  30. synapse/models/base.py +2 -2
  31. synapse/models/inet.py +60 -30
  32. synapse/models/infotech.py +130 -8
  33. synapse/models/orgs.py +3 -0
  34. synapse/models/proj.py +3 -0
  35. synapse/models/risk.py +24 -6
  36. synapse/models/syn.py +0 -38
  37. synapse/tests/test_cmds_cortex.py +1 -1
  38. synapse/tests/test_cortex.py +70 -338
  39. synapse/tests/test_lib_agenda.py +19 -54
  40. synapse/tests/test_lib_aha.py +97 -0
  41. synapse/tests/test_lib_ast.py +596 -0
  42. synapse/tests/test_lib_grammar.py +30 -10
  43. synapse/tests/test_lib_httpapi.py +33 -49
  44. synapse/tests/test_lib_layer.py +19 -234
  45. synapse/tests/test_lib_lmdbslab.py +22 -0
  46. synapse/tests/test_lib_snap.py +9 -0
  47. synapse/tests/test_lib_spooled.py +4 -0
  48. synapse/tests/test_lib_storm.py +16 -309
  49. synapse/tests/test_lib_stormlib_gis.py +21 -0
  50. synapse/tests/test_lib_stormlib_stats.py +107 -20
  51. synapse/tests/test_lib_stormlib_storm.py +25 -0
  52. synapse/tests/test_lib_stormtypes.py +253 -8
  53. synapse/tests/test_lib_types.py +40 -0
  54. synapse/tests/test_lib_view.py +6 -13
  55. synapse/tests/test_model_base.py +1 -1
  56. synapse/tests/test_model_inet.py +15 -0
  57. synapse/tests/test_model_infotech.py +110 -0
  58. synapse/tests/test_model_orgs.py +10 -0
  59. synapse/tests/test_model_person.py +0 -3
  60. synapse/tests/test_model_proj.py +2 -1
  61. synapse/tests/test_model_risk.py +24 -0
  62. synapse/tests/test_model_syn.py +20 -34
  63. synapse/tests/test_tools_csvtool.py +2 -1
  64. synapse/tests/test_tools_feed.py +4 -30
  65. synapse/tools/csvtool.py +2 -1
  66. {synapse-2.154.1.dist-info → synapse-2.156.0.dist-info}/METADATA +9 -9
  67. {synapse-2.154.1.dist-info → synapse-2.156.0.dist-info}/RECORD +70 -72
  68. {synapse-2.154.1.dist-info → synapse-2.156.0.dist-info}/WHEEL +1 -1
  69. synapse/cmds/cron.py +0 -726
  70. synapse/cmds/trigger.py +0 -319
  71. synapse/tests/test_cmds_cron.py +0 -453
  72. synapse/tests/test_cmds_trigger.py +0 -176
  73. {synapse-2.154.1.dist-info → synapse-2.156.0.dist-info}/LICENSE +0 -0
  74. {synapse-2.154.1.dist-info → synapse-2.156.0.dist-info}/top_level.txt +0 -0
synapse/cmds/cortex.py CHANGED
@@ -56,17 +56,6 @@ Examples:
56
56
  ('line', {'type': 'glob'}), # type: ignore
57
57
  )
58
58
 
59
- splicetypes = (
60
- 'tag:add',
61
- 'tag:del',
62
- 'node:add',
63
- 'node:del',
64
- 'prop:set',
65
- 'prop:del',
66
- 'tag:prop:set',
67
- 'tag:prop:del',
68
- )
69
-
70
59
  def _make_argparser(self):
71
60
 
72
61
  parser = s_cmd.Parser(prog='log', outp=self, description=self.__doc__)
@@ -111,7 +100,7 @@ Examples:
111
100
  editsonly = self.locs.get('log:editsonly')
112
101
  nodesonly = self.locs.get('log:nodesonly')
113
102
  if fd and not fd.closed:
114
- if editsonly and mesg[0] not in (*self.splicetypes, 'node:edits'):
103
+ if editsonly and mesg[0] != 'node:edits':
115
104
  return
116
105
  if nodesonly:
117
106
  if mesg[0] != 'node':
@@ -221,7 +210,6 @@ class StormCmd(s_cli.Cmd):
221
210
  --editformat <format>: What format of edits the server shall emit.
222
211
  Options are
223
212
  * nodeedits (default),
224
- * splices (similar to < 2.0.0),
225
213
  * count (just counts of nodeedits), or
226
214
  * none (no such messages emitted).
227
215
  --show-prov: Show provenance messages.
@@ -239,7 +227,7 @@ class StormCmd(s_cli.Cmd):
239
227
  '''
240
228
  _cmd_name = 'storm'
241
229
 
242
- editformat_enums = ('nodeedits', 'splices', 'count', 'none')
230
+ editformat_enums = ('nodeedits', 'count', 'none')
243
231
  _cmd_syntax = (
244
232
  ('--hide-tags', {}), # type: ignore
245
233
  ('--show', {'type': 'valu'}),
synapse/common.py CHANGED
@@ -71,20 +71,24 @@ def now():
71
71
  '''
72
72
  Get the current epoch time in milliseconds.
73
73
 
74
- This relies on time.time(), which is system-dependent in terms of resolution.
75
-
76
- Examples:
77
- Get the current time and make a row for a Cortex::
78
-
79
- tick = now()
80
- row = (someiden, 'foo:prop', 1, tick)
81
- core.addRows([row])
74
+ This relies on time.time_ns(), which is system-dependent in terms of resolution.
82
75
 
83
76
  Returns:
84
77
  int: Epoch time in milliseconds.
85
78
  '''
86
79
  return time.time_ns() // 1000000
87
80
 
81
+ def mononow():
82
+ '''
83
+ Get the current monotonic clock time in milliseconds.
84
+
85
+ This relies on time.monotonic_ns(), which is a relative time.
86
+
87
+ Returns:
88
+ int: Monotonic clock time in milliseconds.
89
+ '''
90
+ return time.monotonic_ns() // 1000000
91
+
88
92
  def guid(valu=None):
89
93
  '''
90
94
  Get a 16 byte guid value.
@@ -931,8 +935,7 @@ def deprecated(name, curv='2.x', eolv='3.0.0'):
931
935
  mesg = f'"{name}" is deprecated in {curv} and will be removed in {eolv}'
932
936
  warnings.warn(mesg, DeprecationWarning)
933
937
 
934
- _splicedepr = '2023-10-01'
935
- def deprdate(name, date):
938
+ def deprdate(name, date): # pragma: no cover
936
939
  mesg = f'{name} is deprecated and will be removed on {date}.'
937
940
  warnings.warn(mesg, DeprecationWarning)
938
941
 
@@ -1155,32 +1158,6 @@ def getSslCtx(cadir, purpose=ssl.Purpose.SERVER_AUTH):
1155
1158
  logger.exception(f'Error loading {certpath}')
1156
1159
  return sslctx
1157
1160
 
1158
- class aclosing(contextlib.AbstractAsyncContextManager): # pragma: no cover
1159
- """Async context manager for safely finalizing an asynchronously cleaned-up
1160
- resource such as an async generator, calling its ``aclose()`` method.
1161
-
1162
- Code like this::
1163
-
1164
- async with aclosing(<module>.fetch(<arguments>)) as agen:
1165
- <block>
1166
-
1167
- is equivalent to this::
1168
-
1169
- agen = <module>.fetch(<arguments>)
1170
- try:
1171
- <block>
1172
- finally:
1173
- await agen.aclose()
1174
-
1175
- """
1176
- def __init__(self, thing):
1177
- deprecated('synapse.common.aclosing()', curv='2.145.0', eolv='v2.150.0')
1178
- self.thing = thing
1179
- async def __aenter__(self):
1180
- return self.thing
1181
- async def __aexit__(self, exc, cls, tb):
1182
- await self.thing.aclose()
1183
-
1184
1161
  def httpcodereason(code):
1185
1162
  '''
1186
1163
  Get the reason for an HTTP status code.