synapse 2.180.1__py311-none-any.whl → 2.182.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/assets/__init__.py +35 -0
- synapse/assets/storm/migrations/model-0.2.28.storm +355 -0
- synapse/common.py +2 -1
- synapse/cortex.py +49 -35
- synapse/cryotank.py +1 -1
- synapse/datamodel.py +30 -0
- synapse/lib/ast.py +12 -7
- synapse/lib/auth.py +17 -0
- synapse/lib/cell.py +7 -9
- synapse/lib/chop.py +0 -1
- synapse/lib/drive.py +8 -8
- synapse/lib/layer.py +55 -13
- synapse/lib/lmdbslab.py +26 -5
- synapse/lib/modelrev.py +28 -1
- synapse/lib/modules.py +1 -0
- synapse/lib/nexus.py +1 -1
- synapse/lib/node.py +5 -0
- synapse/lib/parser.py +23 -16
- synapse/lib/scrape.py +1 -1
- synapse/lib/slabseqn.py +2 -2
- synapse/lib/snap.py +129 -0
- synapse/lib/storm.lark +16 -2
- synapse/lib/storm.py +20 -3
- synapse/lib/storm_format.py +1 -0
- synapse/lib/stormhttp.py +34 -1
- synapse/lib/stormlib/auth.py +5 -3
- synapse/lib/stormlib/cortex.py +5 -2
- synapse/lib/stormlib/easyperm.py +2 -2
- synapse/lib/stormlib/ipv6.py +2 -2
- synapse/lib/stormlib/model.py +114 -12
- synapse/lib/stormlib/project.py +1 -1
- synapse/lib/stormtypes.py +81 -7
- synapse/lib/types.py +7 -0
- synapse/lib/version.py +2 -2
- synapse/lib/view.py +47 -0
- synapse/models/inet.py +10 -3
- synapse/models/infotech.py +2 -1
- synapse/models/language.py +4 -0
- synapse/models/math.py +50 -0
- synapse/models/orgs.py +8 -0
- synapse/models/risk.py +9 -0
- synapse/tests/files/stormcov/pragma-nocov.storm +18 -0
- synapse/tests/test_assets.py +25 -0
- synapse/tests/test_cortex.py +129 -0
- synapse/tests/test_datamodel.py +6 -0
- synapse/tests/test_lib_cell.py +12 -0
- synapse/tests/test_lib_grammar.py +7 -1
- synapse/tests/test_lib_layer.py +35 -0
- synapse/tests/test_lib_lmdbslab.py +11 -9
- synapse/tests/test_lib_modelrev.py +655 -1
- synapse/tests/test_lib_slabseqn.py +5 -4
- synapse/tests/test_lib_snap.py +4 -0
- synapse/tests/test_lib_storm.py +110 -1
- synapse/tests/test_lib_stormhttp.py +99 -1
- synapse/tests/test_lib_stormlib_auth.py +15 -0
- synapse/tests/test_lib_stormlib_cortex.py +21 -4
- synapse/tests/test_lib_stormlib_iters.py +8 -5
- synapse/tests/test_lib_stormlib_model.py +45 -6
- synapse/tests/test_lib_stormtypes.py +158 -2
- synapse/tests/test_lib_types.py +6 -0
- synapse/tests/test_model_inet.py +10 -0
- synapse/tests/test_model_language.py +4 -0
- synapse/tests/test_model_math.py +22 -0
- synapse/tests/test_model_orgs.py +6 -2
- synapse/tests/test_model_risk.py +4 -0
- synapse/tests/test_tools_storm.py +1 -1
- synapse/tests/test_utils_stormcov.py +5 -0
- synapse/tests/utils.py +18 -5
- synapse/utils/stormcov/plugin.py +31 -1
- synapse/vendor/cpython/LICENSE +279 -0
- synapse/vendor/cpython/__init__.py +0 -0
- synapse/vendor/cpython/lib/__init__.py +0 -0
- synapse/vendor/cpython/lib/email/__init__.py +0 -0
- synapse/vendor/cpython/lib/email/_parseaddr.py +560 -0
- synapse/vendor/cpython/lib/email/utils.py +505 -0
- synapse/vendor/cpython/lib/ipaddress.py +2366 -0
- synapse/vendor/cpython/lib/test/__init__.py +0 -0
- synapse/vendor/cpython/lib/test/support/__init__.py +114 -0
- synapse/vendor/cpython/lib/test/test_email/__init__.py +0 -0
- synapse/vendor/cpython/lib/test/test_email/test_email.py +480 -0
- synapse/vendor/cpython/lib/test/test_email/test_utils.py +167 -0
- synapse/vendor/cpython/lib/test/test_ipaddress.py +2672 -0
- synapse/vendor/utils.py +4 -3
- {synapse-2.180.1.dist-info → synapse-2.182.0.dist-info}/METADATA +3 -3
- {synapse-2.180.1.dist-info → synapse-2.182.0.dist-info}/RECORD +88 -71
- {synapse-2.180.1.dist-info → synapse-2.182.0.dist-info}/WHEEL +1 -1
- synapse/lib/jupyter.py +0 -505
- synapse/tests/test_lib_jupyter.py +0 -224
- {synapse-2.180.1.dist-info → synapse-2.182.0.dist-info}/LICENSE +0 -0
- {synapse-2.180.1.dist-info → synapse-2.182.0.dist-info}/top_level.txt +0 -0
synapse/lib/stormtypes.py
CHANGED
|
@@ -1337,7 +1337,7 @@ class LibBase(Lib):
|
|
|
1337
1337
|
Check if the runtime is in debug and print a message::
|
|
1338
1338
|
|
|
1339
1339
|
if $lib.debug {
|
|
1340
|
-
$lib.print('Doing stuff!
|
|
1340
|
+
$lib.print('Doing stuff!')
|
|
1341
1341
|
}
|
|
1342
1342
|
|
|
1343
1343
|
Update the current runtime to enable debugging::
|
|
@@ -1996,7 +1996,7 @@ class LibAxon(Lib):
|
|
|
1996
1996
|
'desc': 'Set to False to disable SSL/TLS certificate verification.', 'default': True},
|
|
1997
1997
|
{'name': 'timeout', 'type': 'int', 'desc': 'Timeout for the download operation.',
|
|
1998
1998
|
'default': None},
|
|
1999
|
-
{'name': 'proxy', 'type': ['
|
|
1999
|
+
{'name': 'proxy', 'type': ['boolean', 'null', 'str'],
|
|
2000
2000
|
'desc': 'Set to a proxy URL string or $lib.false to disable proxy use.', 'default': None},
|
|
2001
2001
|
{'name': 'ssl_opts', 'type': 'dict',
|
|
2002
2002
|
'desc': 'Optional SSL/TLS options. See $lib.axon help for additional details.',
|
|
@@ -2019,7 +2019,7 @@ class LibAxon(Lib):
|
|
|
2019
2019
|
'desc': 'Set to False to disable SSL/TLS certificate verification.', 'default': True},
|
|
2020
2020
|
{'name': 'timeout', 'type': 'int', 'desc': 'Timeout for the download operation.',
|
|
2021
2021
|
'default': None},
|
|
2022
|
-
{'name': 'proxy', 'type': ['
|
|
2022
|
+
{'name': 'proxy', 'type': ['boolean', 'null', 'str'],
|
|
2023
2023
|
'desc': 'Set to a proxy URL string or $lib.false to disable proxy use.', 'default': None},
|
|
2024
2024
|
{'name': 'ssl_opts', 'type': 'dict',
|
|
2025
2025
|
'desc': 'Optional SSL/TLS options. See $lib.axon help for additional details.',
|
|
@@ -4994,7 +4994,7 @@ class List(Prim):
|
|
|
4994
4994
|
{'name': 'sort', 'desc': 'Sort the list in place.',
|
|
4995
4995
|
'type': {'type': 'function', '_funcname': '_methListSort',
|
|
4996
4996
|
'args': (
|
|
4997
|
-
{'name': 'reverse', 'type': '
|
|
4997
|
+
{'name': 'reverse', 'type': 'boolean', 'desc': 'Sort the list in reverse order.',
|
|
4998
4998
|
'default': False},
|
|
4999
4999
|
),
|
|
5000
5000
|
'returns': {'type': 'null', }}},
|
|
@@ -5061,6 +5061,14 @@ class List(Prim):
|
|
|
5061
5061
|
{'name': 'unique', 'desc': 'Get a copy of the list containing unique items.',
|
|
5062
5062
|
'type': {'type': 'function', '_funcname': '_methListUnique',
|
|
5063
5063
|
'returns': {'type': 'list'}}},
|
|
5064
|
+
{'name': 'rem', 'desc': 'Remove a specific item from anywhere in the list.',
|
|
5065
|
+
'type': {'type': 'function', '_funcname': '_methListRemove',
|
|
5066
|
+
'args': (
|
|
5067
|
+
{'name': 'item', 'type': 'any', 'desc': 'An item in the list.'},
|
|
5068
|
+
{'name': 'all', 'type': 'boolean', 'default': False,
|
|
5069
|
+
'desc': 'Remove all instances of item from the list.'},
|
|
5070
|
+
),
|
|
5071
|
+
'returns': {'type': 'boolean', 'desc': 'Boolean indicating if the item was removed from the list.'}}},
|
|
5064
5072
|
)
|
|
5065
5073
|
_storm_typename = 'list'
|
|
5066
5074
|
_ismutable = True
|
|
@@ -5082,6 +5090,7 @@ class List(Prim):
|
|
|
5082
5090
|
'slice': self._methListSlice,
|
|
5083
5091
|
'extend': self._methListExtend,
|
|
5084
5092
|
'unique': self._methListUnique,
|
|
5093
|
+
'rem': self._methListRemove,
|
|
5085
5094
|
}
|
|
5086
5095
|
|
|
5087
5096
|
@stormfunc(readonly=True)
|
|
@@ -5176,7 +5185,6 @@ class List(Prim):
|
|
|
5176
5185
|
end = await toint(end)
|
|
5177
5186
|
return self.valu[start:end]
|
|
5178
5187
|
|
|
5179
|
-
@stormfunc(readonly=True)
|
|
5180
5188
|
async def _methListExtend(self, valu):
|
|
5181
5189
|
async for item in toiter(valu):
|
|
5182
5190
|
self.valu.append(item)
|
|
@@ -5204,6 +5212,21 @@ class List(Prim):
|
|
|
5204
5212
|
ret.append(val)
|
|
5205
5213
|
return ret
|
|
5206
5214
|
|
|
5215
|
+
async def _methListRemove(self, item, all=False):
|
|
5216
|
+
item = await toprim(item)
|
|
5217
|
+
all = await tobool(all)
|
|
5218
|
+
|
|
5219
|
+
if item not in self.valu:
|
|
5220
|
+
return False
|
|
5221
|
+
|
|
5222
|
+
while item in self.valu:
|
|
5223
|
+
self.valu.remove(item)
|
|
5224
|
+
|
|
5225
|
+
if not all:
|
|
5226
|
+
break
|
|
5227
|
+
|
|
5228
|
+
return True
|
|
5229
|
+
|
|
5207
5230
|
async def stormrepr(self):
|
|
5208
5231
|
reprs = [await torepr(k) for k in self.valu]
|
|
5209
5232
|
rval = ', '.join(reprs)
|
|
@@ -6061,7 +6084,7 @@ class Node(Prim):
|
|
|
6061
6084
|
{'name': 'glob', 'type': 'str', 'default': None,
|
|
6062
6085
|
'desc': 'A tag glob expression. If this is provided, only tags which match the expression '
|
|
6063
6086
|
'are returned.'},
|
|
6064
|
-
{'name': 'leaf', 'type': '
|
|
6087
|
+
{'name': 'leaf', 'type': 'boolean', 'default': False,
|
|
6065
6088
|
'desc': 'If true, only leaf tags are included in the returned tags.'},
|
|
6066
6089
|
),
|
|
6067
6090
|
'returns': {'type': 'list',
|
|
@@ -6721,6 +6744,13 @@ class Layer(Prim):
|
|
|
6721
6744
|
'type': {'type': 'function', '_funcname': '_methGetFormcount',
|
|
6722
6745
|
'returns': {'type': 'dict',
|
|
6723
6746
|
'desc': 'Dictionary containing form names and the count of the nodes in the Layer.', }}},
|
|
6747
|
+
{'name': 'getPropValues',
|
|
6748
|
+
'desc': 'Yield unique property values in the layer for the given form or property name.',
|
|
6749
|
+
'type': {'type': 'function', '_funcname': '_methGetPropValues',
|
|
6750
|
+
'args': (
|
|
6751
|
+
{'name': 'propname', 'type': 'str', 'desc': 'The property or form name to look up.', },
|
|
6752
|
+
),
|
|
6753
|
+
'returns': {'name': 'yields', 'type': 'any', 'desc': 'Unique property values.', }}},
|
|
6724
6754
|
{'name': 'getStorNodes', 'desc': '''
|
|
6725
6755
|
Get buid, sode tuples representing the data stored in the layer.
|
|
6726
6756
|
|
|
@@ -6921,6 +6951,7 @@ class Layer(Prim):
|
|
|
6921
6951
|
'liftByProp': self.liftByProp,
|
|
6922
6952
|
'getTagCount': self._methGetTagCount,
|
|
6923
6953
|
'getPropCount': self._methGetPropCount,
|
|
6954
|
+
'getPropValues': self._methGetPropValues,
|
|
6924
6955
|
'getTagPropCount': self._methGetTagPropCount,
|
|
6925
6956
|
'getPropArrayCount': self._methGetPropArrayCount,
|
|
6926
6957
|
'getFormCounts': self._methGetFormcount,
|
|
@@ -7190,6 +7221,29 @@ class Layer(Prim):
|
|
|
7190
7221
|
|
|
7191
7222
|
return layr.getTagPropValuCount(form, tag, prop.name, prop.type.stortype, norm)
|
|
7192
7223
|
|
|
7224
|
+
@stormfunc(readonly=True)
|
|
7225
|
+
async def _methGetPropValues(self, propname):
|
|
7226
|
+
propname = await tostr(propname)
|
|
7227
|
+
|
|
7228
|
+
prop = self.runt.snap.core.model.reqProp(propname)
|
|
7229
|
+
|
|
7230
|
+
layriden = self.valu.get('iden')
|
|
7231
|
+
await self.runt.reqUserCanReadLayer(layriden)
|
|
7232
|
+
layr = self.runt.snap.core.getLayer(layriden)
|
|
7233
|
+
|
|
7234
|
+
formname = None
|
|
7235
|
+
propname = None
|
|
7236
|
+
|
|
7237
|
+
if prop.isform:
|
|
7238
|
+
formname = prop.name
|
|
7239
|
+
else:
|
|
7240
|
+
propname = prop.name
|
|
7241
|
+
if not prop.isuniv:
|
|
7242
|
+
formname = prop.form.name
|
|
7243
|
+
|
|
7244
|
+
async for indx, valu in layr.iterPropValues(formname, propname, prop.type.stortype):
|
|
7245
|
+
yield valu
|
|
7246
|
+
|
|
7193
7247
|
@stormfunc(readonly=True)
|
|
7194
7248
|
async def _methLayerEdits(self, offs=0, wait=True, size=None, reverse=False):
|
|
7195
7249
|
offs = await toint(offs)
|
|
@@ -7367,7 +7421,7 @@ class LibView(Lib):
|
|
|
7367
7421
|
{'name': 'list', 'desc': 'List the Views in the Cortex.',
|
|
7368
7422
|
'type': {'type': 'function', '_funcname': '_methViewList',
|
|
7369
7423
|
'args': (
|
|
7370
|
-
{'name': 'deporder', 'type': '
|
|
7424
|
+
{'name': 'deporder', 'type': 'boolean', 'default': False,
|
|
7371
7425
|
'desc': 'Return the lists in bottom-up dependency order.', },
|
|
7372
7426
|
),
|
|
7373
7427
|
'returns': {'type': 'list', 'desc': 'List of ``view`` objects.', }}},
|
|
@@ -7622,6 +7676,14 @@ class View(Prim):
|
|
|
7622
7676
|
),
|
|
7623
7677
|
'returns': {'type': 'int', 'desc': 'The count of nodes.', }}},
|
|
7624
7678
|
|
|
7679
|
+
{'name': 'getPropValues',
|
|
7680
|
+
'desc': 'Yield unique property values in the view for the given form or property name.',
|
|
7681
|
+
'type': {'type': 'function', '_funcname': '_methGetPropValues',
|
|
7682
|
+
'args': (
|
|
7683
|
+
{'name': 'propname', 'type': 'str', 'desc': 'The property or form name to look up.', },
|
|
7684
|
+
),
|
|
7685
|
+
'returns': {'name': 'yields', 'type': 'any', 'desc': 'Unique property values.', }}},
|
|
7686
|
+
|
|
7625
7687
|
{'name': 'detach', 'desc': 'Detach the view from its parent. WARNING: This cannot be reversed.',
|
|
7626
7688
|
'type': {'type': 'function', '_funcname': 'detach',
|
|
7627
7689
|
'args': (),
|
|
@@ -7725,6 +7787,7 @@ class View(Prim):
|
|
|
7725
7787
|
'getEdgeVerbs': self._methGetEdgeVerbs,
|
|
7726
7788
|
'getFormCounts': self._methGetFormcount,
|
|
7727
7789
|
'getPropCount': self._methGetPropCount,
|
|
7790
|
+
'getPropValues': self._methGetPropValues,
|
|
7728
7791
|
'getTagPropCount': self._methGetTagPropCount,
|
|
7729
7792
|
'getPropArrayCount': self._methGetPropArrayCount,
|
|
7730
7793
|
|
|
@@ -7841,6 +7904,17 @@ class View(Prim):
|
|
|
7841
7904
|
|
|
7842
7905
|
return await view.getPropArrayCount(propname, valu=valu)
|
|
7843
7906
|
|
|
7907
|
+
@stormfunc(readonly=True)
|
|
7908
|
+
async def _methGetPropValues(self, propname):
|
|
7909
|
+
propname = await tostr(propname)
|
|
7910
|
+
|
|
7911
|
+
viewiden = self.valu.get('iden')
|
|
7912
|
+
self.runt.confirm(('view', 'read'), gateiden=viewiden)
|
|
7913
|
+
view = self.runt.snap.core.getView(viewiden)
|
|
7914
|
+
|
|
7915
|
+
async for valu in view.iterPropValues(propname):
|
|
7916
|
+
yield valu
|
|
7917
|
+
|
|
7844
7918
|
@stormfunc(readonly=True)
|
|
7845
7919
|
async def _methGetEdges(self, verb=None):
|
|
7846
7920
|
verb = await toprim(verb)
|
synapse/lib/types.py
CHANGED
|
@@ -368,6 +368,13 @@ class Type:
|
|
|
368
368
|
topt.update(opts)
|
|
369
369
|
return self.__class__(self.modl, self.name, self.info, topt)
|
|
370
370
|
|
|
371
|
+
def __eq__(self, othr):
|
|
372
|
+
if self.name != othr.name:
|
|
373
|
+
return False
|
|
374
|
+
if self.opts != othr.opts:
|
|
375
|
+
return False
|
|
376
|
+
return True
|
|
377
|
+
|
|
371
378
|
class Bool(Type):
|
|
372
379
|
|
|
373
380
|
stortype = s_layer.STOR_TYPE_U8
|
synapse/lib/version.py
CHANGED
|
@@ -223,6 +223,6 @@ def reqVersion(valu, reqver,
|
|
|
223
223
|
##############################################################################
|
|
224
224
|
# The following are touched during the release process by bumpversion.
|
|
225
225
|
# Do not modify these directly.
|
|
226
|
-
version = (2,
|
|
226
|
+
version = (2, 182, 0)
|
|
227
227
|
verstring = '.'.join([str(x) for x in version])
|
|
228
|
-
commit = '
|
|
228
|
+
commit = '72e535c8c22073fd1b7428121849de4b9fb034ae'
|
synapse/lib/view.py
CHANGED
|
@@ -824,6 +824,53 @@ class View(s_nexus.Pusher): # type: ignore
|
|
|
824
824
|
|
|
825
825
|
return count
|
|
826
826
|
|
|
827
|
+
async def iterPropValues(self, propname):
|
|
828
|
+
prop = self.core.model.reqProp(propname)
|
|
829
|
+
|
|
830
|
+
formname = None
|
|
831
|
+
propname = None
|
|
832
|
+
|
|
833
|
+
if prop.isform:
|
|
834
|
+
formname = prop.name
|
|
835
|
+
else:
|
|
836
|
+
propname = prop.name
|
|
837
|
+
if not prop.isuniv:
|
|
838
|
+
formname = prop.form.name
|
|
839
|
+
|
|
840
|
+
async def wrapgenr(lidx, genr):
|
|
841
|
+
async for indx, valu in genr:
|
|
842
|
+
yield indx, valu, lidx
|
|
843
|
+
|
|
844
|
+
genrs = []
|
|
845
|
+
for lidx, layr in enumerate(self.layers):
|
|
846
|
+
genr = layr.iterPropValues(formname, propname, prop.type.stortype)
|
|
847
|
+
genrs.append(wrapgenr(lidx, genr))
|
|
848
|
+
|
|
849
|
+
lastvalu = None
|
|
850
|
+
async for indx, valu, lidx in s_common.merggenr2(genrs):
|
|
851
|
+
if valu == lastvalu:
|
|
852
|
+
continue
|
|
853
|
+
|
|
854
|
+
if lidx == 0 or propname is None:
|
|
855
|
+
lastvalu = valu
|
|
856
|
+
yield valu
|
|
857
|
+
else:
|
|
858
|
+
valid = False
|
|
859
|
+
async for buid in self.layers[lidx].iterPropIndxBuids(formname, propname, indx):
|
|
860
|
+
for layr in self.layers[0:lidx]:
|
|
861
|
+
if (sode := layr._getStorNode(buid)) is None:
|
|
862
|
+
continue
|
|
863
|
+
|
|
864
|
+
if sode['props'].get(propname) is not None:
|
|
865
|
+
break
|
|
866
|
+
else:
|
|
867
|
+
valid = True
|
|
868
|
+
|
|
869
|
+
if valid:
|
|
870
|
+
lastvalu = valu
|
|
871
|
+
yield valu
|
|
872
|
+
break
|
|
873
|
+
|
|
827
874
|
async def getEdgeVerbs(self):
|
|
828
875
|
|
|
829
876
|
async with await s_spooled.Set.anit(dirn=self.core.dirn, cell=self.core) as vset:
|
synapse/models/inet.py
CHANGED
|
@@ -2,8 +2,6 @@ import socket
|
|
|
2
2
|
import asyncio
|
|
3
3
|
import hashlib
|
|
4
4
|
import logging
|
|
5
|
-
import ipaddress
|
|
6
|
-
import email.utils
|
|
7
5
|
import urllib.parse
|
|
8
6
|
|
|
9
7
|
import idna
|
|
@@ -20,7 +18,12 @@ import synapse.lib.scrape as s_scrape
|
|
|
20
18
|
import synapse.lib.module as s_module
|
|
21
19
|
import synapse.lookup.iana as s_l_iana
|
|
22
20
|
|
|
21
|
+
import synapse.vendor.cpython.lib.email.utils as s_v_email_utils
|
|
22
|
+
|
|
23
23
|
logger = logging.getLogger(__name__)
|
|
24
|
+
|
|
25
|
+
ipaddress = s_common.ipaddress
|
|
26
|
+
|
|
24
27
|
drivre = regex.compile(r'^\w[:|]')
|
|
25
28
|
fqdnre = regex.compile(r'^[\w._-]+$', regex.U)
|
|
26
29
|
srv6re = regex.compile(r'^\[([a-f0-9\.:]+)\](?::(\d+))?$', regex.IGNORECASE)
|
|
@@ -811,13 +814,17 @@ class Rfc2822Addr(s_types.Str):
|
|
|
811
814
|
valu = ' '.join(valu.split())
|
|
812
815
|
|
|
813
816
|
try:
|
|
814
|
-
name, addr =
|
|
817
|
+
name, addr = s_v_email_utils.parseaddr(valu, strict=True)
|
|
815
818
|
except Exception as e: # pragma: no cover
|
|
816
819
|
# not sure we can ever really trigger this with a string as input
|
|
817
820
|
mesg = f'email.utils.parsaddr failed: {str(e)}'
|
|
818
821
|
raise s_exc.BadTypeValu(valu=valu, name=self.name,
|
|
819
822
|
mesg=mesg) from None
|
|
820
823
|
|
|
824
|
+
if not name and not addr:
|
|
825
|
+
raise s_exc.BadTypeValu(valu=valu, name=self.name,
|
|
826
|
+
mesg=f'No name or email parsed from {valu}')
|
|
827
|
+
|
|
821
828
|
subs = {}
|
|
822
829
|
if name:
|
|
823
830
|
subs['name'] = name
|
synapse/models/infotech.py
CHANGED
|
@@ -199,7 +199,6 @@ URI_PERCENT_CHARS = [
|
|
|
199
199
|
]
|
|
200
200
|
|
|
201
201
|
def uri_quote(text):
|
|
202
|
-
ret = ''
|
|
203
202
|
for (pct, char) in URI_PERCENT_CHARS:
|
|
204
203
|
text = text.replace(char, pct)
|
|
205
204
|
return text
|
|
@@ -1070,6 +1069,8 @@ class ItModule(s_module.CoreModule):
|
|
|
1070
1069
|
'doc': 'The snort rule is intended for use in detecting the target node.'}),
|
|
1071
1070
|
(('it:app:yara:rule', 'detects', None), {
|
|
1072
1071
|
'doc': 'The YARA rule is intended for use in detecting the target node.'}),
|
|
1072
|
+
(('it:dev:repo', 'has', 'inet:url'), {
|
|
1073
|
+
'doc': 'The repo has content hosted at the URL.'}),
|
|
1073
1074
|
),
|
|
1074
1075
|
'forms': (
|
|
1075
1076
|
('it:hostname', {}, ()),
|
synapse/models/language.py
CHANGED
|
@@ -12,6 +12,9 @@ class LangModule(s_module.CoreModule):
|
|
|
12
12
|
'deprecated': True,
|
|
13
13
|
'doc': 'Deprecated. Please use lang:translation.'}),
|
|
14
14
|
|
|
15
|
+
('lang:phrase', ('str', {'lower': True, 'onespace': True}), {
|
|
16
|
+
'doc': 'A small group of words which stand together as a concept.'}),
|
|
17
|
+
|
|
15
18
|
('lang:trans', ('str', {}), {
|
|
16
19
|
'deprecated': True,
|
|
17
20
|
'doc': 'Deprecated. Please use lang:translation.'}),
|
|
@@ -31,6 +34,7 @@ class LangModule(s_module.CoreModule):
|
|
|
31
34
|
),
|
|
32
35
|
'forms': (
|
|
33
36
|
|
|
37
|
+
('lang:phrase', {}, ()),
|
|
34
38
|
('lang:idiom', {}, (
|
|
35
39
|
|
|
36
40
|
('url', ('inet:url', {}), {
|
synapse/models/math.py
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import synapse.lib.module as s_module
|
|
2
|
+
|
|
3
|
+
class MathModule(s_module.CoreModule):
|
|
4
|
+
|
|
5
|
+
def getModelDefs(self):
|
|
6
|
+
return (('math', {
|
|
7
|
+
'types': (
|
|
8
|
+
|
|
9
|
+
('math:algorithm', ('guid', {}), {
|
|
10
|
+
'doc': 'A mathematical algorithm.'}),
|
|
11
|
+
|
|
12
|
+
('math:algorithm:type:taxonomy', ('taxonomy', {}), {
|
|
13
|
+
'interfaces': ('meta:taxonomy',),
|
|
14
|
+
'doc': 'A hierarchical taxonomy of algorithm types.'}),
|
|
15
|
+
),
|
|
16
|
+
'edges': (
|
|
17
|
+
|
|
18
|
+
(('risk:tool:software', 'uses', 'math:algorithm'), {
|
|
19
|
+
'doc': 'The tool uses the algorithm.'}),
|
|
20
|
+
|
|
21
|
+
(('it:prod:softver', 'uses', 'math:algorithm'), {
|
|
22
|
+
'doc': 'The software uses the algorithm.'}),
|
|
23
|
+
|
|
24
|
+
(('file:bytes', 'uses', 'math:algorithm'), {
|
|
25
|
+
'doc': 'The file uses the algorithm.'}),
|
|
26
|
+
|
|
27
|
+
(('math:algorithm', 'generates', None), {
|
|
28
|
+
'doc': 'The target node was generated by the algorithm.'}),
|
|
29
|
+
),
|
|
30
|
+
'forms': (
|
|
31
|
+
|
|
32
|
+
('math:algorithm:type:taxonomy', {}, ()),
|
|
33
|
+
|
|
34
|
+
('math:algorithm', {}, (
|
|
35
|
+
|
|
36
|
+
('name', ('str', {'lower': True, 'onespace': True}), {
|
|
37
|
+
'doc': 'The name of the algorithm.'}),
|
|
38
|
+
|
|
39
|
+
('type', ('math:algorithm:type:taxonomy', {}), {
|
|
40
|
+
'doc': 'The type of algorithm.'}),
|
|
41
|
+
|
|
42
|
+
('desc', ('str', {}), {
|
|
43
|
+
'disp': {'hint': 'text'},
|
|
44
|
+
'doc': 'A description of the algorithm.'}),
|
|
45
|
+
|
|
46
|
+
('created', ('time', {}), {
|
|
47
|
+
'doc': 'The time that the algorithm was authored.'}),
|
|
48
|
+
)),
|
|
49
|
+
),
|
|
50
|
+
}),)
|
synapse/models/orgs.py
CHANGED
|
@@ -480,6 +480,9 @@ class OuModule(s_module.CoreModule):
|
|
|
480
480
|
('goal', ('ou:goal', {}), {
|
|
481
481
|
'doc': 'The assessed primary goal of the campaign.'}),
|
|
482
482
|
|
|
483
|
+
('slogan', ('lang:phrase', {}), {
|
|
484
|
+
'doc': 'The slogan used by the campaign.'}),
|
|
485
|
+
|
|
483
486
|
('actors', ('array', {'type': 'ps:contact', 'split': ',', 'uniq': True, 'sorted': True}), {
|
|
484
487
|
'doc': 'Actors who participated in the campaign.'}),
|
|
485
488
|
|
|
@@ -633,12 +636,16 @@ class OuModule(s_module.CoreModule):
|
|
|
633
636
|
'doc': 'Location for an organization.'
|
|
634
637
|
}),
|
|
635
638
|
('name', ('ou:name', {}), {
|
|
639
|
+
'alts': ('names',),
|
|
636
640
|
'doc': 'The localized name of an organization.',
|
|
637
641
|
}),
|
|
638
642
|
('type', ('str', {'lower': True, 'strip': True}), {
|
|
639
643
|
'deprecated': True,
|
|
640
644
|
'doc': 'The type of organization.',
|
|
641
645
|
}),
|
|
646
|
+
('motto', ('lang:phrase', {}), {
|
|
647
|
+
'doc': 'The motto used by the organization.'}),
|
|
648
|
+
|
|
642
649
|
('orgtype', ('ou:orgtype', {}), {
|
|
643
650
|
'doc': 'The type of organization.',
|
|
644
651
|
'disp': {'hint': 'taxonomy'},
|
|
@@ -775,6 +782,7 @@ class OuModule(s_module.CoreModule):
|
|
|
775
782
|
'deprecated': True,
|
|
776
783
|
'doc': 'A list of types that apply to the contract.'}),
|
|
777
784
|
)),
|
|
785
|
+
('ou:industry:type:taxonomy', {}, ()),
|
|
778
786
|
('ou:industry', {}, (
|
|
779
787
|
|
|
780
788
|
('name', ('ou:industryname', {}), {
|
synapse/models/risk.py
CHANGED
|
@@ -648,12 +648,21 @@ class RiskModule(s_module.CoreModule):
|
|
|
648
648
|
)),
|
|
649
649
|
|
|
650
650
|
('risk:vulnerable', {}, (
|
|
651
|
+
|
|
651
652
|
('vuln', ('risk:vuln', {}), {
|
|
652
653
|
'doc': 'The vulnerability that the node is susceptible to.'}),
|
|
654
|
+
|
|
653
655
|
('period', ('ival', {}), {
|
|
654
656
|
'doc': 'The time window where the node was vulnerable.'}),
|
|
657
|
+
|
|
655
658
|
('node', ('ndef', {}), {
|
|
656
659
|
'doc': 'The node which is vulnerable.'}),
|
|
660
|
+
|
|
661
|
+
('mitigated', ('bool', {}), {
|
|
662
|
+
'doc': 'Set to true if the vulnerable node has been mitigated.'}),
|
|
663
|
+
|
|
664
|
+
('mitigations', ('array', {'type': 'risk:mitigation', 'sorted': True, 'uniq': True}), {
|
|
665
|
+
'doc': 'The mitigations which were used to address the vulnerable node.'}),
|
|
657
666
|
)),
|
|
658
667
|
|
|
659
668
|
('risk:alert:taxonomy', {}, {}),
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
function foo() {
|
|
2
|
+
if $lib.true {
|
|
3
|
+
stop
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
if $lib.false { $lib.print("no cover") } // pragma: no cover
|
|
7
|
+
|
|
8
|
+
if $lib.false { // pragma: no cover start
|
|
9
|
+
$lib.print("multi-line no cover")
|
|
10
|
+
} // pragma: no cover stop
|
|
11
|
+
|
|
12
|
+
if $lib.false { $lib.print("stop before start") } // pragma: no cover stop
|
|
13
|
+
|
|
14
|
+
if $lib.false { // pragma: no cover start
|
|
15
|
+
$lib.print("start in a block") // pragma: no cover start
|
|
16
|
+
} // pragma: no cover stop
|
|
17
|
+
}
|
|
18
|
+
yield $foo()
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import os
|
|
2
|
+
import synapse.assets as s_assets
|
|
3
|
+
|
|
4
|
+
import synapse.tests.utils as s_t_utils
|
|
5
|
+
|
|
6
|
+
class TestAssets(s_t_utils.SynTest):
|
|
7
|
+
|
|
8
|
+
def test_assets_path(self):
|
|
9
|
+
|
|
10
|
+
fp = s_assets.getAssetPath('storm', 'migrations', 'model-0.2.28.storm')
|
|
11
|
+
self.true(os.path.isfile(fp))
|
|
12
|
+
|
|
13
|
+
with self.raises(ValueError) as cm:
|
|
14
|
+
s_assets.getAssetPath('../../../../../../../etc/passwd')
|
|
15
|
+
self.isin('Path escaping', str(cm.exception))
|
|
16
|
+
|
|
17
|
+
with self.raises(ValueError) as cm:
|
|
18
|
+
s_assets.getAssetPath('newp', 'does', 'not', 'exit')
|
|
19
|
+
self.isin('Asset does not exist', str(cm.exception))
|
|
20
|
+
|
|
21
|
+
def test_assets_storm(self):
|
|
22
|
+
|
|
23
|
+
text = s_assets.getStorm('migrations', 'model-0.2.28.storm')
|
|
24
|
+
self.isinstance(text, str)
|
|
25
|
+
self.gt(len(text), 0)
|