diff --git a/CHANGELOG.md b/CHANGELOG.md index 4e5aecb..2aca616 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,7 +4,7 @@ CHANGELOG master ------ -* todo... +* Added rule to ban shell execution via backticks v1.0.0 ------ diff --git a/README.md b/README.md index 0664579..13060c4 100644 --- a/README.md +++ b/README.md @@ -64,6 +64,11 @@ parameters: - system - var_dump + # enable detection of shell execution by backticks + - + type: Expr_ShellExec + functions: null + # enable detection of `use Tests\Foo\Bar` in a non-test file use_from_tests: true ``` diff --git a/extension.neon b/extension.neon index 00c5ecb..9bdad7b 100644 --- a/extension.neon +++ b/extension.neon @@ -41,6 +41,11 @@ parameters: - system - var_dump + # enable detection of shell execution by backticks + - + type: Expr_ShellExec + functions: null + # enable detection of `use Tests\Foo\Bar` in a non-test file use_from_tests: true diff --git a/snippets/backticks.php b/snippets/backticks.php new file mode 100644 index 0000000..50b7664 --- /dev/null +++ b/snippets/backticks.php @@ -0,0 +1,3 @@ + 'Expr_Eval'], ['type' => 'Expr_Exit'], ['type' => 'Expr_FuncCall', 'functions' => ['debug_backtrace', 'dump']], + ['type' => 'Expr_ShellExec'], ]); $this->scope = $this->createMock(Scope::class); } @@ -128,11 +130,12 @@ public function getUnhandledNodes(): \Generator } /** - * @return \Generator> + * @return \Generator> */ public function getHandledNodes(): \Generator { yield [new Eval_($this->createMock(Expr::class))]; yield [new Exit_()]; + yield [new ShellExec([''])]; } }