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

Disable raw data access for sites with visitor logs/profiles disabled #22933

Open
wants to merge 37 commits into
base: 5.x-dev
Choose a base branch
from

Conversation

nathangavin
Copy link
Contributor

@nathangavin nathangavin commented Jan 15, 2025

Description:

Previously, raw data for sites with visitor logs/profiles disabled was available via the GDPR tools. This PR addresses this by filtering the data retrieved during the PrivacyManager.findDataSubjects API call to redact information related to sites with visitor logs/profiles disabled. Resolves issue #20686

Review

@nathangavin nathangavin marked this pull request as ready for review January 16, 2025 04:17
@nathangavin nathangavin added this to the 5.3.0 milestone Jan 16, 2025
@nathangavin nathangavin requested a review from a team January 16, 2025 04:17
@nathangavin nathangavin self-assigned this Jan 16, 2025
@nathangavin nathangavin added Enhancement For new feature suggestions that enhance Matomo's capabilities or add a new report, new API etc. c: Privacy For issues that impact or improve the privacy. labels Jan 16, 2025
@nathangavin nathangavin added the Needs Review PRs that need a code review label Jan 16, 2025
Copy link
Contributor

@caddoo caddoo left a comment

Choose a reason for hiding this comment

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

Really nice 👍

I like that you found a simpler/cleaner solution for this problem in the end, I tested this manually in the end at it seems to work well.

Requesting changes for some (small) possible problems in code, but also the lack of test coverage,

plugins/PrivacyManager/API.php Outdated Show resolved Hide resolved
plugins/PrivacyManager/API.php Outdated Show resolved Hide resolved
plugins/PrivacyManager/API.php Outdated Show resolved Hide resolved
plugins/PrivacyManager/API.php Outdated Show resolved Hide resolved
plugins/PrivacyManager/API.php Outdated Show resolved Hide resolved
plugins/PrivacyManager/API.php Outdated Show resolved Hide resolved
@nathangavin
Copy link
Contributor Author

working on extending existing system tests at plugins/PrivacyManager/tests/System/APITest.php to properly test new functionality.

@nathangavin nathangavin requested a review from caddoo January 20, 2025 04:37
Copy link
Member

@sgiehl sgiehl left a comment

Choose a reason for hiding this comment

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

Nice work @nathangavin. Overall this is very clean and straight forward. I've nevertheless added some suggestions for improvements you should apply.

Besides that it looks like the PrivacyManager UI tests now started failing due to and exception being shown that the userid segment is not available.

I checked locally for the reason. It seems to be caused by various malfunctions:
When the segment editor is loaded it automatically tries to fetch the suggested values for the selected segment. By default that here is userid. Fetching that is currently done by passing in the siteId from URL instead of the siteId of the selected site. So it always fails if the site has disabled visitslog. That would need to be fixed in the SegmentEditor, but can be ignored for now I think, as the suggestedvalue api does not support all as idsite anyway.
In addition you can currently use the userid segment when searching all sites, but it fails when used on a site directly where visits log is disabled. That does not make much sense. I guess it would be better to have the userid segment available for that specific case.

To ensure the userid segment can always be used for the privacy tools I would suggest this change:

diff --git a/plugins/CoreHome/Columns/UserId.php b/plugins/CoreHome/Columns/UserId.php
index 11c1f0c26a..d91c86d6fa 100644
--- a/plugins/CoreHome/Columns/UserId.php
+++ b/plugins/CoreHome/Columns/UserId.php
@@ -51,8 +51,8 @@ class UserId extends VisitDimension

     public function configureSegments(SegmentsList $segmentsList, DimensionSegmentFactory $dimensionSegmentFactory)
     {
-        // Configure userId segment only if visitor profile is available
-        if (Live::isVisitorProfileEnabled()) {
+        // Configure userId segment only if visitor profile is available or when requesting data for privacy tools
+        if (Live::isVisitorProfileEnabled() || \Piwik\API\Request::getRootApiRequestMethod() === 'PrivacyManager.findDataSubjects') {
             parent::configureSegments($segmentsList, $dimensionSegmentFactory);
         }
     }

plugins/PrivacyManager/API.php Outdated Show resolved Hide resolved
@nathangavin
Copy link
Contributor Author

@sgiehl Updated the UserId column logic regarding segment configuration to allow the segment if this specific API function is being used, as suggested.

@nathangavin nathangavin requested a review from sgiehl January 20, 2025 20:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c: Privacy For issues that impact or improve the privacy. Enhancement For new feature suggestions that enhance Matomo's capabilities or add a new report, new API etc. Needs Review PRs that need a code review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants