dictature 0.10.0__tar.gz → 0.11.0__tar.gz
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.
- {dictature-0.10.0/src/dictature.egg-info → dictature-0.11.0}/PKG-INFO +1 -1
- {dictature-0.10.0 → dictature-0.11.0}/pyproject.toml +1 -1
- {dictature-0.10.0 → dictature-0.11.0}/src/dictature/backend/misp.py +10 -1
- {dictature-0.10.0 → dictature-0.11.0}/src/dictature/backend/mock.py +1 -1
- {dictature-0.10.0 → dictature-0.11.0}/src/dictature/dictature.py +13 -2
- {dictature-0.10.0 → dictature-0.11.0/src/dictature.egg-info}/PKG-INFO +1 -1
- {dictature-0.10.0 → dictature-0.11.0}/LICENSE +0 -0
- {dictature-0.10.0 → dictature-0.11.0}/README.md +0 -0
- {dictature-0.10.0 → dictature-0.11.0}/setup.cfg +0 -0
- {dictature-0.10.0 → dictature-0.11.0}/src/dictature/__init__.py +0 -0
- {dictature-0.10.0 → dictature-0.11.0}/src/dictature/backend/__init__.py +0 -0
- {dictature-0.10.0 → dictature-0.11.0}/src/dictature/backend/directory.py +0 -0
- {dictature-0.10.0 → dictature-0.11.0}/src/dictature/backend/sqlite.py +0 -0
- {dictature-0.10.0 → dictature-0.11.0}/src/dictature/backend/webdav.py +0 -0
- {dictature-0.10.0 → dictature-0.11.0}/src/dictature/transformer/__init__.py +0 -0
- {dictature-0.10.0 → dictature-0.11.0}/src/dictature/transformer/aes.py +0 -0
- {dictature-0.10.0 → dictature-0.11.0}/src/dictature/transformer/gzip.py +0 -0
- {dictature-0.10.0 → dictature-0.11.0}/src/dictature/transformer/hmac.py +0 -0
- {dictature-0.10.0 → dictature-0.11.0}/src/dictature/transformer/mock.py +0 -0
- {dictature-0.10.0 → dictature-0.11.0}/src/dictature/transformer/passthrough.py +0 -0
- {dictature-0.10.0 → dictature-0.11.0}/src/dictature/transformer/pipeline.py +0 -0
- {dictature-0.10.0 → dictature-0.11.0}/src/dictature.egg-info/SOURCES.txt +0 -0
- {dictature-0.10.0 → dictature-0.11.0}/src/dictature.egg-info/dependency_links.txt +0 -0
- {dictature-0.10.0 → dictature-0.11.0}/src/dictature.egg-info/top_level.txt +0 -0
- {dictature-0.10.0 → dictature-0.11.0}/tests/test_operations.py +0 -0
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: dictature
|
3
|
-
Version: 0.
|
3
|
+
Version: 0.11.0
|
4
4
|
Summary: dictature -- A generic wrapper around dict-like interface with mulitple backends
|
5
5
|
Author-email: Adam Hlavacek <git@adamhlavacek.com>
|
6
6
|
Project-URL: Homepage, https://github.com/esoadamo/dictature
|
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|
4
4
|
|
5
5
|
[project]
|
6
6
|
name = "dictature"
|
7
|
-
version = "0.
|
7
|
+
version = "0.11.0"
|
8
8
|
description = "dictature -- A generic wrapper around dict-like interface with mulitple backends"
|
9
9
|
authors = [
|
10
10
|
{ name = "Adam Hlavacek", email = "git@adamhlavacek.com" }
|
@@ -3,7 +3,7 @@ from typing import Iterable, Optional
|
|
3
3
|
from .mock import DictatureTableMock, DictatureBackendMock, Value, ValueMode, ValueSerializer, ValueSerializerMode
|
4
4
|
|
5
5
|
try:
|
6
|
-
from pymisp import PyMISP, MISPEvent, MISPAttribute
|
6
|
+
from pymisp import PyMISP, MISPEvent, MISPAttribute, MISPTag
|
7
7
|
except ImportError as e:
|
8
8
|
raise ImportError("Please install the 'pymisp' package to use the 'DictatureBackendMISP' backend.") from e
|
9
9
|
|
@@ -92,6 +92,15 @@ class DictatureTableMISP(DictatureTableMock):
|
|
92
92
|
self.__event = event
|
93
93
|
break
|
94
94
|
else:
|
95
|
+
# Check if tag exists, create if not
|
96
|
+
existing_tags = self.__misp.search_tags(self.__tag, strict_tagname=True, pythonify=True)
|
97
|
+
if not type(existing_tags) is list or not existing_tags:
|
98
|
+
tag = MISPTag()
|
99
|
+
tag.name = self.__tag
|
100
|
+
tag.colour = '#000000'
|
101
|
+
tag.exportable = True
|
102
|
+
self.__misp.add_tag(tag)
|
103
|
+
|
95
104
|
event = MISPEvent()
|
96
105
|
event.info = self.__event_description
|
97
106
|
event.distribution = 0
|
@@ -74,7 +74,7 @@ class ValueSerializer:
|
|
74
74
|
if self.__mode == ValueSerializerMode.hex_only:
|
75
75
|
allowed_chars = hexdigits
|
76
76
|
elif self.__mode == ValueSerializerMode.filename_only:
|
77
|
-
allowed_chars = ascii_letters + digits + '_.'
|
77
|
+
allowed_chars = ascii_letters + digits + ' -_.'
|
78
78
|
elif self.__mode in (ValueSerializerMode.any_string, ValueSerializerMode.ascii_only):
|
79
79
|
allowed_chars = None
|
80
80
|
else:
|
@@ -16,6 +16,7 @@ class Dictature:
|
|
16
16
|
name_transformer: MockTransformer = PassthroughTransformer(),
|
17
17
|
value_transformer: MockTransformer = PassthroughTransformer(),
|
18
18
|
table_name_transformer: Optional[MockTransformer] = None,
|
19
|
+
allow_pickle: bool = True,
|
19
20
|
) -> None:
|
20
21
|
"""
|
21
22
|
Create a new Dictature object
|
@@ -23,6 +24,7 @@ class Dictature:
|
|
23
24
|
:param name_transformer: transformer to use for table and key names
|
24
25
|
:param value_transformer: transformer to use for values
|
25
26
|
:param table_name_transformer: transformer to use for table names, if None, name_transformer is used
|
27
|
+
:param allow_pickle: if True, pickle is allowed for values (warning: this may be a security risk if the data is not trusted)
|
26
28
|
"""
|
27
29
|
self.__backend = backend
|
28
30
|
self.__table_cache: Dict[str, "DictatureTable"] = {}
|
@@ -30,6 +32,7 @@ class Dictature:
|
|
30
32
|
self.__value_transformer = value_transformer
|
31
33
|
self.__table_name_transformer = table_name_transformer or name_transformer
|
32
34
|
self.__cache_size = 4096
|
35
|
+
self.__allow_pickle = allow_pickle
|
33
36
|
|
34
37
|
def keys(self) -> Set[str]:
|
35
38
|
"""
|
@@ -80,7 +83,8 @@ class Dictature:
|
|
80
83
|
self.__backend,
|
81
84
|
item,
|
82
85
|
name_transformer=self.__name_transformer,
|
83
|
-
value_transformer=self.__value_transformer
|
86
|
+
value_transformer=self.__value_transformer,
|
87
|
+
allow_pickle=self.__allow_pickle,
|
84
88
|
)
|
85
89
|
return self.__table_cache[item]
|
86
90
|
|
@@ -114,7 +118,8 @@ class DictatureTable:
|
|
114
118
|
backend: DictatureBackendMock,
|
115
119
|
table_name: str,
|
116
120
|
name_transformer: MockTransformer = PassthroughTransformer(),
|
117
|
-
value_transformer: MockTransformer = PassthroughTransformer()
|
121
|
+
value_transformer: MockTransformer = PassthroughTransformer(),
|
122
|
+
allow_pickle: bool = True
|
118
123
|
):
|
119
124
|
"""
|
120
125
|
Create a new DictatureTable object
|
@@ -122,12 +127,14 @@ class DictatureTable:
|
|
122
127
|
:param table_name: name of the table
|
123
128
|
:param name_transformer: transformer to use for key names
|
124
129
|
:param value_transformer: transformer to use for values
|
130
|
+
:param allow_pickle: if True, pickle is allowed for values (warning: this may be a security risk if the data is not trusted)
|
125
131
|
"""
|
126
132
|
self.__backend = backend
|
127
133
|
self.__name_transformer = name_transformer
|
128
134
|
self.__value_transformer = value_transformer
|
129
135
|
self.__table = self.__backend.table(self.__table_key(table_name))
|
130
136
|
self.__table_created = False
|
137
|
+
self.__allow_pickle = allow_pickle
|
131
138
|
|
132
139
|
def get(self, item: str, default: Optional[Any] = None) -> Any:
|
133
140
|
"""
|
@@ -210,6 +217,8 @@ class DictatureTable:
|
|
210
217
|
elif mode == ValueMode.json:
|
211
218
|
return json.loads(value)
|
212
219
|
elif mode == ValueMode.pickle:
|
220
|
+
if not self.__allow_pickle:
|
221
|
+
raise ValueError("Pickle is not allowed")
|
213
222
|
return pickle.loads(decompress(b64decode(value.encode('ascii'))))
|
214
223
|
raise ValueError(f"Unknown mode '{mode}'")
|
215
224
|
|
@@ -228,6 +237,8 @@ class DictatureTable:
|
|
228
237
|
value = json.dumps(value)
|
229
238
|
value_mode = ValueMode.json.value
|
230
239
|
except TypeError:
|
240
|
+
if not self.__allow_pickle:
|
241
|
+
raise ValueError("Pickle is not allowed")
|
231
242
|
value = b64encode(compress(pickle.dumps(value))).decode('ascii')
|
232
243
|
value_mode = ValueMode.pickle.value
|
233
244
|
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: dictature
|
3
|
-
Version: 0.
|
3
|
+
Version: 0.11.0
|
4
4
|
Summary: dictature -- A generic wrapper around dict-like interface with mulitple backends
|
5
5
|
Author-email: Adam Hlavacek <git@adamhlavacek.com>
|
6
6
|
Project-URL: Homepage, https://github.com/esoadamo/dictature
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|