Scan RBL zones

@return array    Returns array with failed or success data
(See collector-common/src/Collector.php) for more info.
962136
public function parse()
    {
        /*
         * Preflight validations
         */
        $modes = array_change_key_case(config("{$this->configBase}.collector.modes"), CASE_LOWER);
        if (empty($modes) || !is_array($modes)) {
            return $this->failed('No mode of operation configured, or mode config invalid');
        }

        $feeds = config("{$this->configBase}.feeds");
        if (empty($feeds) || !is_array($feeds)) {
            return $this->failed('No RBL feeds configured, or feed config invalid');
        }

        foreach ($feeds as $feedName => $feedConfig) {
            $validator = Validator::make(
                array_merge($feedConfig, ['name' => $feedName]),
                $this->rulesFeed
            );

            if ($validator->fails()) {
                return $this->failed(implode(' ', $validator->messages()->all()));
            }
        }
        $this->feeds = $feeds;

        /*
         * For each configured mode kick of a scanning process.
         */
        foreach ($modes as $mode) {
            if (!array_key_exists($mode, $this->allowedModes)) {
                return $this->failed("Configuration error detected. Mode {$mode} is not an option");
            }

            if ($this->allowedModes[$mode]) {
                $config = config("{$this->configBase}.collector.{$mode}");

                if (empty($config) || !is_array($config)) {
                    return $this->failed(
                        "Configuration error detected. The settings for mode {$mode} is empty or not an array"
                    );
                }

                foreach ($config as $configElement) {
                    $validator = Validator::make(
                        [ $mode => $configElement ],
                        [ $mode => $this->rulesConfig[$mode] ]
                    );

                    if ($validator->fails()) {
                        return $this->failed(implode(' ', $validator->messages()->all()));
                    }
                }

            } else {
                continue;
            }
        }

        switch($mode) {
            case "asns":
                $this->scanAsn($config);
                break;
            case "netblocks":
                $this->scanNetblock($config);
                break;
            case "ipaddresses":
                $this->scanAddresses($config);
                break;
            case "tickets":
                $this->scanTickets();
                break;
        }


        return $this->success();
    }
1139321
public function getFailedResults(): ResultCollection
    {
        $failedResults = array_filter($this->results, function (Result $result) {
            return $result->isFailed();
        });

        return new self(...$failedResults);
    }
370987
protected function getRegexData()/*# : array */
    {
        // load from cache
        if (empty($this->regex) || !$this->modified) {
            return $this->data;
        }

        // chunk size
        $this->data = array_chunk($this->regex, $this->chunk);

        // join in chunks
        foreach ($this->data as $i => $reg) {
            $this->data[$i] = '~^(?:' . implode('|', $reg) . ')$~x';
        }

        // save to cache here
        $this->modified = false;

        return $this->data;
    }
643011
public function getAllResultsAsArray(): array
    {
        $result = array();

        $entities = $this->getAllResults();

        // Convert search results to array
        foreach ($entities as $entity) {
            if (is_object($entity) && method_exists($entity, 'getValues')) {
                $result[] = $entity->getValues();
            } else {
                $result[] = (array)$entity;
            }
        }

        return $result;
    }
542136
public function getList()
    {
        $pageType = $this->params('pageType', PageTypes::NORMAL);
        $pageId = $this->params('pageId', null);

        /** @var \Rcm\Validator\Page $validator */
        $validator = clone($this->getServiceLocator()->get(\Rcm\Validator\Page::class));
        $validator->setPageType($pageType);

        $return = [
            'valid' => true
        ];

        if (!$validator->isValid($pageId)) {
            $return['valid'] = false;
            $return['error'] = $validator->getMessages();

            /** @var \Zend\Http\Response $response */
            $response = $this->response;

            $errorCodes = array_keys($return['error']);

            foreach ($errorCodes as &$errorCode) {
                if ($errorCode == $validator::PAGE_EXISTS) {
                    $response->setStatusCode(409);
                    break;
                } elseif ($errorCode == $validator::PAGE_NAME) {
                    $response->setStatusCode(417);
                }
            }
        }

        return new JsonModel($return);
    }
406718
protected function _getErrors()
    {
        $aErrors = \OxidEsales\Eshop\Core\Registry::getSession()->getVariable('Errors');

        if (null === $aErrors) {
            $aErrors = [];
        }

        return $aErrors;
    }
