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

Fix some bleeding edge errors #763

Merged
merged 6 commits into from
Oct 3, 2024
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 lib/extension/RexSqlFactoryDynamicReturnTypeExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public function isStaticMethodSupported(MethodReflection $methodReflection): boo
return strtolower($methodReflection->getName()) === 'factory';
}

public function getTypeFromStaticMethodCall(MethodReflection $methodReflection, StaticCall $methodCall, Scope $scope): ?Type
public function getTypeFromStaticMethodCall(MethodReflection $methodReflection, StaticCall $methodCall, Scope $scope): Type
{
return new RexSqlObjectType();
}
Expand Down
15 changes: 4 additions & 11 deletions lib/rule/RexSqlInjectionRule.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,11 +82,7 @@ public function processNode(Node $methodCall, Scope $scope): array
}

$callerType = $scope->getType($methodCall->var);
if (!$callerType instanceof TypeWithClassName) {
return [];
}

if ($callerType->getClassName() !== rex_sql::class) {
if ($callerType->getObjectClassNames() !== [rex_sql::class]) {
return [];
}

Expand Down Expand Up @@ -244,18 +240,15 @@ private function isSafeType(Type $type): bool
return true;
}

$integer = new IntegerType();
if ($integer->isSuperTypeOf($type)->yes()) {
if ($type->isInteger()->yes()) {
return true;
}

$bool = new BooleanType();
if ($bool->isSuperTypeOf($type)->yes()) {
if ($type->isBoolean()->yes()) {
return true;
}

$float = new FloatType();
if ($float->isSuperTypeOf($type)->yes()) {
if ($type->isFloat()->yes()) {
return true;
}

Expand Down
2 changes: 2 additions & 0 deletions tests/expected.out
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
/tests/data/addons/developer/Module Navigationspunkt (Anker).input.php:-1:Module "Module Navigationspunkt (Anker)" contains ouput value "REX_LINK[1]" which is not used in module input.
/tests/data/addons/developer/Module Navigationspunkt (Anker).input.php:-1:Module "Module Navigationspunkt (Anker)" contains ouput value "REX_MEDIA[2]" which is not used in module input.
/tests/data/addons/developer/Module Navigationspunkt (Anker).input.php:-1:Module "Module Navigationspunkt (Anker)" contains ouput value "REX_VALUE[10]" which is not used in module input.
/tests/data/addons/developer/Module Navigationspunkt (Anker).input.php:43:Expression "$x + []" on a separate line does not do anything.
/tests/data/addons/developer/Module Navigationspunkt (Anker).output.php:44:Loose comparison via "==" is not allowed.
/tests/data/addons/developer/Module Navigationspunkt (Anker).output.php:47:Loose comparison via "==" is not allowed.
/tests/data/addons/developer/Template ctypes.template.php:-1:Template "Template ctypes" includes invalid template by ID "REX_TEMPLATE[99999999]"
Expand All @@ -15,6 +16,7 @@
/tests/data/any-get.php:13:No rex_media found with id 'does-not-exist.jpg'.
/tests/data/any-get.php:14:No rex_article found with id 9999999.
/tests/data/any-get.php:15:No rex_category found with id 9999999.
/tests/data/multi-use.php:14:Expression on left side of ?? is not nullable.
/tests/data/object-oriented-framework.php:22:Unknown name 'unknownColumn' given to rex_user::getValue().
/tests/data/object-oriented-framework.php:24:No rex_media found with id 'markus.jpg'.
/tests/data/object-oriented-framework.php:30:Unknown name 'unknownColumn' given to rex_media::getValue().
Expand Down
Loading