Skip to content

Commit

Permalink
update deps
Browse files Browse the repository at this point in the history
  • Loading branch information
chriskapp committed Feb 2, 2025
1 parent 56a00d5 commit 6a251fd
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 33 deletions.
1 change: 1 addition & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ jobs:
php-versions:
- 8.2
- 8.3
- 8.4
steps:
- name: Checkout
uses: actions/checkout@v4
Expand Down
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
"nikic/php-parser": "^4.0|^5.0"
},
"require-dev": {
"phpunit/phpunit": "^9.0",
"vimeo/psalm": "^5.0"
"phpunit/phpunit": "^10.0",
"vimeo/psalm": "^5.0|^6.0"
},
"autoload": {
"psr-4": {
Expand Down
5 changes: 5 additions & 0 deletions psalm.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,9 @@
<directory name="vendor" />
</ignoreFiles>
</projectFiles>
<issueHandlers>
<PossiblyUnusedMethod errorLevel="suppress" />
<PossiblyUnusedParam errorLevel="suppress" />
<UnusedClass errorLevel="suppress" />
</issueHandlers>
</psalm>
60 changes: 30 additions & 30 deletions src/Printer.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public function __construct(SecurityManager $securityManager, array $options = [
$this->securityManager = $securityManager;
}

protected function pExpr_FuncCall(Expr\FuncCall $node)
protected function pExpr_FuncCall(Expr\FuncCall $node): string
{
$functionName = $this->pCallLhs($node->name);

Expand All @@ -52,22 +52,22 @@ protected function pExpr_FuncCall(Expr\FuncCall $node)
return parent::pExpr_FuncCall($node);
}

protected function pExpr_Eval(Expr\Eval_ $node)
protected function pExpr_Eval(Expr\Eval_ $node): string
{
throw new SecurityException('Eval is not allowed');
}

protected function pExpr_Include(Expr\Include_ $node)
protected function pExpr_Include(Expr\Include_ $node, int $precedence, int $lhsPrecedence): string
{
throw new SecurityException('Include is not allowed');
}

protected function pExpr_ShellExec(Expr\ShellExec $node)
protected function pExpr_ShellExec(Expr\ShellExec $node): string
{
throw new SecurityException('Shell exec is not allowed');
}

protected function pExpr_New(Expr\New_ $node)
protected function pExpr_New(Expr\New_ $node): string
{
if ($node->class instanceof Stmt\Class_) {
throw new SecurityException('Anonymous class is not allowed');
Expand All @@ -80,7 +80,7 @@ protected function pExpr_New(Expr\New_ $node)
return parent::pExpr_New($node);
}

protected function pStaticDereferenceLhs(Node $node)
protected function pStaticDereferenceLhs(Node $node): string
{
$class = $this->p($node);

Expand All @@ -89,90 +89,90 @@ protected function pStaticDereferenceLhs(Node $node)
return parent::pStaticDereferenceLhs($node);
}

protected function pExpr_Exit(Expr\Exit_ $node)
protected function pExpr_Exit(Expr\Exit_ $node): string
{
throw new SecurityException('Exit is not allowed');
}

protected function pStmt_Interface(Stmt\Interface_ $node)
protected function pStmt_Interface(Stmt\Interface_ $node): string
{
throw new SecurityException('Interface is not allowed');
}

protected function pStmt_Class(Stmt\Class_ $node)
protected function pStmt_Class(Stmt\Class_ $node): string
{
throw new SecurityException('Class is not allowed');
}

protected function pStmt_Trait(Stmt\Trait_ $node)
protected function pStmt_Trait(Stmt\Trait_ $node): string
{
throw new SecurityException('Trait is not allowed');
}

protected function pStmt_TraitUse(Stmt\TraitUse $node)
protected function pStmt_TraitUse(Stmt\TraitUse $node): string
{
throw new SecurityException('Trait use is not allowed');
}

protected function pStmt_TraitUseAdaptation_Precedence(Stmt\TraitUseAdaptation\Precedence $node)
protected function pStmt_TraitUseAdaptation_Precedence(Stmt\TraitUseAdaptation\Precedence $node): string
{
throw new SecurityException('Trait use adaption is not allowed');
}

protected function pStmt_TraitUseAdaptation_Alias(Stmt\TraitUseAdaptation\Alias $node)
protected function pStmt_TraitUseAdaptation_Alias(Stmt\TraitUseAdaptation\Alias $node): string
{
throw new SecurityException('Trait use adaption alias is not allowed');
}

protected function pStmt_Property(Stmt\Property $node)
protected function pStmt_Property(Stmt\Property $node): string
{
throw new SecurityException('Property is not allowed');
}

protected function pStmt_PropertyProperty(Stmt\PropertyProperty $node)
protected function pStmt_PropertyProperty(Stmt\PropertyProperty $node): string
{
throw new SecurityException('Property property is not allowed');
}

protected function pStmt_ClassMethod(Stmt\ClassMethod $node)
protected function pStmt_ClassMethod(Stmt\ClassMethod $node): string
{
throw new SecurityException('Class method is not allowed');
}

protected function pStmt_ClassConst(Stmt\ClassConst $node)
protected function pStmt_ClassConst(Stmt\ClassConst $node): string
{
throw new SecurityException('Class const is not allowed');
}

protected function pStmt_Function(Stmt\Function_ $node)
protected function pStmt_Function(Stmt\Function_ $node): string
{
$this->securityManager->defineFunction((string)$node->name);

return parent::pStmt_Function($node);
}

protected function pConst(\PhpParser\Node\Const_ $node)
protected function pConst(\PhpParser\Node\Const_ $node): string
{
$this->securityManager->checkDefineConstant();
return parent::pConst($node);
}

protected function pStmt_Declare(Stmt\Declare_ $node)
protected function pStmt_Declare(Stmt\Declare_ $node): string
{
throw new SecurityException('Declare is not allowed');
}

protected function pStmt_DeclareDeclare(Stmt\DeclareDeclare $node)
protected function pStmt_DeclareDeclare(Stmt\DeclareDeclare $node): string
{
throw new SecurityException('Declare declare is not allowed');
}

protected function pStmt_Echo(Stmt\Echo_ $node)
protected function pStmt_Echo(Stmt\Echo_ $node): string
{
throw new SecurityException('Echo is not allowed');
}

protected function pStmt_Expression(Stmt\Expression $node)
protected function pStmt_Expression(Stmt\Expression $node): string
{
$expression = $this->p($node->expr);

Expand All @@ -183,34 +183,34 @@ protected function pStmt_Expression(Stmt\Expression $node)
return $expression . ';';
}

protected function pStmt_Global(Stmt\Global_ $node)
protected function pStmt_Global(Stmt\Global_ $node): string
{
throw new SecurityException('Global is not allowed');
}

protected function pStmt_InlineHTML(Stmt\InlineHTML $node)
protected function pStmt_InlineHTML(Stmt\InlineHTML $node): string
{
throw new SecurityException('Inline HTML is not allowed');
}

protected function pStmt_HaltCompiler(Stmt\HaltCompiler $node)
protected function pStmt_HaltCompiler(Stmt\HaltCompiler $node): string
{
throw new SecurityException('Halt compiler is not allowed');
}

protected function pClassCommon(Stmt\Class_ $node, $afterClassToken)
protected function pClassCommon(Stmt\Class_ $node, $afterClassToken): string
{
throw new SecurityException('Class is not allowed');
}

protected function pStmt_Namespace(Stmt\Namespace_ $node)
protected function pStmt_Namespace(Stmt\Namespace_ $node): string
{
$this->securityManager->setCurrentNamespace($node->name !== null ? (string)$node->name : null);

return parent::pStmt_Namespace( $node );
}

protected function pStmt_Use(Stmt\Use_ $node)
protected function pStmt_Use(Stmt\Use_ $node): string
{
foreach ($node->uses as $use) {
if ($node->type === Stmt\Use_::TYPE_NORMAL) {
Expand All @@ -224,7 +224,7 @@ protected function pStmt_Use(Stmt\Use_ $node)
return parent::pStmt_Use( $node );
}

protected function pStmt_GroupUse(Stmt\GroupUse $node)
protected function pStmt_GroupUse(Stmt\GroupUse $node): string
{
foreach ($node->uses as $use) {
if ($node->type === Stmt\Use_::TYPE_NORMAL) {
Expand Down
1 change: 0 additions & 1 deletion src/SecurityManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -719,7 +719,6 @@ private function getArgumentAt(string $functionName, array $nodes, int $pos): ?N
$reflection = new \ReflectionFunction($functionName);
$name = $reflection->getParameters()[$pos]->getName();

/** @var Node\Arg $node */
foreach ($nodes as $node) {
if ((string)$node->name === $name) {
return $node;
Expand Down

0 comments on commit 6a251fd

Please sign in to comment.