You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Fix 23 correctness and security issues from full-codebase review (#142)
* Fix 23 correctness and security issues from full-codebase review
Security:
- Enforce has_change_permission on the action endpoint (authz bypass)
- Skip empty password values on edit so a blank field no longer overwrites
the stored hash with hash("")
- Refuse to sign/verify JWTs with an unset/empty ADMIN_SECRET_KEY
Correctness:
- Fix falsy-zero PK/user-id traps in auth guards and orm_save_obj across all
five ORM adapters (a legitimate id of 0 no longer misroutes)
- exclude now wins over list_display in serialization
- Malformed date/datetime and empty-condition filters return 422, not 500
- SQLAlchemy: real PK-name fallback for non-autoincrement PKs, cast-to-text
for contains/icontains, PK excluded from required, no post-commit expired
attribute read
- Falsy DB defaults no longer force required (Tortoise/Django/Yara); Tortoise
enum options emit .value; Django choice label/value un-swapped
- Reject unsupported/null export format up front; add widget_action and
configuration None/exception guards (FastAPI/Flask/Django); unify Django
error responses under detail; 422 on malformed sign-in body
- Safe int parsing for ADMIN_QUERY_MAX_LIMIT and ADMIN_SESSION_EXPIRED_AT
* Add tests for new branches and restore 100% coverage
- Cover the empty ADMIN_SECRET_KEY guards in sign_in and
get_user_id_from_session_id
- Cover the unsupported/null export format 422
- Cover the invalid Date/DateTime deserialize 422 branches
- Cover the Django malformed sign-in body 422 and the FastAPI/Flask
configuration AdminApiException handling
- Cover the _env_int blank/garbage fallbacks
- Revert the proactive SQLAlchemy m2m falsy-id guard (not a reported
finding; kept the original truthiness check to preserve behavior)
* Address review observations
- Add a has_action_permission hook (defaults to has_change_permission) and
gate the action endpoint on it, so a read-only admin can be allowed to run
a non-mutating action without granting change permission
- Remove the now-unreachable text/plain export default (format is guaranteed
CSV or JSON by the up-front guard)
- Sweep the malformed-body 422 handling across all Django handlers via a
shared _load_json_body helper (was previously only on sign_in)
- Tests: action 403 without change permission
0 commit comments