mdbq 4.2.10__py3-none-any.whl → 4.2.11__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.
Potentially problematic release.
This version of mdbq might be problematic. Click here for more details.
- mdbq/__version__.py +1 -1
- mdbq/auth/crypto.py +41 -7
- mdbq/redis/redis_cache.py +5 -0
- {mdbq-4.2.10.dist-info → mdbq-4.2.11.dist-info}/METADATA +1 -1
- {mdbq-4.2.10.dist-info → mdbq-4.2.11.dist-info}/RECORD +7 -7
- {mdbq-4.2.10.dist-info → mdbq-4.2.11.dist-info}/WHEEL +0 -0
- {mdbq-4.2.10.dist-info → mdbq-4.2.11.dist-info}/top_level.txt +0 -0
mdbq/__version__.py
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
VERSION = '4.2.
|
|
1
|
+
VERSION = '4.2.11'
|
mdbq/auth/crypto.py
CHANGED
|
@@ -175,8 +175,29 @@ class CryptoService:
|
|
|
175
175
|
def decrypt_token(self, encrypted_token: str) -> Optional[Dict[str, Any]]:
|
|
176
176
|
"""解密令牌"""
|
|
177
177
|
try:
|
|
178
|
+
# 验证输入参数
|
|
179
|
+
if not encrypted_token or not isinstance(encrypted_token, str):
|
|
180
|
+
self.logger.error("无效的加密令牌")
|
|
181
|
+
return None
|
|
182
|
+
|
|
178
183
|
# 解析加密数据
|
|
179
|
-
|
|
184
|
+
try:
|
|
185
|
+
encrypted_data = json.loads(base64.b64decode(encrypted_token))
|
|
186
|
+
except (json.JSONDecodeError, ValueError, TypeError) as e:
|
|
187
|
+
self.logger.error(f"解析加密数据失败: {str(e)}")
|
|
188
|
+
return None
|
|
189
|
+
|
|
190
|
+
# 验证数据类型
|
|
191
|
+
if not isinstance(encrypted_data, dict):
|
|
192
|
+
self.logger.error("加密数据格式错误,应为字典类型")
|
|
193
|
+
return None
|
|
194
|
+
|
|
195
|
+
# 验证必要的字段是否存在
|
|
196
|
+
required_fields = ['key', 'iv', 'ciphertext']
|
|
197
|
+
for field in required_fields:
|
|
198
|
+
if field not in encrypted_data:
|
|
199
|
+
self.logger.error(f"加密数据缺少必要字段: {field}")
|
|
200
|
+
return None
|
|
180
201
|
|
|
181
202
|
# 获取私钥
|
|
182
203
|
private_key = self.key_manager.get_private_key()
|
|
@@ -185,7 +206,11 @@ class CryptoService:
|
|
|
185
206
|
return None
|
|
186
207
|
|
|
187
208
|
# 解密AES密钥
|
|
188
|
-
|
|
209
|
+
try:
|
|
210
|
+
encrypted_aes_key = base64.b64decode(encrypted_data['key'])
|
|
211
|
+
except (ValueError, TypeError) as e:
|
|
212
|
+
self.logger.error(f"解码AES密钥失败: {str(e)}")
|
|
213
|
+
return None
|
|
189
214
|
|
|
190
215
|
# 使用SHA-512加密算法
|
|
191
216
|
try:
|
|
@@ -199,16 +224,25 @@ class CryptoService:
|
|
|
199
224
|
)
|
|
200
225
|
except Exception as decrypt_error:
|
|
201
226
|
self.logger.error("RSA解密失败", {'error': str(decrypt_error)})
|
|
227
|
+
return None
|
|
202
228
|
|
|
203
229
|
# 解密数据
|
|
204
|
-
|
|
205
|
-
|
|
230
|
+
try:
|
|
231
|
+
iv = base64.b64decode(encrypted_data['iv'])
|
|
232
|
+
ciphertext = base64.b64decode(encrypted_data['ciphertext'])
|
|
233
|
+
except (ValueError, TypeError) as e:
|
|
234
|
+
self.logger.error(f"解码IV或密文失败: {str(e)}")
|
|
235
|
+
return None
|
|
206
236
|
|
|
207
237
|
# 检查是否有认证标签(AES-GCM需要)
|
|
208
238
|
if 'tag' in encrypted_data:
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
239
|
+
try:
|
|
240
|
+
tag = base64.b64decode(encrypted_data['tag'])
|
|
241
|
+
# 将tag附加到密文末尾(AES-GCM标准做法)
|
|
242
|
+
ciphertext_with_tag = ciphertext + tag
|
|
243
|
+
except (ValueError, TypeError) as e:
|
|
244
|
+
self.logger.error(f"解码认证标签失败: {str(e)}")
|
|
245
|
+
return None
|
|
212
246
|
else:
|
|
213
247
|
# 如果没有tag,假设密文已经包含tag
|
|
214
248
|
ciphertext_with_tag = ciphertext
|
mdbq/redis/redis_cache.py
CHANGED
|
@@ -1131,6 +1131,11 @@ def _safe_cache_set(cache_system, cache_key, response_data, ttl, namespace,
|
|
|
1131
1131
|
if not status_ok:
|
|
1132
1132
|
return False
|
|
1133
1133
|
|
|
1134
|
+
# 检查 message 字段是否包含"失败"字样,如果包含则跳过缓存
|
|
1135
|
+
message = data.get('message', '')
|
|
1136
|
+
if isinstance(message, str) and ('失败' in message or 'error' in message or 'fail' in message):
|
|
1137
|
+
return False
|
|
1138
|
+
|
|
1134
1139
|
# 检查数据部分(支持多种数据字段名)
|
|
1135
1140
|
has_data_fields = (
|
|
1136
1141
|
'data' in data or # 标准data字段
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
mdbq/__init__.py,sha256=Il5Q9ATdX8yXqVxtP_nYqUhExzxPC_qk_WXQ_4h0exg,16
|
|
2
|
-
mdbq/__version__.py,sha256=
|
|
2
|
+
mdbq/__version__.py,sha256=MqhMtZv7l-q_wRQzpu6U2VaOi2Ddz7_1SDL7MMVF9vs,18
|
|
3
3
|
mdbq/auth/__init__.py,sha256=pnPMAt63sh1B6kEvmutUuro46zVf2v2YDAG7q-jV_To,24
|
|
4
4
|
mdbq/auth/auth_backend.py,sha256=iLN7AqiSq7fQgFtNtge_TIlVOR1hrCSZXH6oId6uGX4,116924
|
|
5
|
-
mdbq/auth/crypto.py,sha256=
|
|
5
|
+
mdbq/auth/crypto.py,sha256=M0i4dRljJuE30WH_13ythA2QGKPXZm6TgpnYp6aHOzw,17431
|
|
6
6
|
mdbq/auth/rate_limiter.py,sha256=1m_Paxp8pDNpmyoFGRpFMVOJpbmeIvfVcfiQ2oH72qM,32850
|
|
7
7
|
mdbq/js/__init__.py,sha256=hpMi3_ZKwIWkzc0LnKL-SY9AS-7PYFHq0izYTgEvxjc,30
|
|
8
8
|
mdbq/js/jc.py,sha256=6Rgf1WqaJJ1oevpn-pt08gXKbX5hjoQaV6uZGCAGbYw,13177
|
|
@@ -27,7 +27,7 @@ mdbq/pbix/pbix_refresh.py,sha256=JUjKW3bNEyoMVfVfo77UhguvS5AWkixvVhDbw4_MHco,239
|
|
|
27
27
|
mdbq/pbix/refresh_all.py,sha256=OBT9EewSZ0aRS9vL_FflVn74d4l2G00wzHiikCC4TC0,5926
|
|
28
28
|
mdbq/redis/__init__.py,sha256=YtgBlVSMDphtpwYX248wGge1x-Ex_mMufz4-8W0XRmA,12
|
|
29
29
|
mdbq/redis/getredis.py,sha256=vdg7YQEjhoMp5QzxygNGx5DQKRnePrcwPYgUrDypA6g,23672
|
|
30
|
-
mdbq/redis/redis_cache.py,sha256=
|
|
30
|
+
mdbq/redis/redis_cache.py,sha256=JWarX_l7LvdKyxtUNPANAqd-y20Jg5uqmllCbT-fyv8,45752
|
|
31
31
|
mdbq/route/__init__.py,sha256=BT_dAY7V-U2o72bevq1B9Mq9QA7GodwtkxyLNdGaoE8,22
|
|
32
32
|
mdbq/route/analytics.py,sha256=dngj5hVwKddEUy59nSYbOoJ9C7OVrtCmCkvW6Uj9RYM,28097
|
|
33
33
|
mdbq/route/monitor.py,sha256=lyowGUU8c2GykeZLrdxd7nXpNMqXWcOsuQsbS8l0pwU,36595
|
|
@@ -35,7 +35,7 @@ mdbq/route/routes.py,sha256=QVGfTvDgu0CpcKCvk1ra74H8uojgqTLUav1fnVAqLEA,29433
|
|
|
35
35
|
mdbq/selenium/__init__.py,sha256=AKzeEceqZyvqn2dEDoJSzDQnbuENkJSHAlbHAD0u0ZI,10
|
|
36
36
|
mdbq/selenium/get_driver.py,sha256=1NTlVUE6QsyjTrVVVqTO2LOnYf578ccFWlWnvIXGtic,20903
|
|
37
37
|
mdbq/spider/__init__.py,sha256=RBMFXGy_jd1HXZhngB2T2XTvJqki8P_Fr-pBcwijnew,18
|
|
38
|
-
mdbq-4.2.
|
|
39
|
-
mdbq-4.2.
|
|
40
|
-
mdbq-4.2.
|
|
41
|
-
mdbq-4.2.
|
|
38
|
+
mdbq-4.2.11.dist-info/METADATA,sha256=HjK2Bl76B_V2Xpxh0lUkdAfk3thD2VXAmCAgkh23pWk,364
|
|
39
|
+
mdbq-4.2.11.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
40
|
+
mdbq-4.2.11.dist-info/top_level.txt,sha256=2FQ-uLnCSB-OwFiWntzmwosW3X2Xqsg0ewh1axsaylA,5
|
|
41
|
+
mdbq-4.2.11.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|