Skip to content

Commit ac64cf4

Browse files
committed
Some improvements.
1 parent 769f021 commit ac64cf4

13 files changed

Lines changed: 69 additions & 11 deletions

File tree

src/CodeQuality/Pahout.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
* @subpackage Plugins
1717
*
1818
* @author Dmitry Khomutov <poisoncorpsee@gmail.com>
19+
* @author Panagiotis Kosmidis <panoskosmidis87@gmail.com>
1920
*/
2021
class Pahout extends Plugin
2122
{

src/CodeQuality/Phan.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
* @subpackage Plugins
1818
*
1919
* @author Dmitry Khomutov <poisoncorpsee@gmail.com>
20+
* @author Fred Delrieu <caouecs@caouecs.net>
2021
*/
2122
class Phan extends Plugin
2223
{

src/CodeQuality/Phlint.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
* @subpackage Plugins
1919
*
2020
* @author Dmitry Khomutov <poisoncorpsee@gmail.com>
21+
* @author Panagiotis Kosmidis <panoskosmidis87@gmail.com>
2122
*/
2223
class Phlint extends Plugin
2324
{

src/CodeQuality/PhpStan.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
* @subpackage Plugins
1919
*
2020
* @author Dmitry Khomutov <poisoncorpsee@gmail.com>
21+
* @author Panagiotis Kosmidis <panoskosmidis87@gmail.com>
2122
*/
2223
class PhpStan extends Plugin
2324
{

src/CodeQuality/Psalm.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
* @subpackage Plugins
1616
*
1717
* @author Dmitry Khomutov <poisoncorpsee@gmail.com>
18+
* @author Panagiotis Kosmidis <panoskosmidis87@gmail.com>
1819
*/
1920
class Psalm extends Plugin
2021
{

src/CodeQuality/SecurityChecker.php

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
use PHPCensor\Common\Build\BuildErrorInterface;
88
use PHPCensor\Common\Build\BuildInterface;
9+
use PHPCensor\Common\Exception\Exception;
910
use PHPCensor\Common\Plugin\Plugin;
1011
use PHPCensor\Common\Plugin\ZeroConfigPluginInterface;
1112
use SensioLabs\Security\SecurityChecker as SensiolabsSecurityChecker;
@@ -38,9 +39,30 @@ public static function getName(): string
3839
*/
3940
public function execute(): bool
4041
{
41-
$success = true;
42-
$checker = new SensiolabsSecurityChecker();
43-
$result = $checker->check($this->build->getBuildPath() . 'composer.lock');
42+
$success = true;
43+
if (\in_array('symfony', $this->binaryNames, true)) {
44+
$lockFile = $this->build->getBuildPath() . 'composer.lock';
45+
if (!\is_file($lockFile)) {
46+
throw new Exception('Lock file (composer.lock) does not exist.');
47+
}
48+
49+
$cmd = '%s check:security --format=json --dir=%s';
50+
$executable = $this->commandExecutor->findBinary($this->binaryNames, $this->binaryPath);
51+
if (!$this->build->isDebug()) {
52+
$this->commandExecutor->disableCommandOutput();
53+
}
54+
55+
// works with dir, composer.lock, composer.json
56+
$this->commandExecutor->executeCommand($cmd, $executable, $lockFile);
57+
58+
$this->commandExecutor->enableCommandOutput();
59+
60+
$result = $this->commandExecutor->getLastCommandOutput();
61+
} else {
62+
$checker = new SensiolabsSecurityChecker();
63+
$result = $checker->check($this->build->getBuildPath() . 'composer.lock');
64+
}
65+
4466
$warnings = \json_decode((string)$result, true);
4567

4668
if ($warnings) {

src/Common/Phar.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
* @subpackage Plugins
1616
*
1717
* @author Dmitry Khomutov <poisoncorpsee@gmail.com>
18+
* @author Wanderson Camargo <wandersonwhcr@gmail.com>
1819
*/
1920
class Phar extends Plugin
2021
{

src/Deploy/Deployer.php

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
namespace PHPCensor\Plugins\Deploy;
66

7-
use GuzzleHttp\Client;
7+
use GuzzleHttp\Client as HttpClient;
88
use PHPCensor\Common\Build\BuildInterface;
99
use PHPCensor\Common\Plugin\Plugin;
1010

@@ -42,7 +42,7 @@ public function execute(): bool
4242
return false;
4343
}
4444

45-
$client = new Client();
45+
$client = new HttpClient();
4646
$response = $client->post(
4747
$this->webhookUrl,
4848
[
@@ -59,9 +59,7 @@ public function execute(): bool
5959

6060
$status = (int)$response->getStatusCode();
6161

62-
return ($status >= 200 && $status < 300)
63-
? true
64-
: false;
62+
return ($status >= 200 && $status < 300);
6563
}
6664

6765
/**

src/Deploy/Mage.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
* @subpackage Plugins
1616
*
1717
* @author Dmitry Khomutov <poisoncorpsee@gmail.com>
18+
* @author Stepan Strelets <s.strelec@nikitaonline.ru>
1819
*/
1920
class Mage extends Plugin
2021
{

src/Deploy/Mage3.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
* @subpackage Plugins
1616
*
1717
* @author Dmitry Khomutov <poisoncorpsee@gmail.com>
18+
* @author Stepan Strelets <s.strelec@nikitaonline.ru>
1819
*/
1920
class Mage3 extends Plugin
2021
{

0 commit comments

Comments
 (0)