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

[TASK] Enforce HTTP methods in module controller #81

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

konhill
Copy link

@konhill konhill commented Jan 21, 2025

No description provided.

Copy link

codeclimate bot commented Jan 21, 2025

Code Climate has analyzed commit 9a0a4f8 and detected 0 issues on this pull request.

The test coverage on the diff in this pull request is 0.0% (50% is the threshold).

This pull request will bring the total coverage in the repository to 0.0% (0.0% change).

View more on Code Climate.

@coveralls
Copy link
Collaborator

coveralls commented Jan 21, 2025

Pull Request Test Coverage Report for Build 12913179724

Details

  • 0 of 1 (0.0%) changed or added relevant line in 1 file are covered.
  • 1 unchanged line in 1 file lost coverage.
  • Overall coverage remained the same at 0.0%

Changes Missing Coverage Covered Lines Changed/Added Lines %
Classes/Controller/MailqueueModuleController.php 0 1 0.0%
Files with Coverage Reduction New Missed Lines %
Classes/Controller/MailqueueModuleController.php 1 0.0%
Totals Coverage Status
Change from base Build 12858691984: 0.0%
Covered Lines: 0
Relevant Lines: 706

💛 - Coveralls

@eliashaeussler eliashaeussler added the bug Something isn't working label Jan 22, 2025
Copy link
Member

@eliashaeussler eliashaeussler left a comment

Choose a reason for hiding this comment

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

Hey @konhill, thank you very much for the PR. I made a few suggestions. In addition, I'd categorize this change as maintenance task rather than bugfix. Would you be so kind and address the requested changes? Thanks in advance!

@@ -67,6 +69,7 @@ public function __invoke(Message\ServerRequestInterface $request): Message\Respo

// Force redirect when page selector was used
if ($request->getMethod() === 'POST' && !isset($request->getQueryParams()['page'])) {
$this->assertAllowedHttpMethod($request, 'POST');
Copy link
Member

Choose a reason for hiding this comment

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

The security check is superfluous here; we already verify and allow POST in the line above.

@@ -92,7 +95,7 @@ public function __invoke(Message\ServerRequestInterface $request): Message\Respo
if ($this->typo3Version->getMajorVersion() < 12) {
return $this->renderLegacyTemplate($template, $templateVariables);
}

$this->assertAllowedHttpMethod($request, 'GET');
Copy link
Member

Choose a reason for hiding this comment

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

The assertion should happen as very first check in the action. Thus, it should be moved to line 64. Since POST and GET methods are allowed it should be changed to:

Suggested change
$this->assertAllowedHttpMethod($request, 'GET');
$this->assertAllowedHttpMethod($request, 'GET', 'POST');

@@ -43,6 +44,7 @@
final class MailqueueModuleController
{
use Traits\TranslatableTrait;
use AllowedMethodsTrait;
Copy link
Member

Choose a reason for hiding this comment

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

The TYPO3\CMS\Core namespace is already imported, thus the import should be written like follows:

Suggested change
use AllowedMethodsTrait;
use Core\Http\AllowedMethodsTrait;

@eliashaeussler eliashaeussler added maintenance Code base is being maintained and removed bug Something isn't working labels Jan 22, 2025
@eliashaeussler eliashaeussler self-assigned this Jan 22, 2025
@eliashaeussler eliashaeussler changed the title [BUGFIX] enforcing http methods [TASK] Enforce HTTP methods in module controller Jan 22, 2025
@eliashaeussler
Copy link
Member

eliashaeussler commented Jan 22, 2025

💡 One more thing: We should adapt the dependency constraints of TYPO3 extensions to require at least those versions which contain the newly introduced trait:

composer.json

"typo3/cms-*": "~11.5.42 || ~12.4.25 || ~13.4.3"

ext_emconf.php

'typo3' => '11.5.42-13.4.99'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
maintenance Code base is being maintained
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants