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

Fix CSP issue when viewing marketplace plugin details #18215

Merged
merged 4 commits into from Oct 27, 2021
Merged

Conversation

sgiehl
Copy link
Member

@sgiehl sgiehl commented Oct 25, 2021

Description:

When viewing the admin page, which contains a widget showing details on new plugins, or when opening the plugin details of a plugin, there is currently a CSP report shown:

[Report Only] Refused to load the image 'https://plugins.matomo.org/RerUserDates/images/4.0.1/RerUserDates-cal.png?w=400' because it violates the following Content Security Policy directive: "img-src 'self' 'unsafe-inline' 'unsafe-eval' data:".

To avoid this I've added *.matomo.org to img-src.

In addition premium plugins are loading the reviews from shop.matomo.org. This would also fail in the future, so added *.matomo.org to default-src as well.

refs #17923

Review

@sgiehl sgiehl added Needs Review PRs that need a code review Regression Indicates a feature used to work in a certain way but it no longer does even though it should. labels Oct 25, 2021
@sgiehl sgiehl added this to the 4.6.0 milestone Oct 25, 2021
@@ -57,6 +57,10 @@ public function home()
$isFeedbackEnabled = Plugin\Manager::getInstance()->isPluginLoaded('Feedback');
$widgetsList = WidgetsList::get();

if ($isInternetEnabled && $isMarketplaceEnabled) {
Copy link
Member

Choose a reason for hiding this comment

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

should this be done directly in the widget? I suppose similar issue would happen when adding a marketplace widget to the dashboard? I suppose it might not work as the widget is rendered in a separate request?

We might need to also check if the marketplace is being viewed in the reporting UI eg in a dashboard

Copy link
Member Author

Choose a reason for hiding this comment

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

Exactly. That doesn't work as it's another request. We could actually always add it if such a widget can be added to dashboard

Copy link
Member Author

Choose a reason for hiding this comment

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

I have checked the marketplace widgets for the dashboard. Both don't seem to show any images. So shouldn't be needed to add a CSP there.

Copy link
Member

Choose a reason for hiding this comment

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

image
@sgiehl they show for me eg when clicking on "more details"

Also when clicking on the left menu on "Marketplace" then there may be screenshots shown when getting details
image

Maybe when Marketplace is enabled, then *.matomo.org always need to be allowed in the reporting page?

Copy link
Member Author

Choose a reason for hiding this comment

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

ah. sure. Should be fixed now.

@tsteur
Copy link
Member

tsteur commented Oct 27, 2021

works 👍

@tsteur tsteur merged commit 1597c82 into 4.x-dev Oct 27, 2021
@tsteur tsteur deleted the fixmarketplacecsp branch October 27, 2021 19:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Needs Review PRs that need a code review Regression Indicates a feature used to work in a certain way but it no longer does even though it should.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants