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

add extra check before accessing whisperedTo #44456

Merged
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions src/libs/ReportActionsUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -191,18 +191,22 @@ function getWhisperedTo(reportAction: OnyxInputOrEntry<ReportAction>): number[]
const originalMessage = getOriginalMessage(reportAction);
const message = getReportActionMessage(reportAction);

if (!(originalMessage && 'whisperedTo' in originalMessage) && !(message && 'whisperedTo' in message)) {
if (!(originalMessage && typeof originalMessage === 'object' && 'whisperedTo' in originalMessage) && !(message && typeof message === 'object' && 'whisperedTo' in message)) {
return [];
}

if (!Array.isArray(message) && typeof message === 'object' && 'whisperedTo' in message) {
return message?.whisperedTo ?? [];
}

if (originalMessage && 'whisperedTo' in originalMessage) {
if (originalMessage && typeof originalMessage === 'object' && 'whisperedTo' in originalMessage) {
return originalMessage?.whisperedTo ?? [];
}

if (typeof originalMessage !== 'object') {
Log.info('Original message is not an object for reportAction: ', true, reportAction);
Copy link
Contributor

Choose a reason for hiding this comment

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

We cannot log the entire report action, that has sensitive data. only its ID and type

Copy link
Contributor Author

Choose a reason for hiding this comment

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

There are some places in ReportActionUtils where the reportAction is logged like here so I followed that.

I will push a commit.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

if (typeof originalMessage !== 'object') {
        Log.info('Original message is not an object for reportAction: ', true, {"reportActionID" : reportAction?.reportActionID, "actionName" : reportAction?.actionName});
    }

This is fine, right?

Copy link
Contributor

Choose a reason for hiding this comment

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

We probably redact the sensitive fields in the backend but still safer to just send the reportActionID

}

return [];
}

Expand Down
Loading