protected function execute(InputInterface $input, OutputInterface $output) { $name = $input->getArgument('name'); $cfg = $this->getSelimConfig($input); if ($cfg->siteExists($name)) { $cfg->removeSite($name); $cfg->write(); echo "removed: '{$name}'" . PHP_EOL; } else { Util::reportError("Site with name '{$name}' doesn't exists!"); } }
protected function execute(InputInterface $input, OutputInterface $output) { $name = $input->getArgument('name'); $cfg = $this->getSelimConfig($input); if ($cfg->siteExists($name)) { echo "Security-test for {$name}:" . PHP_EOL; $site = $cfg->getSite($name); $sc = new SecurityChecker(new SilverstripePage($site)); $vulns = $sc->findVulnerabilities(true); foreach ($vulns as $vul) { $severity = $vul["severity"] ? $vul["severity"] : "Warning"; Util::forceStringMinLength($severity, 9); echo "{$severity} " . $vul["title"] . PHP_EOL; } } else { Util::reportError("Site with name '{$name}' doesn't exists!"); } }
public function setPath($config_path = "", $is_cli = true) { $dir = dirname($config_path); if (file_exists($dir)) { if (!file_exists($config_path) && $is_cli) { echo "The file {$config_path} doesn't exist. Do you want to create it? yes/[no]"; $line = fgets(STDIN); if (preg_match("/^y|yes/", $line)) { file_put_contents($config_path, '{"sites":{}}'); } else { Util::reportError("Aborting..."); } } $this->path_config = $config_path; $this->load(); } else { Util::reportError("The directory \"{$dir}\" doesnt exist."); } }