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

Change priority of kernel exception subscribers to be able to process security exceptions #82

Merged
merged 1 commit into from
Sep 8, 2023

Conversation

niels-nijens
Copy link
Member

@niels-nijens niels-nijens commented Sep 8, 2023

This change is necessary to fix transforming security exceptions to ProblemException instances.

Symfony's ErrorListener converts eg. an AccessDeniedException to an AccessDeniedHttpException even though the exception is already transformed to a ProblemException instance.

By changing the priority of the subscribers to execute after Symfony's ErrorListener the AccessDeniedHttpException (instead of the AccessDeniedException) is transformed to ProblemException instance and then successfully converted to a response.

@github-actions

This comment has been minimized.

@github-actions
Copy link

github-actions bot commented Sep 8, 2023

Code Coverage Report:
2023-09-08 06:28:18

Summary:
Classes: 71.43% (25/35)
Methods: 92.45% (147/159)
Lines: 97.88% (738/754)

Nijens\OpenapiBundle\Controller\CatchAllController
Methods: 100.00% ( 4/ 4) Lines: 100.00% ( 24/ 24)
Nijens\OpenapiBundle\DependencyInjection\Configuration
Methods: 50.00% ( 2/ 4) Lines: 95.70% ( 89/ 93)
Nijens\OpenapiBundle\DependencyInjection\NijensOpenapiExtension
Methods: 66.67% ( 4/ 6) Lines: 94.12% ( 32/ 34)
Nijens\OpenapiBundle\DependencyInjection\ServiceFactory
Methods: 0.00% ( 0/ 1) Lines: 60.00% ( 3/ 5)
Nijens\OpenapiBundle\Deserialization\ArgumentResolver\DeserializedObjectArgumentResolver
Methods: 80.00% ( 4/ 5) Lines: 95.00% ( 19/ 20)
Nijens\OpenapiBundle\Deserialization\Attribute\DeserializedObject
Methods: ( 0/ 0) Lines: ( 0/ 0)
Nijens\OpenapiBundle\Deserialization\DeserializationContext
Methods: ( 0/ 0) Lines: ( 0/ 0)
Nijens\OpenapiBundle\Deserialization\EventSubscriber\JsonRequestBodyDeserializationSubscriber
Methods: 100.00% ( 3/ 3) Lines: 100.00% ( 13/ 13)
Nijens\OpenapiBundle\EventListener\JsonRequestBodyValidationSubscriber
Methods: 100.00% ( 6/ 6) Lines: 100.00% ( 37/ 37)
Nijens\OpenapiBundle\EventListener\JsonResponseExceptionSubscriber
Methods: 66.67% ( 2/ 3) Lines: 81.82% ( 9/ 11)
Nijens\OpenapiBundle\ExceptionHandling\DeprecatedExceptionToProblemExceptionTransformer
Methods: 66.67% ( 2/ 3) Lines: 92.31% ( 12/ 13)
Nijens\OpenapiBundle\ExceptionHandling\EventSubscriber\ProblemExceptionToJsonResponseSubscriber
Methods: 66.67% ( 2/ 3) Lines: 90.91% ( 10/ 11)
Nijens\OpenapiBundle\ExceptionHandling\EventSubscriber\ThrowableToProblemExceptionSubscriber
Methods: 75.00% ( 3/ 4) Lines: 90.00% ( 9/ 10)
Nijens\OpenapiBundle\ExceptionHandling\Exception\InvalidContentTypeProblemException
Methods: ( 0/ 0) Lines: ( 0/ 0)
Nijens\OpenapiBundle\ExceptionHandling\Exception\InvalidRequestBodyProblemException
Methods: ( 0/ 0) Lines: ( 0/ 0)
Nijens\OpenapiBundle\ExceptionHandling\Exception\InvalidRequestParameterProblemException
Methods: ( 0/ 0) Lines: ( 0/ 0)
Nijens\OpenapiBundle\ExceptionHandling\Exception\InvalidRequestProblemException
Methods: 100.00% ( 5/ 5) Lines: 100.00% ( 12/ 12)
Nijens\OpenapiBundle\ExceptionHandling\Exception\ProblemException
Methods: 100.00% (16/16) Lines: 100.00% ( 46/ 46)
Nijens\OpenapiBundle\ExceptionHandling\Exception\Violation
Methods: 100.00% ( 6/ 6) Lines: 100.00% ( 13/ 13)
Nijens\OpenapiBundle\ExceptionHandling\Normalizer\ProblemExceptionNormalizer
Methods: 80.00% ( 4/ 5) Lines: 95.65% ( 22/ 23)
Nijens\OpenapiBundle\ExceptionHandling\ThrowableToProblemExceptionTransformer
Methods: 100.00% ( 3/ 3) Lines: 100.00% ( 18/ 18)
Nijens\OpenapiBundle\Exception\BadJsonRequestHttpException
Methods: 100.00% ( 1/ 1) Lines: 100.00% ( 5/ 5)
Nijens\OpenapiBundle\Exception\InvalidRequestHttpException
Methods: 100.00% ( 2/ 2) Lines: 100.00% ( 2/ 2)
Nijens\OpenapiBundle\Json\Dereferencer
Methods: 100.00% ( 6/ 6) Lines: 100.00% ( 35/ 35)
Nijens\OpenapiBundle\Json\Exception\InvalidArgumentException
Methods: ( 0/ 0) Lines: ( 0/ 0)
Nijens\OpenapiBundle\Json\Exception\InvalidJsonPointerException
Methods: ( 0/ 0) Lines: ( 0/ 0)
Nijens\OpenapiBundle\Json\Exception\LoaderLoadException
Methods: ( 0/ 0) Lines: ( 0/ 0)
Nijens\OpenapiBundle\Json\JsonPointer
Methods: 100.00% (11/11) Lines: 100.00% ( 35/ 35)
Nijens\OpenapiBundle\Json\Loader\ChainLoader
Methods: 100.00% ( 3/ 3) Lines: 100.00% ( 9/ 9)
Nijens\OpenapiBundle\Json\Loader\JsonLoader
Methods: 100.00% ( 2/ 2) Lines: 100.00% ( 7/ 7)
Nijens\OpenapiBundle\Json\Loader\YamlLoader
Methods: 100.00% ( 2/ 2) Lines: 100.00% ( 4/ 4)
Nijens\OpenapiBundle\Json\Reference
Methods: 100.00% (11/11) Lines: 100.00% ( 20/ 20)
Nijens\OpenapiBundle\Json\SchemaLoader
Methods: 100.00% ( 3/ 3) Lines: 100.00% ( 10/ 10)
Nijens\OpenapiBundle\Json\Schema\Constraint\TypeConstraint
Methods: 100.00% ( 1/ 1) Lines: 100.00% ( 8/ 8)
Nijens\OpenapiBundle\NijensOpenapiBundle
Methods: 100.00% ( 1/ 1) Lines: 100.00% ( 3/ 3)
Nijens\OpenapiBundle\Routing\RouteContext
Methods: ( 0/ 0) Lines: ( 0/ 0)
Nijens\OpenapiBundle\Routing\RouteLoader
Methods: 100.00% (10/10) Lines: 100.00% ( 75/ 75)
Nijens\OpenapiBundle\Serialization\SerializationContextBuilder
Methods: 85.71% ( 6/ 7) Lines: 97.67% ( 42/ 43)
Nijens\OpenapiBundle\Service\ExceptionJsonResponseBuilder
Methods: 100.00% ( 2/ 2) Lines: 100.00% ( 16/ 16)
Nijens\OpenapiBundle\Validation\EventSubscriber\RequestValidationSubscriber
Methods: 100.00% ( 4/ 4) Lines: 100.00% ( 9/ 9)
Nijens\OpenapiBundle\Validation\RequestValidator\CompositeRequestValidator
Methods: 100.00% ( 2/ 2) Lines: 100.00% ( 6/ 6)
Nijens\OpenapiBundle\Validation\RequestValidator\RequestBodyValidator
Methods: 100.00% ( 7/ 7) Lines: 100.00% ( 40/ 40)
Nijens\OpenapiBundle\Validation\RequestValidator\RequestContentTypeValidator
Methods: 100.00% ( 3/ 3) Lines: 100.00% ( 15/ 15)
Nijens\OpenapiBundle\Validation\RequestValidator\RequestParameterValidator
Methods: 100.00% ( 4/ 4) Lines: 100.00% ( 29/ 29)
Nijens\OpenapiBundle\Validation\ValidationContext
Methods: ( 0/ 0) Lines: ( 0/ 0)

@niels-nijens niels-nijens marked this pull request as ready for review September 8, 2023 07:31
@niels-nijens niels-nijens merged commit f9cf94e into nijens:main Sep 8, 2023
21 checks passed
@niels-nijens niels-nijens deleted the improve-event-priority branch September 8, 2023 07:32
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.

None yet

1 participant