Skip to content

Commit

Permalink
OIS-417: Upgrade phpstan to 0.12.* for SQL Injection testing (#6)
Browse files Browse the repository at this point in the history
* OIS-417: Upgrade phpstan to 0.12.* for SQL Injection testing
  • Loading branch information
x86demon authored Jan 14, 2021
1 parent 906455e commit 023e899
Show file tree
Hide file tree
Showing 8 changed files with 331 additions and 344 deletions.
6 changes: 3 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
"psr-4": {"": "src/"}
},
"require": {
"phpstan/phpstan-shim": "0.11.*",
"phpstan/phpstan-doctrine": "0.11.*",
"ocramius/proxy-manager": "2.2.*"
"phpstan/phpstan": "0.12.*",
"phpstan/phpstan-doctrine": "0.12.*",
"nette/neon": "^3.1"
}
}
93 changes: 93 additions & 0 deletions extension.neon
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
includes:
- ../../phpstan/phpstan-doctrine/extension.neon

services:
-
class: Oro\Rules\Methods\QueryBuilderInjectionRule
arguments:
checkThisOnly: %checkThisOnly%
trustedData: %sql_injection_testing.trusted_data%
tags:
- phpstan.rules.rule

-
class: Oro\Rules\Types\RequestGetSessionTypeExtension
tags:
- phpstan.broker.dynamicMethodReturnTypeExtension

-
class: Oro\Rules\Types\EntityManagerReturnTypeExtension
arguments:
supportedClass: Doctrine\ORM\EntityManagerInterface
tags:
- phpstan.broker.dynamicMethodReturnTypeExtension

-
class: Oro\Rules\Types\EntityManagerReturnTypeExtension
arguments:
supportedClass: Doctrine\Persistence\ManagerRegistry
tags:
- phpstan.broker.dynamicMethodReturnTypeExtension

-
class: Oro\Rules\Types\ManagerRegistryEMReturnTypeExtension
arguments:
supportedClass: Doctrine\Persistence\ManagerRegistry
tags:
- phpstan.broker.dynamicMethodReturnTypeExtension

-
class: Oro\Rules\Types\ObjectRepositoryReturnTypeExtension
arguments:
supportedClass: Doctrine\ORM\EntityRepository
tags:
- phpstan.broker.dynamicMethodReturnTypeExtension

persistenceManagerRegistryGetRepository:
class: Oro\Rules\Types\GetRepositoryDynamicReturnTypeExtension
tags:
- phpstan.broker.dynamicMethodReturnTypeExtension
arguments:
managerClass: Doctrine\Persistence\ManagerRegistry

persistenceObjectManagerGetRepository:
class: Oro\Rules\Types\GetRepositoryDynamicReturnTypeExtension
tags:
- phpstan.broker.dynamicMethodReturnTypeExtension
arguments:
managerClass: Doctrine\Persistence\ObjectManager

managerRegistryGetRepository:
class: Oro\Rules\Types\GetRepositoryDynamicReturnTypeExtension
tags:
- phpstan.broker.dynamicMethodReturnTypeExtension
arguments:
managerClass: Doctrine\Persistence\ManagerRegistry

objectManagerGetRepository:
class: Oro\Rules\Types\GetRepositoryDynamicReturnTypeExtension
tags:
- phpstan.broker.dynamicMethodReturnTypeExtension
arguments:
managerClass: Doctrine\Persistence\ObjectManager

# Should be uncommented after existing problems fixed
#-
#class: Oro\Rules\ValidExceptionCatchRule
#tags:
#- phpstan.rules.rule

parametersSchema:
sql_injection_testing: structure([
trusted_data: structure([
variables: arrayOf(arrayOf(arrayOf(bool())))
properties: arrayOf(arrayOf(arrayOf(bool())))
safe_static_methods: arrayOf(arrayOf(bool()))
safe_methods: arrayOf(arrayOf(anyOf(bool(), arrayOf(int()))))
check_static_methods_safety: arrayOf(arrayOf(anyOf(bool(), arrayOf(int()))))
check_methods_safety: arrayOf(arrayOf(anyOf(bool(), arrayOf(int()))))
check_methods: arrayOf(arrayOf(anyOf(bool(), arrayOf(int()))))
clear_static_methods: arrayOf(arrayOf(bool()))
clear_methods: arrayOf(arrayOf(bool()))
])
])
8 changes: 8 additions & 0 deletions phpstan.neon
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
includes:
- extension.neon
- rules.neon

parameters:
customRulesetUsed: true
checkThisOnly: false
inferPrivatePropertyTypeFromConstructor: true
Loading

0 comments on commit 023e899

Please sign in to comment.