Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@ indent_style = tab
indent_size = tab
tab_width = 4

[{*.json, *.yaml, *.yml, *.md}]
[*.{json,yaml,yml,md}]
indent_style = space
indent_size = 2
10 changes: 0 additions & 10 deletions .github/.kodiak.toml

This file was deleted.

2 changes: 1 addition & 1 deletion .github/workflows/codesniffer.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@ jobs:
name: "Codesniffer"
uses: contributte/.github/.github/workflows/codesniffer.yml@master
with:
php: "8.3"
php: "8.2"
2 changes: 1 addition & 1 deletion .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@ jobs:
name: "Nette Tester"
uses: contributte/.github/.github/workflows/nette-tester-coverage-v2.yml@master
with:
php: "8.3"
php: "8.2"
2 changes: 1 addition & 1 deletion .github/workflows/phpstan.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@ jobs:
name: "Phpstan"
uses: contributte/.github/.github/workflows/phpstan.yml@master
with:
php: "8.3"
php: "8.2"
6 changes: 6 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@ on:
- cron: "0 8 * * 1"

jobs:
test85:
name: "Nette Tester"
uses: contributte/.github/.github/workflows/nette-tester.yml@master
with:
php: "8.5"

test84:
name: "Nette Tester"
uses: contributte/.github/.github/workflows/nette-tester.yml@master
Expand Down
6 changes: 3 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@
"php-http/guzzle7-adapter": "^1.1.0"
},
"require-dev": {
"contributte/qa": "^0.4",
"contributte/tester": "^0.3",
"contributte/phpstan": "^0.3",
"contributte/qa": "~0.4.0",
"contributte/tester": "~0.3.0",
"contributte/phpstan": "~0.3.0",
"mockery/mockery": "^1.5.1",
"nette/application": "^3.1.0",
"nette/di": "^3.1.0",
Expand Down
2 changes: 0 additions & 2 deletions phpstan.neon
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,3 @@ parameters:
paths:
- src
- .docs

ignoreErrors:
7 changes: 5 additions & 2 deletions ruleset.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="vendor/squizlabs/php_codesniffer/phpcs.xsd"
>
<rule ref="./vendor/contributte/qa/ruleset.xml">
<rule ref="./vendor/contributte/qa/ruleset-8.2.xml">
<exclude name="Squiz.Commenting.FunctionComment.MissingParamName"/>
<exclude name="SlevomatCodingStandard.Variables.DisallowSuperGlobalVariable.DisallowedSuperGlobalVariable"/>
</rule>
Expand All @@ -16,7 +16,10 @@
<element key="src" value="Contributte\Sentry"/>
<element key="tests" value="Tests"/>
</property>
<property name="extensions" type="array" value="php,phpt"/>
<property name="extensions" type="array">
<element value="php"/>
<element value="phpt"/>
</property>
</properties>
</rule>

Expand Down
20 changes: 12 additions & 8 deletions src/Integration/NetteSecurityIntegration.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@
use Nette\DI\Container;
use Nette\Http\IRequest;
use Nette\Http\Session;
use Nette\Security\Identity;
use Nette\Security\SimpleIdentity;
use Nette\Security\IIdentity;
use Nette\Security\UserStorage;
use Sentry\Event;
use Sentry\EventHint;
Expand Down Expand Up @@ -51,21 +50,26 @@ public function setup(HubInterface $hub, Event $event, EventHint $hint): ?Event
$identity = $state[1];

// Anonymous user
if (!($identity instanceof SimpleIdentity) && !($identity instanceof Identity)) {
if (!($identity instanceof IIdentity)) {
return $event;
}

$httpRequest = $this->context->getByType(IRequest::class);

/** @var array<string, mixed> $identityData */
$identityData = $identity->getData();
$identityRoles = $identity->getRoles();
$identityId = $identity->getId();

$bag = new UserDataBag(
strval($identity->getId()),
$identity->getData()['email'] ?? null,
is_scalar($identityId) ? (string) $identityId : '',
is_string($identityData['email'] ?? null) ? $identityData['email'] : null,
$httpRequest->getRemoteAddress(),
$identity->getData()['username'] ?? null
is_string($identityData['username'] ?? null) ? $identityData['username'] : null
);

$bag->setMetadata('Roles', implode(',', $identity->getRoles()));
$bag->setMetadata('Identity', $identity->getData());
$bag->setMetadata('Roles', implode(',', $identityRoles));
$bag->setMetadata('Identity', $identityData);

$event->setUser($bag);

Expand Down
8 changes: 8 additions & 0 deletions src/Upload/S3Uploader.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,17 @@ public function upload(string $file): array

$url = $signed['url'];

if ($url === '') {
throw new UploadException('Invalid signed URL');
}

// Read file
$content = file_get_contents($file);

if ($content === false) {
throw new UploadException(sprintf('Cannot read file: %s', $file));
}

try {
$curl = curl_init();
curl_setopt_array($curl, [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,12 @@ use Sentry\ExceptionDataBag;
use Sentry\SentrySdk;
use Sentry\State\Scope;
use Tester\Assert;
use Tests\Fixtures\BadException;
use Tests\Fixtures\GoodException;
use function Sentry\withScope;

require_once __DIR__ . '/../../../bootstrap.php';

class GoodException extends RuntimeException
{
}

class BadException extends RuntimeException
{
}

// not matched exception and matched event
Toolkit::test(function (): void {
$integration = new IgnoreErrorIntegration([
Expand Down
10 changes: 10 additions & 0 deletions tests/Fixtures/BadException.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php declare(strict_types = 1);

namespace Tests\Fixtures;

use RuntimeException;

class BadException extends RuntimeException
{

}
10 changes: 10 additions & 0 deletions tests/Fixtures/GoodException.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php declare(strict_types = 1);

namespace Tests\Fixtures;

use RuntimeException;

class GoodException extends RuntimeException
{

}