Merge pull request #1325 from venkateshpabbati/main
Browse files- .github/dependabot.yml +11 -0
- SECURITY.md +21 -0
- lightrag/kg/tidb_impl.py +20 -7
.github/dependabot.yml
ADDED
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# To get started with Dependabot version updates, you'll need to specify which
|
2 |
+
# package ecosystems to update and where the package manifests are located.
|
3 |
+
# Please see the documentation for all configuration options:
|
4 |
+
# https://docs.github.com/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file
|
5 |
+
|
6 |
+
version: 2
|
7 |
+
updates:
|
8 |
+
- package-ecosystem: "pip" # See documentation for possible values
|
9 |
+
directory: "/" # Location of package manifests
|
10 |
+
schedule:
|
11 |
+
interval: "weekly"
|
SECURITY.md
ADDED
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Security Policy
|
2 |
+
|
3 |
+
## Supported Versions
|
4 |
+
|
5 |
+
Use this section to tell people about which versions of your project are
|
6 |
+
currently being supported with security updates.
|
7 |
+
|
8 |
+
| Version | Supported |
|
9 |
+
| ------- | ------------------ |
|
10 |
+
| 5.1.x | :white_check_mark: |
|
11 |
+
| 5.0.x | :x: |
|
12 |
+
| 4.0.x | :white_check_mark: |
|
13 |
+
| < 4.0 | :x: |
|
14 |
+
|
15 |
+
## Reporting a Vulnerability
|
16 |
+
|
17 |
+
Use this section to tell people how to report a vulnerability.
|
18 |
+
|
19 |
+
Tell them where to go, how often they can expect to get an update on a
|
20 |
+
reported vulnerability, what to expect if the vulnerability is accepted or
|
21 |
+
declined, etc.
|
lightrag/kg/tidb_impl.py
CHANGED
@@ -23,6 +23,14 @@ if not pm.is_installed("sqlalchemy"):
|
|
23 |
from sqlalchemy import create_engine, text # type: ignore
|
24 |
|
25 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
26 |
class TiDB:
|
27 |
def __init__(self, config, **kwargs):
|
28 |
self.host = config.get("host", None)
|
@@ -38,9 +46,9 @@ class TiDB:
|
|
38 |
|
39 |
try:
|
40 |
self.engine = create_engine(connection_string)
|
41 |
-
logger.info(
|
42 |
except Exception as e:
|
43 |
-
logger.error(
|
44 |
logger.error(f"TiDB database error: {e}")
|
45 |
raise
|
46 |
|
@@ -55,13 +63,13 @@ class TiDB:
|
|
55 |
try:
|
56 |
await self.query(f"SELECT 1 FROM {k}".format(k=k))
|
57 |
except Exception as e:
|
58 |
-
logger.error(
|
59 |
logger.error(f"TiDB database error: {e}")
|
60 |
try:
|
61 |
await self.execute(v["ddl"])
|
62 |
-
logger.info(
|
63 |
except Exception as e:
|
64 |
-
logger.error(
|
65 |
logger.error(f"TiDB database error: {e}")
|
66 |
|
67 |
# After all tables are created, try to migrate timestamp fields
|
@@ -82,7 +90,10 @@ class TiDB:
|
|
82 |
try:
|
83 |
result = conn.execute(text(sql), params)
|
84 |
except Exception as e:
|
85 |
-
|
|
|
|
|
|
|
86 |
raise
|
87 |
if multirows:
|
88 |
rows = result.all()
|
@@ -107,7 +118,9 @@ class TiDB:
|
|
107 |
else:
|
108 |
conn.execute(text(sql), parameters=data)
|
109 |
except Exception as e:
|
110 |
-
|
|
|
|
|
111 |
raise
|
112 |
|
113 |
|
|
|
23 |
from sqlalchemy import create_engine, text # type: ignore
|
24 |
|
25 |
|
26 |
+
def sanitize_sensitive_info(data: dict) -> dict:
|
27 |
+
sanitized_data = data.copy()
|
28 |
+
sensitive_fields = ['password', 'user', 'host', 'database', 'port', 'ssl_verify_cert', 'ssl_verify_identity']
|
29 |
+
for field in sensitive_fields:
|
30 |
+
if field in sanitized_data:
|
31 |
+
sanitized_data[field] = '***'
|
32 |
+
return sanitized_data
|
33 |
+
|
34 |
class TiDB:
|
35 |
def __init__(self, config, **kwargs):
|
36 |
self.host = config.get("host", None)
|
|
|
46 |
|
47 |
try:
|
48 |
self.engine = create_engine(connection_string)
|
49 |
+
logger.info("Connected to TiDB database")
|
50 |
except Exception as e:
|
51 |
+
logger.error("Failed to connect to TiDB database")
|
52 |
logger.error(f"TiDB database error: {e}")
|
53 |
raise
|
54 |
|
|
|
63 |
try:
|
64 |
await self.query(f"SELECT 1 FROM {k}".format(k=k))
|
65 |
except Exception as e:
|
66 |
+
logger.error("Failed to check table in TiDB database")
|
67 |
logger.error(f"TiDB database error: {e}")
|
68 |
try:
|
69 |
await self.execute(v["ddl"])
|
70 |
+
logger.info("Created table in TiDB database")
|
71 |
except Exception as e:
|
72 |
+
logger.error("Failed to create table in TiDB database")
|
73 |
logger.error(f"TiDB database error: {e}")
|
74 |
|
75 |
# After all tables are created, try to migrate timestamp fields
|
|
|
90 |
try:
|
91 |
result = conn.execute(text(sql), params)
|
92 |
except Exception as e:
|
93 |
+
sanitized_params = sanitize_sensitive_info(params)
|
94 |
+
sanitized_params = sanitize_sensitive_info(params)
|
95 |
+
sanitized_error = sanitize_sensitive_info({'error': str(e)})
|
96 |
+
logger.error(f"Tidb database,\nsql:{sql},\nparams:{sanitized_params},\nerror:{sanitized_error}")
|
97 |
raise
|
98 |
if multirows:
|
99 |
rows = result.all()
|
|
|
118 |
else:
|
119 |
conn.execute(text(sql), parameters=data)
|
120 |
except Exception as e:
|
121 |
+
sanitized_data = sanitize_sensitive_info(data) if data else None
|
122 |
+
sanitized_error = sanitize_sensitive_info({'error': str(e)})
|
123 |
+
logger.error(f"Tidb database,\nsql:{sql},\ndata:{sanitized_data},\nerror:{sanitized_error}")
|
124 |
raise
|
125 |
|
126 |
|