784612
public function getScanPaths() : array
    {
        $paths = $this->paths;

        $paths[] = $this->getPath();

        if ($this->config('scan.enabled')) {
            $paths = array_merge($paths, $this->config('scan.paths'));
        }

        $paths = array_map(function ($path) {
            return Str::endsWith($path, '/*') ? $path : Str::finish($path, '/*');
        }, $paths);

        return $paths;
    }
617228
public function read() : array
    {
        if (!$this->beta or !$this->gamma) {
            throw new RuntimeException('Layer has not been initilaized.');
        }

        return [
            'beta' => clone $this->beta,
            'gamma' => clone $this->gamma,
        ];
    }
66554
public function getTrackingFailures()
    {
        if (Piwik::hasUserSuperUserAccess()) {
            $failures = $this->trackingFailures->getAllFailures();
        } else {
            Piwik::checkUserHasSomeAdminAccess();
            $idSites = Access::getInstance()->getSitesIdWithAdminAccess();
            Piwik::checkUserHasAdminAccess($idSites);

            $failures = $this->trackingFailures->getFailuresForSites($idSites);
        }

        return $failures;
    }
592263
public function getAttempts() {
        $rs = $this->runQuery(
            "SELECT attempts FROM " . self::$jobsTable . " WHERE id = ?",
            array($this->job_id)
        );
        foreach ($rs as $r) return $r["attempts"];
        return false;
    }
291417
protected function processLegacyZone(array $zones): array
    {
        $resourceRecords = [];
        foreach ($zones as $domain => $types) {
            $domain = rtrim($domain, '.').'.';
            foreach ($types as $type => $data) {
                $data = (array) $data;
                $type = RecordTypeEnum::getTypeFromName($type);
                foreach ($data as $rdata) {
                    $resourceRecords[] = (new ResourceRecord())
                        ->setName($domain)
                        ->setType($type)
                        ->setClass($this->defaultClass)
                        ->setTtl($this->defaultTtl)
                        ->setRdata($rdata);
                }
            }
        }

        return $resourceRecords;
    }
897613
public function getPageMainZones()
    {
        $result = array();

        if (null === $this->getLayout()) {
            return $result;
        }

        $currentpageRootZones = $this->getContentSet();
        $layoutZones = $this->getLayout()->getZones();
        $count = count($layoutZones);
        for ($i = 0; $i < $count; $i++) {
            $zoneInfos = $layoutZones[$i];
            $currentZone = $currentpageRootZones->item($i);

            if (
                null !== $currentZone
                && null !== $zoneInfos
                && true === property_exists($zoneInfos, 'mainZone')
                && true === $zoneInfos->mainZone
            ) {
                $result[$currentZone->getUid()] = $currentZone;
            }
        }

        return $result;
    }
243909
public function getScanPaths()
    {
        $paths = $this->paths;

        $paths[] = $this->getPath().'/*';

        if ($this->config('scan.enabled')) {
            $paths = array_merge($paths, $this->config('scan.paths'));
        }

        return $paths;
    }
20678
public function getResults()
    {
        $list = (array) $this->parent->getAttributeFromArray($this->localKey);
        $result = [];

        foreach ($list as $index => $item) {
            $result[$index] = $model = $this->related->newInstance([], true);
            $model->setId($index);
        }

        return collect($result);
    }
787169
public function getMatchingCodes()
    {
        $codes = [$this->getCode()];
        foreach ($this->getChildren() as $child) {
            /** @noinspection SlowArrayOperationsInLoopInspection */
            $codes = array_merge($codes, $child->getMatchingCodes());
        }

        return $codes;
    }
341782
public function check()
    {
        $response = Director::test($this->url);

        if ($response->getStatusCode() != 200) {
            return [
                EnvironmentCheck::ERROR,
                sprintf('Error retrieving "%s" (Code: %d)', $this->url, $response->getStatusCode())
            ];
        } elseif ($this->testString && (strpos($response->getBody(), $this->testString) === false)) {
            return [
                EnvironmentCheck::WARNING,
                sprintf('Success retrieving "%s", but string "%s" not found', $this->url, $this->testString)
            ];
        }
        return [
            EnvironmentCheck::OK,
            sprintf('Success retrieving "%s"', $this->url)
        ];
    }
275084
public function getResults()
    {
        $results = array();

        $this->debugStart();

        $executeResults = $this->executeGetResults();

        $this->debugStop();

        foreach ($executeResults as $result) {
            $r = $this->getResult($result);
            if ($r != null) {
                $results[] = $r;
            }
        }

        return $results;
    }