sqlite-rx 1.2.2__tar.gz → 1.3.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.
- {sqlite_rx-1.2.2 → sqlite_rx-1.3.0}/PKG-INFO +32 -35
- {sqlite_rx-1.2.2 → sqlite_rx-1.3.0}/README.md +10 -12
- sqlite_rx-1.3.0/pyproject.toml +101 -0
- sqlite_rx-1.3.0/setup.cfg +4 -0
- sqlite_rx-1.3.0/sqlite_rx/__init__.py +46 -0
- {sqlite_rx-1.2.2 → sqlite_rx-1.3.0}/sqlite_rx/auth.py +70 -45
- {sqlite_rx-1.2.2 → sqlite_rx-1.3.0}/sqlite_rx/backup.py +7 -6
- sqlite_rx-1.3.0/sqlite_rx/cli/client.py +161 -0
- sqlite_rx-1.3.0/sqlite_rx/cli/keygen.py +33 -0
- sqlite_rx-1.3.0/sqlite_rx/cli/server.py +191 -0
- {sqlite_rx-1.2.2 → sqlite_rx-1.3.0}/sqlite_rx/client.py +65 -37
- {sqlite_rx-1.2.2 → sqlite_rx-1.3.0}/sqlite_rx/exception.py +2 -2
- {sqlite_rx-1.2.2 → sqlite_rx-1.3.0}/sqlite_rx/server.py +109 -76
- {sqlite_rx-1.2.2 → sqlite_rx-1.3.0}/sqlite_rx/tests/__init__.py +11 -9
- sqlite_rx-1.3.0/sqlite_rx/tests/backup/conftest.py +70 -0
- sqlite_rx-1.3.0/sqlite_rx/tests/backup/test_queries.py +84 -0
- sqlite_rx-1.3.0/sqlite_rx/tests/curezmq/conftest.py +73 -0
- sqlite_rx-1.3.0/sqlite_rx/tests/curezmq/test_queries.py +65 -0
- {sqlite_rx-1.2.2 → sqlite_rx-1.3.0}/sqlite_rx/tests/error/test_connection.py +3 -1
- {sqlite_rx-1.2.2 → sqlite_rx-1.3.0}/sqlite_rx/tests/misc/test_backup_exception.py +6 -1
- {sqlite_rx-1.2.2 → sqlite_rx-1.3.0}/sqlite_rx/tests/misc/test_curvekeygen.py +7 -2
- {sqlite_rx-1.2.2 → sqlite_rx-1.3.0}/sqlite_rx/tests/plain/conftest.py +12 -15
- sqlite_rx-1.3.0/sqlite_rx/tests/plain/test_queries.py +158 -0
- sqlite_rx-1.3.0/sqlite_rx/tests/zap/conftest.py +74 -0
- sqlite_rx-1.3.0/sqlite_rx/tests/zap/test_queries.py +64 -0
- sqlite_rx-1.3.0/sqlite_rx/version.py +1 -0
- {sqlite_rx-1.2.2 → sqlite_rx-1.3.0}/sqlite_rx.egg-info/PKG-INFO +32 -35
- {sqlite_rx-1.2.2 → sqlite_rx-1.3.0}/sqlite_rx.egg-info/SOURCES.txt +2 -3
- {sqlite_rx-1.2.2 → sqlite_rx-1.3.0}/sqlite_rx.egg-info/entry_points.txt +1 -0
- sqlite_rx-1.3.0/sqlite_rx.egg-info/requires.txt +13 -0
- sqlite_rx-1.2.2/pyproject.toml +0 -3
- sqlite_rx-1.2.2/setup.cfg +0 -83
- sqlite_rx-1.2.2/setup.py +0 -99
- sqlite_rx-1.2.2/sqlite_rx/__init__.py +0 -45
- sqlite_rx-1.2.2/sqlite_rx/cli/client.py +0 -126
- sqlite_rx-1.2.2/sqlite_rx/cli/server.py +0 -152
- sqlite_rx-1.2.2/sqlite_rx/tests/backup/conftest.py +0 -64
- sqlite_rx-1.2.2/sqlite_rx/tests/backup/test_queries.py +0 -75
- sqlite_rx-1.2.2/sqlite_rx/tests/curezmq/conftest.py +0 -63
- sqlite_rx-1.2.2/sqlite_rx/tests/curezmq/test_queries.py +0 -59
- sqlite_rx-1.2.2/sqlite_rx/tests/plain/test_queries.py +0 -138
- sqlite_rx-1.2.2/sqlite_rx/tests/zap/conftest.py +0 -66
- sqlite_rx-1.2.2/sqlite_rx/tests/zap/test_queries.py +0 -57
- sqlite_rx-1.2.2/sqlite_rx.egg-info/not-zip-safe +0 -1
- sqlite_rx-1.2.2/sqlite_rx.egg-info/requires.txt +0 -9
- {sqlite_rx-1.2.2 → sqlite_rx-1.3.0}/LICENSE +0 -0
- {sqlite_rx-1.2.2 → sqlite_rx-1.3.0}/bin/curve-keygen +0 -0
- {sqlite_rx-1.2.2 → sqlite_rx-1.3.0}/sqlite_rx/cli/__init__.py +0 -0
- {sqlite_rx-1.2.2 → sqlite_rx-1.3.0}/sqlite_rx/tests/backup/__init__.py +0 -0
- {sqlite_rx-1.2.2 → sqlite_rx-1.3.0}/sqlite_rx/tests/curezmq/__init__.py +0 -0
- {sqlite_rx-1.2.2 → sqlite_rx-1.3.0}/sqlite_rx/tests/error/__init__.py +0 -0
- {sqlite_rx-1.2.2 → sqlite_rx-1.3.0}/sqlite_rx/tests/error/conftest.py +2 -2
- {sqlite_rx-1.2.2 → sqlite_rx-1.3.0}/sqlite_rx/tests/misc/__init__.py +0 -0
- {sqlite_rx-1.2.2 → sqlite_rx-1.3.0}/sqlite_rx/tests/plain/__init__.py +0 -0
- {sqlite_rx-1.2.2 → sqlite_rx-1.3.0}/sqlite_rx/tests/zap/__init__.py +0 -0
- {sqlite_rx-1.2.2 → sqlite_rx-1.3.0}/sqlite_rx.egg-info/dependency_links.txt +0 -0
- {sqlite_rx-1.2.2 → sqlite_rx-1.3.0}/sqlite_rx.egg-info/top_level.txt +0 -0
|
@@ -1,70 +1,68 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
2
|
Name: sqlite_rx
|
|
3
|
-
Version: 1.
|
|
3
|
+
Version: 1.3.0
|
|
4
4
|
Summary: Python SQLite Client and Server
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
5
|
+
Author-email: Abhishek Singh <abhishek.singh20141@gmail.com>
|
|
6
|
+
Maintainer-email: Abhishek Singh <abhishek.singh20141@gmail.com>
|
|
7
|
+
License-Expression: MIT
|
|
8
|
+
Project-URL: Homepage, https://github.com/aosingh/sqlite_rx
|
|
9
|
+
Project-URL: Repository, https://github.com/aosingh/sqlite_rx
|
|
10
|
+
Project-URL: Issues, https://github.com/aosingh/sqlite_rx/issues
|
|
11
11
|
Project-URL: Documentation, https://aosingh.github.io/sqlite_rx/
|
|
12
|
-
Project-URL: Source, https://github.com/aosingh/sqlite_rx
|
|
13
|
-
Project-URL: Bug Tracker, https://github.com/aosingh/sqlite_rx/issues
|
|
14
12
|
Project-URL: CI, https://github.com/aosingh/sqlite_rx/actions
|
|
15
|
-
|
|
16
|
-
Project-URL: License, https://github.com/aosingh/sqlite_rx/blob/master/LICENSE
|
|
17
|
-
Keywords: sqlite client server fast secure
|
|
13
|
+
Keywords: sqlite,server,client,secure
|
|
18
14
|
Classifier: Topic :: Database :: Database Engines/Servers
|
|
19
15
|
Classifier: Development Status :: 5 - Production/Stable
|
|
20
16
|
Classifier: Intended Audience :: Education
|
|
21
17
|
Classifier: Intended Audience :: Developers
|
|
22
18
|
Classifier: Intended Audience :: Science/Research
|
|
23
19
|
Classifier: Intended Audience :: System Administrators
|
|
24
|
-
Classifier: License :: OSI Approved :: MIT License
|
|
25
20
|
Classifier: Programming Language :: Python :: 3 :: Only
|
|
26
|
-
Classifier: Programming Language :: Python :: 3.8
|
|
27
21
|
Classifier: Programming Language :: Python :: 3.9
|
|
28
22
|
Classifier: Programming Language :: Python :: 3.10
|
|
29
23
|
Classifier: Programming Language :: Python :: 3.11
|
|
30
24
|
Classifier: Programming Language :: Python :: 3.12
|
|
31
25
|
Classifier: Programming Language :: Python :: 3.13
|
|
26
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
32
27
|
Classifier: Operating System :: POSIX :: Linux
|
|
33
28
|
Classifier: Operating System :: Unix
|
|
34
29
|
Classifier: Operating System :: Microsoft :: Windows
|
|
35
30
|
Classifier: Operating System :: MacOS
|
|
36
|
-
Requires-Python: >=3.
|
|
31
|
+
Requires-Python: >=3.10
|
|
37
32
|
Description-Content-Type: text/markdown
|
|
38
33
|
License-File: LICENSE
|
|
39
|
-
Requires-Dist: msgpack
|
|
40
|
-
Requires-Dist:
|
|
41
|
-
Requires-Dist:
|
|
42
|
-
Requires-Dist: billiard
|
|
34
|
+
Requires-Dist: msgpack
|
|
35
|
+
Requires-Dist: tornado
|
|
36
|
+
Requires-Dist: pyzmq
|
|
37
|
+
Requires-Dist: billiard
|
|
38
|
+
Provides-Extra: test
|
|
39
|
+
Requires-Dist: coverage; extra == "test"
|
|
40
|
+
Requires-Dist: pytest; extra == "test"
|
|
43
41
|
Provides-Extra: cli
|
|
44
|
-
Requires-Dist: click
|
|
45
|
-
Requires-Dist: rich
|
|
46
|
-
Requires-Dist: pygments
|
|
42
|
+
Requires-Dist: click; extra == "cli"
|
|
43
|
+
Requires-Dist: rich; extra == "cli"
|
|
44
|
+
Requires-Dist: pygments; extra == "cli"
|
|
45
|
+
Dynamic: license-file
|
|
47
46
|
|
|
48
|
-
# sqlite_rx
|
|
47
|
+
# sqlite_rx
|
|
49
48
|
[](https://pypi.python.org/pypi/sqlite-rx) [](https://github.com/aosingh/sqlite_rx/actions) [](https://pepy.tech/project/sqlite-rx)
|
|
50
49
|
|
|
51
50
|
|
|
52
|
-
[](https://www.python.org/downloads/release/python-380/)
|
|
53
|
-
[]((https://www.python.org/downloads/release/python-390/))
|
|
54
51
|
[](https://www.python.org/downloads/release/python-3100/)
|
|
55
52
|
[](https://www.python.org/downloads/release/python-3110/)
|
|
56
53
|
[](https://www.python.org/downloads/release/python-3120/)
|
|
54
|
+
[](https://www.python.org/downloads/release/python-3130/)
|
|
55
|
+
[](https://www.python.org/downloads/release/python-3140/)
|
|
57
56
|
|
|
58
|
-
|
|
59
|
-
[](https://www.pypy.org/download.html)
|
|
57
|
+
[](https://www.pypy.org/download.html)
|
|
58
|
+
[](https://www.pypy.org/download.html)
|
|
61
59
|
|
|
62
60
|
|
|
63
61
|
#### For documentation, usage and examples refer [https://aosingh.github.io/sqlite_rx/](https://aosingh.github.io/sqlite_rx/)
|
|
64
62
|
|
|
65
63
|
# Introduction
|
|
66
64
|
|
|
67
|
-
[SQLite](https://www.sqlite.org/index.html) is a lightweight database written in C.
|
|
65
|
+
[SQLite](https://www.sqlite.org/index.html) is a lightweight database written in C.
|
|
68
66
|
Python has in-built support to interact with the database (locally) which is either stored on disk or in memory.
|
|
69
67
|
|
|
70
68
|
With `sqlite_rx`, clients should be able to communicate with an `SQLiteServer` in a fast, simple and secure manner and execute queries remotely.
|
|
@@ -94,10 +92,10 @@ from sqlite_rx.server import SQLiteServer
|
|
|
94
92
|
|
|
95
93
|
def main():
|
|
96
94
|
|
|
97
|
-
# database is a path-like object giving the pathname
|
|
98
|
-
# of the database file to be opened.
|
|
99
|
-
|
|
100
|
-
# You can use ":memory:" to open a database connection to a database
|
|
95
|
+
# database is a path-like object giving the pathname
|
|
96
|
+
# of the database file to be opened.
|
|
97
|
+
|
|
98
|
+
# You can use ":memory:" to open a database connection to a database
|
|
101
99
|
# that resides in RAM instead of on disk
|
|
102
100
|
|
|
103
101
|
server = SQLiteServer(database=":memory:",
|
|
@@ -132,4 +130,3 @@ with client:
|
|
|
132
130
|
|
|
133
131
|
{'error': None, 'items': []}
|
|
134
132
|
```
|
|
135
|
-
|
|
@@ -1,23 +1,22 @@
|
|
|
1
|
-
# sqlite_rx
|
|
1
|
+
# sqlite_rx
|
|
2
2
|
[](https://pypi.python.org/pypi/sqlite-rx) [](https://github.com/aosingh/sqlite_rx/actions) [](https://pepy.tech/project/sqlite-rx)
|
|
3
3
|
|
|
4
4
|
|
|
5
|
-
[](https://www.python.org/downloads/release/python-380/)
|
|
6
|
-
[]((https://www.python.org/downloads/release/python-390/))
|
|
7
5
|
[](https://www.python.org/downloads/release/python-3100/)
|
|
8
6
|
[](https://www.python.org/downloads/release/python-3110/)
|
|
9
7
|
[](https://www.python.org/downloads/release/python-3120/)
|
|
8
|
+
[](https://www.python.org/downloads/release/python-3130/)
|
|
9
|
+
[](https://www.python.org/downloads/release/python-3140/)
|
|
10
10
|
|
|
11
|
-
|
|
12
|
-
[](https://www.pypy.org/download.html)
|
|
11
|
+
[](https://www.pypy.org/download.html)
|
|
12
|
+
[](https://www.pypy.org/download.html)
|
|
14
13
|
|
|
15
14
|
|
|
16
15
|
#### For documentation, usage and examples refer [https://aosingh.github.io/sqlite_rx/](https://aosingh.github.io/sqlite_rx/)
|
|
17
16
|
|
|
18
17
|
# Introduction
|
|
19
18
|
|
|
20
|
-
[SQLite](https://www.sqlite.org/index.html) is a lightweight database written in C.
|
|
19
|
+
[SQLite](https://www.sqlite.org/index.html) is a lightweight database written in C.
|
|
21
20
|
Python has in-built support to interact with the database (locally) which is either stored on disk or in memory.
|
|
22
21
|
|
|
23
22
|
With `sqlite_rx`, clients should be able to communicate with an `SQLiteServer` in a fast, simple and secure manner and execute queries remotely.
|
|
@@ -47,10 +46,10 @@ from sqlite_rx.server import SQLiteServer
|
|
|
47
46
|
|
|
48
47
|
def main():
|
|
49
48
|
|
|
50
|
-
# database is a path-like object giving the pathname
|
|
51
|
-
# of the database file to be opened.
|
|
52
|
-
|
|
53
|
-
# You can use ":memory:" to open a database connection to a database
|
|
49
|
+
# database is a path-like object giving the pathname
|
|
50
|
+
# of the database file to be opened.
|
|
51
|
+
|
|
52
|
+
# You can use ":memory:" to open a database connection to a database
|
|
54
53
|
# that resides in RAM instead of on disk
|
|
55
54
|
|
|
56
55
|
server = SQLiteServer(database=":memory:",
|
|
@@ -85,4 +84,3 @@ with client:
|
|
|
85
84
|
|
|
86
85
|
{'error': None, 'items': []}
|
|
87
86
|
```
|
|
88
|
-
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ['setuptools >= 40.8.0', 'wheel']
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "sqlite_rx"
|
|
7
|
+
dynamic = ["version"]
|
|
8
|
+
description = "Python SQLite Client and Server"
|
|
9
|
+
readme = {file = "README.md", content-type = "text/markdown"}
|
|
10
|
+
requires-python = ">=3.10"
|
|
11
|
+
authors = [
|
|
12
|
+
{name="Abhishek Singh", email="abhishek.singh20141@gmail.com"}
|
|
13
|
+
]
|
|
14
|
+
maintainers =[
|
|
15
|
+
{name="Abhishek Singh", email="abhishek.singh20141@gmail.com"}
|
|
16
|
+
]
|
|
17
|
+
keywords = [
|
|
18
|
+
"sqlite",
|
|
19
|
+
"server",
|
|
20
|
+
"client",
|
|
21
|
+
"secure"
|
|
22
|
+
]
|
|
23
|
+
license = "MIT"
|
|
24
|
+
license-files = ["LICENSE"]
|
|
25
|
+
classifiers = [
|
|
26
|
+
"Topic :: Database :: Database Engines/Servers",
|
|
27
|
+
"Development Status :: 5 - Production/Stable",
|
|
28
|
+
"Intended Audience :: Education",
|
|
29
|
+
"Intended Audience :: Developers",
|
|
30
|
+
"Intended Audience :: Science/Research",
|
|
31
|
+
"Intended Audience :: System Administrators",
|
|
32
|
+
"Programming Language :: Python :: 3 :: Only",
|
|
33
|
+
"Programming Language :: Python :: 3.9",
|
|
34
|
+
"Programming Language :: Python :: 3.10",
|
|
35
|
+
"Programming Language :: Python :: 3.11",
|
|
36
|
+
"Programming Language :: Python :: 3.12",
|
|
37
|
+
"Programming Language :: Python :: 3.13",
|
|
38
|
+
"Programming Language :: Python :: 3.14",
|
|
39
|
+
"Operating System :: POSIX :: Linux",
|
|
40
|
+
"Operating System :: Unix",
|
|
41
|
+
"Operating System :: Microsoft :: Windows",
|
|
42
|
+
"Operating System :: MacOS"
|
|
43
|
+
]
|
|
44
|
+
dependencies = [
|
|
45
|
+
"msgpack",
|
|
46
|
+
"tornado",
|
|
47
|
+
"pyzmq",
|
|
48
|
+
"billiard"
|
|
49
|
+
]
|
|
50
|
+
|
|
51
|
+
[project.optional-dependencies]
|
|
52
|
+
test = [
|
|
53
|
+
"coverage",
|
|
54
|
+
"pytest",
|
|
55
|
+
]
|
|
56
|
+
cli = [
|
|
57
|
+
"click",
|
|
58
|
+
"rich",
|
|
59
|
+
"pygments",
|
|
60
|
+
]
|
|
61
|
+
|
|
62
|
+
[project.scripts]
|
|
63
|
+
curve-keygen = "sqlite_rx.cli.keygen:main"
|
|
64
|
+
sqlite-server = "sqlite_rx.cli.server:main"
|
|
65
|
+
sqlite-client = "sqlite_rx.cli.client:main"
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
[project.urls]
|
|
69
|
+
Homepage = "https://github.com/aosingh/sqlite_rx"
|
|
70
|
+
Repository = "https://github.com/aosingh/sqlite_rx"
|
|
71
|
+
Issues = "https://github.com/aosingh/sqlite_rx/issues"
|
|
72
|
+
Documentation = "https://aosingh.github.io/sqlite_rx/"
|
|
73
|
+
CI = "https://github.com/aosingh/sqlite_rx/actions"
|
|
74
|
+
|
|
75
|
+
[tool.setuptools]
|
|
76
|
+
packages = ["sqlite_rx", "sqlite_rx.cli"]
|
|
77
|
+
|
|
78
|
+
[tool.setuptools.dynamic]
|
|
79
|
+
version = { attr = "sqlite_rx.version.__version__" }
|
|
80
|
+
|
|
81
|
+
[tool.black]
|
|
82
|
+
line-length = 79
|
|
83
|
+
target-version = ["py310", "py311", "py312", "py313"]
|
|
84
|
+
required-version = 24
|
|
85
|
+
|
|
86
|
+
[tool.ruff]
|
|
87
|
+
line-length = 79
|
|
88
|
+
target-version = "py310"
|
|
89
|
+
per-file-ignores = { "__init__.py" = ["F401"] }
|
|
90
|
+
|
|
91
|
+
[tool.pytest.ini_options]
|
|
92
|
+
minversion = "8.3.0"
|
|
93
|
+
testpaths = [
|
|
94
|
+
"tests"
|
|
95
|
+
]
|
|
96
|
+
|
|
97
|
+
[tools.coverage.run]
|
|
98
|
+
branch = true
|
|
99
|
+
concurrency = "multiprocessing"
|
|
100
|
+
parallel = true
|
|
101
|
+
source = "sqlite_rx"
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
from sqlite_rx.version import __version__
|
|
2
|
+
|
|
3
|
+
__author__ = "Abhishek Singh"
|
|
4
|
+
__authoremail__ = "abhishek.singh20141@gmail.com"
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
def get_default_logger_settings(level: str = "DEBUG"):
|
|
8
|
+
return {
|
|
9
|
+
"version": 1,
|
|
10
|
+
"disable_existing_loggers": False,
|
|
11
|
+
"formatters": {
|
|
12
|
+
"standard": {
|
|
13
|
+
"()": "logging.Formatter",
|
|
14
|
+
"format": "%(asctime)s - %(levelname)s - [%(name)s:%(funcName)s:%(lineno)d] %(message)s",
|
|
15
|
+
},
|
|
16
|
+
},
|
|
17
|
+
"handlers": {
|
|
18
|
+
"default": {
|
|
19
|
+
"level": level,
|
|
20
|
+
"formatter": "standard",
|
|
21
|
+
"class": "logging.StreamHandler",
|
|
22
|
+
"stream": "ext://sys.stdout", # Default is stderr
|
|
23
|
+
},
|
|
24
|
+
},
|
|
25
|
+
"loggers": {
|
|
26
|
+
"": { # root logger
|
|
27
|
+
"handlers": ["default"],
|
|
28
|
+
"level": level,
|
|
29
|
+
"propagate": False,
|
|
30
|
+
},
|
|
31
|
+
"sqlite_rx": {
|
|
32
|
+
"handlers": ["default"],
|
|
33
|
+
"level": level,
|
|
34
|
+
"propagate": False,
|
|
35
|
+
},
|
|
36
|
+
"__main__": { # if __name__ == '__main__'
|
|
37
|
+
"handlers": ["default"],
|
|
38
|
+
"level": level,
|
|
39
|
+
"propagate": False,
|
|
40
|
+
},
|
|
41
|
+
},
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
def get_version():
|
|
46
|
+
return __version__
|
|
@@ -6,12 +6,12 @@ from typing import Dict, Set
|
|
|
6
6
|
|
|
7
7
|
import zmq
|
|
8
8
|
import zmq.auth
|
|
9
|
-
from sqlite_rx.exception import SQLiteRxAuthConfigError
|
|
10
9
|
|
|
10
|
+
from sqlite_rx.exception import SQLiteRxAuthConfigError
|
|
11
11
|
|
|
12
12
|
LOG = logging.getLogger(__name__)
|
|
13
13
|
|
|
14
|
-
__all__ = [
|
|
14
|
+
__all__ = ["Authorizer", "KeyGenerator", "KeyMonkey", "DEFAULT_AUTH_CONFIG"]
|
|
15
15
|
|
|
16
16
|
# Default Authorization Config
|
|
17
17
|
DEFAULT_AUTH_CONFIG = {
|
|
@@ -35,7 +35,6 @@ DEFAULT_AUTH_CONFIG = {
|
|
|
35
35
|
sqlite3.SQLITE_REINDEX,
|
|
36
36
|
sqlite3.SQLITE_ANALYZE,
|
|
37
37
|
},
|
|
38
|
-
|
|
39
38
|
sqlite3.SQLITE_DENY: {
|
|
40
39
|
sqlite3.SQLITE_DELETE,
|
|
41
40
|
sqlite3.SQLITE_DROP_INDEX,
|
|
@@ -47,11 +46,7 @@ DEFAULT_AUTH_CONFIG = {
|
|
|
47
46
|
sqlite3.SQLITE_DROP_TRIGGER,
|
|
48
47
|
sqlite3.SQLITE_DROP_VIEW,
|
|
49
48
|
},
|
|
50
|
-
|
|
51
|
-
sqlite3.SQLITE_IGNORE: {
|
|
52
|
-
sqlite3.SQLITE_PRAGMA
|
|
53
|
-
}
|
|
54
|
-
|
|
49
|
+
sqlite3.SQLITE_IGNORE: {sqlite3.SQLITE_PRAGMA},
|
|
55
50
|
}
|
|
56
51
|
|
|
57
52
|
|
|
@@ -82,11 +77,13 @@ class Authorizer:
|
|
|
82
77
|
self.valid_return_values = {
|
|
83
78
|
sqlite3.SQLITE_IGNORE,
|
|
84
79
|
sqlite3.SQLITE_OK,
|
|
85
|
-
sqlite3.SQLITE_DENY
|
|
80
|
+
sqlite3.SQLITE_DENY,
|
|
81
|
+
}
|
|
86
82
|
if any(k not in self.valid_return_values for k in self.config.keys()):
|
|
87
83
|
raise SQLiteRxAuthConfigError(
|
|
88
84
|
"Allowed return values are: "
|
|
89
|
-
"sqlite3.SQLITE_OK(0), sqlite3.SQLITE_DENY(1), sqlite3.SQLITE_IGNORE(2)"
|
|
85
|
+
"sqlite3.SQLITE_OK(0), sqlite3.SQLITE_DENY(1), sqlite3.SQLITE_IGNORE(2)"
|
|
86
|
+
)
|
|
90
87
|
|
|
91
88
|
def __call__(self, action: int, *args, **kwargs) -> int:
|
|
92
89
|
"""Returns the permission for the passed ``action``
|
|
@@ -108,9 +105,7 @@ class Authorizer:
|
|
|
108
105
|
|
|
109
106
|
class KeyGenerator:
|
|
110
107
|
|
|
111
|
-
def __init__(self,
|
|
112
|
-
key_id: str = "id_curve",
|
|
113
|
-
destination_dir: str = None):
|
|
108
|
+
def __init__(self, key_id: str = "id_curve", destination_dir: str = None):
|
|
114
109
|
"""Generates curve public and private keys required for encryption.
|
|
115
110
|
This class should not be used by users to generate keys.
|
|
116
111
|
Use the script ``curve-keygen``
|
|
@@ -129,16 +124,20 @@ class KeyGenerator:
|
|
|
129
124
|
|
|
130
125
|
"""
|
|
131
126
|
self.my_id = key_id
|
|
132
|
-
self.curvedir =
|
|
133
|
-
|
|
127
|
+
self.curvedir = (
|
|
128
|
+
destination_dir
|
|
129
|
+
if destination_dir
|
|
130
|
+
else os.path.join(os.path.expanduser("~"), ".curve")
|
|
131
|
+
)
|
|
134
132
|
self.public_key = os.path.join(
|
|
135
|
-
self.curvedir, "{}.key".format(self.my_id)
|
|
133
|
+
self.curvedir, "{}.key".format(self.my_id)
|
|
134
|
+
)
|
|
136
135
|
self.private_key = os.path.join(
|
|
137
|
-
self.curvedir,
|
|
138
|
-
|
|
139
|
-
self.my_id))
|
|
136
|
+
self.curvedir, "{}.key_secret".format(self.my_id)
|
|
137
|
+
)
|
|
140
138
|
self.authorized_clients_dir = os.path.join(
|
|
141
|
-
self.curvedir, "authorized_clients"
|
|
139
|
+
self.curvedir, "authorized_clients"
|
|
140
|
+
)
|
|
142
141
|
|
|
143
142
|
def generate(self):
|
|
144
143
|
"""
|
|
@@ -166,7 +165,8 @@ class KeyGenerator:
|
|
|
166
165
|
os.chmod(self.authorized_clients_dir, 0o700)
|
|
167
166
|
|
|
168
167
|
server_public_file, server_secret_file = zmq.auth.create_certificates(
|
|
169
|
-
self.curvedir, self.my_id
|
|
168
|
+
self.curvedir, self.my_id
|
|
169
|
+
)
|
|
170
170
|
LOG.info(server_public_file)
|
|
171
171
|
LOG.info(server_secret_file)
|
|
172
172
|
os.chmod(self.public_key, 0o600)
|
|
@@ -177,9 +177,7 @@ class KeyGenerator:
|
|
|
177
177
|
|
|
178
178
|
class KeyMonkey:
|
|
179
179
|
|
|
180
|
-
def __init__(self,
|
|
181
|
-
key_id: str = "id_curve",
|
|
182
|
-
destination_dir: str = None):
|
|
180
|
+
def __init__(self, key_id: str = "id_curve", destination_dir: str = None):
|
|
183
181
|
"""Setup secure client or server using the CurveZMQ
|
|
184
182
|
|
|
185
183
|
This class expects the following keys depending on whether you want to setup a secure server
|
|
@@ -199,14 +197,22 @@ class KeyMonkey:
|
|
|
199
197
|
"""
|
|
200
198
|
|
|
201
199
|
self.my_id = key_id
|
|
202
|
-
self.curvedir =
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
200
|
+
self.curvedir = (
|
|
201
|
+
destination_dir
|
|
202
|
+
if destination_dir
|
|
203
|
+
else os.path.join(os.path.expanduser("~"), ".curve")
|
|
204
|
+
)
|
|
205
|
+
self.public_key = os.path.join(
|
|
206
|
+
self.curvedir, "{}.key".format(self.my_id)
|
|
207
|
+
)
|
|
208
|
+
self.private_key = os.path.join(
|
|
209
|
+
self.curvedir, "{}.key_secret".format(self.my_id)
|
|
210
|
+
)
|
|
211
|
+
self.authorized_clients_dir = os.path.join(
|
|
212
|
+
self.curvedir, "authorized_clients"
|
|
213
|
+
)
|
|
214
|
+
|
|
215
|
+
def setup_secure_server(self, server, bind_address: str):
|
|
210
216
|
"""
|
|
211
217
|
Use this method to setup a secure server.
|
|
212
218
|
|
|
@@ -219,21 +225,28 @@ class KeyMonkey:
|
|
|
219
225
|
|
|
220
226
|
"""
|
|
221
227
|
try:
|
|
222
|
-
server.curve_publickey, server.curve_secretkey =
|
|
228
|
+
server.curve_publickey, server.curve_secretkey = (
|
|
229
|
+
zmq.auth.load_certificate(self.private_key)
|
|
230
|
+
)
|
|
223
231
|
server.curve_server = True
|
|
224
|
-
LOG.info(
|
|
232
|
+
LOG.info(
|
|
233
|
+
"Secure setup completed using on %s using curve key %s",
|
|
234
|
+
bind_address,
|
|
235
|
+
self.my_id,
|
|
236
|
+
)
|
|
225
237
|
return server
|
|
226
238
|
except IOError:
|
|
227
|
-
LOG.exception(
|
|
239
|
+
LOG.exception(
|
|
240
|
+
"Couldn't load the private key: %s", self.private_key
|
|
241
|
+
)
|
|
228
242
|
raise
|
|
229
243
|
except Exception:
|
|
230
244
|
LOG.exception("Exception while setting up CURVECP")
|
|
231
245
|
raise
|
|
232
246
|
|
|
233
|
-
def setup_secure_client(
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
servername: str):
|
|
247
|
+
def setup_secure_client(
|
|
248
|
+
self, client, connect_address: str, servername: str
|
|
249
|
+
):
|
|
237
250
|
"""
|
|
238
251
|
Use this method to setup a secure client. Clients also need the
|
|
239
252
|
servername to look for server's public key
|
|
@@ -251,19 +264,31 @@ class KeyMonkey:
|
|
|
251
264
|
|
|
252
265
|
"""
|
|
253
266
|
try:
|
|
254
|
-
client.curve_publickey, client.curve_secretkey =
|
|
267
|
+
client.curve_publickey, client.curve_secretkey = (
|
|
268
|
+
zmq.auth.load_certificate(self.private_key)
|
|
269
|
+
)
|
|
255
270
|
except IOError:
|
|
256
|
-
LOG.exception(
|
|
271
|
+
LOG.exception(
|
|
272
|
+
"Couldn't load the client private key: %s", self.private_key
|
|
273
|
+
)
|
|
257
274
|
raise
|
|
258
275
|
else:
|
|
259
276
|
# Clients need server's public key for encryption
|
|
260
277
|
try:
|
|
261
|
-
client.curve_serverkey, _ = zmq.auth.load_certificate(
|
|
278
|
+
client.curve_serverkey, _ = zmq.auth.load_certificate(
|
|
279
|
+
os.path.join(self.curvedir, f"{servername}.key")
|
|
280
|
+
)
|
|
262
281
|
except IOError:
|
|
263
282
|
LOG.exception(
|
|
264
|
-
"Couldn't load the server public key %s ",
|
|
283
|
+
"Couldn't load the server public key %s ",
|
|
284
|
+
os.path.join(self.curvedir, f"{servername}.key"),
|
|
285
|
+
)
|
|
265
286
|
raise
|
|
266
287
|
else:
|
|
267
|
-
LOG.info(
|
|
268
|
-
|
|
288
|
+
LOG.info(
|
|
289
|
+
"Client connecting to %s (key %s) using curve key '%s'.",
|
|
290
|
+
connect_address,
|
|
291
|
+
servername,
|
|
292
|
+
self.my_id,
|
|
293
|
+
)
|
|
269
294
|
return client
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import logging.config
|
|
2
|
-
import threading
|
|
3
2
|
import platform
|
|
4
3
|
import sqlite3
|
|
5
4
|
import sys
|
|
6
|
-
|
|
5
|
+
import threading
|
|
7
6
|
from typing import Any
|
|
8
7
|
|
|
9
8
|
LOG = logging.getLogger(__name__)
|
|
@@ -11,10 +10,10 @@ LOG = logging.getLogger(__name__)
|
|
|
11
10
|
|
|
12
11
|
def is_backup_supported():
|
|
13
12
|
|
|
14
|
-
if sys.platform.startswith(
|
|
13
|
+
if sys.platform.startswith("win"):
|
|
15
14
|
return False
|
|
16
15
|
|
|
17
|
-
if platform.python_implementation().lower() ==
|
|
16
|
+
if platform.python_implementation().lower() == "pypy":
|
|
18
17
|
return False
|
|
19
18
|
|
|
20
19
|
return True
|
|
@@ -31,7 +30,7 @@ class SQLiteBackUp:
|
|
|
31
30
|
|
|
32
31
|
def progress(status, remaining, total):
|
|
33
32
|
copied = total - remaining
|
|
34
|
-
LOG.info(
|
|
33
|
+
LOG.info("Copied %s of %s pages", copied, total)
|
|
35
34
|
|
|
36
35
|
source = sqlite3.connect(self.src)
|
|
37
36
|
backup = sqlite3.connect(self.target)
|
|
@@ -39,7 +38,9 @@ class SQLiteBackUp:
|
|
|
39
38
|
with backup:
|
|
40
39
|
source.backup(backup, pages=self.pages, progress=progress)
|
|
41
40
|
|
|
42
|
-
LOG.info(
|
|
41
|
+
LOG.info(
|
|
42
|
+
"Finished Backup: Source %s , Target %s ", self.src, self.target
|
|
43
|
+
)
|
|
43
44
|
|
|
44
45
|
|
|
45
46
|
class RecurringTimer(threading.Timer):
|