-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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 the Chrome project API "protected" for the Serverless plugin #157307
Make the Chrome project API "protected" for the Serverless plugin #157307
Conversation
): ServerlessSearchPluginStart { | ||
core.chrome.project.setSideNavComponent(createComponent(core)); | ||
serverless.setSideNavComponent(createComponent(core)); |
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.
2bb0753
to
26e462c
Compare
26e462c
to
060f94a
Compare
Pinging @elastic/appex-sharedux (Team:SharedUX) |
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.
Great work.
@@ -64,7 +63,8 @@ export class ServerlessPlugin | |||
|
|||
return { | |||
setSideNavComponent: (sideNavigationComponent) => | |||
core.chrome.project.setSideNavComponent(sideNavigationComponent), | |||
// Casting the "chrome.projects" service to an "internal" type: it's intentional to call the service only from here. | |||
(core.chrome as InternalChromeStart).project.setSideNavComponent(sideNavigationComponent), |
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.
We should couple this with a throw on these methods if chromeStyle
is not set properly.
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.
@@ -64,7 +63,8 @@ export class ServerlessPlugin | |||
|
|||
return { | |||
setSideNavComponent: (sideNavigationComponent) => |
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: I've always disliked abbreviations, (and Component
feels redundant, as the parameter is a React
component)... perhaps we could consider setSidebarNavigation
...?
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 agree w/ you, but serverless.setSideNavComponent
already has presence in the 3 serverless project plugins. Let's find a new name at our next sync and change this in a standalone PR.
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.
setSidebarNavigation()
is reserved (™) and will be used when there is no need to provide a component (UI) (define the navigation through an object - see first example in Proposal #157702).
Well actually it will even be shorter: setNavigation()
😊
I do think "Component" is explicit of the intent. It could be "UI" suffix instead.
Co-authored-by: Clint Andrew Hall <clint@clintandrewhall.com>
💛 Build succeeded, but was flaky
Failed CI StepsTest Failures
Metrics [docs]Page load bundle
Unknown metric groupsAPI count
ESLint disabled line counts
Total ESLint disabled count
History
To update your PR or re-run it, just comment with: |
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
…57307) ## Summary Addresses #156600 (comment) > Let's think if there is a way to throw an error when core chrome api are called from invalid plugins (in this cases only the serverless plugin would be allowed. This PR can be a starting point for discussion on the behavior we really want. This PR has a simple goal to ensure that non-serverless plugins do not call the `chrome.projects` API. However, it's not complete security, as the compile-time error would be easy to override. cc @sebelga @Dosant @clintandrewhall --- --- ### Checklist Delete any items that are not applicable to this PR. - [x] Documentation was added for features that require explanation or tutorials Internal documentation: https://docs.google.com/document/d/1ew8KYl6ROs_V7jeIXgeP_C9YgkYK2IPtuceo6KVF_jE/edit# --------- Co-authored-by: Clint Andrew Hall <clint@clintandrewhall.com>
Summary
Addresses #156600 (comment)
This PR can be a starting point for discussion on the behavior we really want. This PR has a simple goal to ensure that non-serverless plugins do not call the
chrome.projects
API. However, it's not complete security, as the compile-time error would be easy to override.cc @sebelga @Dosant @clintandrewhall
Checklist
Delete any items that are not applicable to this PR.
Internal documentation: https://docs.google.com/document/d/1ew8KYl6ROs_V7jeIXgeP_C9YgkYK2IPtuceo6KVF_jE/edit#