[Custom Reports] Enforce report sharing checks on drill-down, export, clone, delete, and column-config#1950
Open
robertSt7 wants to merge 4 commits into
Open
[Custom Reports] Enforce report sharing checks on drill-down, export, clone, delete, and column-config#1950robertSt7 wants to merge 4 commits into
robertSt7 wants to merge 4 commits into
Conversation
… clone, delete, and column-config endpoints loadByName() bypassed the per-report sharing model (shareGlobally, sharedUserIds, sharedRoleIds) that loadByNameForCurrentUser() enforces. Several code paths used the unprotected method, letting any user with only the generic reports permission read or manage private reports they were never shared: - CustomReportService::getDrillDownOptions() - CsvService::generateCsvFile() (queues the async CSV export job) - CsvCollectionHandler (async worker; resolves the job-owning user via UserResolverInterface since it runs with no HTTP security token) - CustomReportConfigService::cloneCustomReport()/deleteCustomReport() - ColumnService::getColumnConfig() All now route through getAllowedReport()/getAllowedReportForUser(), matching the already-correct getChartData() and updateCustomReport(). Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Up to standards ✅🟢 Issues
|
| Category | Results |
|---|---|
| CodeStyle | 5 minor |
🟢 Metrics 4 complexity
Metric Results Complexity 4
NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.
Contributor
There was a problem hiding this comment.
Pull request overview
Enforces custom-report sharing permissions across previously unprotected operations, including asynchronous CSV exports.
Changes:
- Adds current-user and explicit-user report authorization checks.
- Secures drill-down, export, clone, delete, and column configuration paths.
- Adds translated execution-engine permission errors.
Reviewed changes
Copilot reviewed 22 out of 22 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
translations/studio.sv.yaml |
Adds Swedish permission error. |
translations/studio.no.yaml |
Adds Norwegian permission error. |
translations/studio.it.yaml |
Adds Italian permission error. |
translations/studio.fr.yaml |
Adds French permission error. |
translations/studio.es.yaml |
Adds Spanish permission error. |
translations/studio.en.yaml |
Adds English permission error. |
translations/studio.de.yaml |
Adds German permission error. |
src/ExecutionEngine/Util/Config.php |
Defines the report permission message key. |
src/Bundle/CustomReport/Service/CustomReportService.php |
Secures drill-down access. |
src/Bundle/CustomReport/Service/CustomReportConfigServiceInterface.php |
Exposes authorization methods and exceptions. |
src/Bundle/CustomReport/Service/CustomReportConfigService.php |
Secures clone/delete and delegates user checks. |
src/Bundle/CustomReport/Service/CsvServiceInterface.php |
Documents export authorization. |
src/Bundle/CustomReport/Service/CsvService.php |
Checks access before queuing exports. |
src/Bundle/CustomReport/Service/ColumnServiceInterface.php |
Documents authorization failures. |
src/Bundle/CustomReport/Service/ColumnService.php |
Secures column configuration. |
src/Bundle/CustomReport/Repository/CustomReportRepositoryInterface.php |
Adds explicit-user report lookup. |
src/Bundle/CustomReport/Repository/CustomReportRepository.php |
Implements explicit-user sharing checks. |
src/Bundle/CustomReport/ExecutionEngine/AutomationAction/Messenger/Handler/CsvCollectionHandler.php |
Revalidates export access asynchronously. |
src/Bundle/CustomReport/Controller/Config/UpdateController.php |
Documents forbidden responses. |
src/Bundle/CustomReport/Controller/Config/DeleteController.php |
Documents forbidden responses. |
src/Bundle/CustomReport/Controller/Config/ColumnConfigController.php |
Documents forbidden responses. |
src/Bundle/CustomReport/Controller/Config/CloneController.php |
Documents forbidden responses. |
…on, update @throws docs - CsvCollectionHandler: keep the report lookup's NotFoundException on its own abort path (CSV_DATA_COLLECTION_FAILED_MESSAGE), separate from the explicit permission-denied abort, instead of letting it propagate uncaught and cause the Messenger message to fail/retry. - Document NotFoundException alongside ForbiddenException on CsvServiceInterface/CsvService::generateCsvFile() and getDrillDownOptions(), since getAllowedReport() can throw either. Also fixes the same pre-existing gap on getChartData()'s interface docblock. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
PHPStan couldn't prove the catch branch's abort() call always terminates, so it flagged \$reportConfig as possibly undefined at the later null-check. Pre-initializing to null resolves it and matches the \$user pattern already used earlier in the same method. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
|
martineiber
approved these changes
Jul 15, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Summary
CustomReportRepository::loadByName()resolves a report by name with no ownershipcheck, while
loadByNameForCurrentUser()wraps it and enforces the report's sharingmodel (admin flag,
shareGlobally,sharedUserIds,sharedRoleIds). Several codepaths called the unprotected method directly, letting any user with only the
generic
reports/reports-configpermission read or manage private reports theywere never shared:
CustomReportService::getDrillDownOptions()—POST /bundle/custom-reports/drill-down-optionsCsvService::generateCsvFile()—POST /bundle/custom-reports/export/csv(queues the async export job)CsvCollectionHandler— the async Messenger worker that actually collects the export data; it runs with no HTTP security token, so it resolves the job-owning user viaUserResolverInterface/JobRun::getOwnerId()(the same patternAbstractHandler::validateJobParametersalready uses elsewhere)CustomReportConfigService::cloneCustomReport()/deleteCustomReport()— clone/delete config endpointsColumnService::getColumnConfig()— column-config endpointAll of these now route through
getAllowedReport()(throwsForbiddenException,synchronous HTTP context) or the new
getAllowedReportForUser()(returnsnull,used from the async worker), matching the pattern already used correctly by
getChartData()andupdateCustomReport().Changes
CustomReportRepository: newloadByNameForUser(string $name, User $user): ?ConfigCustomReportConfigService:getAllowedReport()made public (was private, reusedby existing callers unchanged); new
getAllowedReportForUser()REPORT_PERMISSION_MISSING_MESSAGEto the execution-engineConfigenumplus translations in all 8 locale files, for the async abort path
@throwsdocblocks on the affected interfaces/controllersTest plan
reports/reports-configpermission and nosharing on a given report, confirm
drill-down-options,export/csv,clone, delete, and
column-configall now return 403 (matching the existingchartendpoint behavior) instead of returning report dataallowed to access (request-time check passes, async worker check passes,
file downloads normally)
🤖 Generated with Claude Code