MySQL error 1143 (column-level SELECT denied) is not translated to AccessError
维护者通常 1 天内回复
还没有人认领这个 Issue。
评估
调研方向
从 src/datajoint/adapters/mysql.py 中的 translate_error 开始,其中 case 1044 | 1142: 分支将访问错误映射为 AccessError。阅读现有的访问错误测试,了解受限 MySQL 用户是如何设置的,然后添加一个具有列级 GRANT SELECT (...) 权限的用户。完成标准是:错误 1143 会抛出 dj.errors.AccessError,并且有一个测试覆盖列级权限被拒绝的查询。
由索引模型根据 Issue 内容生成。
描述
On MySQL, a query that names a column the user has no privilege on fails with error 1143. DataJoint
passes that error through as a raw pymysql.err.OperationalError. The table-level equivalent, 1142, is
translated to dj.errors.AccessError. Code that catches AccessError to handle a missing privilege
therefore misses column-level grants.
Reproduction
import datajoint as dj
admin = dj.Connection("127.0.0.1", "root", "simple", 3306)
schema = dj.Schema("demo_access", connection=admin)
@schema
class Measurement(dj.Manual):
definition = """
measurement_id: int32
---
value: float64
operator: varchar(32)
"""
@schema
class Note(dj.Manual):
definition = """
note_id: int32
---
text: varchar(64)
"""
# '%%' because Connection.query formats its arguments
admin.query("CREATE USER 'reader'@'%%' IDENTIFIED BY 'pw'")
admin.query("GRANT SELECT (measurement_id, value) ON demo_access.measurement TO 'reader'@'%%'")
reader = dj.Connection("127.0.0.1", "reader", "pw", 3306)
reader.query("SELECT text FROM demo_access.note")
# datajoint.errors.AccessError: ('Insufficient privileges.', "SELECT command denied ... for table 'note'", ...)
reader.query("SELECT operator FROM demo_access.measurement")
# pymysql.err.OperationalError: (1143, "SELECT command denied ... for column 'operator' in table 'measurement'")
Observed on MySQL 8.0 with master at b9ace66.
Expected behavior
1143 raises dj.errors.AccessError, like 1044 and 1142. The PostgreSQL adapter already maps
insufficient_privilege (42501) to AccessError for table and column denials alike, so the change also
makes the two backends agree.
Where
src/datajoint/adapters/mysql.py, translate_error: case 1044 | 1142: becomes case 1044 | 1142 | 1143:.
A test beside the existing access-error tests would need a user with a column-level grant.
- 主要语言
- Python
- 星标
- 197
- 派生
- 99
- 平均合并
- 1 天 11 小时
- 30 天内合并 PR
- 10
环境准备
- 提供 Dockerfile 或 Docker Compose 文件
- 没有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
datajoint/datajoint-python 的其他 Issue
-
难度 2/5 1-3 小时 新手友好度 70/100
datajoint/datajoint-python#1581 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 76/100
datajoint/datajoint-python#1539 · 3 条评论 ·
维护者通常 1 天内回复
-
Environment variables lose to datajoint.json for settings missing from ENV_VAR_MAPPING可能已有人在做 @dimitri-yatsenko 今天认领。 未关闭
datajoint/datajoint-python#1585 · 已指派 1 人 ·
维护者通常 1 天内回复
-
_job_start_time records the populating host's local time, with no zone可能已有人在做 @dimitri-yatsenko 于 1 天前认领。 未关闭
datajoint/datajoint-python#1584 · 已指派 1 人 ·
维护者通常 1 天内回复
-
database.name should namespace schema names on MySQL, as it does on PostgreSQL可能已有人在做 @dimitri-yatsenko 于 4 天前认领。 未关闭feature
难度 4/5 3-5 天 新手友好度 15/100
datajoint/datajoint-python#1582 ·
维护者通常 1 天内回复
查看 datajoint/datajoint-python 的全部 Issue
相似的 Issue
-
[Bug]: Streamed /v1/chat/completions sends unredacted agent error text (keys) in the final chunk可能已有人在做 @rodricksz4h5 今天认领。 未关闭area/streaming comp/gateway P2 type/security
难度 2/5 1-3 小时 新手友好度 78/100
NousResearch/hermes-agent#138245 ·
维护者通常 1 天内回复
-
[oblt-aw][autodoc] Update user onboarding guide for mandatory trigger CODEOWNERS step可能已有人在做 @github-actions 今天认领。 未关闭
难度 2/5 1-3 小时 新手友好度 66/100
维护者通常 1 天内回复
-
correction metadata
难度 2/5 1 小时以内 新手友好度 68/100
acl-org/acl-anthology#10378 · 1 条评论 ·
维护者通常 1 天内回复
-
cloudtrail_multi_region_enabled_logging_management_events fails when the advanced event selector has a custom name可能已有人在做 @12YYCCYY16 今天认领。 未关闭
难度 2/5 1-3 小时 新手友好度 78/100
prowler-cloud/prowler#13033 ·
维护者通常 1 天内回复
-
enhancement
难度 1/5 1-3 小时 新手友好度 88/100
graygarbage/HermesKey#23 ·