Skip to content

Commit

Permalink
Fix: Psalm
Browse files Browse the repository at this point in the history
  • Loading branch information
OskarStark committed Sep 17, 2024
1 parent ab94531 commit 1bb027e
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/Service/GitHubRequestHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,18 @@ public function handle(Request $request): array
throw new PreconditionFailedHttpException(sprintf('Unsupported repository "%s".', $repositoryFullName));
}

if (!empty($repository->getSecret())) {
$secret = $repository->getSecret();
if (is_string($secret) && '' !== trim($secret)) {
if (!$request->headers->has('X-Hub-Signature')) {
throw new AccessDeniedHttpException('The request is not secured.');
}
if (!$this->authenticate($request->headers->get('X-Hub-Signature'), $repository->getSecret(), $request->getContent())) {

$content = $request->getContent();
if (!is_string($content)) {
throw new BadRequestHttpException('Empty request body!');
}

if (!$this->authenticate($request->headers->get('X-Hub-Signature'), $secret, $content)) {

Check failure on line 60 in src/Service/GitHubRequestHandler.php

View workflow job for this annotation

GitHub Actions / Psalm

PossiblyNullArgument

src/Service/GitHubRequestHandler.php:60:38: PossiblyNullArgument: Argument 1 of App\Service\GitHubRequestHandler::authenticate cannot be null, possibly null value provided (see https://psalm.dev/078)
throw new AccessDeniedHttpException('Invalid signature.');
}
}
Expand Down

0 comments on commit 1bb027e

Please sign in to comment.