Skip to content

feat(auditlog): Add audit logs for file create/delete#2303

Open
sakshamarora1 wants to merge 1 commit intoinveniosoftware:masterfrom
sakshamarora1:feature/file_audit_logs
Open

feat(auditlog): Add audit logs for file create/delete#2303
sakshamarora1 wants to merge 1 commit intoinveniosoftware:masterfrom
sakshamarora1:feature/file_audit_logs

Conversation

@sakshamarora1
Copy link
Copy Markdown
Contributor

closes: CERNDocumentServer/cds-rdm#681

For files, from what I've observed users can only delete and upload a new file. There aren't any changes done via the service layer on the same file (eg. metadata).

If there is, and maybe I have missed it, please let me know and we can add tracking for that as well.

@sakshamarora1 sakshamarora1 force-pushed the feature/file_audit_logs branch from 5cfa968 to 26512b4 Compare April 7, 2026 13:19
@kpsherva kpsherva moved this to In review 🔍 in Sprint Q2 2026 Apr 8, 2026
@sakshamarora1 sakshamarora1 force-pushed the feature/file_audit_logs branch from 26512b4 to c8ab7f4 Compare April 8, 2026 14:30
result = super().commit_file(identity, id_, file_key, uow=uow)

uow.register(
AuditLogOp(FileCreateAuditLog.build(identity, id_, file_key=file_key))
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why did we choose to use the drafts id for file creation logs and not the parent.pid.pid_value as we do In the other logs?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For the share access logs, the metadata of the parent is updated. Here, the metadata of the files attached to the record are updated. And through the UI, we can only create or delete a file.


def __call__(self, data, **kwargs):
"""Update data with file data."""
file_key = kwargs.get("file_key", None)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit; the marshmallow schema is required, but here it can possibly be None

class FileCreateAuditLog(BaseAuditLog):
"""Audit log for file create."""

resource_type = "draft"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this log only for the initial file creation? What if a record is modified and files are added?

Copy link
Copy Markdown
Contributor Author

@sakshamarora1 sakshamarora1 Apr 20, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Then it's a new file and a new audit log entry, through the FileService commit_file method

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: In review 🔍

Development

Successfully merging this pull request may close these issues.

Audit logs: Files and grants

3 participants