Users: get_users + set_password (223), plaintext, verified live - #14
Conversation
Captured from AjDevTools "Batch Set Password" and confirmed live on MTF45-4G_AF: code 223 = SystemConfig/UserConfig. The tool sends the password in PLAINTEXT (<UserConfig><Account Username=".." Password="<plaintext>" Group=".." Status=".." /></UserConfig>) and the device computes the stored EncryptPwd — no client-side hashing, so the EncryptPwd cipher is not needed to set a password. - set_password(password, username="admin", group=..., status=..., confirm=True): verified live by changing the admin password, re-authenticating with it, then reverting to 123456. - get_users(): parses the accounts (Username/Group/Status/EncryptPwd) from the config download (read-only). set_password changes the login for every service (binary control, ONVIF, web), so it is confirm-gated. const.CFG_USER="223". Tests: plaintext frame, confirm gate, XML-escaping of special chars, get_users parsing. Docs updated.
PR Summary by QodoAdd user listing and confirm-gated password updates
AI Description
Diagram
High-Level Assessment
Files changed (4)
|
Code Review by Qodo
1.
|
Two review findings: 1. Security — the old signature defaulted Group="Administrator", so resetting a non-admin user's password would elevate them to admin. set_password now read-modify-writes the target account: it preserves the account's existing Group/Status and only replaces the password (drops the stale EncryptPwd, adds plaintext). Raises if the username does not exist. 2. Correctness — after changing the password of the account the client logs in as, self.password was stale, so a reconnect failed. Now self.password is synced when username == self.user. Re-verified live on MTF45-4G_AF (admin change + reconnect + revert). Tests: group preserved, guest not escalated, self.password synced, unknown-user raises, confirm gate, XML-escaping.
|
Addressed both findings: |
What
User-account access over code 223 =
SystemConfig/UserConfig, captured from AjDevTools "Batch Set Password" and verified live on an MTF45-4G_AF.set_password(password, username="admin", group=..., status=..., confirm=True)— the tool sends the plaintext password; the device computes the storedEncryptPwd(no client-side hashing, so theEncryptPwdcipher is not needed). Body:<UserConfig><Account Username=".." Password="<plaintext>" Group=".." Status=".." /></UserConfig>. Verified live: changed the admin password, re-authenticated with the new one (old rejected), then reverted to123456.get_users()— reads the accounts (Username/Group/Status/EncryptPwd) from the config download (read-only).Safety
set_passwordchanges the login for every service (binary control, ONVIF, web), so it isconfirm=True-gated. The docstring says so.Changes
anjoy/comm.py:get_users,set_password.anjoy/const.py:CFG_USER="223".tests/test_comm.py: plaintext frame, confirm gate, XML-escaping of special chars,get_usersparsing (91 tests pass).docs/devices.md: the captured 223 body + the plaintext/EncryptPwd note.