synapse 2.184.0__py311-none-any.whl → 2.185.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/cortex.py +1 -1
- synapse/datamodel.py +41 -6
- synapse/lib/ast.py +82 -21
- synapse/lib/auth.py +13 -0
- synapse/lib/cell.py +13 -0
- synapse/lib/modules.py +1 -0
- synapse/lib/parser.py +1 -0
- synapse/lib/snap.py +1 -0
- synapse/lib/storm.lark +12 -6
- synapse/lib/storm.py +45 -9
- synapse/lib/storm_format.py +1 -0
- synapse/lib/stormlib/stix.py +14 -5
- synapse/lib/stormtypes.py +64 -36
- synapse/lib/version.py +2 -2
- synapse/models/doc.py +93 -0
- synapse/models/infotech.py +2 -1
- synapse/models/media.py +0 -1
- synapse/models/orgs.py +26 -3
- synapse/models/proj.py +56 -36
- synapse/models/syn.py +64 -6
- synapse/tests/test_cortex.py +39 -1
- synapse/tests/test_lib_cell.py +44 -1
- synapse/tests/test_lib_grammar.py +2 -0
- synapse/tests/test_lib_storm.py +54 -1
- synapse/tests/test_lib_stormlib_stix.py +3 -2
- synapse/tests/test_model_doc.py +51 -0
- synapse/tests/test_model_orgs.py +41 -0
- synapse/tests/test_model_syn.py +43 -0
- synapse/tests/test_tools_promote.py +67 -0
- synapse/tools/promote.py +14 -1
- {synapse-2.184.0.dist-info → synapse-2.185.0.dist-info}/METADATA +5 -10
- {synapse-2.184.0.dist-info → synapse-2.185.0.dist-info}/RECORD +35 -32
- {synapse-2.184.0.dist-info → synapse-2.185.0.dist-info}/LICENSE +0 -0
- {synapse-2.184.0.dist-info → synapse-2.185.0.dist-info}/WHEEL +0 -0
- {synapse-2.184.0.dist-info → synapse-2.185.0.dist-info}/top_level.txt +0 -0
synapse/lib/stormtypes.py
CHANGED
|
@@ -1328,6 +1328,22 @@ class LibBase(Lib):
|
|
|
1328
1328
|
),
|
|
1329
1329
|
'returns': {'type': 'list',
|
|
1330
1330
|
'desc': 'A list of (<bool>, <prim>) for status and normalized value.', }}},
|
|
1331
|
+
{'name': 'repr', 'desc': '''
|
|
1332
|
+
Attempt to convert a system mode value to a display mode string.
|
|
1333
|
+
|
|
1334
|
+
Examples:
|
|
1335
|
+
Print the Synapse user name for an iden::
|
|
1336
|
+
|
|
1337
|
+
$lib.print($lib.repr(syn:user, $iden))
|
|
1338
|
+
|
|
1339
|
+
''',
|
|
1340
|
+
'type': {'type': 'function', '_funcname': '_repr',
|
|
1341
|
+
'args': (
|
|
1342
|
+
{'name': 'name', 'type': 'str', 'desc': 'The name of the model type.'},
|
|
1343
|
+
{'name': 'valu', 'type': 'any', 'desc': 'The value to convert.'},
|
|
1344
|
+
),
|
|
1345
|
+
'returns': {'type': 'str', 'desc': 'A display mode representation of the value.'}}},
|
|
1346
|
+
|
|
1331
1347
|
{'name': 'debug', 'desc': '''
|
|
1332
1348
|
True if the current runtime has debugging enabled.
|
|
1333
1349
|
|
|
@@ -1400,6 +1416,7 @@ class LibBase(Lib):
|
|
|
1400
1416
|
'false': False,
|
|
1401
1417
|
'text': self._text,
|
|
1402
1418
|
'cast': self._cast,
|
|
1419
|
+
'repr': self._repr,
|
|
1403
1420
|
'warn': self._warn,
|
|
1404
1421
|
'print': self._print,
|
|
1405
1422
|
'raise': self._raise,
|
|
@@ -1489,22 +1506,26 @@ class LibBase(Lib):
|
|
|
1489
1506
|
mesg = 'Nested type does not support being copied!'
|
|
1490
1507
|
raise s_exc.BadArg(mesg=mesg) from None
|
|
1491
1508
|
|
|
1509
|
+
def _reqTypeByName(self, name):
|
|
1510
|
+
typeitem = self.runt.snap.core.model.type(name)
|
|
1511
|
+
if typeitem is not None:
|
|
1512
|
+
return typeitem
|
|
1513
|
+
|
|
1514
|
+
# If a type cannot be found for the form, see if name is a property
|
|
1515
|
+
# that has a type we can use
|
|
1516
|
+
propitem = self.runt.snap.core.model.prop(name)
|
|
1517
|
+
if propitem is not None:
|
|
1518
|
+
return propitem.type
|
|
1519
|
+
|
|
1520
|
+
mesg = f'No type or prop found for name {name}.'
|
|
1521
|
+
raise s_exc.NoSuchType(mesg=mesg)
|
|
1522
|
+
|
|
1492
1523
|
@stormfunc(readonly=True)
|
|
1493
1524
|
async def _cast(self, name, valu):
|
|
1494
1525
|
name = await toprim(name)
|
|
1495
1526
|
valu = await toprim(valu)
|
|
1496
1527
|
|
|
1497
|
-
typeitem = self.
|
|
1498
|
-
if typeitem is None:
|
|
1499
|
-
# If a type cannot be found for the form, see if name is a property
|
|
1500
|
-
# that has a type we can use
|
|
1501
|
-
propitem = self.runt.snap.core.model.prop(name)
|
|
1502
|
-
if propitem is None:
|
|
1503
|
-
mesg = f'No type or prop found for name {name}.'
|
|
1504
|
-
raise s_exc.NoSuchType(mesg=mesg)
|
|
1505
|
-
|
|
1506
|
-
typeitem = propitem.type
|
|
1507
|
-
|
|
1528
|
+
typeitem = self._reqTypeByName(name)
|
|
1508
1529
|
# TODO an eventual mapping between model types and storm prims
|
|
1509
1530
|
|
|
1510
1531
|
norm, info = typeitem.norm(valu)
|
|
@@ -1515,16 +1536,7 @@ class LibBase(Lib):
|
|
|
1515
1536
|
name = await toprim(name)
|
|
1516
1537
|
valu = await toprim(valu)
|
|
1517
1538
|
|
|
1518
|
-
typeitem = self.
|
|
1519
|
-
if typeitem is None:
|
|
1520
|
-
# If a type cannot be found for the form, see if name is a property
|
|
1521
|
-
# that has a type we can use
|
|
1522
|
-
propitem = self.runt.snap.core.model.prop(name)
|
|
1523
|
-
if propitem is None:
|
|
1524
|
-
mesg = f'No type or prop found for name {name}.'
|
|
1525
|
-
raise s_exc.NoSuchType(mesg=mesg)
|
|
1526
|
-
|
|
1527
|
-
typeitem = propitem.type
|
|
1539
|
+
typeitem = self._reqTypeByName(name)
|
|
1528
1540
|
|
|
1529
1541
|
try:
|
|
1530
1542
|
norm, info = typeitem.norm(valu)
|
|
@@ -1532,6 +1544,13 @@ class LibBase(Lib):
|
|
|
1532
1544
|
except s_exc.BadTypeValu:
|
|
1533
1545
|
return (False, None)
|
|
1534
1546
|
|
|
1547
|
+
@stormfunc(readonly=True)
|
|
1548
|
+
async def _repr(self, name, valu):
|
|
1549
|
+
name = await toprim(name)
|
|
1550
|
+
valu = await toprim(valu)
|
|
1551
|
+
|
|
1552
|
+
return self._reqTypeByName(name).repr(valu)
|
|
1553
|
+
|
|
1535
1554
|
@stormfunc(readonly=True)
|
|
1536
1555
|
async def _exit(self, mesg=None, **kwargs):
|
|
1537
1556
|
if mesg:
|
|
@@ -1720,7 +1739,7 @@ class LibDict(Lib):
|
|
|
1720
1739
|
'type': {'type': 'function', '_funcname': '_has',
|
|
1721
1740
|
'args': (
|
|
1722
1741
|
{'name': 'valu', 'type': 'dict', 'desc': 'The dictionary being checked.'},
|
|
1723
|
-
{'name': '
|
|
1742
|
+
{'name': 'key', 'type': 'any', 'desc': 'The key to check.'},
|
|
1724
1743
|
),
|
|
1725
1744
|
'returns': {'type': 'boolean', 'desc': 'True if the key is present, false if the key is not present.'}}},
|
|
1726
1745
|
{'name': 'keys', 'desc': 'Retrieve a list of keys in the specified dictionary.',
|
|
@@ -1733,7 +1752,7 @@ class LibDict(Lib):
|
|
|
1733
1752
|
'type': {'type': 'function', '_funcname': '_pop',
|
|
1734
1753
|
'args': (
|
|
1735
1754
|
{'name': 'valu', 'type': 'dict', 'desc': 'The dictionary to operate on.'},
|
|
1736
|
-
{'name': 'key', 'type': '
|
|
1755
|
+
{'name': 'key', 'type': 'any', 'desc': 'The key to pop.'},
|
|
1737
1756
|
{'name': 'default', 'type': 'any', 'default': '$lib.undef',
|
|
1738
1757
|
'desc': 'Optional default value to return if the key does not exist in the dictionary.'},
|
|
1739
1758
|
),
|
|
@@ -1776,10 +1795,11 @@ class LibDict(Lib):
|
|
|
1776
1795
|
raise s_exc.BadArg(mesg=mesg)
|
|
1777
1796
|
|
|
1778
1797
|
@stormfunc(readonly=True)
|
|
1779
|
-
async def _has(self, valu,
|
|
1798
|
+
async def _has(self, valu, key):
|
|
1780
1799
|
await self._check_type(valu)
|
|
1800
|
+
key = await toprim(key)
|
|
1781
1801
|
valu = await toprim(valu)
|
|
1782
|
-
return
|
|
1802
|
+
return key in valu
|
|
1783
1803
|
|
|
1784
1804
|
@stormfunc(readonly=True)
|
|
1785
1805
|
async def _keys(self, valu):
|
|
@@ -1791,8 +1811,8 @@ class LibDict(Lib):
|
|
|
1791
1811
|
async def _pop(self, valu, key, default=undef):
|
|
1792
1812
|
await self._check_type(valu)
|
|
1793
1813
|
|
|
1814
|
+
key = await toprim(key)
|
|
1794
1815
|
real = await toprim(valu)
|
|
1795
|
-
key = await tostr(key)
|
|
1796
1816
|
|
|
1797
1817
|
if key not in real:
|
|
1798
1818
|
if default == undef:
|
|
@@ -4808,8 +4828,8 @@ class Dict(Prim):
|
|
|
4808
4828
|
name = await toprim(name)
|
|
4809
4829
|
return self.valu.get(name)
|
|
4810
4830
|
|
|
4811
|
-
async def value(self):
|
|
4812
|
-
return {await toprim(k): await toprim(v) for (k, v) in self.valu.items()}
|
|
4831
|
+
async def value(self, use_list=False):
|
|
4832
|
+
return {await toprim(k): await toprim(v, use_list=use_list) for (k, v) in self.valu.items()}
|
|
4813
4833
|
|
|
4814
4834
|
async def stormrepr(self):
|
|
4815
4835
|
reprs = ["{}: {}".format(await torepr(k), await torepr(v)) for (k, v) in list(self.valu.items())]
|
|
@@ -4845,9 +4865,9 @@ class CmdOpts(Dict):
|
|
|
4845
4865
|
name = await tostr(name)
|
|
4846
4866
|
return getattr(self.valu.opts, name, None)
|
|
4847
4867
|
|
|
4848
|
-
async def value(self):
|
|
4868
|
+
async def value(self, use_list=False):
|
|
4849
4869
|
valu = vars(self.valu.opts)
|
|
4850
|
-
return {await toprim(k): await toprim(v) for (k, v) in valu.items()}
|
|
4870
|
+
return {await toprim(k): await toprim(v, use_list=use_list) for (k, v) in valu.items()}
|
|
4851
4871
|
|
|
4852
4872
|
async def iter(self):
|
|
4853
4873
|
valu = vars(self.valu.opts)
|
|
@@ -5193,8 +5213,10 @@ class List(Prim):
|
|
|
5193
5213
|
async for item in toiter(valu):
|
|
5194
5214
|
self.valu.append(item)
|
|
5195
5215
|
|
|
5196
|
-
async def value(self):
|
|
5197
|
-
|
|
5216
|
+
async def value(self, use_list=False):
|
|
5217
|
+
if use_list:
|
|
5218
|
+
return [await toprim(v, use_list=use_list) for v in self.valu]
|
|
5219
|
+
return tuple([await toprim(v, use_list=use_list) for v in self.valu])
|
|
5198
5220
|
|
|
5199
5221
|
async def iter(self):
|
|
5200
5222
|
for item in self.valu:
|
|
@@ -9476,7 +9498,7 @@ class CronJob(Prim):
|
|
|
9476
9498
|
return job
|
|
9477
9499
|
|
|
9478
9500
|
# These will go away once we have value objects in storm runtime
|
|
9479
|
-
async def toprim(valu, path=None):
|
|
9501
|
+
async def toprim(valu, path=None, use_list=False):
|
|
9480
9502
|
|
|
9481
9503
|
if isinstance(valu, (str, int, bool, float, bytes, types.AsyncGeneratorType, types.GeneratorType)) or valu is None:
|
|
9482
9504
|
return valu
|
|
@@ -9485,16 +9507,19 @@ async def toprim(valu, path=None):
|
|
|
9485
9507
|
retn = []
|
|
9486
9508
|
for v in valu:
|
|
9487
9509
|
try:
|
|
9488
|
-
retn.append(await toprim(v))
|
|
9510
|
+
retn.append(await toprim(v, use_list=use_list))
|
|
9489
9511
|
except s_exc.NoSuchType:
|
|
9490
9512
|
pass
|
|
9491
|
-
|
|
9513
|
+
|
|
9514
|
+
if not use_list:
|
|
9515
|
+
return tuple(retn)
|
|
9516
|
+
return retn
|
|
9492
9517
|
|
|
9493
9518
|
if isinstance(valu, dict):
|
|
9494
9519
|
retn = {}
|
|
9495
9520
|
for k, v in valu.items():
|
|
9496
9521
|
try:
|
|
9497
|
-
retn[k] = await toprim(v)
|
|
9522
|
+
retn[k] = await toprim(v, use_list=use_list)
|
|
9498
9523
|
except s_exc.NoSuchType:
|
|
9499
9524
|
pass
|
|
9500
9525
|
return retn
|
|
@@ -9502,6 +9527,9 @@ async def toprim(valu, path=None):
|
|
|
9502
9527
|
if isinstance(valu, Number):
|
|
9503
9528
|
return float(valu.value())
|
|
9504
9529
|
|
|
9530
|
+
if isinstance(valu, (Dict, List)):
|
|
9531
|
+
return await valu.value(use_list=use_list)
|
|
9532
|
+
|
|
9505
9533
|
if isinstance(valu, Prim):
|
|
9506
9534
|
return await s_coro.ornot(valu.value)
|
|
9507
9535
|
|
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, 185, 0)
|
|
227
227
|
verstring = '.'.join([str(x) for x in version])
|
|
228
|
-
commit = '
|
|
228
|
+
commit = 'c2ef0eded02f8ac5f34704a117947f44095f41f4'
|
synapse/models/doc.py
ADDED
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import synapse.exc as s_exc
|
|
2
|
+
import synapse.lib.module as s_module
|
|
3
|
+
|
|
4
|
+
class DocModule(s_module.CoreModule):
|
|
5
|
+
|
|
6
|
+
def getModelDefs(self):
|
|
7
|
+
return (('doc', {
|
|
8
|
+
'interfaces': (
|
|
9
|
+
('doc:document', {
|
|
10
|
+
|
|
11
|
+
'doc': 'A common interface for documents.',
|
|
12
|
+
|
|
13
|
+
'template': {
|
|
14
|
+
'type': 'NEWP',
|
|
15
|
+
'document': 'document',
|
|
16
|
+
'documents': 'documents'},
|
|
17
|
+
|
|
18
|
+
'props': (
|
|
19
|
+
|
|
20
|
+
('id', ('str', {'strip': True}), {
|
|
21
|
+
'doc': 'The {document} ID.'}),
|
|
22
|
+
|
|
23
|
+
('name', ('str', {'lower': True, 'onespace': True}), {
|
|
24
|
+
'doc': 'The {document} name.'}),
|
|
25
|
+
|
|
26
|
+
('type', ('{type}', {}), {
|
|
27
|
+
'doc': 'The type of {document}.'}),
|
|
28
|
+
|
|
29
|
+
('text', ('str', {}), {
|
|
30
|
+
'doc': 'The text of the {document}.'}),
|
|
31
|
+
|
|
32
|
+
('file', ('file:bytes', {}), {
|
|
33
|
+
'doc': 'The file which contains the {document}.'}),
|
|
34
|
+
|
|
35
|
+
('created', ('time', {}), {
|
|
36
|
+
'doc': 'The time that the {document} was created.'}),
|
|
37
|
+
|
|
38
|
+
('updated', ('time', {}), {
|
|
39
|
+
'doc': 'The time that the {document} was last updated.'}),
|
|
40
|
+
|
|
41
|
+
('author', ('ps:contact', {}), {
|
|
42
|
+
'doc': 'The contact information of the primary author.'}),
|
|
43
|
+
|
|
44
|
+
('contributors', ('array', {'type': 'ps:contact', 'sorted': True, 'uniq': True}), {
|
|
45
|
+
'doc': 'An array of contacts which contributed to the {document}.'}),
|
|
46
|
+
|
|
47
|
+
('version', ('it:semver', {}), {
|
|
48
|
+
'doc': 'The version of the {document}.'}),
|
|
49
|
+
|
|
50
|
+
('supersedes', ('array', {'type': '$self', 'sorted': True, 'uniq': True}), {
|
|
51
|
+
'doc': 'An array of {documents} which are superseded by this {document}.'}),
|
|
52
|
+
),
|
|
53
|
+
}),
|
|
54
|
+
),
|
|
55
|
+
'types': (
|
|
56
|
+
|
|
57
|
+
('doc:policy:type:taxonomy', ('taxonomy', {}), {
|
|
58
|
+
'interfaces': ('meta:taxonomy',),
|
|
59
|
+
'doc': 'A taxonomy of policy types.'}),
|
|
60
|
+
|
|
61
|
+
('doc:policy', ('guid', {}), {
|
|
62
|
+
'interfaces': ('doc:document',),
|
|
63
|
+
'template': {
|
|
64
|
+
'document': 'policy',
|
|
65
|
+
'documents': 'policies',
|
|
66
|
+
'type': 'doc:policy:type:taxonomy'},
|
|
67
|
+
'doc': 'Guiding principles used to reach a set of goals.'}),
|
|
68
|
+
|
|
69
|
+
('doc:standard:type:taxonomy', ('taxonomy', {}), {
|
|
70
|
+
'interfaces': ('meta:taxonomy',),
|
|
71
|
+
'doc': 'A taxonomy of standard types.'}),
|
|
72
|
+
|
|
73
|
+
('doc:standard', ('guid', {}), {
|
|
74
|
+
'interfaces': ('doc:document',),
|
|
75
|
+
'template': {
|
|
76
|
+
'document': 'standard',
|
|
77
|
+
'documents': 'standards',
|
|
78
|
+
'type': 'doc:standard:type:taxonomy'},
|
|
79
|
+
'doc': 'A group of requirements which define how to implement a policy or goal.'}),
|
|
80
|
+
),
|
|
81
|
+
'forms': (
|
|
82
|
+
|
|
83
|
+
('doc:policy:type:taxonomy', {}, ()),
|
|
84
|
+
('doc:policy', {}, ()),
|
|
85
|
+
|
|
86
|
+
('doc:standard:type:taxonomy', {}, ()),
|
|
87
|
+
('doc:standard', {}, (
|
|
88
|
+
('policy', ('doc:policy', {}), {
|
|
89
|
+
'doc': 'The policy which was used to derive the standard.'}),
|
|
90
|
+
)),
|
|
91
|
+
),
|
|
92
|
+
'edges': (),
|
|
93
|
+
}),)
|
synapse/models/infotech.py
CHANGED
|
@@ -1882,7 +1882,8 @@ class ItModule(s_module.CoreModule):
|
|
|
1882
1882
|
'disp': {'hint': 'text'},
|
|
1883
1883
|
'doc': 'The commit message describing the changes in the commit.'}),
|
|
1884
1884
|
|
|
1885
|
-
|
|
1885
|
+
# we mirror the interface type options...
|
|
1886
|
+
('id', ('str', {'strip': True}), {
|
|
1886
1887
|
'doc': 'The version control system specific commit identifier.'}),
|
|
1887
1888
|
|
|
1888
1889
|
('created', ('time', {}), {
|
synapse/models/media.py
CHANGED
synapse/models/orgs.py
CHANGED
|
@@ -262,13 +262,25 @@ class OuModule(s_module.CoreModule):
|
|
|
262
262
|
'interfaces': ('meta:taxonomy',),
|
|
263
263
|
}),
|
|
264
264
|
('ou:jobtitle', ('str', {'lower': True, 'onespace': True}), {
|
|
265
|
-
'doc': 'A title for a position within an org.',
|
|
266
|
-
|
|
265
|
+
'doc': 'A title for a position within an org.'}),
|
|
266
|
+
|
|
267
|
+
('ou:enacted:status:taxonomy', ('taxonomy', {}), {
|
|
268
|
+
'interfaces': ('meta:taxonomy',),
|
|
269
|
+
'doc': 'A taxonomy of enacted statuses.'}),
|
|
270
|
+
|
|
271
|
+
('ou:enacted', ('guid', {}), {
|
|
272
|
+
'interfaces': ('proj:task',),
|
|
273
|
+
'template': {
|
|
274
|
+
'task': 'adoption task'},
|
|
275
|
+
'doc': 'An organization enacting a document.'}),
|
|
276
|
+
|
|
267
277
|
('ou:requirement:type:taxonomy', ('taxonomy', {}), {
|
|
268
278
|
'interfaces': ('meta:taxonomy',),
|
|
269
279
|
'doc': 'A taxonomy of requirement types.'}),
|
|
280
|
+
|
|
270
281
|
('ou:requirement', ('guid', {}), {
|
|
271
282
|
'doc': 'A specific requirement.'}),
|
|
283
|
+
|
|
272
284
|
),
|
|
273
285
|
'edges': (
|
|
274
286
|
(('ou:campaign', 'uses', 'ou:technique'), {
|
|
@@ -1281,8 +1293,19 @@ class OuModule(s_module.CoreModule):
|
|
|
1281
1293
|
('url', ('inet:url', {}), {
|
|
1282
1294
|
'doc': 'The contest result website URL.',
|
|
1283
1295
|
}),
|
|
1284
|
-
# TODO duration ('duration'
|
|
1285
1296
|
)),
|
|
1297
|
+
('ou:enacted:status:taxonomy', {}, ()),
|
|
1298
|
+
('ou:enacted', {}, (
|
|
1299
|
+
('org', ('ou:org', {}), {
|
|
1300
|
+
'doc': 'The organization which is enacting the document.'}),
|
|
1301
|
+
|
|
1302
|
+
('doc', ('ndef', {'forms': ('doc:policy', 'doc:standard')}), {
|
|
1303
|
+
'doc': 'The document enacted by the organization.'}),
|
|
1304
|
+
|
|
1305
|
+
('scope', ('ndef', {}), {
|
|
1306
|
+
'doc': 'The scope of responsbility for the assignee to enact the document.'}),
|
|
1307
|
+
)),
|
|
1308
|
+
|
|
1286
1309
|
('ou:requirement:type:taxonomy', {}, ()),
|
|
1287
1310
|
('ou:requirement', {}, (
|
|
1288
1311
|
|
synapse/models/proj.py
CHANGED
|
@@ -1,14 +1,5 @@
|
|
|
1
1
|
import synapse.lib.module as s_module
|
|
2
2
|
|
|
3
|
-
prioenums = (
|
|
4
|
-
(0, 'none'),
|
|
5
|
-
(10, 'lowest'),
|
|
6
|
-
(20, 'low'),
|
|
7
|
-
(30, 'medium'),
|
|
8
|
-
(40, 'high'),
|
|
9
|
-
(50, 'highest'),
|
|
10
|
-
)
|
|
11
|
-
|
|
12
3
|
statusenums = (
|
|
13
4
|
(0, 'new'),
|
|
14
5
|
(10, 'in validation'),
|
|
@@ -47,11 +38,63 @@ class ProjectModule(s_module.CoreModule):
|
|
|
47
38
|
|
|
48
39
|
('proj', {
|
|
49
40
|
|
|
41
|
+
'interfaces': (
|
|
42
|
+
('proj:task', {
|
|
43
|
+
|
|
44
|
+
'doc': 'A common interface for tasks.',
|
|
45
|
+
|
|
46
|
+
'template': {
|
|
47
|
+
'task': 'task'},
|
|
48
|
+
|
|
49
|
+
'props': (
|
|
50
|
+
|
|
51
|
+
('id', ('str', {'strip': True}), {
|
|
52
|
+
'doc': 'The ID of the {task}.'}),
|
|
53
|
+
|
|
54
|
+
('project', ('proj:project', {}), {
|
|
55
|
+
'doc': 'The project containing the {task}.'}),
|
|
56
|
+
|
|
57
|
+
('status', ('int', {}), {
|
|
58
|
+
# TODO: make runtime setable int enum typeopts
|
|
59
|
+
'doc': 'The status of the {task}.'}),
|
|
60
|
+
|
|
61
|
+
('priority', ('meta:priority', {}), {
|
|
62
|
+
'doc': 'The priority of the {task}.'}),
|
|
63
|
+
|
|
64
|
+
('created', ('time', {}), {
|
|
65
|
+
'doc': 'The time the {task} was created.'}),
|
|
66
|
+
|
|
67
|
+
('updated', ('time', {}), {
|
|
68
|
+
'doc': 'The time the {task} was last updated.'}),
|
|
69
|
+
|
|
70
|
+
('due', ('time', {}), {
|
|
71
|
+
'doc': 'The time the {task} must be complete.'}),
|
|
72
|
+
|
|
73
|
+
('completed', ('time', {}), {
|
|
74
|
+
'doc': 'The time the {task} was completed.'}),
|
|
75
|
+
|
|
76
|
+
('creator', ('syn:user', {}), {
|
|
77
|
+
'doc': 'The user which created the {task}.'}),
|
|
78
|
+
|
|
79
|
+
('assignee', ('syn:user', {}), {
|
|
80
|
+
'doc': 'The user assigned to complete the {task}.'}),
|
|
81
|
+
|
|
82
|
+
('ext:creator', ('ps:contact', {}), {
|
|
83
|
+
'doc': 'The contact information of the creator from an external system.'}),
|
|
84
|
+
|
|
85
|
+
('ext:assignee', ('ps:contact', {}), {
|
|
86
|
+
'doc': 'The contact information of the assignee from an external system.'}),
|
|
87
|
+
),
|
|
88
|
+
}),
|
|
89
|
+
),
|
|
50
90
|
'types': (
|
|
51
91
|
('proj:epic', ('guid', {}), {
|
|
52
|
-
'doc': 'A collection of tickets related to a topic.',
|
|
53
|
-
|
|
92
|
+
'doc': 'A collection of tickets related to a topic.'}),
|
|
93
|
+
|
|
54
94
|
('proj:ticket', ('guid', {}), {
|
|
95
|
+
'interfaces': ('proj:task',),
|
|
96
|
+
'template': {
|
|
97
|
+
'task': 'ticket'},
|
|
55
98
|
'doc': 'A ticket in a ticketing system.'}),
|
|
56
99
|
|
|
57
100
|
('proj:project:type:taxonomy', ('taxonomy', {}), {
|
|
@@ -180,30 +223,16 @@ class ProjectModule(s_module.CoreModule):
|
|
|
180
223
|
|
|
181
224
|
('proj:ticket', {}, (
|
|
182
225
|
|
|
183
|
-
('project', ('proj:project', {}), {
|
|
184
|
-
'doc': 'The project containing the ticket.'}),
|
|
185
|
-
|
|
186
226
|
('ext:id', ('str', {'strip': True}), {
|
|
187
|
-
'
|
|
227
|
+
'deprecated': True,
|
|
228
|
+
'doc': 'Deprecated. Please use :id.'}),
|
|
188
229
|
|
|
189
230
|
('ext:url', ('inet:url', {}), {
|
|
190
231
|
'doc': 'A URL to the ticket in an external system.'}),
|
|
191
232
|
|
|
192
|
-
('ext:creator', ('ps:contact', {}), {
|
|
193
|
-
'doc': 'Ticket creator contact information from an external system.'}),
|
|
194
|
-
|
|
195
|
-
('ext:assignee', ('ps:contact', {}), {
|
|
196
|
-
'doc': 'Ticket assignee contact information from an external system.'}),
|
|
197
|
-
|
|
198
233
|
('epic', ('proj:epic', {}), {
|
|
199
234
|
'doc': 'The epic that includes the ticket.'}),
|
|
200
235
|
|
|
201
|
-
('created', ('time', {}), {
|
|
202
|
-
'doc': 'The time the ticket was created.'}),
|
|
203
|
-
|
|
204
|
-
('updated', ('time', {'ismax': True}), {
|
|
205
|
-
'doc': 'The last time the ticket was updated.'}),
|
|
206
|
-
|
|
207
236
|
('name', ('str', {'onespace': True}), {
|
|
208
237
|
'doc': 'The name of the ticket.'}),
|
|
209
238
|
|
|
@@ -219,17 +248,8 @@ class ProjectModule(s_module.CoreModule):
|
|
|
219
248
|
('sprint', ('proj:sprint', {}), {
|
|
220
249
|
'doc': 'The sprint that contains the ticket.'}),
|
|
221
250
|
|
|
222
|
-
('priority', ('int', {'enums': prioenums}), {
|
|
223
|
-
'doc': 'The priority of the ticket.'}),
|
|
224
|
-
|
|
225
251
|
('type', ('str', {'lower': True, 'strip': True}), {
|
|
226
252
|
'doc': 'The type of ticket. (eg story / bug)'}),
|
|
227
|
-
|
|
228
|
-
('creator', ('syn:user', {}), {
|
|
229
|
-
'doc': 'The synapse user who created the ticket.'}),
|
|
230
|
-
|
|
231
|
-
('assignee', ('syn:user', {}), {
|
|
232
|
-
'doc': 'The synapse user who the ticket is assigned to.'}),
|
|
233
253
|
)),
|
|
234
254
|
),
|
|
235
255
|
}),
|
synapse/models/syn.py
CHANGED
|
@@ -2,10 +2,67 @@ import logging
|
|
|
2
2
|
|
|
3
3
|
import synapse.exc as s_exc
|
|
4
4
|
|
|
5
|
+
import synapse.lib.types as s_types
|
|
5
6
|
import synapse.lib.module as s_module
|
|
6
7
|
|
|
7
8
|
logger = logging.getLogger(__name__)
|
|
8
9
|
|
|
10
|
+
class SynUser(s_types.Guid):
|
|
11
|
+
|
|
12
|
+
def _normPyStr(self, text):
|
|
13
|
+
|
|
14
|
+
core = self.modl.core
|
|
15
|
+
if core is not None:
|
|
16
|
+
|
|
17
|
+
# direct use of an iden takes precedence...
|
|
18
|
+
user = core.auth.user(text)
|
|
19
|
+
if user is not None:
|
|
20
|
+
return user.iden, {}
|
|
21
|
+
|
|
22
|
+
user = core.auth._getUserByName(text)
|
|
23
|
+
if user is not None:
|
|
24
|
+
return user.iden, {}
|
|
25
|
+
|
|
26
|
+
return s_types.Guid._normPyStr(self, text)
|
|
27
|
+
|
|
28
|
+
def repr(self, iden):
|
|
29
|
+
|
|
30
|
+
core = self.modl.core
|
|
31
|
+
if core is not None:
|
|
32
|
+
user = core.auth.user(iden)
|
|
33
|
+
if user is not None:
|
|
34
|
+
return user.name
|
|
35
|
+
|
|
36
|
+
return iden
|
|
37
|
+
|
|
38
|
+
class SynRole(s_types.Guid):
|
|
39
|
+
|
|
40
|
+
def _normPyStr(self, text):
|
|
41
|
+
|
|
42
|
+
core = self.modl.core
|
|
43
|
+
if core is not None:
|
|
44
|
+
|
|
45
|
+
# direct use of an iden takes precedence...
|
|
46
|
+
role = core.auth.role(text)
|
|
47
|
+
if role is not None:
|
|
48
|
+
return role.iden, {}
|
|
49
|
+
|
|
50
|
+
role = core.auth._getRoleByName(text)
|
|
51
|
+
if role is not None:
|
|
52
|
+
return role.iden, {}
|
|
53
|
+
|
|
54
|
+
return s_types.Guid._normPyStr(self, text)
|
|
55
|
+
|
|
56
|
+
def repr(self, iden):
|
|
57
|
+
|
|
58
|
+
core = self.modl.core
|
|
59
|
+
if core is not None:
|
|
60
|
+
role = core.auth.role(iden)
|
|
61
|
+
if role is not None:
|
|
62
|
+
return role.name
|
|
63
|
+
|
|
64
|
+
return iden
|
|
65
|
+
|
|
9
66
|
class SynModule(s_module.CoreModule):
|
|
10
67
|
|
|
11
68
|
def initCoreModule(self):
|
|
@@ -105,6 +162,13 @@ class SynModule(s_module.CoreModule):
|
|
|
105
162
|
|
|
106
163
|
return (('syn', {
|
|
107
164
|
|
|
165
|
+
'ctors': (
|
|
166
|
+
('syn:user', 'synapse.models.syn.SynUser', {}, {
|
|
167
|
+
'doc': 'A Synapse user.'}),
|
|
168
|
+
|
|
169
|
+
('syn:role', 'synapse.models.syn.SynRole', {}, {
|
|
170
|
+
'doc': 'A Synapse role.'}),
|
|
171
|
+
),
|
|
108
172
|
'types': (
|
|
109
173
|
('syn:type', ('str', {'strip': True}), {
|
|
110
174
|
'doc': 'A Synapse type used for normalizing nodes and properties.',
|
|
@@ -130,12 +194,6 @@ class SynModule(s_module.CoreModule):
|
|
|
130
194
|
('syn:nodedata', ('comp', {'fields': (('key', 'str'), ('form', 'syn:form'))}), {
|
|
131
195
|
'doc': 'A nodedata key and the form it may be present on.',
|
|
132
196
|
}),
|
|
133
|
-
('syn:user', ('guid', {'strip': True}), {
|
|
134
|
-
'doc': 'A Synapse user GUID.'
|
|
135
|
-
}),
|
|
136
|
-
('syn:role', ('guid', {'strip': True}), {
|
|
137
|
-
'doc': 'A Synapse role GUID.'
|
|
138
|
-
}),
|
|
139
197
|
),
|
|
140
198
|
|
|
141
199
|
'forms': (
|