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

Make attachments and app bindings more robust yet secure #8570

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

larkox
Copy link
Contributor

@larkox larkox commented Feb 7, 2025

Summary

When addressing some security issues, we started validating attachments and app bindings. This led to consider some missing fields as "invalid" attachments (or bindings).

This PR just consider every field as optional, and handle that in the code.

Will try to do something similar for webapp.

Ticket Link

Mobile part of https://mattermost.atlassian.net/browse/MM-62356

Release Note

Fix issues where App Bindings and Message Attachments may not show properly

@larkox larkox added 2: Dev Review Requires review by a core commiter 3: QA Review Requires review by a QA tester labels Feb 7, 2025
@larkox larkox requested review from a team, mgdelacroix and hanzei and removed request for a team February 7, 2025 17:59
@larkox
Copy link
Contributor Author

larkox commented Feb 21, 2025

@mgdelacroix @hanzei Friendly reminder on this

Copy link
Member

@mgdelacroix mgdelacroix left a comment

Choose a reason for hiding this comment

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

LGTM! 👍

@@ -327,7 +330,7 @@ function AppsFormComponent({

const performLookup = useCallback(async (name: string, userInput: string): Promise<AppSelectOption[]> => {
const field = form.fields?.find((f) => f.name === name);
if (!field) {
if (!field || !field.name) {
Copy link
Member

Choose a reason for hiding this comment

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

nit:

Suggested change
if (!field || !field.name) {
if (!field?.name) {

Copy link

@hanzei hanzei left a comment

Choose a reason for hiding this comment

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

I fully support the changes for message attachments.

For apps, I'm more hesitant. They have almost no usage and I'm not sure what the value of changing their code is. The current implementation is in line with the docs. Why relax it?

Comment on lines +352 to +357
if (!this.field.name) {
return this.asError(this.intl.formatMessage({
id: 'apps.error.parser.missing_field_name',
defaultMessage: 'Field name is missing.',
}));
}
Copy link

Choose a reason for hiding this comment

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

I'm surprised this is caught on the server side. Anyway, it doesn't hurt to validate also client side.

However, I wonder how much time we should spend on Apps. 1/5 that we should touch this code.

@@ -23,15 +23,15 @@ type AppsState = {
};

type AppBinding = {
app_id: string;
location: string;
app_id?: string;
Copy link

Choose a reason for hiding this comment

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

Is that field really optional?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes and no. The thing is... many of these fields can be inherited. So... the "root binding" should have them, but the rest don't need to define it. The cleanBindings function will take care of that.

I thought about making the distinction between clean and raw bindings, but it complicated many things, so I preferred to go with just making them optional everywhere.

app_id: string;
location: string;
app_id?: string;
location?: string;
Copy link

Choose a reason for hiding this comment

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

Should we be more strict and require a location?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Same as in the previous comment.

@larkox
Copy link
Contributor Author

larkox commented Feb 28, 2025

Regarding Apps, there has been some complaints about this breaking: https://community.mattermost.com/core/pl/4xqtw5taef88xk8wz71yq585je

That is why I wanted to fix it.

@larkox larkox added the Build Apps for PR Build the mobile app for iOS and Android to test label Feb 28, 2025
@yasserfaraazkhan
Copy link
Contributor

@larkox the build app is failing. Can you help checking if its due to pr changes?

@larkox
Copy link
Contributor Author

larkox commented Feb 28, 2025

/update-branch

@larkox larkox added Build Apps for PR Build the mobile app for iOS and Android to test and removed Build Apps for PR Build the mobile app for iOS and Android to test labels Feb 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
2: Dev Review Requires review by a core commiter 3: QA Review Requires review by a QA tester Build Apps for PR Build the mobile app for iOS and Android to test release-note
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants