|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* Mage Scan |
|
4
|
|
|
* |
|
5
|
|
|
* PHP version 5 |
|
6
|
|
|
* |
|
7
|
|
|
* @category MageScan |
|
8
|
|
|
* @package MageScan |
|
9
|
|
|
* @author Steve Robbins <[email protected]> |
|
10
|
|
|
* @copyright 2015 Steve Robbins |
|
11
|
|
|
* @license http://creativecommons.org/licenses/by/4.0/ CC BY 4.0 |
|
12
|
|
|
* @link https://github.com/steverobbins/magescan |
|
13
|
|
|
*/ |
|
14
|
|
|
|
|
15
|
|
|
namespace MageScan\Command\Scan; |
|
16
|
|
|
|
|
17
|
|
|
use MageScan\Check\UnreachablePath; |
|
18
|
|
|
use Symfony\Component\Console\Input\InputInterface; |
|
19
|
|
|
use Symfony\Component\Console\Output\OutputInterface; |
|
20
|
|
|
|
|
21
|
|
|
/** |
|
22
|
|
|
* Scan unreachable path command |
|
23
|
|
|
* |
|
24
|
|
|
* @category MageScan |
|
25
|
|
|
* @package MageScan |
|
26
|
|
|
* @author Steve Robbins <[email protected]> |
|
27
|
|
|
* @copyright 2015 Steve Robbins |
|
28
|
|
|
* @license http://creativecommons.org/licenses/by/4.0/ CC BY 4.0 |
|
29
|
|
|
* @link https://github.com/steverobbins/magescan |
|
30
|
|
|
*/ |
|
31
|
|
|
class UnreachableCommand extends AbstractCommand |
|
32
|
|
|
{ |
|
33
|
|
|
/** |
|
34
|
|
|
* Configure command |
|
35
|
|
|
* |
|
36
|
|
|
* @return void |
|
37
|
|
|
*/ |
|
38
|
|
|
protected function configure() |
|
39
|
|
|
{ |
|
40
|
|
|
$this |
|
41
|
|
|
->setName('scan:unreachable') |
|
42
|
|
|
->setDescription('Check unreachable paths'); |
|
43
|
|
|
parent::configure(); |
|
44
|
|
|
} |
|
45
|
|
|
|
|
46
|
|
|
/** |
|
47
|
|
|
* Execute command |
|
48
|
|
|
* |
|
49
|
|
|
* @param InputInterface $input |
|
50
|
|
|
* @param OutputInterface $output |
|
51
|
|
|
* |
|
52
|
|
|
* @return void |
|
53
|
|
|
*/ |
|
54
|
|
|
protected function execute(InputInterface $input, OutputInterface $output) |
|
55
|
|
|
{ |
|
56
|
|
|
$unreachablePath = new UnreachablePath; |
|
57
|
|
|
$unreachablePath->setRequest($this->request); |
|
58
|
|
|
$results = $unreachablePath->checkPaths(); |
|
59
|
|
|
foreach ($results as &$result) { |
|
60
|
|
|
if ($result[2] === false) { |
|
61
|
|
|
$result[2] = '<error>Fail</error>'; |
|
62
|
|
|
} elseif ($result[2] === true) { |
|
63
|
|
|
$result[2] = '<bg=green>Pass</bg=green>'; |
|
64
|
|
|
} |
|
65
|
|
|
} |
|
66
|
|
|
$this->out('Unreachable Path Check', [[ |
|
67
|
|
|
'type' => 'table', |
|
68
|
|
|
'data' => [ |
|
69
|
|
|
['Path', 'Response Code', 'Status'], |
|
70
|
|
|
$results |
|
71
|
|
|
] |
|
72
|
|
|
]]); |
|
73
|
|
|
} |
|
74
|
|
|
} |
|
75
|
|
|
|