Skip to content

Normalize entry params - #2004

Open
alexej-d wants to merge 4 commits into
pimcore:2026.xfrom
alexej-d:2026.x
Open

Normalize entry params#2004
alexej-d wants to merge 4 commits into
pimcore:2026.xfrom
alexej-d:2026.x

Conversation

@alexej-d

Copy link
Copy Markdown

Changes in this pull request

Resolves #321

Additional info

Needed in addition to the main patch.

Copilot AI balanced review requested due to automatic review settings August 19, 2026 08:38

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@jcPimcore jcPimcore self-assigned this Aug 19, 2026
@jcPimcore
jcPimcore requested a balanced review from Copilot August 19, 2026 11:34

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated no new comments.

Suppressed comments (1)

src/Email/Service/EmailLogService.php:181

  • The linked issue and “main patch” are about adding search/filtering to the sent-mails list, but this change only alters the email-parameter response. It neither implements nor supports the /emails/search flow in UI PR #3946, so it cannot resolve the cited issue as described. Please correct the PR description/linkage if this normalization is the intended scope, or include the backend search support that the description claims.
                $this->normalizeParamValue($value)

@jcPimcore jcPimcore left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Good fix — EmailLogEntryParameter's constructor requires ?string under strict_types=1, but Mail::setParam() accepts mixed, so any logged email with a bool/int/array template param would TypeError on GET /emails/{id}/params. normalizeParamValue() fixes this at the right spot (the service producing the value, not the schema contract), and correctly leaves the resend path (setEmailDocumentContent) untouched since that needs the original typed value.

One ask before merging: this repo has a solid per-service unit-test convention (tests/Unit/<Module>/Service/*ServiceTest.php), but there's no tests/Unit/Email suite at all. Since this fixes an actual crash, could you add a small test for getEntryParams()/normalizeParamValue covering bool/int/array values?

@jcPimcore jcPimcore added this to the 2026.2.7 milestone Aug 19, 2026
@alexej-d

Copy link
Copy Markdown
Author

Good fix — EmailLogEntryParameter's constructor requires ?string under strict_types=1, but Mail::setParam() accepts mixed, so any logged email with a bool/int/array template param would TypeError on GET /emails/{id}/params. normalizeParamValue() fixes this at the right spot (the service producing the value, not the schema contract), and correctly leaves the resend path (setEmailDocumentContent) untouched since that needs the original typed value.

One ask before merging: this repo has a solid per-service unit-test convention (tests/Unit/<Module>/Service/*ServiceTest.php), but there's no tests/Unit/Email suite at all. Since this fixes an actual crash, could you add a small test for getEntryParams()/normalizeParamValue covering bool/int/array values?

Check the new commit @jcPimcore

@jcPimcore

Copy link
Copy Markdown
Contributor

Confirmed — EmailLogServiceTest::testGetEntryParamsNormalizesNonStringValues correctly exercises the fixed path (bool → 'true', int → '118', array → JSON) and matches this repo's Codeception/makeEmpty convention. Thanks!

@jcPimcore

Copy link
Copy Markdown
Contributor

Hi @alexej-d
Thank you for the update! Looks good! 👍
Since it is related to pimcore/studio-ui-bundle#3946 we will not merge this immediately but waiting for the other PR.

@alexej-d

Copy link
Copy Markdown
Author

Hi @alexej-d Thank you for the update! Looks good! 👍 Since it is related to pimcore/studio-ui-bundle#3946 we will not merge this immediately but waiting for the other PR.

I have adjusted my code in both bundles @jcPimcore

@jcPimcore jcPimcore modified the milestones: 2026.2.7, 2026.2.8, 2026.3.0 Aug 25, 2026
@jcPimcore

Copy link
Copy Markdown
Contributor

Hi @alexej-d
Great work again! 👍

There was something found which was not adressed before. Can you please implement this?

Security: /emails/search broadens exposure to an ORDER-BY injection sink

POST /emails/search (added in studio-backend-bundle#2004) passes the request's sortFilter.key straight through EmailLogRepository::applySearchOptions() → Listing::setOrderKey() → AbstractDao::getOrder(), which builds ORDER BY via raw string concatenation — no allow-list, no escaping.

This sink already exists (reachable today via POST /gdpr/search?provider=sent_mails), but that path requires the gdpr_data_extractor permission. The new endpoint gates the same sink behind emails instead — a much more commonly granted permission — so this PR meaningfully widens who can reach it.

Suggested fix: allow-list the sortable columns at EmailLogRepository::applySearchOptions() before calling setOrderKey(), e.g.:

private const array SORTABLE_KEYS = ['id', 'sentDate', 'from', 'to', 'subject'];

$sortFilter = $filter->getSortFilter();
if ($sortFilter->getKey() && in_array($sortFilter->getKey(), self::SORTABLE_KEYS, true) && $sortFilter->getDirection()) {
$listing->setOrderKey($sortFilter->getKey());
...
}

falling back to the existing default order otherwise. That's the smallest fix at the right boundary — it doesn't touch shared core (AbstractDao) and mirrors how a fixed version of this pattern should look.


Thanks again in advance!

Jochen

@jcPimcore jcPimcore left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Security fix as commented.

@alexej-d

alexej-d commented Sep 2, 2026

Copy link
Copy Markdown
Author

Security fix as commented.

Hi @jcPimcore – the fix is implemented as requested. I also added a test

@sonarqubecloud

sonarqubecloud Bot commented Sep 2, 2026

Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants