Bug 51941 - import hook that logs attributes of user before/after changes
import hook that logs attributes of user before/after changes
Status: CLOSED FIXED
Product: UCS@school
Classification: Unclassified
Component: Import scripts
UCS@school 4.4
Other Linux
: P5 normal (vote)
: UCS@school 4.4 v7
Assigned To: Daniel Tröder
Tobias Wenzel
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2020-09-04 08:55 CEST by Daniel Tröder
Modified: 2020-10-12 16:19 CEST (History)
1 user (show)

See Also:
What kind of report is it?: Feature Request
What type of bug is this?: ---
Who will be affected by this bug?: ---
How will those affected feel about the bug?: ---
User Pain:
Enterprise Customer affected?:
School Customer affected?:
ISV affected?:
Waiting Support:
Flags outvoted (downgraded) after PO Review:
Ticket number:
Bug group (optional):
Max CVSS v3 score:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Daniel Tröder univentionstaff 2020-09-04 08:55:07 CEST
Create an import hook that runs before and/or after create/modify/move/delete operations and writes a configurable number of attributes of a user to the log file.

The intention is to facilitate easier debugging in cases where users attributes seem to be changed in unexpected ways.
Comment 1 Daniel Tröder univentionstaff 2020-09-04 08:58:07 CEST
The hook "log_user_object.py" has been added to /usr/share/ucs-school-import/pyhooks-available in git  branch dtroeder/51941_log_user_hook

[7d4099d71] Bug #51941: add import hook to log user state before and/or after create/modify/move/delete operations

Please reopen for merge and build, when QAing.
Comment 2 Tobias Wenzel univentionstaff 2020-09-18 13:24:57 CEST
QA -> All Ok, but first read QA -> REOPEN for merge & build

Code- > looks good

PROPS are logged as expected  -> OK

If prop is neither in  user._attributes nor in udm_obj, I get a KeyError. I think this is Ok, but I would prefer an error logging like "Property %s does not exist for user".

when creating a user log_user_attrs gets called
- in post_create as last hook

when modifying a user log_user_attrs gets called
- in pre_modify as first hook
- post_modify as last hook

when deleting a user log_user_attrs gets called
- in pre_remove as first hook

when moving a user log_user_attrs gets called
- in pre_move as first hook
- in post_move as first hook
(tested with sisopi, afterwards pre & post_modify are called as well.)
Comment 3 Daniel Tröder univentionstaff 2020-09-21 08:56:10 CEST
I squashed the fixup commits, merged and built:

[8575a55b9] Bug #51941: add import hook to log user state before and/or after create/modify/move/delete operations
[79544c1a9] Bug #51941: Merge branch 'dtroeder/51941_log_user_hook' into 4.4
[bc6bf404e] Bug #51941: changelog
[23664516a] Bug #51941: advisory

ucs-school-import (17.0.45)
Comment 4 Tobias Wenzel univentionstaff 2020-09-22 12:03:01 CEST
Thanks for the quick response!


QA -> All OK

Changelog -> OK
YAML -> OK
no merge conflicts -> OK

set to VERIFIED
Comment 5 Daniel Tröder univentionstaff 2020-10-12 16:19:01 CEST
UCS@school 4.4 v7 has been released.

https://docs.software-univention.de/changelog-ucsschool-4.4v7-de.html

If this error occurs again, please clone this bug.