Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[backend/frontend] Improve auditing to split file read and file download (#5005) #5006

Merged
merged 1 commit into from Dec 2, 2023

Conversation

richard-julien
Copy link
Member

See #5005

@richard-julien richard-julien added the filigran team use to identify PR from the Filigran team label Nov 29, 2023
Comment on lines +54 to +66
const publishFileDownload = async (executeContext, auth, file) => {
const { filename, entity_id } = file.metaData;
const entity = entity_id ? await internalLoadById(executeContext, auth, entity_id) : undefined;
const data = buildContextDataForFile(entity, file.id, filename);
await publishUserAction({
user: auth,
event_type: 'file',
event_access: 'extended',
event_scope: 'download',
context_data: data
});
};

Copy link
Member

Choose a reason for hiding this comment

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

Can't we just have one function taking the scope download or read in parameter to avoid duplicates ? In a same way checkFileAccess has been made

Suggested change
const publishFileDownload = async (executeContext, auth, file) => {
const { filename, entity_id } = file.metaData;
const entity = entity_id ? await internalLoadById(executeContext, auth, entity_id) : undefined;
const data = buildContextDataForFile(entity, file.id, filename);
await publishUserAction({
user: auth,
event_type: 'file',
event_access: 'extended',
event_scope: 'download',
context_data: data
});
};
const publishFile = async (executeContext, auth, file, event_scope) => {
const { filename, entity_id } = file.metaData;
const entity = entity_id ? await internalLoadById(executeContext, auth, entity_id) : undefined;
const data = buildContextDataForFile(entity, file.id, filename);
await publishUserAction({
user: auth,
event_type: 'file',
event_access: 'extended',
event_scope,
context_data: data
});
};

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks for the comment. I will merge as it is and will be part of future refactor.

@richard-julien richard-julien self-assigned this Dec 1, 2023
@Kedae Kedae linked an issue Dec 1, 2023 that may be closed by this pull request
@SamuelHassine SamuelHassine merged commit b535aa7 into master Dec 2, 2023
6 checks passed
@SamuelHassine SamuelHassine deleted the issue/5005 branch December 2, 2023 06:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
filigran team use to identify PR from the Filigran team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Improve auditing to split file read and file download
4 participants