-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
base: main
Are you sure you want to change the base?
Conversation
@mgdelacroix @hanzei Friendly reminder on this |
There was a problem hiding this 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) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit:
if (!field || !field.name) { | |
if (!field?.name) { |
There was a problem hiding this 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?
if (!this.field.name) { | ||
return this.asError(this.intl.formatMessage({ | ||
id: 'apps.error.parser.missing_field_name', | ||
defaultMessage: 'Field name is missing.', | ||
})); | ||
} |
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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
?
There was a problem hiding this comment.
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.
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 the build app is failing. Can you help checking if its due to pr changes? |
/update-branch |
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