backstop 0.1.0__py3-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.
- backstop/__init__.py +47 -0
- backstop/cli.py +931 -0
- backstop/guard.py +311 -0
- backstop/logger.py +103 -0
- backstop/metadata.py +110 -0
- backstop/native.py +423 -0
- backstop/parser.py +358 -0
- backstop/restore.py +384 -0
- backstop/snapshot.py +645 -0
- backstop/sqlalchemy.py +85 -0
- backstop-0.1.0.dist-info/METADATA +34 -0
- backstop-0.1.0.dist-info/RECORD +15 -0
- backstop-0.1.0.dist-info/WHEEL +5 -0
- backstop-0.1.0.dist-info/entry_points.txt +2 -0
- backstop-0.1.0.dist-info/top_level.txt +1 -0
backstop/__init__.py
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"""backstop — production-grade database safety platform.
|
|
2
|
+
|
|
3
|
+
Public API
|
|
4
|
+
----------
|
|
5
|
+
guard(conn, storage, actor, mode) → GuardedConnection
|
|
6
|
+
Wrap a psycopg2 connection with backstop protection.
|
|
7
|
+
|
|
8
|
+
protect_engine(engine, storage, actor, mode)
|
|
9
|
+
Attach backstop protection to a SQLAlchemy Engine.
|
|
10
|
+
|
|
11
|
+
RiskLevel
|
|
12
|
+
Enum of risk classifications: SAFE, LOW, HIGH, CRITICAL.
|
|
13
|
+
|
|
14
|
+
RiskResult
|
|
15
|
+
Dataclass describing the result of a SQL risk assessment.
|
|
16
|
+
|
|
17
|
+
Example usage::
|
|
18
|
+
|
|
19
|
+
import psycopg2
|
|
20
|
+
import backstop
|
|
21
|
+
|
|
22
|
+
raw_conn = psycopg2.connect(DATABASE_URL)
|
|
23
|
+
db = backstop.guard(
|
|
24
|
+
conn=raw_conn,
|
|
25
|
+
storage="s3://my-bucket@http://localhost:9000",
|
|
26
|
+
actor="gpt-agent-prod",
|
|
27
|
+
mode="protect",
|
|
28
|
+
)
|
|
29
|
+
|
|
30
|
+
# All SQL executed through db.execute() is now intercepted and protected.
|
|
31
|
+
db.execute("DROP TABLE users") # Snapshots users → S3, then drops the table
|
|
32
|
+
db.commit()
|
|
33
|
+
"""
|
|
34
|
+
|
|
35
|
+
from .guard import GuardedConnection, GuardedCursor, guard
|
|
36
|
+
from .parser import RiskLevel, RiskResult
|
|
37
|
+
from .sqlalchemy import protect_engine
|
|
38
|
+
|
|
39
|
+
__all__ = [
|
|
40
|
+
"guard",
|
|
41
|
+
"GuardedConnection",
|
|
42
|
+
"GuardedCursor",
|
|
43
|
+
"protect_engine",
|
|
44
|
+
"RiskLevel",
|
|
45
|
+
"RiskResult",
|
|
46
|
+
]
|
|
47
|
+
|