| @@ -18,9 +18,10 @@ | |||||
| "require": { | "require": { | ||||
| "php": ">=7.2", | "php": ">=7.2", | ||||
| "ext-mbstring": "*", | "ext-mbstring": "*", | ||||
| "symfony/console": "^3.4", | |||||
| "symfony/debug": "^3.4", | |||||
| "symfony/yaml": "^3.4" | |||||
| "symfony/console": "^3.4 | ^4.0 | ^5.0", | |||||
| "symfony/debug": "^3.4 | ^4.0 | ^5.0", | |||||
| "symfony/yaml": "^3.4 | ^4.0 | ^5.0", | |||||
| "symfony/process": "^3.4 | ^4.0 | ^5.0" | |||||
| }, | }, | ||||
| "bin": ["bin/logchecker"], | "bin": ["bin/logchecker"], | ||||
| "require-dev": { | "require-dev": { | ||||
| @@ -4,7 +4,7 @@ | |||||
| "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", | "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", | ||||
| "This file is @generated automatically" | "This file is @generated automatically" | ||||
| ], | ], | ||||
| "content-hash": "cd99ec05b86608c741f0f4cdf62b27d9", | |||||
| "content-hash": "2f3702b4303474d7c0f6960a7bb1cdc3", | |||||
| "packages": [ | "packages": [ | ||||
| { | { | ||||
| "name": "psr/log", | "name": "psr/log", | ||||
| @@ -354,6 +354,69 @@ | |||||
| ], | ], | ||||
| "time": "2020-03-09T19:04:49+00:00" | "time": "2020-03-09T19:04:49+00:00" | ||||
| }, | }, | ||||
| { | |||||
| "name": "symfony/process", | |||||
| "version": "v5.0.7", | |||||
| "source": { | |||||
| "type": "git", | |||||
| "url": "https://github.com/symfony/process.git", | |||||
| "reference": "c5ca4a0fc16a0c888067d43fbcfe1f8a53d8e70e" | |||||
| }, | |||||
| "dist": { | |||||
| "type": "zip", | |||||
| "url": "https://api.github.com/repos/symfony/process/zipball/c5ca4a0fc16a0c888067d43fbcfe1f8a53d8e70e", | |||||
| "reference": "c5ca4a0fc16a0c888067d43fbcfe1f8a53d8e70e", | |||||
| "shasum": "" | |||||
| }, | |||||
| "require": { | |||||
| "php": "^7.2.5" | |||||
| }, | |||||
| "type": "library", | |||||
| "extra": { | |||||
| "branch-alias": { | |||||
| "dev-master": "5.0-dev" | |||||
| } | |||||
| }, | |||||
| "autoload": { | |||||
| "psr-4": { | |||||
| "Symfony\\Component\\Process\\": "" | |||||
| }, | |||||
| "exclude-from-classmap": [ | |||||
| "/Tests/" | |||||
| ] | |||||
| }, | |||||
| "notification-url": "https://packagist.org/downloads/", | |||||
| "license": [ | |||||
| "MIT" | |||||
| ], | |||||
| "authors": [ | |||||
| { | |||||
| "name": "Fabien Potencier", | |||||
| "email": "fabien@symfony.com" | |||||
| }, | |||||
| { | |||||
| "name": "Symfony Community", | |||||
| "homepage": "https://symfony.com/contributors" | |||||
| } | |||||
| ], | |||||
| "description": "Symfony Process Component", | |||||
| "homepage": "https://symfony.com", | |||||
| "funding": [ | |||||
| { | |||||
| "url": "https://symfony.com/sponsor", | |||||
| "type": "custom" | |||||
| }, | |||||
| { | |||||
| "url": "https://github.com/fabpot", | |||||
| "type": "github" | |||||
| }, | |||||
| { | |||||
| "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", | |||||
| "type": "tidelift" | |||||
| } | |||||
| ], | |||||
| "time": "2020-03-27T16:56:45+00:00" | |||||
| }, | |||||
| { | { | ||||
| "name": "symfony/yaml", | "name": "symfony/yaml", | ||||
| "version": "v3.4.39", | "version": "v3.4.39", | ||||
| @@ -3,6 +3,8 @@ | |||||
| namespace OrpheusNET\Logchecker; | namespace OrpheusNET\Logchecker; | ||||
| use OrpheusNET\Logchecker\Exception\FileNotFoundException; | use OrpheusNET\Logchecker\Exception\FileNotFoundException; | ||||
| use Symfony\Component\Process\Exception\ProcessFailedException; | |||||
| use Symfony\Component\Process\Process; | |||||
| class Chardet | class Chardet | ||||
| { | { | ||||
| @@ -33,13 +35,15 @@ class Chardet | |||||
| throw new FileNotFoundException($filename); | throw new FileNotFoundException($filename); | ||||
| } | } | ||||
| $output = shell_exec($this->executable . " " . escapeshellarg($filename)); | |||||
| $process = new Process([$this->executable, $filename]); | |||||
| $process->run(); | |||||
| // Following regex: | // Following regex: | ||||
| // matches[1] - file path | // matches[1] - file path | ||||
| // matches[2] - charset | // matches[2] - charset | ||||
| // matches[3] - confidence | // matches[3] - confidence | ||||
| if ((preg_match('/(.+): (.+) .+confidence:? ([^\)]+)/', $output, $matches) === 0)) { | |||||
| if ((preg_match('/(.+): (.+) .+confidence:? ([^\)]+)/', $process->getOutput(), $matches) === 0)) { | |||||
| throw new \Exception('This file is not analyzed'); | throw new \Exception('This file is not analyzed'); | ||||
| } elseif (isset($matches[2]) && $matches[2] === 'None') { | } elseif (isset($matches[2]) && $matches[2] === 'None') { | ||||
| throw new \Exception('Could not determine character set'); | throw new \Exception('Could not determine character set'); | ||||
| @@ -3,6 +3,7 @@ | |||||
| namespace OrpheusNET\Logchecker\Checks; | namespace OrpheusNET\Logchecker\Checks; | ||||
| use OrpheusNET\Logchecker\Util; | use OrpheusNET\Logchecker\Util; | ||||
| use Symfony\Component\Process\Process; | |||||
| class Checksum | class Checksum | ||||
| { | { | ||||
| @@ -25,7 +26,9 @@ class Checksum | |||||
| } | } | ||||
| if (static::logcheckerExists($command)) { | if (static::logcheckerExists($command)) { | ||||
| $output = shell_exec("{$command} " . escapeshellarg($logPath)); | |||||
| $process = new Process([$command, $logPath]); | |||||
| $process->run(); | |||||
| $output = $process->getOutput(); | |||||
| if (strpos($output, $goodResult) === false) { | if (strpos($output, $goodResult) === false) { | ||||
| if ($output == null) { | if ($output == null) { | ||||
| return ChecksumStates::CHECKSUM_MISSING; | return ChecksumStates::CHECKSUM_MISSING; | ||||