FEAT: Add session audit context setter/getter API (set_audit_context / get_audit_context) for compliance tracing
Maintainer thường phản hồi trong vòng 1 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 48/100
- Loại issue
- Tính năng
- Độ rõ ràng
- Khá rõ ràng
- Mức độ hoạt động
- Ít trao đổi
- Lĩnh vực
- backend-api-design, databases
Hướng nghiên cứu
Bắt đầu bằng cách xác định lớp kết nối và các mẫu hiện có của nó về thực thi, xác thực, bộ nhớ đệm và ngoại lệ. Xem lại cách các lệnh gọi stored procedure có tham số và các kết nối đã đóng được kiểm thử, sau đó triển khai hành vi setter/getter được yêu cầu xung quanh sp_set_session_context; hoàn tất nghĩa là có các cập nhật context đã được xác thực, hỗ trợ read-only, khả năng lấy dữ liệu từ dictionary cục bộ và các lỗi phù hợp.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Is your feature request related to a problem? Please describe.
There is no built-in way to attach session-level auditing or tracing metadata to a Connection in mssql-python. Applications that need to propagate end-user identity, module names, or action context to SQL Server for auditing, or Extended Events tracing must manually execute raw sp_set_session_context calls, handle input validation themselves, and track which keys have been set. This is error-prone, verbose, and inconsistent across codebases.
Describe the solution you'd like
A setter/getter pair on the connection class
set_audit_context()
Accepts well-known keys (application, module, action, user_id) as named parameters and arbitrary extra keys via **kwargs.
Validates key/value lengths against SQL Server limits (128-char keys, 8000-char values) before executing.
Uses parameterized queries to call sp_set_session_context, preventing SQL injection.
Supports a read_only flag to lock keys for the remainder of the session.
Raises appropriate ProgrammingError / InterfaceError exceptions on invalid input or closed connections.
get_audit_context()
Returns the current session audit context as a dictionary.
The getter reads from the local cache without making a server round-trip
Describe alternatives you've considered
Raw cursor execution — Users call cursor.execute("EXEC sp_set_session_context @key=?, @value=?", ...) directly. This works but requires boilerplate, duplicates validation logic, and lacks discoverability.
Connection string properties — Encoding audit metadata into the connection string (e.g., Application Name). This only covers a single field, is immutable after connect, and doesn't flow to SESSION_CONTEXT().
Additional context
Applications that need to comply with regulations (GDPR, PCI-DSS etc) must propagate end-user identity, module context, and action tracking to SQL Server for audit trail generation and compliance reporting. Without a dedicated setter API, developers are forced to manually execute raw sp_set_session_context stored procedure calls, implement their own input validation, and maintain their own getter/cache logic
- Ngôn ngữ chính
- Python
- Star
- 478
- Fork
- 62
- Merge trung bình
- 3 ngày 1 giờ
- Pull request đã merge (30 ngày)
- 27
Chuẩn bị môi trường
Khởi chạy dev container của dự án ngay trên trình duyệt, bằng tài khoản GitHub của bạn.
- Không có Dockerfile hay tệp Docker Compose
- Có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của microsoft/mssql-python
-
area: bulk-copy
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
microsoft/mssql-python#843 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
macOS: encrypted connections fail after Homebrew moved the `openssl` alias to `openssl@4`Có thể đã có người làm @bewithgaurav đã nhận 14 ngày trước. Đang mởarea: packaging-platform bug triage needed
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 55/100
microsoft/mssql-python#826 · 2 bình luận · 1 người được giao ·
Maintainer thường phản hồi trong vòng 1 ngày
-
bulkcopy PyCore login is closed by SQL Server 2019 while ODBC and Go clients succeed (1.14.0)Có thể làm lại được @bewithgaurav đã nhận 34 ngày trước và không có pull request nào đang mở. Đang mởarea: bulk-copy bug triage done
microsoft/mssql-python#750 · 4 bình luận · 1 người được giao ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Announcement: mssql-python is coming to Django through mssql-django 2.0Có thể làm lại được @bewithgaurav đã nhận 41 ngày trước và không có pull request nào đang mở. Đang mởannouncement
microsoft/mssql-python#748 · 1 người được giao ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Connection pool can briefly exceed max_size when pooling is disabled under loadCó thể đã có người làm @bewithgaurav đã nhận 23 ngày trước. Đang mởarea: connectivity-auth bug triage done under development
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 62/100
microsoft/mssql-python#746 · 1 bình luận · 1 người được giao ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của microsoft/mssql-python
Issue tương tự
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
Deltares/imod-python#1940 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
effort: low prio: low ready
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 82/100
digitalfabrik/integreat-cms#4621 ·
Maintainer thường phản hồi trong vòng 5 ngày
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 88/100
ioos/compliance-checker#1375 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
Maintainer thường phản hồi trong vòng 1 ngày
-
netbox status: backlog topic: testing type: housekeeping
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
netbox-community/netbox#23395 ·
Maintainer thường phản hồi trong vòng 1 ngày