diff --git a/.github/workflows/code-quality.yml b/.github/workflows/code-quality.yml new file mode 100644 index 00000000..b5173c37 --- /dev/null +++ b/.github/workflows/code-quality.yml @@ -0,0 +1,101 @@ +# +-------------------------------------------------------------------------+ +# | Copyright (C) 2004-2026 The Cacti Group | +# | | +# | This program is free software; you can redistribute it and/or | +# | modify it under the terms of the GNU General Public License | +# | as published by the Free Software Foundation; either version 2 | +# | of the License, or (at your option) any later version. | +# +-------------------------------------------------------------------------+ +# | Cacti: The Complete RRDtool-based Graphing Solution | +# +-------------------------------------------------------------------------+ + +name: Code Quality + +on: + push: + branches: + - main + - develop + pull_request: + branches: + - main + - develop + +permissions: + contents: read + +jobs: + lint: + name: PHP Lint (PHP ${{ matrix.php }}) + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + php: ['8.1', '8.2', '8.3', '8.4'] + steps: + - name: Checkout plugin + uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 + + - name: Install PHP ${{ matrix.php }} + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php }} + coverage: none + + # Lint only the plugin's own PHP. Vendored code (Net/, vendor/) is pruned + # so third-party sources never gate the plugin. + - name: Lint plugin PHP + run: | + find . -path ./.git -prune \ + -o -path ./Net -prune \ + -o -path ./vendor -prune \ + -o -name '*.php' -print0 \ + | xargs -0 -n1 -P4 php -l + + phpstan: + name: PHPStan level 6 (PHP ${{ matrix.php }}) + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + php: ['8.1', '8.2', '8.3', '8.4'] + steps: + - name: Checkout Cacti core + uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 + with: + repository: Cacti/cacti + ref: release/1.2.31 + path: cacti + + - name: Checkout plugin + uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 + with: + path: cacti/plugins/mactrack + + - name: Install PHP ${{ matrix.php }} + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php }} + coverage: none + tools: composer:v2, phpstan + + # Cacti core ships an incomplete vendor tree; its bootstrap needs the + # runtime dependencies installed so core functions resolve for PHPStan. + - name: Install Cacti core dependencies + working-directory: cacti + run: composer install --no-dev --no-interaction --no-progress + + # release/1.2.31 does not ship .phpstan-bootstrap.php (develop does). + # Provide a no-op stub so the plugin config can load either core tree. + - name: Ensure PHPStan bootstrap exists + working-directory: cacti + run: | + if [ ! -f .phpstan-bootstrap.php ]; then + printf '%s\n' ' .phpstan-bootstrap.php + fi + + # Analysis runs against the plugin's own code only; the config excludes + # Net/ and vendor/. The committed baseline pins the accepted findings. + - name: Run PHPStan + working-directory: cacti/plugins/mactrack + run: phpstan analyse --configuration=.phpstan.neon --no-progress --memory-limit=2G diff --git a/.github/workflows/plugin-ci-workflow.yml b/.github/workflows/plugin-ci-workflow.yml index bdbd8891..951dcadc 100644 --- a/.github/workflows/plugin-ci-workflow.yml +++ b/.github/workflows/plugin-ci-workflow.yml @@ -64,6 +64,7 @@ jobs: uses: actions/checkout@v4 with: repository: Cacti/cacti + ref: release/1.2.31 path: cacti - name: Checkout mactrack Plugin @@ -85,7 +86,7 @@ jobs: run: sudo apt-get update - name: Install System Dependencies - run: sudo apt-get install -y apache2 snmp snmpd rrdtool fping libapache2-mod-php${{ matrix.php }} + run: sudo apt-get install -y apache2 snmp snmpd rrdtool fping - name: Start SNMPD Agent and Test run: | @@ -164,6 +165,13 @@ jobs: run: | cd ${{ github.workspace }}/cacti sudo php cli/install_cacti.php --accept-eula --install --force + + - name: Install Mactrack Composer Dependencies + run: | + cd ${{ github.workspace }}/cacti/plugins/mactrack + if [ -f composer.json ]; then + sudo composer install --no-dev --prefer-dist --no-progress --no-interaction + fi - name: Install mactrack Plugin run: | @@ -182,24 +190,40 @@ jobs: - name: Check PHP Syntax for Plugin run: | cd ${{ github.workspace }}/cacti/plugins/mactrack - if find . -name '*.php' -exec php -l {} 2>&1 \; | grep -iv 'no syntax errors detected'; then - echo "Syntax errors found!" - exit 1 - fi - + find . -path './vendor' -prune -o -name '*.php' -print0 | xargs -0 -n1 php -l + + # Cacti 1.2.31 has no .phpstan.neon / lint scripts; only touch them when present. - name: Remove the plugins directory exclusion from the .phpstan.neon - run: sed '/plugins/d' -i .phpstan.neon + run: | + if [ -f .phpstan.neon ]; then + sed '/plugins/d' -i .phpstan.neon + else + echo '.phpstan.neon not present; skipping' + fi working-directory: ${{ github.workspace }}/cacti - name: Mark composer scripts executable - run: sudo chmod +x ${{ github.workspace }}/cacti/include/vendor/bin/* + run: | + if [ -d "${{ github.workspace }}/cacti/include/vendor/bin" ]; then + sudo find "${{ github.workspace }}/cacti/include/vendor/bin" -maxdepth 1 -type f -exec chmod +x {} + + fi - name: Run Linter on base code - run: composer run-script lint ${{ github.workspace }}/cacti/plugins/mactrack + run: | + if composer run-script --list | grep -qE '^ lint'; then + composer run-script lint ${{ github.workspace }}/cacti/plugins/mactrack + else + echo 'Composer lint script is not defined; skipping.' + fi working-directory: ${{ github.workspace }}/cacti - name: Checking coding standards on base code - run: composer run-script phpcsfixer ${{ github.workspace }}/cacti/plugins/mactrack + run: | + if composer run-script --list | grep -qE '^ phpcsfixer'; then + composer run-script phpcsfixer ${{ github.workspace }}/cacti/plugins/mactrack + else + echo 'Composer phpcsfixer script is not defined; skipping.' + fi working-directory: ${{ github.workspace }}/cacti # - name: Run PHPStan at Level 6 on base code outside of Composer due to technical issues diff --git a/.phpstan.neon b/.phpstan.neon new file mode 100644 index 00000000..b4d1cff2 --- /dev/null +++ b/.phpstan.neon @@ -0,0 +1,48 @@ +includes: + - phpstan-baseline.neon + +parameters: + level: 6 + parallel: + maximumNumberOfProcesses: 8 + # Cacti core is checked out at ../.. by the Code Quality workflow so its + # library functions resolve for the plugin. Only the plugin's own code is + # analyzed; vendored Net_DNS2 (Net/, vendor/) is never scanned. + scanDirectories: + - ../../lib + - ../../include + paths: + - lib + - includes + - . + excludePaths: + analyseAndScan: + - Net/* + - vendor/* + - tests/* + bootstrapFiles: + - ../../.phpstan-bootstrap.php + - ../../include/vendor/autoload.php + - ../../include/config.php.dist + - ../../include/global_constants.php + - ../../lib/functions.php + - ../../include/global.php + - ../../include/global_languages.php + - ../../include/global_arrays.php + - ../../include/global_form.php + - ../../include/global_settings.php + reportUnmatchedIgnoredErrors: false + ignoreErrors: + - identifier: missingType.iterableValue + - identifier: if.alwaysFalse + - identifier: notEqual.alwaysFalse + - identifier: notEqual.alwaysTrue + - identifier: equal.alwaysTrue + - identifier: if.alwaysTrue + - identifier: while.alwaysTrue + - identifier: greater.alwaysFalse + - identifier: identical.alwaysTrue + - identifier: identical.alwaysFalse + - identifier: booleanAnd.leftAlwaysTrue + - identifier: booleanAnd.leftAlwaysFalse + - identifier: function.alreadyNarrowedType diff --git a/CHANGELOG.md b/CHANGELOG.md index b03f8f52..ab1009c2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,19 @@ --- develop --- +* compat: Replace vendored Net_DNS2 with Composer-managed mikepultz/netdns2 1.5, retaining the established resolver API +* issue: Harden device-type vendor filtering against SQL injection +* issue: Validate aggregated MAC bulk-action IDs and use prepared deletion SQL +* security: Replace MAC action request deserialization with escaped JSON payloads +* security: Validate and escape MAC bulk-action form values before rendering +* security: Escape rescan executable and script paths before command execution +* security: Parameterize stale-process site filtering and validate process IDs before termination +* security: Escape Cabletron SNMP command arguments and normalize numeric options +* security: Safely quote ignored-interface regexes and normalize interface report filters +* security: Normalize device report SQL filters before query construction +* security: Normalize administrative device list SQL filters before query construction +* security: Validate canonical local-file paths for OUI database imports +* compat: Fix PHP 8 parameter ordering and partition conversion arguments * issue#246: Fix Cisco device collection * issue#248: Cacti process control, terminate dns resolvet when is nothing to do * issue#250: Disable automatic MIBs load diff --git a/Net/DNS2.php b/Net/DNS2.php deleted file mode 100644 index 2a6360dd..00000000 --- a/Net/DNS2.php +++ /dev/null @@ -1,1235 +0,0 @@ -. All rights reserved. - * - * See LICENSE for more details. - * - * @category Networking - * @package Net_DNS2 - * @author Mike Pultz - * @copyright 2020 Mike Pultz - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @link https://netdns2.com/ - * @since File available since Release 0.6.0 - * - */ - -// register the auto-load function -spl_autoload_register('Net_DNS2::autoload'); - -/** - * This is the base class for the Net_DNS2_Resolver and Net_DNS2_Updater classes. - * - */ -class Net_DNS2 { - // the current version of this library - const VERSION = '1.5.0'; - - // the default path to a resolv.conf file - const RESOLV_CONF = '/etc/resolv.conf'; - - /* - * override options from the resolv.conf file - * - * if this is set, then certain values from the resolv.conf file will override - * local settings. This is disabled by default to remain backwards compatible. - * - */ - public $use_resolv_options = false; - - // use TCP only (true/false) - public $use_tcp = false; - - // DNS Port to use (53) - public $dns_port = 53; - - // the ip/port for use as a local socket - public $local_host = ''; - public $local_port = 0; - - // timeout value for socket connections - public $timeout = 5; - - // randomize the name servers list - public $ns_random = false; - - // default domains - public $domain = ''; - - // domain search list - not actually used right now - public $search_list = []; - - // enable cache; either "shared", "file" or "none" - public $cache_type = 'none'; - - // file name to use for shared memory segment or file cache - public $cache_file = '/tmp/net_dns2.cache'; - - // the max size of the cache file (in bytes) - public $cache_size = 50000; - - /* - * the method to use for storing cache data; either "serialize" or "json" - * - * json is faster, but can't remember the class names (everything comes back - * as a "stdClass Object"; all the data is the same though. serialize is - * slower, but will have all the class info. - * - * defaults to 'serialize' - */ - public $cache_serializer = 'serialize'; - - /* - * by default, according to RFC 1034 - * - * CNAME RRs cause special action in DNS software. When a name server - * fails to find a desired RR in the resource set associated with the - * domain name, it checks to see if the resource set consists of a CNAME - * record with a matching class. If so, the name server includes the CNAME - * record in the response and restarts the query at the domain name - * specified in the data field of the CNAME record. - * - * this can cause "unexpected" behaviours, since i'm sure *most* people - * don't know DNS does this; there may be cases where Net_DNS2 returns a - * positive response, even though the hostname the user looked up did not - * actually exist. - * - * strict_query_mode means that if the hostname that was looked up isn't - * actually in the answer section of the response, Net_DNS2 will return an - * empty answer section, instead of an answer section that could contain - * CNAME records. - * - */ - public $strict_query_mode = false; - - /* - * if we should set the recursion desired bit to 1 or 0. - * - * by default this is set to true, we want the DNS server to perform a recursive - * request. If set to false, the RD bit will be set to 0, and the server will - * not perform recursion on the request. - */ - public $recurse = true; - - /* - * request DNSSEC values, by setting the DO flag to 1; this actually makes - * the resolver add a OPT RR to the additional section, and sets the DO flag - * in this RR to 1 - * - */ - public $dnssec = false; - - /* - * set the DNSSEC AD (Authentic Data) bit on/off; the AD bit on the request - * side was previously undefined, and resolvers we instructed to always clear - * the AD bit when sending a request. - * - * RFC6840 section 5.7 defines setting the AD bit in the query as a signal to - * the server that it wants the value of the AD bit, without needed to request - * all the DNSSEC data via the DO bit. - * - */ - public $dnssec_ad_flag = false; - - /* - * set the DNSSEC CD (Checking Disabled) bit on/off; turning this off, means - * that the DNS resolver will perform it's own signature validation- so the DNS - * servers simply pass through all the details. - * - */ - public $dnssec_cd_flag = false; - - /* - * the EDNS(0) UDP payload size to use when making DNSSEC requests - * see RFC 4035 section 4.1 - EDNS Support. - * - * there is some different ideas on the suggest size to support; but it seems to - * be "at least 1220 bytes, but SHOULD support 4000 bytes. - * - * we'll just support 4000 - * - */ - public $dnssec_payload_size = 4000; - - // the last exception that was generated - public $last_exception = null; - - // the list of exceptions by name server - public $last_exception_list = []; - - // name server list - public $nameservers = []; - - // local sockets - protected $sock = [ Net_DNS2_Socket::SOCK_DGRAM => [], Net_DNS2_Socket::SOCK_STREAM => [] ]; - - // the TSIG or SIG RR object for authentication - protected $auth_signature = null; - - // the shared memory segment id for the local cache - protected $cache = null; - - // internal setting for enabling cache - protected $use_cache = false; - - /** - * Constructor - base constructor for the Resolver and Updater - * - * @param mixed $options array of options or null for none - * - * @throws Net_DNS2_Exception - * @access public - * - */ - public function __construct(array $options = null) { - // - // load any options that were provided - // - if (!empty($options)) { - foreach ($options as $key => $value) { - if ($key == 'nameservers') { - $this->setServers($value); - } else { - $this->$key = $value; - } - } - } - - // - // if we're set to use the local shared memory cache, then - // make sure it's been initialized - // - switch($this->cache_type) { - case 'shared': - if (extension_loaded('shmop')) { - $this->cache = new Net_DNS2_Cache_Shm; - $this->use_cache = true; - } else { - throw new Net_DNS2_Exception( - 'shmop library is not available for cache', - Net_DNS2_Lookups::E_CACHE_SHM_UNAVAIL - ); - } - - break; - case 'file': - $this->cache = new Net_DNS2_Cache_File; - $this->use_cache = true; - - break; - case 'none': - $this->use_cache = false; - - break; - default: - throw new Net_DNS2_Exception( - 'un-supported cache type: ' . $this->cache_type, - Net_DNS2_Lookups::E_CACHE_UNSUPPORTED - ); - } - } - - /** - * autoload call-back function; used to auto-load classes - * - * @param string $name the name of the class - * - * @return void - * @access public - * - */ - static public function autoload($name) { - // - // only auto-load our classes - // - if (strncmp($name, 'Net_DNS2', 8) == 0) { - include str_replace('_', '/', $name) . '.php'; - } - - return; - } - - /** - * sets the name servers to be used - * - * @param mixed $nameservers either an array of name servers, or a file name - * to parse, assuming it's in the resolv.conf format - * - * @return boolean - * @throws Net_DNS2_Exception - * @access public - * - */ - public function setServers($nameservers) { - // - // if it's an array, then use it directly - // - // otherwise, see if it's a path to a resolv.conf file and if so, load it - // - if (is_array($nameservers)) { - $this->nameservers = $nameservers; - } else { - // - // temporary list of name servers; do it this way rather than just - // resetting the local nameservers value, just incase an exception - // is thrown here; this way we might avoid ending up with an empty - // namservers list. - // - $ns = []; - - // - // check to see if the file is readable - // - if (is_readable($nameservers) === true) { - $data = file_get_contents($nameservers); - - if ($data === false) { - throw new Net_DNS2_Exception( - 'failed to read contents of file: ' . $nameservers, - Net_DNS2_Lookups::E_NS_INVALID_FILE - ); - } - - $lines = explode("\n", $data); - - foreach ($lines as $line) { - $line = trim($line); - - // - // ignore empty lines, and lines that are commented out - // - if ((strlen($line) == 0) - || ($line[0] == '#') - || ($line[0] == ';') - ) { - continue; - } - - // - // ignore lines with no spaces in them. - // - if (strpos($line, ' ') === false) { - continue; - } - - [$key, $value] = preg_split('/\s+/', $line, 2); - - $key = trim(strtolower($key)); - $value = trim(strtolower($value)); - - switch($key) { - case 'nameserver': - // - // nameserver can be a IPv4 or IPv6 address - // - if ((self::isIPv4($value) == true) - || (self::isIPv6($value) == true) - ) { - $ns[] = $value; - } else { - throw new Net_DNS2_Exception( - 'invalid nameserver entry: ' . $value, - Net_DNS2_Lookups::E_NS_INVALID_ENTRY - ); - } - - break; - case 'domain': - $this->domain = $value; - - break; - case 'search': - $this->search_list = preg_split('/\s+/', $value); - - break; - case 'options': - $this->parseOptions($value); - - break; - default:; - } - } - - // - // if we don't have a domain, but we have a search list, then - // take the first entry on the search list as the domain - // - if ((strlen($this->domain) == 0) - && (cacti_sizeof($this->search_list) > 0) - ) { - $this->domain = $this->search_list[0]; - } - } else { - throw new Net_DNS2_Exception( - 'resolver file file provided is not readable: ' . $nameservers, - Net_DNS2_Lookups::E_NS_INVALID_FILE - ); - } - - // - // store the name servers locally - // - if (cacti_sizeof($ns) > 0) { - $this->nameservers = $ns; - } - } - - // - // remove any duplicates; not sure if we should bother with this- if people - // put duplicate name servers, who I am to stop them? - // - $this->nameservers = array_unique($this->nameservers); - - // - // check the name servers - // - $this->checkServers(); - - return true; - } - - /** - * return the internal $sock array - * - * @return array - * @access public - */ - public function getSockets() { - return $this->sock; - } - - /** - * give users access to close all open sockets on the resolver object; resetting each - * array, calls the destructor on the Net_DNS2_Socket object, which calls the close() - * method on each object. - * - * @return boolean - * @access public - * - */ - public function closeSockets() { - $this->sock[Net_DNS2_Socket::SOCK_DGRAM] = []; - $this->sock[Net_DNS2_Socket::SOCK_STREAM] = []; - - return true; - } - - /** - * parses the options line from a resolv.conf file; we don't support all the options - * yet, and using them is optional. - * - * @param string $value is the options string from the resolv.conf file. - * - * @return boolean - * @access private - * - */ - private function parseOptions($value) { - // - // if overrides are disabled (the default), or the options list is empty for some - // reason, then we don't need to do any of this work. - // - if (($this->use_resolv_options == false) || (strlen($value) == 0)) { - return true; - } - - $options = preg_split('/\s+/', strtolower($value)); - - foreach ($options as $option) { - // - // override the timeout value from the resolv.conf file. - // - if ((strncmp($option, 'timeout', 7) == 0) && (strpos($option, ':') !== false)) { - [$key, $val] = explode(':', $option); - - if (($val > 0) && ($val <= 30)) { - $this->timeout = $val; - } - - // - // the rotate option just enabled the ns_random option - // - } elseif (strncmp($option, 'rotate', 6) == 0) { - $this->ns_random = true; - } - } - - return true; - } - - /** - * checks the list of name servers to make sure they're set - * - * @param mixed $default a path to a resolv.conf file or an array of servers. - * - * @return boolean - * @throws Net_DNS2_Exception - * @access protected - * - */ - protected function checkServers($default = null) { - if (empty($this->nameservers)) { - if (isset($default)) { - $this->setServers($default); - } else { - throw new Net_DNS2_Exception( - 'empty name servers list; you must provide a list of name ' . - 'servers, or the path to a resolv.conf file.', - Net_DNS2_Lookups::E_NS_INVALID_ENTRY - ); - } - } - - return true; - } - - /** - * adds a TSIG RR object for authentication - * - * @param string $keyname the key name to use for the TSIG RR - * @param string $signature the key to sign the request. - * @param string $algorithm the algorithm to use - * - * @return boolean - * @access public - * @since function available since release 1.1.0 - * - */ - public function signTSIG( - $keyname, $signature = '', $algorithm = Net_DNS2_RR_TSIG::HMAC_MD5 - ) { - // - // if the TSIG was pre-created and passed in, then we can just used - // it as provided. - // - if ($keyname instanceof Net_DNS2_RR_TSIG) { - $this->auth_signature = $keyname; - } else { - // - // otherwise create the TSIG RR, but don't add it just yet; TSIG needs - // to be added as the last additional entry- so we'll add it just - // before we send. - // - $this->auth_signature = Net_DNS2_RR::fromString( - strtolower(trim($keyname)) . - ' TSIG ' . $signature - ); - - // - // set the algorithm to use - // - $this->auth_signature->algorithm = $algorithm; - } - - return true; - } - - /** - * adds a SIG RR object for authentication - * - * @param string $filename the name of a file to load the signature from. - * - * @return boolean - * @throws Net_DNS2_Exception - * @access public - * @since function available since release 1.1.0 - * - */ - public function signSIG0($filename) { - // - // check for OpenSSL - // - if (extension_loaded('openssl') === false) { - throw new Net_DNS2_Exception( - 'the OpenSSL extension is required to use SIG(0).', - Net_DNS2_Lookups::E_OPENSSL_UNAVAIL - ); - } - - // - // if the SIG was pre-created, then use it as-is - // - if ($filename instanceof Net_DNS2_RR_SIG) { - $this->auth_signature = $filename; - } else { - // - // otherwise, it's filename which needs to be parsed and processed. - // - $private = new Net_DNS2_PrivateKey($filename); - - // - // create a new Net_DNS2_RR_SIG object - // - $this->auth_signature = new Net_DNS2_RR_SIG(); - - // - // reset some values - // - $this->auth_signature->name = $private->signname; - $this->auth_signature->ttl = 0; - $this->auth_signature->class = 'ANY'; - - // - // these values are pulled from the private key - // - $this->auth_signature->algorithm = $private->algorithm; - $this->auth_signature->keytag = $private->keytag; - $this->auth_signature->signname = $private->signname; - - // - // these values are hard-coded for SIG0 - // - $this->auth_signature->typecovered = 'SIG0'; - $this->auth_signature->labels = 0; - $this->auth_signature->origttl = 0; - - // - // generate the dates - // - $t = time(); - - $this->auth_signature->sigincep = gmdate('YmdHis', $t); - $this->auth_signature->sigexp = gmdate('YmdHis', $t + 500); - - // - // store the private key in the SIG object for later. - // - $this->auth_signature->private_key = $private; - } - - // - // only RSA algorithms are supported for SIG(0) - // - switch($this->auth_signature->algorithm) { - case Net_DNS2_Lookups::DNSSEC_ALGORITHM_RSAMD5: - case Net_DNS2_Lookups::DNSSEC_ALGORITHM_RSASHA1: - case Net_DNS2_Lookups::DNSSEC_ALGORITHM_RSASHA256: - case Net_DNS2_Lookups::DNSSEC_ALGORITHM_RSASHA512: - case Net_DNS2_Lookups::DNSSEC_ALGORITHM_DSA: - break; - default: - throw new Net_DNS2_Exception( - 'only asymmetric algorithms work with SIG(0)!', - Net_DNS2_Lookups::E_OPENSSL_INV_ALGO - ); - } - - return true; - } - - /** - * a simple function to determine if the RR type is cacheable - * - * @param string $_type the RR type string - * - * @return bool returns true/false if the RR type if cacheable - * @access public - * - */ - public function cacheable($_type) { - switch($_type) { - case 'AXFR': - case 'OPT': - return false; - } - - return true; - } - - /** - * PHP doesn't support unsigned integers, but many of the RR's return - * unsigned values (like SOA), so there is the possibility that the - * value will overrun on 32bit systems, and you'll end up with a - * negative value. - * - * 64bit systems are not affected, as their PHP_IN_MAX value should - * be 64bit (ie 9223372036854775807) - * - * This function returns a negative integer value, as a string, with - * the correct unsigned value. - * - * @param string $_int the unsigned integer value to check - * - * @return string returns the unsigned value as a string. - * @access public - * - */ - public static function expandUint32($_int) { - if (($_int < 0) && (PHP_INT_MAX == 2147483647)) { - return sprintf('%u', $_int); - } else { - return $_int; - } - } - - /** - * returns true/false if the given address is a valid IPv4 address - * - * @param string $_address the IPv4 address to check - * - * @return boolean returns true/false if the address is IPv4 address - * @access public - * - */ - public static function isIPv4($_address) { - // - // use filter_var() if it's available; it's faster than preg - // - if (extension_loaded('filter') == true) { - if (filter_var($_address, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4) == false) { - return false; - } - } else { - // - // do the main check here; - // - if (inet_pton($_address) === false) { - return false; - } - - // - // then make sure we're not a IPv6 address - // - if (preg_match('/^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$/', $_address) == 0) { - return false; - } - } - - return true; - } - - /** - * returns true/false if the given address is a valid IPv6 address - * - * @param string $_address the IPv6 address to check - * - * @return boolean returns true/false if the address is IPv6 address - * @access public - * - */ - public static function isIPv6($_address) { - // - // use filter_var() if it's available; it's faster than preg - // - if (extension_loaded('filter') == true) { - if (filter_var($_address, FILTER_VALIDATE_IP, FILTER_FLAG_IPV6) == false) { - return false; - } - } else { - // - // do the main check here - // - if (inet_pton($_address) === false) { - return false; - } - - // - // then make sure it doesn't match a IPv4 address - // - if (preg_match('/^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$/', $_address) == 1) { - return false; - } - } - - return true; - } - - /** - * formats the given IPv6 address as a fully expanded IPv6 address - * - * @param string $_address the IPv6 address to expand - * - * @return string the fully expanded IPv6 address - * @access public - * - */ - public static function expandIPv6($_address) { - $hex = unpack('H*hex', inet_pton($_address)); - - return substr(preg_replace('/([A-f0-9]{4})/', '$1:', $hex['hex']), 0, -1); - } - - /** - * sends a standard Net_DNS2_Packet_Request packet - * - * @param Net_DNS2_Packet $request a Net_DNS2_Packet_Request object - * @param boolean $use_tcp true/false if the function should - * use TCP for the request - * - * @return Net_DNS2_Packet_Response - * @throws Net_DNS2_Exception - * @access protected - * - */ - protected function sendPacket(Net_DNS2_Packet $request, $use_tcp) { - // - // get the data from the packet - // - $data = $request->get(); - - if (strlen($data) < Net_DNS2_Lookups::DNS_HEADER_SIZE) { - throw new Net_DNS2_Exception( - 'invalid or empty packet for sending!', - Net_DNS2_Lookups::E_PACKET_INVALID, - null, - $request - ); - } - - reset($this->nameservers); - - // - // randomize the name server list if it's asked for - // - if ($this->ns_random == true) { - shuffle($this->nameservers); - } - - // - // loop so we can handle server errors - // - $response = null; - $ns = ''; - - while (1) { - // - // grab the next DNS server - // - $ns = current($this->nameservers); - next($this->nameservers); - - if ($ns === false) { - if (is_null($this->last_exception) == false) { - throw $this->last_exception; - } else { - throw new Net_DNS2_Exception( - 'every name server provided has failed', - Net_DNS2_Lookups::E_NS_FAILED - ); - } - } - - // - // if the use TCP flag (force TCP) is set, or the packet is bigger than our - // max allowed UDP size- which is either 512, or if this is DNSSEC request, - // then whatever the configured dnssec_payload_size is. - // - $max_udp_size = Net_DNS2_Lookups::DNS_MAX_UDP_SIZE; - - if ($this->dnssec == true) { - $max_udp_size = $this->dnssec_payload_size; - } - - if (($use_tcp == true) || (strlen($data) > $max_udp_size)) { - try { - $response = $this->sendTCPRequest($ns, $data, ($request->question[0]->qtype == 'AXFR') ? true : false); - } catch (Net_DNS2_Exception $e) { - $this->last_exception = $e; - $this->last_exception_list[$ns] = $e; - - continue; - } - - // - // otherwise, send it using UDP - // - } else { - try { - $response = $this->sendUDPRequest($ns, $data); - - // - // check the packet header for a truncated bit; if it was truncated, - // then re-send the request as TCP. - // - if ($response->header->tc == 1) { - $response = $this->sendTCPRequest($ns, $data); - } - } catch (Net_DNS2_Exception $e) { - $this->last_exception = $e; - $this->last_exception_list[$ns] = $e; - - continue; - } - } - - // - // make sure header id's match between the request and response - // - if ($request->header->id != $response->header->id) { - $this->last_exception = new Net_DNS2_Exception( - 'invalid header: the request and response id do not match.', - Net_DNS2_Lookups::E_HEADER_INVALID, - null, - $request, - $response - ); - - $this->last_exception_list[$ns] = $this->last_exception; - - continue; - } - - // - // make sure the response is actually a response - // - // 0 = query, 1 = response - // - if ($response->header->qr != Net_DNS2_Lookups::QR_RESPONSE) { - $this->last_exception = new Net_DNS2_Exception( - 'invalid header: the response provided is not a response packet.', - Net_DNS2_Lookups::E_HEADER_INVALID, - null, - $request, - $response - ); - - $this->last_exception_list[$ns] = $this->last_exception; - - continue; - } - - // - // make sure the response code in the header is ok - // - if ($response->header->rcode != Net_DNS2_Lookups::RCODE_NOERROR) { - $this->last_exception = new Net_DNS2_Exception( - 'DNS request failed: ' . - Net_DNS2_Lookups::$result_code_messages[$response->header->rcode], - $response->header->rcode, - null, - $request, - $response - ); - - $this->last_exception_list[$ns] = $this->last_exception; - - continue; - } - - break; - } - - return $response; - } - - /** - * cleans up a failed socket and throws the given exception - * - * @param string $_proto the protocol of the socket - * @param string $_ns the name server to use for the request - * @param string $_error the error message to throw at the end of the function - * - * @throws Net_DNS2_Exception - * @access private - * - */ - private function generateError($_proto, $_ns, $_error) { - if (isset($this->sock[$_proto][$_ns]) == false) { - throw new Net_DNS2_Exception('invalid socket referenced', Net_DNS2_Lookups::E_NS_INVALID_SOCKET); - } - - // - // grab the last error message off the socket - // - $last_error = $this->sock[$_proto][$_ns]->last_error; - - // - // remove it from the socket cache; this will call the destructor, which calls close() on the socket - // - unset($this->sock[$_proto][$_ns]); - - // - // throw the error provided - // - throw new Net_DNS2_Exception($last_error, $_error); - } - - /** - * sends a DNS request using TCP - * - * @param string $_ns the name server to use for the request - * @param string $_data the raw DNS packet data - * @param boolean $_axfr if this is a zone transfer request - * - * @return Net_DNS2_Packet_Response the response object - * @throws Net_DNS2_Exception - * @access private - * - */ - private function sendTCPRequest($_ns, $_data, $_axfr = false) { - // - // grab the start time - // - $start_time = microtime(true); - - // - // see if we already have an open socket from a previous request; if so, try to use - // that instead of opening a new one. - // - if ((!isset($this->sock[Net_DNS2_Socket::SOCK_STREAM][$_ns])) - || (!($this->sock[Net_DNS2_Socket::SOCK_STREAM][$_ns] instanceof Net_DNS2_Socket)) - ) { - // - // create the socket object - // - $this->sock[Net_DNS2_Socket::SOCK_STREAM][$_ns] = new Net_DNS2_Socket( - Net_DNS2_Socket::SOCK_STREAM, $_ns, $this->dns_port, $this->timeout - ); - - // - // if a local IP address / port is set, then add it - // - if (strlen($this->local_host) > 0) { - $this->sock[Net_DNS2_Socket::SOCK_STREAM][$_ns]->bindAddress( - $this->local_host, $this->local_port - ); - } - - // - // open the socket - // - if ($this->sock[Net_DNS2_Socket::SOCK_STREAM][$_ns]->open() === false) { - $this->generateError(Net_DNS2_Socket::SOCK_STREAM, $_ns, Net_DNS2_Lookups::E_NS_SOCKET_FAILED); - } - } - - // - // write the data to the socket; if it fails, continue on - // the while loop - // - if ($this->sock[Net_DNS2_Socket::SOCK_STREAM][$_ns]->write($_data) === false) { - $this->generateError(Net_DNS2_Socket::SOCK_STREAM, $_ns, Net_DNS2_Lookups::E_NS_SOCKET_FAILED); - } - - // - // read the content, using select to wait for a response - // - $size = 0; - $result = null; - $response = null; - - // - // handle zone transfer requests differently than other requests. - // - if ($_axfr == true) { - $soa_count = 0; - - while (1) { - // - // read the data off the socket - // - $result = $this->sock[Net_DNS2_Socket::SOCK_STREAM][$_ns]->read($size, - ($this->dnssec == true) ? $this->dnssec_payload_size : Net_DNS2_Lookups::DNS_MAX_UDP_SIZE); - - if (($result === false) || ($size < Net_DNS2_Lookups::DNS_HEADER_SIZE)) { - // - // if we get an error, then keeping this socket around for a future request, could cause - // an error- for example, https://github.com/mikepultz/netdns2/issues/61 - // - // in this case, the connection was timing out, which once it did finally respond, left - // data on the socket, which could be captured on a subsequent request. - // - // since there's no way to "reset" a socket, the only thing we can do it close it. - // - $this->generateError(Net_DNS2_Socket::SOCK_STREAM, $_ns, Net_DNS2_Lookups::E_NS_SOCKET_FAILED); - } - - // - // parse the first chunk as a packet - // - $chunk = new Net_DNS2_Packet_Response($result, $size); - - // - // if this is the first packet, then clone it directly, then - // go through it to see if there are two SOA records - // (indicating that it's the only packet) - // - if (is_null($response) == true) { - $response = clone $chunk; - - // - // look for a failed response; if the zone transfer - // failed, then we don't need to do anything else at this - // point, and we should just break out. - // - if ($response->header->rcode != Net_DNS2_Lookups::RCODE_NOERROR) { - break; - } - - // - // go through each answer - // - foreach ($response->answer as $index => $rr) { - // - // count the SOA records - // - if ($rr->type == 'SOA') { - $soa_count++; - } - } - - // - // if we have 2 or more SOA records, then we're done; - // otherwise continue out so we read the rest of the - // packets off the socket - // - if ($soa_count >= 2) { - break; - } else { - continue; - } - } else { - // - // go through all these answers, and look for SOA records - // - foreach ($chunk->answer as $index => $rr) { - // - // count the number of SOA records we find - // - if ($rr->type == 'SOA') { - $soa_count++; - } - - // - // add the records to a single response object - // - $response->answer[] = $rr; - } - - // - // if we've found the second SOA record, we're done - // - if ($soa_count >= 2) { - break; - } - } - } - - // - // everything other than a AXFR - // - } else { - $result = $this->sock[Net_DNS2_Socket::SOCK_STREAM][$_ns]->read($size, - ($this->dnssec == true) ? $this->dnssec_payload_size : Net_DNS2_Lookups::DNS_MAX_UDP_SIZE); - - if (($result === false) || ($size < Net_DNS2_Lookups::DNS_HEADER_SIZE)) { - $this->generateError(Net_DNS2_Socket::SOCK_STREAM, $_ns, Net_DNS2_Lookups::E_NS_SOCKET_FAILED); - } - - // - // create the packet object - // - $response = new Net_DNS2_Packet_Response($result, $size); - } - - // - // store the query time - // - $response->response_time = microtime(true) - $start_time; - - // - // add the name server that the response came from to the response object, - // and the socket type that was used. - // - $response->answer_from = $_ns; - $response->answer_socket_type = Net_DNS2_Socket::SOCK_STREAM; - - // - // return the Net_DNS2_Packet_Response object - // - return $response; - } - - /** - * sends a DNS request using UDP - * - * @param string $_ns the name server to use for the request - * @param string $_data the raw DNS packet data - * - * @return Net_DNS2_Packet_Response the response object - * @throws Net_DNS2_Exception - * @access private - * - */ - private function sendUDPRequest($_ns, $_data) { - // - // grab the start time - // - $start_time = microtime(true); - - // - // see if we already have an open socket from a previous request; if so, try to use - // that instead of opening a new one. - // - if ((!isset($this->sock[Net_DNS2_Socket::SOCK_DGRAM][$_ns])) - || (!($this->sock[Net_DNS2_Socket::SOCK_DGRAM][$_ns] instanceof Net_DNS2_Socket)) - ) { - // - // create the socket object - // - $this->sock[Net_DNS2_Socket::SOCK_DGRAM][$_ns] = new Net_DNS2_Socket( - Net_DNS2_Socket::SOCK_DGRAM, $_ns, $this->dns_port, $this->timeout - ); - - // - // if a local IP address / port is set, then add it - // - if (strlen($this->local_host) > 0) { - $this->sock[Net_DNS2_Socket::SOCK_DGRAM][$_ns]->bindAddress( - $this->local_host, $this->local_port - ); - } - - // - // open the socket - // - if ($this->sock[Net_DNS2_Socket::SOCK_DGRAM][$_ns]->open() === false) { - $this->generateError(Net_DNS2_Socket::SOCK_DGRAM, $_ns, Net_DNS2_Lookups::E_NS_SOCKET_FAILED); - } - } - - // - // write the data to the socket - // - if ($this->sock[Net_DNS2_Socket::SOCK_DGRAM][$_ns]->write($_data) === false) { - $this->generateError(Net_DNS2_Socket::SOCK_DGRAM, $_ns, Net_DNS2_Lookups::E_NS_SOCKET_FAILED); - } - - // - // read the content, using select to wait for a response - // - $size = 0; - - $result = $this->sock[Net_DNS2_Socket::SOCK_DGRAM][$_ns]->read($size, - ($this->dnssec == true) ? $this->dnssec_payload_size : Net_DNS2_Lookups::DNS_MAX_UDP_SIZE); - - if (($result === false) || ($size < Net_DNS2_Lookups::DNS_HEADER_SIZE)) { - $this->generateError(Net_DNS2_Socket::SOCK_DGRAM, $_ns, Net_DNS2_Lookups::E_NS_SOCKET_FAILED); - } - - // - // create the packet object - // - $response = new Net_DNS2_Packet_Response($result, $size); - - // - // store the query time - // - $response->response_time = microtime(true) - $start_time; - - // - // add the name server that the response came from to the response object, - // and the socket type that was used. - // - $response->answer_from = $_ns; - $response->answer_socket_type = Net_DNS2_Socket::SOCK_DGRAM; - - // - // return the Net_DNS2_Packet_Response object - // - return $response; - } -} diff --git a/Net/DNS2/BitMap.php b/Net/DNS2/BitMap.php deleted file mode 100644 index 2107f6e4..00000000 --- a/Net/DNS2/BitMap.php +++ /dev/null @@ -1,194 +0,0 @@ -. All rights reserved. - * - * See LICENSE for more details. - * - * @category Networking - * @package Net_DNS2 - * @author Mike Pultz - * @copyright 2020 Mike Pultz - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @link https://netdns2.com/ - * @since File available since Release 0.6.0 - * - */ - -/** - * a class to handle converting RR bitmaps to arrays and back; used on NSEC - * and NSEC3 RR's - * - */ -class Net_DNS2_BitMap { - /** - * parses a RR bitmap field defined in RFC3845, into an array of RR names. - * - * Type Bit Map(s) Field = ( Window Block # | Bitmap Length | Bitmap ) + - * - * @param string $data a bitmap stringto parse - * - * @return array - * @access public - * - */ - public static function bitMapToArray($data) { - if (strlen($data) == 0) { - return []; - } - - $output = []; - $offset = 0; - $length = strlen($data); - - while ($offset < $length) { - // - // unpack the window and length values - // - $x = unpack('@' . $offset . '/Cwindow/Clength', $data); - $offset += 2; - - // - // copy out the bitmap value - // - $bitmap = unpack('C*', substr($data, $offset, $x['length'])); - $offset += $x['length']; - - // - // I'm not sure if there's a better way of doing this, but PHP doesn't - // have a 'B' flag for unpack() - // - $bitstr = ''; - - foreach ($bitmap as $r) { - $bitstr .= sprintf('%08b', $r); - } - - $blen = strlen($bitstr); - - for ($i = 0; $i < $blen; $i++) { - if ($bitstr[$i] == '1') { - $type = $x['window'] * 256 + $i; - - if (isset(Net_DNS2_Lookups::$rr_types_by_id[$type])) { - $output[] = Net_DNS2_Lookups::$rr_types_by_id[$type]; - } else { - $output[] = 'TYPE' . $type; - } - } - } - } - - return $output; - } - - /** - * builds a RR Bit map from an array of RR type names - * - * @param array $data a list of RR names - * - * @return string - * @access public - * - */ - public static function arrayToBitMap(array $data) { - if (cacti_sizeof($data) == 0) { - return ''; - } - - $current_window = 0; - - // - // go through each RR - // - $max = 0; - $bm = []; - - foreach ($data as $rr) { - $rr = strtoupper($rr); - - // - // get the type id for the RR - // - $type = @Net_DNS2_Lookups::$rr_types_by_name[$rr]; - - if (isset($type)) { - // - // skip meta types or qtypes - // - if ((isset(Net_DNS2_Lookups::$rr_qtypes_by_id[$type])) - || (isset(Net_DNS2_Lookups::$rr_metatypes_by_id[$type])) - ) { - continue; - } - } else { - // - // if it's not found, then it must be defined as TYPE, per - // RFC3845 section 2.2, if it's not, we ignore it. - // - [$name, $type] = explode('TYPE', $rr); - - if (!isset($type)) { - continue; - } - } - - // - // build the current window - // - $current_window = (int)($type / 256); - - $val = $type - $current_window * 256.0; - - if ($val > $max) { - $max = $val; - } - - $bm[$current_window][$val] = 1; - $bm[$current_window]['length'] = ceil(($max + 1) / 8); - } - - $output = ''; - - foreach ($bm as $window => $bitdata) { - $bitstr = ''; - - for ($i = 0; $i < $bm[$window]['length'] * 8; $i++) { - if (isset($bm[$window][$i])) { - $bitstr .= '1'; - } else { - $bitstr .= '0'; - } - } - - $output .= pack('CC', $window, $bm[$window]['length']); - $output .= pack('H*', self::bigBaseConvert($bitstr)); - } - - return $output; - } - - /** - * a base_convert that handles large numbers; forced to 2/16 - * - * @param string $number a bit string - * - * @return string - * @access public - * - */ - public static function bigBaseConvert($number) { - $result = ''; - - $bin = substr(chunk_split(strrev($number), 4, '-'), 0, -1); - $temp = preg_split('[-]', $bin, -1, PREG_SPLIT_DELIM_CAPTURE); - - for ($i = cacti_sizeof($temp) - 1; $i >= 0; $i--) { - $result = $result . base_convert(strrev($temp[$i]), 2, 16); - } - - return strtoupper($result); - } -} diff --git a/Net/DNS2/Cache.php b/Net/DNS2/Cache.php deleted file mode 100644 index 19ee6b19..00000000 --- a/Net/DNS2/Cache.php +++ /dev/null @@ -1,236 +0,0 @@ -. All rights reserved. - * - * See LICENSE for more details. - * - * @category Networking - * @package Net_DNS2 - * @author Mike Pultz - * @copyright 2020 Mike Pultz - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @link https://netdns2.com/ - * @since File available since Release 1.1.0 - * - */ - -/** - * A class to provide simple dns lookup caching. - * - */ -class Net_DNS2_Cache { - // the filename of the cache file - protected $cache_file = ''; - - // the local data store for the cache - protected $cache_data = []; - - // the size of the cache to use - protected $cache_size = 0; - - // the cache serializer - protected $cache_serializer; - - /* - * an internal flag to make sure we don't load the cache content more - * than once per instance. - */ - protected $cache_opened = false; - - /** - * returns true/false if the provided key is defined in the cache - * - * @param string $key the key to lookup in the local cache - * - * @return boolean - * @access public - * - */ - public function has($key) { - return isset($this->cache_data[$key]); - } - - /** - * returns the value for the given key - * - * @param string $key the key to lookup in the local cache - * - * @return mixed returns the cache data on success, false on error - * @access public - * - */ - public function get($key) { - if (isset($this->cache_data[$key])) { - if ($this->cache_serializer == 'json') { - return json_decode($this->cache_data[$key]['object']); - } else { - return unserialize($this->cache_data[$key]['object'], ['allowed_classes' => false]); - } - } else { - return false; - } - } - - /** - * adds a new key/value pair to the cache - * - * @param string $key the key for the new cache entry - * @param mixed $data the data to store in cache - * - * @return void - * @access public - * - */ - public function put($key, $data) { - $ttl = 86400 * 365; - - // - // clear the rdata values - // - $data->rdata = ''; - $data->rdlength = 0; - - // - // find the lowest TTL, and use that as the TTL for the whole cached - // object. The downside to using one TTL for the whole object, is that - // we'll invalidate entries before they actually expire, causing a - // real lookup to happen. - // - // The upside is that we don't need to require() each RR type in the - // cache, so we can look at their individual TTL's on each run- we only - // unserialize the actual RR object when it's get() from the cache. - // - foreach ($data->answer as $index => $rr) { - if ($rr->ttl < $ttl) { - $ttl = $rr->ttl; - } - - $rr->rdata = ''; - $rr->rdlength = 0; - } - - foreach ($data->authority as $index => $rr) { - if ($rr->ttl < $ttl) { - $ttl = $rr->ttl; - } - - $rr->rdata = ''; - $rr->rdlength = 0; - } - - foreach ($data->additional as $index => $rr) { - if ($rr->ttl < $ttl) { - $ttl = $rr->ttl; - } - - $rr->rdata = ''; - $rr->rdlength = 0; - } - - $this->cache_data[$key] = [ - 'cache_date' => time(), - 'ttl' => $ttl - ]; - - if ($this->cache_serializer == 'json') { - $this->cache_data[$key]['object'] = json_encode($data); - } else { - $this->cache_data[$key]['object'] = serialize($data); - } - } - - /** - * runs a clean up process on the cache data - * - * @return void - * @access protected - * - */ - protected function clean() { - if (cacti_sizeof($this->cache_data) > 0) { - // - // go through each entry and adjust their TTL, and remove entries that - // have expired - // - $now = time(); - - foreach ($this->cache_data as $key => $data) { - $diff = $now - $data['cache_date']; - - if ($data['ttl'] <= $diff) { - unset($this->cache_data[$key]); - } else { - $this->cache_data[$key]['ttl'] -= $diff; - $this->cache_data[$key]['cache_date'] = $now; - } - } - } - } - - /** - * runs a clean up process on the cache data - * - * @return mixed - * @access protected - * - */ - protected function resize() { - if (cacti_sizeof($this->cache_data) > 0) { - // - // serialize the cache data - // - if ($this->cache_serializer == 'json') { - $cache = json_encode($this->cache_data); - } else { - $cache = serialize($this->cache_data); - } - - // - // only do this part if the size allocated to the cache storage - // is smaller than the actual cache data - // - if (strlen($cache) > $this->cache_size) { - while (strlen($cache) > $this->cache_size) { - // - // go through the data, and remove the entries closed to - // their expiration date. - // - $smallest_ttl = time(); - $smallest_key = null; - - foreach ($this->cache_data as $key => $data) { - if ($data['ttl'] < $smallest_ttl) { - $smallest_ttl = $data['ttl']; - $smallest_key = $key; - } - } - - // - // unset the key with the smallest TTL - // - unset($this->cache_data[$smallest_key]); - - // - // re-serialize - // - if ($this->cache_serializer == 'json') { - $cache = json_encode($this->cache_data); - } else { - $cache = serialize($this->cache_data); - } - } - } - - if (($cache == 'a:0:{}') || ($cache == '{}')) { - return null; - } else { - return $cache; - } - } - - return null; - } -} diff --git a/Net/DNS2/Cache/File.php b/Net/DNS2/Cache/File.php deleted file mode 100644 index 20f8b33f..00000000 --- a/Net/DNS2/Cache/File.php +++ /dev/null @@ -1,189 +0,0 @@ -. All rights reserved. - * - * See LICENSE for more details. - * - * @category Networking - * @package Net_DNS2 - * @author Mike Pultz - * @copyright 2020 Mike Pultz - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @link https://netdns2.com/ - * @since File available since Release 1.1.0 - * - */ - -/** - * File-based caching for the Net_DNS2_Cache class - * - */ -class Net_DNS2_Cache_File extends Net_DNS2_Cache { - /** - * open a cache object - * - * @param string $cache_file path to a file to use for cache storage - * @param integer $size the size of the shared memory segment to create - * @param string $serializer the name of the cache serialize to use - * - * @throws Net_DNS2_Exception - * @access public - * @return void - * - */ - public function open($cache_file, $size, $serializer) { - $this->cache_size = $size; - $this->cache_file = $cache_file; - $this->cache_serializer = $serializer; - - // - // check that the file exists first - // - if (($this->cache_opened == false) - && (file_exists($this->cache_file) == true) - && (filesize($this->cache_file) > 0) - ) { - // - // open the file for reading - // - $fp = @fopen($this->cache_file, 'r'); - - if ($fp !== false) { - // - // lock the file just in case - // - flock($fp, LOCK_EX); - - // - // read the file contents - // - $data = fread($fp, filesize($this->cache_file)); - - $decoded = null; - - if ($this->cache_serializer == 'json') { - $decoded = json_decode($data, true); - } else { - $decoded = unserialize($data, ['allowed_classes' => false]); - } - - if (is_array($decoded) == true) { - $this->cache_data = $decoded; - } else { - $this->cache_data = []; - } - - // - // unlock - // - flock($fp, LOCK_UN); - - // - // close the file - // - fclose($fp); - - // - // clean up the data - // - $this->clean(); - - // - // mark this so we don't read this contents more than once per instance. - // - $this->cache_opened = true; - } - } - } - - /** - * Destructor - * - * @access public - * - */ - public function __destruct() { - // - // if there's no cache file set, then there's nothing to do - // - if (strlen($this->cache_file) == 0) { - return; - } - - // - // open the file for reading/writing - // - $fp = fopen($this->cache_file, 'a+'); - - if ($fp !== false) { - // - // lock the file just in case - // - flock($fp, LOCK_EX); - - // - // seek to the start of the file to read - // - fseek($fp, 0, SEEK_SET); - - // - // read the file contents - // - $data = @fread($fp, filesize($this->cache_file)); - - if (($data !== false) && (strlen($data) > 0)) { - // - // unserialize and store the data - // - $c = $this->cache_data; - - $decoded = null; - - if ($this->cache_serializer == 'json') { - $decoded = json_decode($data, true); - } else { - $decoded = unserialize($data, ['allowed_classes' => false]); - } - - if (is_array($decoded) == true) { - $this->cache_data = array_merge($c, $decoded); - } - } - - // - // trucate the file - // - ftruncate($fp, 0); - - // - // clean the data - // - $this->clean(); - - // - // resize the data - // - $data = $this->resize(); - - if (!is_null($data)) { - // - // write the file contents - // - fwrite($fp, $data); - } - - // - // unlock - // - flock($fp, LOCK_UN); - - // - // close the file - // - fclose($fp); - } - } -} diff --git a/Net/DNS2/Cache/Shm.php b/Net/DNS2/Cache/Shm.php deleted file mode 100644 index d1571ae9..00000000 --- a/Net/DNS2/Cache/Shm.php +++ /dev/null @@ -1,252 +0,0 @@ -. All rights reserved. - * - * See LICENSE for more details. - * - * @category Networking - * @package Net_DNS2 - * @author Mike Pultz - * @copyright 2020 Mike Pultz - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @link https://netdns2.com/ - * @since File available since Release 1.1.0 - * - */ - -/** - * Shared Memory-based caching for the Net_DNS2_Cache class - * - */ -class Net_DNS2_Cache_Shm extends Net_DNS2_Cache { - // resource id of the shared memory cache - private $_cache_id = false; - - // the IPC key - private $_cache_file_tok = -1; - - /** - * open a cache object - * - * @param string $cache_file path to a file to use for cache storage - * @param integer $size the size of the shared memory segment to create - * @param string $serializer the name of the cache serialize to use - * - * @throws Net_DNS2_Exception - * @access public - * @return void - * - */ - public function open($cache_file, $size, $serializer) { - $this->cache_size = $size; - $this->cache_file = $cache_file; - $this->cache_serializer = $serializer; - - // - // if we've already loaded the cache data, then just return right away - // - if ($this->cache_opened == true) { - return; - } - - // - // make sure the file exists first - // - if (!file_exists($cache_file)) { - if (file_put_contents($cache_file, '') === false) { - throw new Net_DNS2_Exception( - 'failed to create empty SHM file: ' . $cache_file, - Net_DNS2_Lookups::E_CACHE_SHM_FILE - ); - } - } - - // - // convert the filename to a IPC key - // - $this->_cache_file_tok = ftok($cache_file, 't'); - - if ($this->_cache_file_tok == -1) { - throw new Net_DNS2_Exception( - 'failed on ftok() file: ' . $this->_cache_file_tok, - Net_DNS2_Lookups::E_CACHE_SHM_FILE - ); - } - - // - // try to open an existing cache; if it doesn't exist, then there's no - // cache, and nothing to do. - // - $this->_cache_id = @shmop_open($this->_cache_file_tok, 'w', 0, 0); - - if ($this->_cache_id !== false) { - // - // this returns the size allocated, and not the size used, but it's - // still a good check to make sure there's space allocated. - // - $allocated = shmop_size($this->_cache_id); - - if ($allocated > 0) { - // - // read the data from the shared memory segment - // - $data = trim(shmop_read($this->_cache_id, 0, $allocated)); - - if (($data !== false) && (strlen($data) > 0)) { - // - // unserialize and store the data - // - $decoded = null; - - if ($this->cache_serializer == 'json') { - $decoded = json_decode($data, true); - } else { - $decoded = unserialize($data, ['allowed_classes' => false]); - } - - if (is_array($decoded) == true) { - $this->cache_data = $decoded; - } else { - $this->cache_data = []; - } - - // - // call clean to clean up old entries - // - $this->clean(); - - // - // mark the cache as loaded, so we don't load it more than once - // - $this->cache_opened = true; - } - } - } - } - - /** - * Destructor - * - * @access public - * - */ - public function __destruct() { - // - // if there's no cache file set, then there's nothing to do - // - if (strlen($this->cache_file) == 0) { - return; - } - - $fp = fopen($this->cache_file, 'r'); - - if ($fp !== false) { - // - // lock the file - // - flock($fp, LOCK_EX); - - // - // check to see if we have an open shm segment - // - if ($this->_cache_id === false) { - // - // try opening it again, incase it was created by another - // process in the mean time - // - $this->_cache_id = @shmop_open( - $this->_cache_file_tok, 'w', 0, 0 - ); - - if ($this->_cache_id === false) { - // - // otherwise, create it. - // - $this->_cache_id = @shmop_open( - $this->_cache_file_tok, 'c', 0, $this->cache_size - ); - } - } - - // - // get the size allocated to the segment - // - $allocated = shmop_size($this->_cache_id); - - // - // read the contents - // - $data = trim(shmop_read($this->_cache_id, 0, $allocated)); - - // - // if there was some data - // - if (($data !== false) && (strlen($data) > 0)) { - // - // unserialize and store the data - // - $c = $this->cache_data; - - $decoded = null; - - if ($this->cache_serializer == 'json') { - $decoded = json_decode($data, true); - } else { - $decoded = unserialize($data, ['allowed_classes' => false]); - } - - if (is_array($decoded) == true) { - $this->cache_data = array_merge($c, $decoded); - } - } - - // - // delete the segment - // - shmop_delete($this->_cache_id); - - // - // clean the data - // - $this->clean(); - - // - // clean up and write the data - // - $data = $this->resize(); - - if (!is_null($data)) { - // - // re-create segment - // - $this->_cache_id = @shmop_open( - $this->_cache_file_tok, 'c', 0644, $this->cache_size - ); - - if ($this->_cache_id === false) { - return; - } - - $o = shmop_write($this->_cache_id, $data, 0); - } - - // - // close the segment - // - shmop_close($this->_cache_id); - - // - // unlock - // - flock($fp, LOCK_UN); - - // - // close the file - // - fclose($fp); - } - } -} diff --git a/Net/DNS2/Exception.php b/Net/DNS2/Exception.php deleted file mode 100644 index 4cd70299..00000000 --- a/Net/DNS2/Exception.php +++ /dev/null @@ -1,91 +0,0 @@ -. All rights reserved. - * - * See LICENSE for more details. - * - * @category Networking - * @package Net_DNS2 - * @author Mike Pultz - * @copyright 2020 Mike Pultz - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @link https://netdns2.com/ - * @since File available since Release 0.6.0 - * - */ - -/** - * Exception handler used by Net_DNS2 - * - */ -class Net_DNS2_Exception extends Exception { - private $_request; - private $_response; - - /** - * Constructor - overload the constructor so we can pass in the request - * and response object (when it's available) - * - * @param string $message the exception message - * @param int $code the exception code - * @param object $previous the previous Exception object - * @param object $request the Net_DNS2_Packet_Request object for this request - * @param object $response the Net_DNS2_Packet_Response object for this request - * - * @access public - * - */ - public function __construct( - $message = '', - $code = 0, - $previous = null, - Net_DNS2_Packet_Request $request = null, - Net_DNS2_Packet_Response $response = null - ) { - // - // store the request/response objects (if passed) - // - $this->_request = $request; - $this->_response = $response; - - // - // call the parent constructor - // - // the "previous" argument was added in PHP 5.3.0 - // - // https://code.google.com/p/netdns2/issues/detail?id=25 - // - if (version_compare(PHP_VERSION, '5.3.0', '>=') == true) { - parent::__construct($message, $code, $previous); - } else { - parent::__construct($message, $code); - } - } - - /** - * returns the Net_DNS2_Packet_Request object (if available) - * - * @return Net_DNS2_Packet_Request object - * @access public - * @since function available since release 1.3.1 - * - */ - public function getRequest() { - return $this->_request; - } - - /** - * returns the Net_DNS2_Packet_Response object (if available) - * - * @return Net_DNS2_Packet_Response object - * @access public - * @since function available since release 1.3.1 - * - */ - public function getResponse() { - return $this->_response; - } -} diff --git a/Net/DNS2/Header.php b/Net/DNS2/Header.php deleted file mode 100644 index 656561ef..00000000 --- a/Net/DNS2/Header.php +++ /dev/null @@ -1,219 +0,0 @@ -. All rights reserved. - * - * See LICENSE for more details. - * - * @category Networking - * @package Net_DNS2 - * @author Mike Pultz - * @copyright 2020 Mike Pultz - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @link https://netdns2.com/ - * @since File available since Release 0.6.0 - * - */ - -/** - * DNS Packet Header class - * - * This class handles parsing and constructing DNS Packet Headers as defined - * by section 4.1.1 of RFC1035. - * - * DNS header format - RFC1035 section 4.1.1 - * DNS header format - RFC4035 section 3.2 - * - * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 - * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ - * | ID | - * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ - * |QR| Opcode |AA|TC|RD|RA| Z|AD|CD| RCODE | - * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ - * | QDCOUNT | - * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ - * | ANCOUNT | - * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ - * | NSCOUNT | - * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ - * | ARCOUNT | - * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ - * - */ -class Net_DNS2_Header { - public $id; // 16 bit - identifier - public $qr; // 1 bit - 0 = query, 1 = response - public $opcode; // 4 bit - op code - public $aa; // 1 bit - Authoritative Answer - public $tc; // 1 bit - Truncation - public $rd; // 1 bit - Recursion Desired - public $ra; // 1 bit - Recursion Available - public $z; // 1 bit - Reserved - public $ad; // 1 bit - Authentic Data (RFC4035) - public $cd; // 1 bit - Checking Disabled (RFC4035) - public $rcode; // 4 bit - Response code - public $qdcount; // 16 bit - entries in the question section - public $ancount; // 16 bit - resource records in the answer section - public $nscount; // 16 bit - name server rr in the authority records section - public $arcount; // 16 bit - rr's in the additional records section - - /** - * Constructor - builds a new Net_DNS2_Header object - * - * @param mixed &$packet either a Net_DNS2_Packet object or null - * - * @throws Net_DNS2_Exception - * @access public - * - */ - public function __construct(Net_DNS2_Packet &$packet = null) { - if (!is_null($packet)) { - $this->set($packet); - } else { - $this->id = $this->nextPacketId(); - $this->qr = Net_DNS2_Lookups::QR_QUERY; - $this->opcode = Net_DNS2_Lookups::OPCODE_QUERY; - $this->aa = 0; - $this->tc = 0; - $this->rd = 1; - $this->ra = 0; - $this->z = 0; - $this->ad = 0; - $this->cd = 0; - $this->rcode = Net_DNS2_Lookups::RCODE_NOERROR; - $this->qdcount = 1; - $this->ancount = 0; - $this->nscount = 0; - $this->arcount = 0; - } - } - - /** - * returns the next available packet id - * - * @return integer - * @access public - * - */ - public function nextPacketId() { - if (++Net_DNS2_Lookups::$next_packet_id > 65535) { - Net_DNS2_Lookups::$next_packet_id = 1; - } - - return Net_DNS2_Lookups::$next_packet_id; - } - - /** - * magic __toString() method to return the header as a string - * - * @return string - * @access public - * - */ - public function __toString() { - $output = ";;\n;; Header:\n"; - - $output .= ";;\t id = " . $this->id . "\n"; - $output .= ";;\t qr = " . $this->qr . "\n"; - $output .= ";;\t opcode = " . $this->opcode . "\n"; - $output .= ";;\t aa = " . $this->aa . "\n"; - $output .= ";;\t tc = " . $this->tc . "\n"; - $output .= ";;\t rd = " . $this->rd . "\n"; - $output .= ";;\t ra = " . $this->ra . "\n"; - $output .= ";;\t z = " . $this->z . "\n"; - $output .= ";;\t ad = " . $this->ad . "\n"; - $output .= ";;\t cd = " . $this->cd . "\n"; - $output .= ";;\t rcode = " . $this->rcode . "\n"; - $output .= ";;\t qdcount = " . $this->qdcount . "\n"; - $output .= ";;\t ancount = " . $this->ancount . "\n"; - $output .= ";;\t nscount = " . $this->nscount . "\n"; - $output .= ";;\t arcount = " . $this->arcount . "\n"; - - return $output; - } - - /** - * constructs a Net_DNS2_Header from a Net_DNS2_Packet object - * - * @param Net_DNS2_Packet &$packet Object - * - * @return boolean - * @throws Net_DNS2_Exception - * @access public - * - */ - public function set(Net_DNS2_Packet &$packet) { - // - // the header must be at least 12 bytes long. - // - if ($packet->rdlength < Net_DNS2_Lookups::DNS_HEADER_SIZE) { - throw new Net_DNS2_Exception( - 'invalid header data provided; too small', - Net_DNS2_Lookups::E_HEADER_INVALID - ); - } - - $offset = 0; - - // - // parse the values - // - $this->id = ord($packet->rdata[$offset]) << 8 | - ord($packet->rdata[++$offset]); - - ++$offset; - $this->qr = (ord($packet->rdata[$offset]) >> 7) & 0x1; - $this->opcode = (ord($packet->rdata[$offset]) >> 3) & 0xf; - $this->aa = (ord($packet->rdata[$offset]) >> 2) & 0x1; - $this->tc = (ord($packet->rdata[$offset]) >> 1) & 0x1; - $this->rd = ord($packet->rdata[$offset]) & 0x1; - - ++$offset; - $this->ra = (ord($packet->rdata[$offset]) >> 7) & 0x1; - $this->z = (ord($packet->rdata[$offset]) >> 6) & 0x1; - $this->ad = (ord($packet->rdata[$offset]) >> 5) & 0x1; - $this->cd = (ord($packet->rdata[$offset]) >> 4) & 0x1; - $this->rcode = ord($packet->rdata[$offset]) & 0xf; - - $this->qdcount = ord($packet->rdata[++$offset]) << 8 | - ord($packet->rdata[++$offset]); - $this->ancount = ord($packet->rdata[++$offset]) << 8 | - ord($packet->rdata[++$offset]); - $this->nscount = ord($packet->rdata[++$offset]) << 8 | - ord($packet->rdata[++$offset]); - $this->arcount = ord($packet->rdata[++$offset]) << 8 | - ord($packet->rdata[++$offset]); - - // - // increment the internal offset - // - $packet->offset += Net_DNS2_Lookups::DNS_HEADER_SIZE; - - return true; - } - - /** - * returns a binary packed DNS Header - * - * @param Net_DNS2_Packet &$packet Object - * - * @return string - * @access public - * - */ - public function get(Net_DNS2_Packet &$packet) { - $packet->offset += Net_DNS2_Lookups::DNS_HEADER_SIZE; - - return pack('n', $this->id) . - chr( - ($this->qr << 7) | ($this->opcode << 3) | - ($this->aa << 2) | ($this->tc << 1) | ($this->rd) - ) . - chr( - ($this->ra << 7) | ($this->ad << 5) | ($this->cd << 4) | $this->rcode - ) . - pack('n4', $this->qdcount, $this->ancount, $this->nscount, $this->arcount); - } -} diff --git a/Net/DNS2/Lookups.php b/Net/DNS2/Lookups.php deleted file mode 100644 index 099e8fba..00000000 --- a/Net/DNS2/Lookups.php +++ /dev/null @@ -1,513 +0,0 @@ -. All rights reserved. - * - * See LICENSE for more details. - * - * @category Networking - * @package Net_DNS2 - * @author Mike Pultz - * @copyright 2020 Mike Pultz - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @link https://netdns2.com/ - * @since File available since Release 0.6.0 - * - */ - -// -// initialize the packet id value -// -Net_DNS2_Lookups::$next_packet_id = mt_rand(0, 65535); - -// -// build the reverse lookup tables; this is just so we don't have to -// have duplicate static content laying around. -// -Net_DNS2_Lookups::$rr_types_by_id = array_flip(Net_DNS2_Lookups::$rr_types_by_name); -Net_DNS2_Lookups::$classes_by_id = array_flip(Net_DNS2_Lookups::$classes_by_name); -Net_DNS2_Lookups::$rr_types_class_to_id = array_flip(Net_DNS2_Lookups::$rr_types_id_to_class); -Net_DNS2_Lookups::$algorithm_name_to_id = array_flip(Net_DNS2_Lookups::$algorithm_id_to_name); -Net_DNS2_Lookups::$digest_name_to_id = array_flip(Net_DNS2_Lookups::$digest_id_to_name); -Net_DNS2_Lookups::$rr_qtypes_by_id = array_flip(Net_DNS2_Lookups::$rr_qtypes_by_name); -Net_DNS2_Lookups::$rr_metatypes_by_id = array_flip(Net_DNS2_Lookups::$rr_metatypes_by_name); -Net_DNS2_Lookups::$protocol_by_id = array_flip(Net_DNS2_Lookups::$protocol_by_name); - -/** - * This class provides simple lookups used throughout the Net_DNS2 code - * - */ -class Net_DNS2_Lookups { - // size (in bytes) of a header in a standard DNS packet - const DNS_HEADER_SIZE = 12; - - // max size of a UDP packet - const DNS_MAX_UDP_SIZE = 512; - - // Query/Response flag - const QR_QUERY = 0; // RFC 1035 - const QR_RESPONSE = 1; // RFC 1035 - - // DNS Op Codes - const OPCODE_QUERY = 0; // RFC 1035 - const OPCODE_IQUERY = 1; // RFC 1035, RFC 3425 - const OPCODE_STATUS = 2; // RFC 1035 - const OPCODE_NOTIFY = 4; // RFC 1996 - const OPCODE_UPDATE = 5; // RFC 2136 - const OPCODE_DSO = 6; // RFC 8490 - - // Resource Record Classes - const RR_CLASS_IN = 1; // RFC 1035 - const RR_CLASS_CH = 3; // RFC 1035 - const RR_CLASS_HS = 4; // RFC 1035 - const RR_CLASS_NONE = 254; // RFC 2136 - const RR_CLASS_ANY = 255; // RFC 1035 - - // DNS Response Codes - const RCODE_NOERROR = 0; // RFC 1035 - const RCODE_FORMERR = 1; // RFC 1035 - const RCODE_SERVFAIL = 2; // RFC 1035 - const RCODE_NXDOMAIN = 3; // RFC 1035 - const RCODE_NOTIMP = 4; // RFC 1035 - const RCODE_REFUSED = 5; // RFC 1035 - const RCODE_YXDOMAIN = 6; // RFC 2136 - const RCODE_YXRRSET = 7; // RFC 2136 - const RCODE_NXRRSET = 8; // RFC 2136 - const RCODE_NOTAUTH = 9; // RFC 2136 - const RCODE_NOTZONE = 10; // RFC 2136 - const RCODE_DSOTYPENI = 11; // RFC 8490 - - // 12-15 reserved - - const RCODE_BADSIG = 16; // RFC 2845 - const RCODE_BADVERS = 16; // RFC 6891 - const RCODE_BADKEY = 17; // RFC 2845 - const RCODE_BADTIME = 18; // RFC 2845 - const RCODE_BADMODE = 19; // RFC 2930 - const RCODE_BADNAME = 20; // RFC 2930 - const RCODE_BADALG = 21; // RFC 2930 - const RCODE_BADTRUNC = 22; // RFC 4635 - const RCODE_BADCOOKIE = 23; // RFC 7873 - - // internal errors codes returned by the exceptions class - const E_NONE = 0; - const E_DNS_FORMERR = self::RCODE_FORMERR; - const E_DNS_SERVFAIL = self::RCODE_SERVFAIL; - const E_DNS_NXDOMAIN = self::RCODE_NXDOMAIN; - const E_DNS_NOTIMP = self::RCODE_NOTIMP; - const E_DNS_REFUSED = self::RCODE_REFUSED; - const E_DNS_YXDOMAIN = self::RCODE_YXDOMAIN; - const E_DNS_YXRRSET = self::RCODE_YXRRSET; - const E_DNS_NXRRSET = self::RCODE_NXRRSET; - const E_DNS_NOTAUTH = self::RCODE_NOTAUTH; - const E_DNS_NOTZONE = self::RCODE_NOTZONE; - - // 11-15 reserved - - const E_DNS_BADSIG = self::RCODE_BADSIG; - const E_DNS_BADKEY = self::RCODE_BADKEY; - const E_DNS_BADTIME = self::RCODE_BADTIME; - const E_DNS_BADMODE = self::RCODE_BADMODE; - const E_DNS_BADNAME = self::RCODE_BADNAME; - const E_DNS_BADALG = self::RCODE_BADALG; - const E_DNS_BADTRUNC = self::RCODE_BADTRUNC; - const E_DNS_BADCOOKIE = self::RCODE_BADCOOKIE; - - // other error conditions - - const E_NS_INVALID_FILE = 200; - const E_NS_INVALID_ENTRY = 201; - const E_NS_FAILED = 202; - const E_NS_SOCKET_FAILED = 203; - const E_NS_INVALID_SOCKET = 204; - - const E_PACKET_INVALID = 300; - const E_PARSE_ERROR = 301; - const E_HEADER_INVALID = 302; - const E_QUESTION_INVALID = 303; - const E_RR_INVALID = 304; - - const E_OPENSSL_ERROR = 400; - const E_OPENSSL_UNAVAIL = 401; - const E_OPENSSL_INV_PKEY = 402; - const E_OPENSSL_INV_ALGO = 403; - - const E_CACHE_UNSUPPORTED = 500; - const E_CACHE_SHM_FILE = 501; - const E_CACHE_SHM_UNAVAIL = 502; - - // EDNS0 Option Codes (OPT) - // 0 - Reserved - const EDNS0_OPT_LLQ = 1; - const EDNS0_OPT_UL = 2; - const EDNS0_OPT_NSID = 3; - // 4 - Reserved - const EDNS0_OPT_DAU = 5; - const EDNS0_OPT_DHU = 6; - const EDNS0_OPT_N3U = 7; - const EDNS0_OPT_CLIENT_SUBNET = 8; - const EDNS0_OPT_EXPIRE = 9; - const EDNS0_OPT_COOKIE = 10; - const EDNS0_OPT_TCP_KEEPALIVE = 11; - const EDNS0_OPT_PADDING = 12; - const EDNS0_OPT_CHAIN = 13; - const EDNS0_OPT_KEY_TAG = 14; - // 15 - unsassigned - const EDNS0_OPT_CLIENT_TAG = 16; - const EDNS0_OPT_SERVER_TAG = 17; - // 18-26945 - unassigned - const EDNS0_OPT_DEVICEID = 26946; - - // DNSSEC Algorithms - const DNSSEC_ALGORITHM_RES = 0; - const DNSSEC_ALGORITHM_RSAMD5 = 1; - const DNSSEC_ALGORITHM_DH = 2; - const DNSSEC_ALGORITHM_DSA = 3; - const DNSSEC_ALGORITHM_ECC = 4; - const DNSSEC_ALGORITHM_RSASHA1 = 5; - const DNSSEC_ALGORITHM_DSANSEC3SHA1 = 6; - const DSNSEC_ALGORITHM_RSASHA1NSEC3SHA1 = 7; - const DNSSEC_ALGORITHM_RSASHA256 = 8; - const DNSSEC_ALGORITHM_RSASHA512 = 10; - const DNSSEC_ALGORITHM_ECCGOST = 12; - const DNSSEC_ALGORITHM_ECDSAP256SHA256 = 13; - const DNSSEC_ALGORITHM_ECDSAP384SHA384 = 14; - const DNSSEC_ALGORITHM_ED25519 = 15; - const DNSSEC_ALGORITHM_ED448 = 16; - const DNSSEC_ALGORITHM_INDIRECT = 252; - const DNSSEC_ALGORITHM_PRIVATEDNS = 253; - const DNSSEC_ALGORITHM_PRIVATEOID = 254; - - // DNSSEC Digest Types - const DNSSEC_DIGEST_RES = 0; - const DNSSEC_DIGEST_SHA1 = 1; - const DNSSEC_DIGEST_SHA256 = 2; - const DNSSEC_DIGEST_GOST = 3; - const DNSSEC_DIGEST_SHA384 = 4; - - // The packet id used when sending requests - public static $next_packet_id; - - // Used to map resource record types to their id's, and back - public static $rr_types_by_id = []; - public static $rr_types_by_name = [ - 'SIG0' => 0, // RFC 2931 pseudo type - 'A' => 1, // RFC 1035 - 'NS' => 2, // RFC 1035 - 'MD' => 3, // RFC 1035 - obsolete, Not implemented - 'MF' => 4, // RFC 1035 - obsolete, Not implemented - 'CNAME' => 5, // RFC 1035 - 'SOA' => 6, // RFC 1035 - 'MB' => 7, // RFC 1035 - obsolete, Not implemented - 'MG' => 8, // RFC 1035 - obsolete, Not implemented - 'MR' => 9, // RFC 1035 - obsolete, Not implemented - 'NULL' => 10, // RFC 1035 - obsolete, Not implemented - 'WKS' => 11, // RFC 1035 - 'PTR' => 12, // RFC 1035 - 'HINFO' => 13, // RFC 1035 - 'MINFO' => 14, // RFC 1035 - obsolete, Not implemented - 'MX' => 15, // RFC 1035 - 'TXT' => 16, // RFC 1035 - 'RP' => 17, // RFC 1183 - 'AFSDB' => 18, // RFC 1183 - 'X25' => 19, // RFC 1183 - 'ISDN' => 20, // RFC 1183 - 'RT' => 21, // RFC 1183 - 'NSAP' => 22, // RFC 1706 - 'NSAP_PTR' => 23, // RFC 1348 - obsolete, Not implemented - 'SIG' => 24, // RFC 2535 - 'KEY' => 25, // RFC 2535, RFC 2930 - 'PX' => 26, // RFC 2163 - 'GPOS' => 27, // RFC 1712 - Not implemented - 'AAAA' => 28, // RFC 3596 - 'LOC' => 29, // RFC 1876 - 'NXT' => 30, // RFC 2065, obsoleted by by RFC 3755 - 'EID' => 31, // [Patton][Patton1995] - 'NIMLOC' => 32, // [Patton][Patton1995] - 'SRV' => 33, // RFC 2782 - 'ATMA' => 34, // Windows only - 'NAPTR' => 35, // RFC 2915 - 'KX' => 36, // RFC 2230 - 'CERT' => 37, // RFC 4398 - 'A6' => 38, // downgraded to experimental by RFC 3363 - 'DNAME' => 39, // RFC 2672 - 'SINK' => 40, // Not implemented - 'OPT' => 41, // RFC 2671 - 'APL' => 42, // RFC 3123 - 'DS' => 43, // RFC 4034 - 'SSHFP' => 44, // RFC 4255 - 'IPSECKEY' => 45, // RFC 4025 - 'RRSIG' => 46, // RFC 4034 - 'NSEC' => 47, // RFC 4034 - 'DNSKEY' => 48, // RFC 4034 - 'DHCID' => 49, // RFC 4701 - 'NSEC3' => 50, // RFC 5155 - 'NSEC3PARAM' => 51, // RFC 5155 - 'TLSA' => 52, // RFC 6698 - 'SMIMEA' => 53, // RFC 8162 - - // 54 unassigned - - 'HIP' => 55, // RFC 5205 - 'NINFO' => 56, // Not implemented - 'RKEY' => 57, // Not implemented - 'TALINK' => 58, // - 'CDS' => 59, // RFC 7344 - 'CDNSKEY' => 60, // RFC 7344 - 'OPENPGPKEY' => 61, // RFC 7929 - 'CSYNC' => 62, // RFC 7477 - 'ZONEMD' => 63, // Not implemented yet - 'SVCB' => 64, // Not implemented yet - 'HTTPS' => 65, // Not implemented yet - - // 66 - 98 unassigned - - 'SPF' => 99, // RFC 4408 - 'UINFO' => 100, // no RFC, Not implemented - 'UID' => 101, // no RFC, Not implemented - 'GID' => 102, // no RFC, Not implemented - 'UNSPEC' => 103, // no RFC, Not implemented - 'NID' => 104, // RFC 6742 - 'L32' => 105, // RFC 6742 - 'L64' => 106, // RFC 6742 - 'LP' => 107, // RFC 6742 - 'EUI48' => 108, // RFC 7043 - 'EUI64' => 109, // RFC 7043 - - // 110 - 248 unassigned - - 'TKEY' => 249, // RFC 2930 - 'TSIG' => 250, // RFC 2845 - 'IXFR' => 251, // RFC 1995 - only a full (AXFR) is supported - 'AXFR' => 252, // RFC 1035 - 'MAILB' => 253, // RFC 883, Not implemented - 'MAILA' => 254, // RFC 973, Not implemented - 'ANY' => 255, // RFC 1035 - we support both 'ANY' and '*' - 'URI' => 256, // RFC 7553 - 'CAA' => 257, // RFC 8659 - 'AVC' => 258, // Application Visibility and Control - 'DOA' => 259, // Not implemented yet - 'AMTRELAY' => 260, // RFC 8777 - - // 261 - 32767 unassigned - - 'TA' => 32768, // same as DS - 'DLV' => 32769, // RFC 4431 - 'TYPE65534' => 65534 // Private Bind record - ]; - - // Qtypes and Metatypes - defined in RFC2929 section 3.1 - public static $rr_qtypes_by_id = []; - public static $rr_qtypes_by_name = [ - 'IXFR' => 251, // RFC 1995 - only a full (AXFR) is supported - 'AXFR' => 252, // RFC 1035 - 'MAILB' => 253, // RFC 883, Not implemented - 'MAILA' => 254, // RFC 973, Not implemented - 'ANY' => 255 // RFC 1035 - we support both 'ANY' and '*' - ]; - - public static $rr_metatypes_by_id = []; - public static $rr_metatypes_by_name = [ - 'OPT' => 41, // RFC 2671 - 'TKEY' => 249, // RFC 2930 - 'TSIG' => 250 // RFC 2845 - ]; - - // used to map resource record id's to RR class names - public static $rr_types_class_to_id = []; - public static $rr_types_id_to_class = [ - 1 => 'Net_DNS2_RR_A', - 2 => 'Net_DNS2_RR_NS', - 5 => 'Net_DNS2_RR_CNAME', - 6 => 'Net_DNS2_RR_SOA', - 11 => 'Net_DNS2_RR_WKS', - 12 => 'Net_DNS2_RR_PTR', - 13 => 'Net_DNS2_RR_HINFO', - 15 => 'Net_DNS2_RR_MX', - 16 => 'Net_DNS2_RR_TXT', - 17 => 'Net_DNS2_RR_RP', - 18 => 'Net_DNS2_RR_AFSDB', - 19 => 'Net_DNS2_RR_X25', - 20 => 'Net_DNS2_RR_ISDN', - 21 => 'Net_DNS2_RR_RT', - 22 => 'Net_DNS2_RR_NSAP', - 24 => 'Net_DNS2_RR_SIG', - 25 => 'Net_DNS2_RR_KEY', - 26 => 'Net_DNS2_RR_PX', - 28 => 'Net_DNS2_RR_AAAA', - 29 => 'Net_DNS2_RR_LOC', - 31 => 'Net_DNS2_RR_EID', - 32 => 'Net_DNS2_RR_NIMLOC', - 33 => 'Net_DNS2_RR_SRV', - 34 => 'Net_DNS2_RR_ATMA', - 35 => 'Net_DNS2_RR_NAPTR', - 36 => 'Net_DNS2_RR_KX', - 37 => 'Net_DNS2_RR_CERT', - 39 => 'Net_DNS2_RR_DNAME', - 41 => 'Net_DNS2_RR_OPT', - 42 => 'Net_DNS2_RR_APL', - 43 => 'Net_DNS2_RR_DS', - 44 => 'Net_DNS2_RR_SSHFP', - 45 => 'Net_DNS2_RR_IPSECKEY', - 46 => 'Net_DNS2_RR_RRSIG', - 47 => 'Net_DNS2_RR_NSEC', - 48 => 'Net_DNS2_RR_DNSKEY', - 49 => 'Net_DNS2_RR_DHCID', - 50 => 'Net_DNS2_RR_NSEC3', - 51 => 'Net_DNS2_RR_NSEC3PARAM', - 52 => 'Net_DNS2_RR_TLSA', - 53 => 'Net_DNS2_RR_SMIMEA', - 55 => 'Net_DNS2_RR_HIP', - 58 => 'Net_DNS2_RR_TALINK', - 59 => 'Net_DNS2_RR_CDS', - 60 => 'Net_DNS2_RR_CDNSKEY', - 61 => 'Net_DNS2_RR_OPENPGPKEY', - 62 => 'Net_DNS2_RR_CSYNC', - 99 => 'Net_DNS2_RR_SPF', - 104 => 'Net_DNS2_RR_NID', - 105 => 'Net_DNS2_RR_L32', - 106 => 'Net_DNS2_RR_L64', - 107 => 'Net_DNS2_RR_LP', - 108 => 'Net_DNS2_RR_EUI48', - 109 => 'Net_DNS2_RR_EUI64', - - 249 => 'Net_DNS2_RR_TKEY', - 250 => 'Net_DNS2_RR_TSIG', - - // 251 - IXFR - handled as a full zone transfer (252) - // 252 - AXFR - handled as a function call - - 255 => 'Net_DNS2_RR_ANY', - 256 => 'Net_DNS2_RR_URI', - 257 => 'Net_DNS2_RR_CAA', - 258 => 'Net_DNS2_RR_AVC', - 260 => 'Net_DNS2_RR_AMTRELAY', - 32768 => 'Net_DNS2_RR_TA', - 32769 => 'Net_DNS2_RR_DLV', - 65534 => 'Net_DNS2_RR_TYPE65534' - ]; - - // used to map resource record class names to their id's, and back - public static $classes_by_id = []; - public static $classes_by_name = [ - 'IN' => self::RR_CLASS_IN, // RFC 1035 - 'CH' => self::RR_CLASS_CH, // RFC 1035 - 'HS' => self::RR_CLASS_HS, // RFC 1035 - 'NONE' => self::RR_CLASS_NONE, // RFC 2136 - 'ANY' => self::RR_CLASS_ANY // RFC 1035 - ]; - - // maps response codes to error messages - public static $result_code_messages = [ - self::RCODE_NOERROR => 'The request completed successfully.', - self::RCODE_FORMERR => 'The name server was unable to interpret the query.', - self::RCODE_SERVFAIL => 'The name server was unable to process this query due to a problem with the name server.', - self::RCODE_NXDOMAIN => 'The domain name referenced in the query does not exist.', - self::RCODE_NOTIMP => 'The name server does not support the requested kind of query.', - self::RCODE_REFUSED => 'The name server refuses to perform the specified operation for policy reasons.', - self::RCODE_YXDOMAIN => 'Name Exists when it should not.', - self::RCODE_YXRRSET => 'RR Set Exists when it should not.', - self::RCODE_NXRRSET => 'RR Set that should exist does not.', - self::RCODE_NOTAUTH => 'Server Not Authoritative for zone.', - self::RCODE_NOTZONE => 'Name not contained in zone.', - - self::RCODE_BADSIG => 'TSIG Signature Failure.', - self::RCODE_BADKEY => 'Key not recognized.', - self::RCODE_BADTIME => 'Signature out of time window.', - self::RCODE_BADMODE => 'Bad TKEY Mode.', - self::RCODE_BADNAME => 'Duplicate key name.', - self::RCODE_BADALG => 'Algorithm not supported.', - self::RCODE_BADTRUNC => 'Bad truncation.' - ]; - - // maps DNS SEC alrorithms to their mnemonics - public static $algorithm_name_to_id = []; - public static $algorithm_id_to_name = [ - self::DNSSEC_ALGORITHM_RES => 'RES', - self::DNSSEC_ALGORITHM_RSAMD5 => 'RSAMD5', - self::DNSSEC_ALGORITHM_DH => 'DH', - self::DNSSEC_ALGORITHM_DSA => 'DSA', - self::DNSSEC_ALGORITHM_ECC => 'ECC', - self::DNSSEC_ALGORITHM_RSASHA1 => 'RSASHA1', - self::DNSSEC_ALGORITHM_DSANSEC3SHA1 => 'DSA-NSEC3-SHA1', - self::DSNSEC_ALGORITHM_RSASHA1NSEC3SHA1 => 'RSASHA1-NSEC3-SHA1', - self::DNSSEC_ALGORITHM_RSASHA256 => 'RSASHA256', - self::DNSSEC_ALGORITHM_RSASHA512 => 'RSASHA512', - self::DNSSEC_ALGORITHM_ECCGOST => 'ECC-GOST', - self::DNSSEC_ALGORITHM_ECDSAP256SHA256 => 'ECDSAP256SHA256', - self::DNSSEC_ALGORITHM_ECDSAP384SHA384 => 'ECDSAP384SHA384', - self::DNSSEC_ALGORITHM_ED25519 => 'ED25519', - self::DNSSEC_ALGORITHM_ED448 => 'ED448', - self::DNSSEC_ALGORITHM_INDIRECT => 'INDIRECT', - self::DNSSEC_ALGORITHM_PRIVATEDNS => 'PRIVATEDNS', - self::DNSSEC_ALGORITHM_PRIVATEOID => 'PRIVATEOID' - ]; - - // maps DNSSEC digest types to their mnemonics - public static $digest_name_to_id = []; - public static $digest_id_to_name = [ - self::DNSSEC_DIGEST_RES => 'RES', - self::DNSSEC_DIGEST_SHA1 => 'SHA-1', - self::DNSSEC_DIGEST_SHA256 => 'SHA-256', - self::DNSSEC_DIGEST_GOST => 'GOST-R-34.11-94', - self::DNSSEC_DIGEST_SHA384 => 'SHA-384' - ]; - - // Protocols names - RFC 1010 - public static $protocol_by_id = []; - public static $protocol_by_name = [ - 'ICMP' => 1, - 'IGMP' => 2, - 'GGP' => 3, - 'ST' => 5, - 'TCP' => 6, - 'UCL' => 7, - 'EGP' => 8, - 'IGP' => 9, - 'BBN-RCC-MON' => 10, - 'NVP-II' => 11, - 'PUP' => 12, - 'ARGUS' => 13, - 'EMCON' => 14, - 'XNET' => 15, - 'CHAOS' => 16, - 'UDP' => 17, - 'MUX' => 18, - 'DCN-MEAS' => 19, - 'HMP' => 20, - 'PRM' => 21, - 'XNS-IDP' => 22, - 'TRUNK-1' => 23, - 'TRUNK-2' => 24, - 'LEAF-1' => 25, - 'LEAF-2' => 26, - 'RDP' => 27, - 'IRTP' => 28, - 'ISO-TP4' => 29, - 'NETBLT' => 30, - 'MFE-NSP' => 31, - 'MERIT-INP' => 32, - 'SEP' => 33, - // 34 - 60 - Unassigned - // 61 - any host internal protocol - 'CFTP' => 62, - // 63 - any local network - 'SAT-EXPAK' => 64, - 'MIT-SUBNET' => 65, - 'RVD' => 66, - 'IPPC' => 67, - // 68 - any distributed file system - 'SAT-MON' => 69, - // 70 - Unassigned - 'IPCV' => 71, - // 72 - 75 - Unassigned - 'BR-SAT-MON' => 76, - // 77 - Unassigned - 'WB-MON' => 78, - 'WB-EXPAK' => 79 - // 80 - 254 - Unassigned - // 255 - Reserved - ]; -} diff --git a/Net/DNS2/Notifier.php b/Net/DNS2/Notifier.php deleted file mode 100644 index 2e34fc62..00000000 --- a/Net/DNS2/Notifier.php +++ /dev/null @@ -1,213 +0,0 @@ -. All rights reserved. - * - * See LICENSE for more details. - * - * @category Networking - * @package Net_DNS2 - * @author Mike Pultz - * @copyright 2020 Mike Pultz - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @link https://netdns2.com/ - * @since File available since Release 0.6.0 - * - */ - -/** - * The main dynamic DNS notifier class. - * - * This class provices functions to handle DNS notify requests as defined by RFC 1996. - * - * This is separate from the Net_DNS2_Resolver class, as while the underlying - * protocol is the same, the functionality is completely different. - * - * Generally, query (recursive) lookups are done against caching server, while - * notify requests are done against authoritative servers. - * - */ -class Net_DNS2_Notifier extends Net_DNS2 { - // a Net_DNS2_Packet_Request object used for the notify request - private $_packet; - - /** - * Constructor - builds a new Net_DNS2_Notifier objected used for doing - * DNS notification for a changed zone - * - * @param string $zone the domain name to use for DNS updates - * @param mixed $options an array of config options or null - * - * @throws Net_DNS2_Exception - * @access public - * - */ - public function __construct($zone, array $options = null) { - parent::__construct($options); - - // - // create the packet - // - $this->_packet = new Net_DNS2_Packet_Request( - strtolower(trim($zone, " \n\r\t.")), 'SOA', 'IN' - ); - - // - // make sure the opcode on the packet is set to NOTIFY - // - $this->_packet->header->opcode = Net_DNS2_Lookups::OPCODE_NOTIFY; - } - - /** - * checks that the given name matches the name for the zone we're notifying - * - * @param string $name The name to be checked. - * - * @return boolean - * @throws Net_DNS2_Exception - * @access private - * - */ - private function _checkName($name) { - if (!preg_match('/' . $this->_packet->question[0]->qname . '$/', $name)) { - throw new Net_DNS2_Exception( - 'name provided (' . $name . ') does not match zone name (' . - $this->_packet->question[0]->qname . ')', - Net_DNS2_Lookups::E_PACKET_INVALID - ); - } - - return true; - } - - /** - * 3.7 - Add RR to notify - * - * @param Net_DNS2_RR $rr the Net_DNS2_RR object to be sent in the notify message - * - * @return boolean - * @throws Net_DNS2_Exception - * @access public - * - */ - public function add(Net_DNS2_RR $rr) { - $this->_checkName($rr->name); - - // - // add the RR to the "notify" section - // - if (!in_array($rr, $this->_packet->answer, true)) { - $this->_packet->answer[] = $rr; - } - - return true; - } - - /** - * add a signature to the request for authentication - * - * @param string $keyname the key name to use for the TSIG RR - * @param string $signature the key to sign the request. - * @param mixed $algorithm - * - * @return boolean - * @access public - * @see Net_DNS2::signTSIG() - * @deprecated function deprecated in 1.1.0 - * - */ - public function signature($keyname, $signature, $algorithm = Net_DNS2_RR_TSIG::HMAC_MD5) { - return $this->signTSIG($keyname, $signature, $algorithm); - } - - /** - * returns the current internal packet object. - * - * @return Net_DNS2_Packet_Request - * @access public - * # - */ - public function packet() { - // - // take a copy - // - $p = $this->_packet; - - // - // check for an authentication method; either TSIG or SIG - // - if (($this->auth_signature instanceof Net_DNS2_RR_TSIG) - || ($this->auth_signature instanceof Net_DNS2_RR_SIG) - ) { - $p->additional[] = $this->auth_signature; - } - - // - // update the counts - // - $p->header->qdcount = cacti_sizeof($p->question); - $p->header->ancount = cacti_sizeof($p->answer); - $p->header->nscount = cacti_sizeof($p->authority); - $p->header->arcount = cacti_sizeof($p->additional); - - return $p; - } - - /** - * executes the notify request - * - * @param Net_DNS2_Packet_Response &$response ref to the response object - * - * @return boolean - * @throws Net_DNS2_Exception - * @access public - * - */ - public function notify(&$response = null) { - // - // check for an authentication method; either TSIG or SIG - // - if (($this->auth_signature instanceof Net_DNS2_RR_TSIG) - || ($this->auth_signature instanceof Net_DNS2_RR_SIG) - ) { - $this->_packet->additional[] = $this->auth_signature; - } - - // - // update the counts - // - $this->_packet->header->qdcount = cacti_sizeof($this->_packet->question); - $this->_packet->header->ancount = cacti_sizeof($this->_packet->answer); - $this->_packet->header->nscount = cacti_sizeof($this->_packet->authority); - $this->_packet->header->arcount = cacti_sizeof($this->_packet->additional); - - // - // make sure we have some data to send - // - if ($this->_packet->header->qdcount == 0) { - throw new Net_DNS2_Exception( - 'empty headers- nothing to send!', - Net_DNS2_Lookups::E_PACKET_INVALID - ); - } - - // - // send the packet and get back the response - // - $response = $this->sendPacket($this->_packet, $this->use_tcp); - - // - // clear the internal packet so if we make another request, we don't have - // old data being sent. - // - $this->_packet->reset(); - - // - // for notifies, we just need to know it worked- we don't actually need to - // return the response object - // - return true; - } -} diff --git a/Net/DNS2/Packet.php b/Net/DNS2/Packet.php deleted file mode 100644 index c14ff3f4..00000000 --- a/Net/DNS2/Packet.php +++ /dev/null @@ -1,372 +0,0 @@ -. All rights reserved. - * - * See LICENSE for more details. - * - * @category Networking - * @package Net_DNS2 - * @author Mike Pultz - * @copyright 2020 Mike Pultz - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @link https://netdns2.com/ - * @since File available since Release 0.6.0 - * - * This file contains code based off the Net::DNS Perl module by Michael Fuhr. - * - * This is the copyright notice from the PERL Net::DNS module: - * - * Copyright (c) 1997-2000 Michael Fuhr. All rights reserved. This program is - * free software; you can redistribute it and/or modify it under the same terms - * as Perl itself. - * - */ - -/** - * This is the base class that holds a standard DNS packet. - * - * The Net_DNS2_Packet_Request and Net_DNS2_Packet_Response classes extend this - * class. - * - */ -class Net_DNS2_Packet { - // the full binary data and length for this packet - public $rdata; - public $rdlength; - - // the offset pointer used when building/parsing packets - public $offset = 0; - - // Net_DNS2_Header object with the DNS packet header - public $header; - - /* - * array of Net_DNS2_Question objects - * - * used as "zone" for updates per RFC2136 - * - */ - public $question = []; - - /* - * array of Net_DNS2_RR Objects for Answers - * - * used as "prerequisite" for updates per RFC2136 - * - */ - public $answer = []; - - /* - * array of Net_DNS2_RR Objects for Authority - * - * used as "update" for updates per RFC2136 - * - */ - public $authority = []; - - // array of Net_DNS2_RR Objects for Additional - public $additional = []; - - // array of compressed labeles - private $_compressed = []; - - /** - * magic __toString() method to return the Net_DNS2_Packet as a string - * - * @return string - * @access public - * - */ - public function __toString() { - $output = $this->header->__toString(); - - foreach ($this->question as $x) { - $output .= $x->__toString() . "\n"; - } - - foreach ($this->answer as $x) { - $output .= $x->__toString() . "\n"; - } - - foreach ($this->authority as $x) { - $output .= $x->__toString() . "\n"; - } - - foreach ($this->additional as $x) { - $output .= $x->__toString() . "\n"; - } - - return $output; - } - - /** - * returns a full binary DNS packet - * - * @return string - * @throws Net_DNS2_Exception - * @access public - * - */ - public function get() { - $data = $this->header->get($this); - - foreach ($this->question as $x) { - $data .= $x->get($this); - } - - foreach ($this->answer as $x) { - $data .= $x->get($this); - } - - foreach ($this->authority as $x) { - $data .= $x->get($this); - } - - foreach ($this->additional as $x) { - $data .= $x->get($this); - } - - return $data; - } - - /** - * applies a standard DNS name compression on the given name/offset - * - * This logic was based on the Net::DNS::Packet::dn_comp() function - * by Michanel Fuhr - * - * @param string $name the name to be compressed - * @param integer &$offset the offset into the given packet object - * - * @return string - * @access public - * - */ - public function compress($name, &$offset) { - // - // we're using preg_split() rather than explode() so that we can use the negative lookbehind, - // to catch cases where we have escaped dots in strings. - // - // there's only a few cases like this- the rname in SOA for example - // - $names = str_replace('\.', '.', preg_split('/(?_compressed[$dname])) { - $compname .= pack('n', 0xc000 | $this->_compressed[$dname]); - $offset += 2; - - break; - } - - $this->_compressed[$dname] = $offset; - - $first = array_shift($names); - - $length = strlen($first); - - if ($length <= 0) { - continue; - } - - // - // truncate see RFC1035 2.3.1 - // - if ($length > 63) { - $length = 63; - $first = substr($first, 0, $length); - } - - $compname .= pack('Ca*', $length, $first); - $offset += $length + 1; - } - - if (empty($names)) { - $compname .= pack('C', 0); - $offset++; - } - - return $compname; - } - - /** - * applies a standard DNS name compression on the given name/offset - * - * This logic was based on the Net::DNS::Packet::dn_comp() function - * by Michanel Fuhr - * - * @param string $name the name to be compressed - * - * @return string - * @access public - * - */ - public static function pack($name) { - $offset = 0; - $names = explode('.', $name); - $compname = ''; - - while (!empty($names)) { - $first = array_shift($names); - $length = strlen($first); - - $compname .= pack('Ca*', $length, $first); - $offset += $length + 1; - } - - $compname .= "\0"; - $offset++; - - return $compname; - } - - /** - * expands the domain name stored at a given offset in a DNS Packet - * - * This logic was based on the Net::DNS::Packet::dn_expand() function - * by Michanel Fuhr - * - * @param Net_DNS2_Packet &$packet the DNS packet to look in for the domain name - * @param integer &$offset the offset into the given packet object - * @param boolean $escape_dot_literals if we should escape periods in names - * - * @return mixed either the domain name or null if it's not found. - * @access public - * - */ - public static function expand(Net_DNS2_Packet &$packet, &$offset, $escape_dot_literals = false) { - $name = ''; - - while (1) { - if ($packet->rdlength < ($offset + 1)) { - return null; - } - - $xlen = ord($packet->rdata[$offset]); - - if ($xlen == 0) { - ++$offset; - - break; - } - - if (($xlen & 0xc0) == 0xc0) { - if ($packet->rdlength < ($offset + 2)) { - return null; - } - - $ptr = ord($packet->rdata[$offset]) << 8 | ord($packet->rdata[$offset + 1]); - $ptr = $ptr & 0x3fff; - - $name2 = Net_DNS2_Packet::expand($packet, $ptr); - - if (is_null($name2)) { - return null; - } - - $name .= $name2; - $offset += 2; - - break; - } else { - ++$offset; - - if ($packet->rdlength < ($offset + $xlen)) { - return null; - } - - $elem = ''; - $elem = substr($packet->rdata, $offset, $xlen); - - // - // escape literal dots in certain cases (SOA rname) - // - if (($escape_dot_literals == true) && (strpos($elem, '.') !== false)) { - $elem = str_replace('.', '\.', $elem); - } - - $name .= $elem . '.'; - $offset += $xlen; - } - } - - return trim($name, '.'); - } - - /** - * parses a domain label from a DNS Packet at the given offset - * - * @param Net_DNS2_Packet &$packet the DNS packet to look in for the domain name - * @param integer &$offset the offset into the given packet object - * - * @return mixed either the domain name or null if it's not found. - * @access public - * - */ - public static function label(Net_DNS2_Packet &$packet, &$offset) { - $name = ''; - - if ($packet->rdlength < ($offset + 1)) { - return null; - } - - $xlen = ord($packet->rdata[$offset]); - ++$offset; - - if (($xlen + $offset) > $packet->rdlength) { - $name = substr($packet->rdata, $offset); - $offset = $packet->rdlength; - } else { - $name = substr($packet->rdata, $offset, $xlen); - $offset += $xlen; - } - - return $name; - } - - /** - * copies the contents of the given packet, to the local packet object. this - * function intentionally ignores some of the packet data. - * - * @param Net_DNS2_Packet $packet the DNS packet to copy the data from - * - * @return boolean - * @access public - * - */ - public function copy(Net_DNS2_Packet $packet) { - $this->header = $packet->header; - $this->question = $packet->question; - $this->answer = $packet->answer; - $this->authority = $packet->authority; - $this->additional = $packet->additional; - - return true; - } - - /** - * resets the values in the current packet object - * - * @return boolean - * @access public - * - */ - public function reset() { - $this->header->id = $this->header->nextPacketId(); - $this->rdata = ''; - $this->rdlength = 0; - $this->offset = 0; - $this->answer = []; - $this->authority = []; - $this->additional = []; - $this->_compressed = []; - - return true; - } -} diff --git a/Net/DNS2/Packet/Request.php b/Net/DNS2/Packet/Request.php deleted file mode 100644 index 0c05ec27..00000000 --- a/Net/DNS2/Packet/Request.php +++ /dev/null @@ -1,157 +0,0 @@ -. All rights reserved. - * - * See LICENSE for more details. - * - * @category Networking - * @package Net_DNS2 - * @author Mike Pultz - * @copyright 2020 Mike Pultz - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @link https://netdns2.com/ - * @since File available since Release 0.6.0 - * - */ - -/** - * This class handles building new DNS request packets; packets used for DNS - * queries and updates. - * - */ -class Net_DNS2_Packet_Request extends Net_DNS2_Packet { - /** - * Constructor - builds a new Net_DNS2_Packet_Request object - * - * @param string $name the domain name for the packet - * @param string $type the DNS RR type for the packet - * @param string $class the DNS class for the packet - * - * @throws Net_DNS2_Exception - * @access public - * - */ - public function __construct($name, $type = null, $class = null) { - $this->set($name, $type, $class); - } - - /** - * builds a new Net_DNS2_Packet_Request object - * - * @param string $name the domain name for the packet - * @param string $type the DNS RR type for the packet - * @param string $class the DNS class for the packet - * - * @return boolean - * @throws Net_DNS2_Exception - * @access public - * - */ - public function set($name, $type = 'A', $class = 'IN') { - // - // generate a new header - // - $this->header = new Net_DNS2_Header; - - // - // add a new question - // - $q = new Net_DNS2_Question(); - - // - // allow queries directly to . for the root name servers - // - if ($name != '.') { - $name = trim(strtolower($name), " \t\n\r\0\x0B."); - } - - $type = strtoupper(trim($type)); - $class = strtoupper(trim($class)); - - // - // check that the input string has some data in it - // - if (empty($name)) { - throw new Net_DNS2_Exception( - 'empty query string provided', - Net_DNS2_Lookups::E_PACKET_INVALID - ); - } - - // - // if the type is "*", rename it to "ANY"- both are acceptable. - // - if ($type == '*') { - $type = 'ANY'; - } - - // - // check that the type and class are valid - // - if ((!isset(Net_DNS2_Lookups::$rr_types_by_name[$type])) - || (!isset(Net_DNS2_Lookups::$classes_by_name[$class])) - ) { - throw new Net_DNS2_Exception( - 'invalid type (' . $type . ') or class (' . $class . ') specified.', - Net_DNS2_Lookups::E_PACKET_INVALID - ); - } - - if ($type == 'PTR') { - // - // if it's a PTR request for an IP address, then make sure we tack on - // the arpa domain. - // - // there are other types of PTR requests, so if an IP adress doesn't match, - // then just let it flow through and assume it's a hostname - // - if (Net_DNS2::isIPv4($name) == true) { - // - // IPv4 - // - $name = implode('.', array_reverse(explode('.', $name))); - $name .= '.in-addr.arpa'; - } elseif (Net_DNS2::isIPv6($name) == true) { - // - // IPv6 - // - $e = Net_DNS2::expandIPv6($name); - - if ($e !== false) { - $name = implode( - '.', array_reverse(str_split(str_replace(':', '', $e))) - ); - - $name .= '.ip6.arpa'; - } else { - throw new Net_DNS2_Exception( - 'unsupported PTR value: ' . $name, - Net_DNS2_Lookups::E_PACKET_INVALID - ); - } - } - } - - // - // store the data - // - $q->qname = $name; - $q->qtype = $type; - $q->qclass = $class; - - $this->question[] = $q; - - // - // the answer, authority and additional are empty; they can be modified - // after the request is created for UPDATE requests if needed. - // - $this->answer = []; - $this->authority = []; - $this->additional = []; - - return true; - } -} diff --git a/Net/DNS2/Packet/Response.php b/Net/DNS2/Packet/Response.php deleted file mode 100644 index fc72f75c..00000000 --- a/Net/DNS2/Packet/Response.php +++ /dev/null @@ -1,131 +0,0 @@ -. All rights reserved. - * - * See LICENSE for more details. - * - * @category Networking - * @package Net_DNS2 - * @author Mike Pultz - * @copyright 2020 Mike Pultz - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @link https://netdns2.com/ - * @since File available since Release 0.6.0 - * - */ - -/** - * This class handles building new DNS response packets; it parses binary packed - * packets that come off the wire - * - */ -class Net_DNS2_Packet_Response extends Net_DNS2_Packet { - // The name servers that this response came from - public $answer_from; - - // The socket type the answer came from (TCP/UDP) - public $answer_socket_type; - - // The query response time in microseconds - public $response_time = 0; - - /** - * Constructor - builds a new Net_DNS2_Packet_Response object - * - * @param string $data binary DNS packet - * @param integer $size the length of the DNS packet - * - * @throws Net_DNS2_Exception - * @access public - * - */ - public function __construct($data, $size) { - $this->set($data, $size); - } - - /** - * builds a new Net_DNS2_Packet_Response object - * - * @param string $data binary DNS packet - * @param integer $size the length of the DNS packet - * - * @return boolean - * @throws Net_DNS2_Exception - * @access public - * - */ - public function set($data, $size) { - // - // store the full packet - // - $this->rdata = $data; - $this->rdlength = $size; - - // - // parse the header - // - // we don't bother checking the size earlier, because the first thing the - // header class does, is check the size and throw and exception if it's - // invalid. - // - $this->header = new Net_DNS2_Header($this); - - // - // if the truncation bit is set, then just return right here, because the - // rest of the packet is probably empty; and there's no point in processing - // anything else. - // - // we also don't need to worry about checking to see if the the header is - // null or not, since the Net_DNS2_Header() constructor will throw an - // exception if the packet is invalid. - // - if ($this->header->tc == 1) { - return false; - } - - // - // parse the questions - // - for ($x = 0; $x < $this->header->qdcount; ++$x) { - $this->question[$x] = new Net_DNS2_Question($this); - } - - // - // parse the answers - // - for ($x = 0; $x < $this->header->ancount; ++$x) { - $o = Net_DNS2_RR::parse($this); - - if (!is_null($o)) { - $this->answer[] = $o; - } - } - - // - // parse the authority section - // - for ($x = 0; $x < $this->header->nscount; ++$x) { - $o = Net_DNS2_RR::parse($this); - - if (!is_null($o)) { - $this->authority[] = $o; - } - } - - // - // parse the additional section - // - for ($x = 0; $x < $this->header->arcount; ++$x) { - $o = Net_DNS2_RR::parse($this); - - if (!is_null($o)) { - $this->additional[] = $o; - } - } - - return true; - } -} diff --git a/Net/DNS2/PrivateKey.php b/Net/DNS2/PrivateKey.php deleted file mode 100644 index 4064b560..00000000 --- a/Net/DNS2/PrivateKey.php +++ /dev/null @@ -1,321 +0,0 @@ -. All rights reserved. - * - * See LICENSE for more details. - * - * @category Networking - * @package Net_DNS2 - * @author Mike Pultz - * @copyright 2020 Mike Pultz - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @link https://netdns2.com/ - * @since File available since Release 1.1.0 - * - */ - -/** - * SSL Private Key container class - * - */ -class Net_DNS2_PrivateKey { - // the filename that was loaded; stored for reference - public $filename; - - // the keytag for the signature - public $keytag; - - // the sign name for the signature - public $signname; - - // the algorithm used for the signature - public $algorithm; - - // the key format of the signature - public $key_format; - - // the openssl private key id - public $instance; - - // RSA: modulus - private $_modulus; - - // RSA: public exponent - private $_public_exponent; - - // RSA: rivate exponent - private $_private_exponent; - - // RSA: prime1 - private $_prime1; - - // RSA: prime2 - private $_prime2; - - // RSA: exponent 1 - private $_exponent1; - - // RSA: exponent 2 - private $_exponent2; - - // RSA: coefficient - private $_coefficient; - - // DSA: prime - public $prime; - - // DSA: subprime - public $subprime; - - // DSA: base - public $base; - - // DSA: private value - public $private_value; - - // DSA: public value - public $public_value; - - /** - * Constructor - base constructor the private key container class - * - * @param string $file path to a private-key file to parse and load - * - * @throws Net_DNS2_Exception - * @access public - * - */ - public function __construct($file = null) { - if (isset($file)) { - $this->parseFile($file); - } - } - - /** - * parses a private key file generated by dnssec-keygen - * - * @param string $file path to a private-key file to parse and load - * - * @return boolean - * @throws Net_DNS2_Exception - * @access public - * - */ - public function parseFile($file) { - // - // check for OpenSSL - // - if (extension_loaded('openssl') === false) { - throw new Net_DNS2_Exception( - 'the OpenSSL extension is required to use parse private key.', - Net_DNS2_Lookups::E_OPENSSL_UNAVAIL - ); - } - - // - // check to make sure the file exists - // - if (is_readable($file) == false) { - throw new Net_DNS2_Exception( - 'invalid private key file: ' . $file, - Net_DNS2_Lookups::E_OPENSSL_INV_PKEY - ); - } - - // - // get the base filename, and parse it for the local value - // - $keyname = basename($file); - - if (strlen($keyname) == 0) { - throw new Net_DNS2_Exception( - 'failed to get basename() for: ' . $file, - Net_DNS2_Lookups::E_OPENSSL_INV_PKEY - ); - } - - // - // parse the keyname - // - if (preg_match("/K(.*)\.\+(\d{3})\+(\d*)\.private/", $keyname, $matches)) { - $this->signname = $matches[1]; - $this->algorithm = intval($matches[2]); - $this->keytag = intval($matches[3]); - } else { - throw new Net_DNS2_Exception( - 'file ' . $keyname . ' does not look like a private key file!', - Net_DNS2_Lookups::E_OPENSSL_INV_PKEY - ); - } - - // - // read all the data from the - // - $data = file($file, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES); - - if (cacti_sizeof($data) == 0) { - throw new Net_DNS2_Exception( - 'file ' . $keyname . ' is empty!', - Net_DNS2_Lookups::E_OPENSSL_INV_PKEY - ); - } - - foreach ($data as $line) { - [$key, $value] = explode(':', $line); - - $key = trim($key); - $value = trim($value); - - switch(strtolower($key)) { - case 'private-key-format': - $this->key_format = $value; - - break; - case 'algorithm': - if ($this->algorithm != $value) { - throw new Net_DNS2_Exception( - 'Algorithm mismatch! filename is ' . $this->algorithm . - ', contents say ' . $value, - Net_DNS2_Lookups::E_OPENSSL_INV_ALGO - ); - } - - break; - // - // RSA - // - case 'modulus': - $this->_modulus = $value; - - break; - case 'publicexponent': - $this->_public_exponent = $value; - - break; - case 'privateexponent': - $this->_private_exponent = $value; - - break; - case 'prime1': - $this->_prime1 = $value; - - break; - case 'prime2': - $this->_prime2 = $value; - - break; - case 'exponent1': - $this->_exponent1 = $value; - - break; - case 'exponent2': - $this->_exponent2 = $value; - - break; - case 'coefficient': - $this->_coefficient = $value; - - break; - // - // DSA - this won't work in PHP until the OpenSSL extension is better - // - case 'prime(p)': - $this->prime = $value; - - break; - case 'subprime(q)': - $this->subprime = $value; - - break; - case 'base(g)': - $this->base = $value; - - break; - case 'private_value(x)': - $this->private_value = $value; - - break; - case 'public_value(y)': - $this->public_value = $value; - - break; - default: - throw new Net_DNS2_Exception( - 'unknown private key data: ' . $key . ': ' . $value, - Net_DNS2_Lookups::E_OPENSSL_INV_PKEY - ); - } - } - - // - // generate the private key - // - $args = []; - - switch($this->algorithm) { - // - // RSA - // - case Net_DNS2_Lookups::DNSSEC_ALGORITHM_RSAMD5: - case Net_DNS2_Lookups::DNSSEC_ALGORITHM_RSASHA1: - case Net_DNS2_Lookups::DNSSEC_ALGORITHM_RSASHA256: - case Net_DNS2_Lookups::DNSSEC_ALGORITHM_RSASHA512: - $args = [ - 'rsa' => [ - 'n' => base64_decode($this->_modulus, true), - 'e' => base64_decode($this->_public_exponent, true), - 'd' => base64_decode($this->_private_exponent, true), - 'p' => base64_decode($this->_prime1, true), - 'q' => base64_decode($this->_prime2, true), - 'dmp1' => base64_decode($this->_exponent1, true), - 'dmq1' => base64_decode($this->_exponent2, true), - 'iqmp' => base64_decode($this->_coefficient, true) - ] - ]; - - break; - // - // DSA - this won't work in PHP until the OpenSSL extension is better - // - case Net_DNS2_Lookups::DNSSEC_ALGORITHM_DSA: - $args = [ - 'dsa' => [ - 'p' => base64_decode($this->prime, true), - 'q' => base64_decode($this->subprime, true), - 'g' => base64_decode($this->base, true), - 'priv_key' => base64_decode($this->private_value, true), - 'pub_key' => base64_decode($this->public_value, true) - ] - ]; - - break; - default: - throw new Net_DNS2_Exception( - 'we only currently support RSAMD5 and RSASHA1 encryption.', - Net_DNS2_Lookups::E_OPENSSL_INV_PKEY - ); - } - - // - // generate and store the key - // - $this->instance = openssl_pkey_new($args); - - if ($this->instance === false) { - throw new Net_DNS2_Exception( - openssl_error_string(), - Net_DNS2_Lookups::E_OPENSSL_ERROR - ); - } - - // - // store the filename incase we need it for something - // - $this->filename = $file; - - return true; - } -} diff --git a/Net/DNS2/Question.php b/Net/DNS2/Question.php deleted file mode 100644 index 31826fbb..00000000 --- a/Net/DNS2/Question.php +++ /dev/null @@ -1,187 +0,0 @@ -. All rights reserved. - * - * See LICENSE for more details. - * - * @category Networking - * @package Net_DNS2 - * @author Mike Pultz - * @copyright 2020 Mike Pultz - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @link https://netdns2.com/ - * @since File available since Release 0.6.0 - * - */ - -/** - * This class handles parsing and constructing the question sectino of DNS - * packets. - * - * This is referred to as the "zone" for update per RFC2136 - * - * DNS question format - RFC1035 section 4.1.2 - * - * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 - * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ - * | | - * / QNAME / - * / / - * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ - * | QTYPE | - * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ - * | QCLASS | - * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ - * - */ -class Net_DNS2_Question { - /* - * The name of the question - * - * referred to as "zname" for updates per RFC2136 - * - */ - public $qname; - - /* - * The RR type for the questino - * - * referred to as "ztype" for updates per RFC2136 - * - */ - public $qtype; - - /* - * The RR class for the questino - * - * referred to as "zclass" for updates per RFC2136 - * - */ - public $qclass; - - /** - * Constructor - builds a new Net_DNS2_Question object - * - * @param mixed &$packet either a Net_DNS2_Packet object, or null to - * build an empty object - * - * @throws Net_DNS2_Exception - * @access public - * - */ - public function __construct(Net_DNS2_Packet &$packet = null) { - if (!is_null($packet)) { - $this->set($packet); - } else { - $this->qname = ''; - $this->qtype = 'A'; - $this->qclass = 'IN'; - } - } - - /** - * magic __toString() function to return the Net_DNS2_Question object as a string - * - * @return string - * @access public - * - */ - public function __toString() { - return ";;\n;; Question:\n;;\t " . $this->qname . '. ' . - $this->qtype . ' ' . $this->qclass . "\n"; - } - - /** - * builds a new Net_DNS2_Header object from a Net_DNS2_Packet object - * - * @param Net_DNS2_Packet &$packet a Net_DNS2_Packet object - * - * @return boolean - * @throws Net_DNS2_Exception - * @access public - * - */ - public function set(Net_DNS2_Packet &$packet) { - // - // expand the name - // - $this->qname = $packet->expand($packet, $packet->offset); - - if ($packet->rdlength < ($packet->offset + 4)) { - throw new Net_DNS2_Exception( - 'invalid question section: to small', - Net_DNS2_Lookups::E_QUESTION_INVALID - ); - } - - // - // unpack the type and class - // - $type = ord($packet->rdata[$packet->offset++]) << 8 | - ord($packet->rdata[$packet->offset++]); - $class = ord($packet->rdata[$packet->offset++]) << 8 | - ord($packet->rdata[$packet->offset++]); - - // - // validate it - // - $type_name = Net_DNS2_Lookups::$rr_types_by_id[$type]; - $class_name = Net_DNS2_Lookups::$classes_by_id[$class]; - - if ((!isset($type_name)) || (!isset($class_name))) { - throw new Net_DNS2_Exception( - 'invalid question section: invalid type (' . $type . - ') or class (' . $class . ') specified.', - Net_DNS2_Lookups::E_QUESTION_INVALID - ); - } - - // - // store it - // - $this->qtype = $type_name; - $this->qclass = $class_name; - - return true; - } - - /** - * returns a binary packed Net_DNS2_Question object - * - * @param Net_DNS2_Packet &$packet the Net_DNS2_Packet object this question is - * part of. This needs to be passed in so that - * the compressed qname value can be packed in - * with the names of the other parts of the - * packet. - * - * @return string - * @throws Net_DNS2_Exception - * @access public - * - */ - public function get(Net_DNS2_Packet &$packet) { - // - // validate the type and class - // - $type = Net_DNS2_Lookups::$rr_types_by_name[$this->qtype]; - $class = Net_DNS2_Lookups::$classes_by_name[$this->qclass]; - - if ((!isset($type)) || (!isset($class))) { - throw new Net_DNS2_Exception( - 'invalid question section: invalid type (' . $this->qtype . - ') or class (' . $this->qclass . ') specified.', - Net_DNS2_Lookups::E_QUESTION_INVALID - ); - } - - $data = $packet->compress($this->qname, $packet->offset); - - $data .= chr($type >> 8) . chr($type) . chr($class >> 8) . chr($class); - $packet->offset += 4; - - return $data; - } -} diff --git a/Net/DNS2/RR.php b/Net/DNS2/RR.php deleted file mode 100644 index 82fed871..00000000 --- a/Net/DNS2/RR.php +++ /dev/null @@ -1,565 +0,0 @@ -. All rights reserved. - * - * See LICENSE for more details. - * - * @category Networking - * @package Net_DNS2 - * @author Mike Pultz - * @copyright 2020 Mike Pultz - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @link https://netdns2.com/ - * @since File available since Release 0.6.0 - * - */ - -/** - * This is the base class for DNS Resource Records - * - * Each resource record type (defined in RR/*.php) extends this class for - * base functionality. - * - * This class handles parsing and constructing the common parts of the DNS - * resource records, while the RR specific functionality is handled in each - * child class. - * - * DNS resource record format - RFC1035 section 4.1.3 - * - * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 - * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ - * | | - * / / - * / NAME / - * | | - * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ - * | TYPE | - * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ - * | CLASS | - * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ - * | TTL | - * | | - * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ - * | RDLENGTH | - * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--| - * / RDATA / - * / / - * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ - * - */ -abstract class Net_DNS2_RR { - // The name of the resource record - public $name; - - // The resource record type - public $type; - - // The resource record class - public $class; - - // The time to live for this resource record - public $ttl; - - // The length of the rdata field - public $rdlength; - - // The resource record specific data as a packed binary string - public $rdata; - - /** - * abstract definition - method to return a RR as a string; not to - * be confused with the __toString() magic method. - * - * @return string - * @access protected - * - */ - abstract protected function rrToString(); - - /** - * abstract definition - parses a RR from a standard DNS config line - * - * @param array $rdata a string split line of values for the rdata - * - * @return boolean - * @access protected - * - */ - abstract protected function rrFromString(array $rdata); - - /** - * abstract definition - sets a Net_DNS2_RR from a Net_DNS2_Packet object - * - * @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet to parse the RR from - * - * @return boolean - * @access protected - * - */ - abstract protected function rrSet(Net_DNS2_Packet &$packet); - - /** - * abstract definition - returns a binary packet DNS RR object - * - * @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet use for - * compressed names - * - * @return mixed either returns a binary packed string or - * null on failure - * @access protected - * - */ - abstract protected function rrGet(Net_DNS2_Packet &$packet); - - /** - * Constructor - builds a new Net_DNS2_RR object - * - * @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet or null to create - * an empty object - * @param array $rr an array with RR parse values or null to - * create an empty object - * - * @throws Net_DNS2_Exception - * @access public - * - */ - public function __construct(Net_DNS2_Packet &$packet = null, array $rr = null) { - if ((!is_null($packet)) && (!is_null($rr))) { - if ($this->set($packet, $rr) == false) { - throw new Net_DNS2_Exception( - 'failed to generate resource record', - Net_DNS2_Lookups::E_RR_INVALID - ); - } - } else { - $class = Net_DNS2_Lookups::$rr_types_class_to_id[get_class($this)]; - - if (isset($class)) { - $this->type = Net_DNS2_Lookups::$rr_types_by_id[$class]; - } - - $this->class = 'IN'; - $this->ttl = 86400; - } - } - - /** - * magic __toString() method to return the Net_DNS2_RR object object as a string - * - * @return string - * @access public - * - */ - public function __toString() { - return $this->name . '. ' . $this->ttl . ' ' . $this->class . - ' ' . $this->type . ' ' . $this->rrToString(); - } - - /** - * return the same data as __toString(), but as an array, so each value can be - * used without having to parse the string. - * - * @return array - * @access public - * - */ - public function asArray() { - return [ - 'name' => $this->name, - 'ttl' => $this->ttl, - 'class' => $this->class, - 'type' => $this->type, - 'rdata' => $this->rrToString() - ]; - } - - /** - * return a formatted string; if a string has spaces in it, then return - * it with double quotes around it, otherwise, return it as it was passed in. - * - * @param string $string the string to format - * - * @return string - * @access protected - * - */ - protected function formatString($string) { - return '"' . str_replace('"', '\"', trim($string, '"')) . '"'; - } - - /** - * builds an array of strings from an array of chunks of text split by spaces - * - * @param array $chunks an array of chunks of text split by spaces - * - * @return array - * @access protected - * - */ - protected function buildString(array $chunks) { - $data = []; - $c = 0; - $in = false; - - foreach ($chunks as $r) { - $r = trim($r); - - if (strlen($r) == 0) { - continue; - } - - if (($r[0] == '"') - && ($r[strlen($r) - 1] == '"') - && ($r[strlen($r) - 2] != '\\') - ) { - $data[$c] = $r; - ++$c; - $in = false; - } elseif ($r[0] == '"') { - $data[$c] = $r; - $in = true; - } elseif (($r[strlen($r) - 1] == '"') - && ($r[strlen($r) - 2] != '\\') - ) { - $data[$c] .= ' ' . $r; - ++$c; - $in = false; - } else { - if ($in == true) { - $data[$c] .= ' ' . $r; - } else { - $data[$c++] = $r; - } - } - } - - foreach ($data as $index => $string) { - $data[$index] = str_replace('\"', '"', trim($string, '"')); - } - - return $data; - } - - /** - * builds a new Net_DNS2_RR object - * - * @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet or null to create - * an empty object - * @param array $rr an array with RR parse values or null to - * create an empty object - * - * @return boolean - * @throws Net_DNS2_Exception - * @access public - * - */ - public function set(Net_DNS2_Packet &$packet, array $rr) { - $this->name = $rr['name']; - $this->type = Net_DNS2_Lookups::$rr_types_by_id[$rr['type']]; - - // - // for RR OPT (41), the class value includes the requesters UDP payload size, - // and not a class value - // - if ($this->type == 'OPT') { - $this->class = $rr['class']; - } else { - $this->class = Net_DNS2_Lookups::$classes_by_id[$rr['class']]; - } - - $this->ttl = $rr['ttl']; - $this->rdlength = $rr['rdlength']; - $this->rdata = substr($packet->rdata, $packet->offset, $rr['rdlength']); - - return $this->rrSet($packet); - } - - /** - * returns a binary packed DNS RR object - * - * @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet used for - * compressing names - * - * @return string - * @throws Net_DNS2_Exception - * @access public - * - */ - public function get(Net_DNS2_Packet &$packet) { - $data = ''; - $rdata = ''; - - // - // pack the name - // - $data = $packet->compress($this->name, $packet->offset); - - // - // pack the main values - // - if ($this->type == 'OPT') { - // - // pre-build the TTL value - // - $this->preBuild(); - - // - // the class value is different for OPT types - // - $data .= pack( - 'nnN', - Net_DNS2_Lookups::$rr_types_by_name[$this->type], - $this->class, - $this->ttl - ); - } else { - $data .= pack( - 'nnN', - Net_DNS2_Lookups::$rr_types_by_name[$this->type], - Net_DNS2_Lookups::$classes_by_name[$this->class], - $this->ttl - ); - } - - // - // increase the offset, and allow for the rdlength - // - $packet->offset += 10; - - // - // get the RR specific details - // - if ($this->rdlength != -1) { - $rdata = $this->rrGet($packet); - } - - // - // add the RR - // - $data .= pack('n', strlen($rdata)) . $rdata; - - return $data; - } - - /** - * parses a binary packet, and returns the appropriate Net_DNS2_RR object, - * based on the RR type of the binary content. - * - * @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet used for - * decompressing names - * - * @return mixed returns a new Net_DNS2_RR_* object for - * the given RR - * @throws Net_DNS2_Exception - * @access public - * - */ - public static function parse(Net_DNS2_Packet &$packet) { - $object = []; - - // - // expand the name - // - $object['name'] = $packet->expand($packet, $packet->offset); - - if (is_null($object['name'])) { - throw new Net_DNS2_Exception( - 'failed to parse resource record: failed to expand name.', - Net_DNS2_Lookups::E_PARSE_ERROR - ); - } - - if ($packet->rdlength < ($packet->offset + 10)) { - throw new Net_DNS2_Exception( - 'failed to parse resource record: packet too small.', - Net_DNS2_Lookups::E_PARSE_ERROR - ); - } - - // - // unpack the RR details - // - $object['type'] = ord($packet->rdata[$packet->offset++]) << 8 | - ord($packet->rdata[$packet->offset++]); - $object['class'] = ord($packet->rdata[$packet->offset++]) << 8 | - ord($packet->rdata[$packet->offset++]); - - $object['ttl'] = ord($packet->rdata[$packet->offset++]) << 24 | - ord($packet->rdata[$packet->offset++]) << 16 | - ord($packet->rdata[$packet->offset++]) << 8 | - ord($packet->rdata[$packet->offset++]); - - $object['rdlength'] = ord($packet->rdata[$packet->offset++]) << 8 | - ord($packet->rdata[$packet->offset++]); - - if ($packet->rdlength < ($packet->offset + $object['rdlength'])) { - return null; - } - - // - // lookup the class to use - // - $o = null; - $class = Net_DNS2_Lookups::$rr_types_id_to_class[$object['type']]; - - if (isset($class)) { - $o = new $class($packet, $object); - - if ($o) { - $packet->offset += $object['rdlength']; - } - } else { - throw new Net_DNS2_Exception( - 'un-implemented resource record type: ' . $object['type'], - Net_DNS2_Lookups::E_RR_INVALID - ); - } - - return $o; - } - - /** - * cleans up some RR data - * - * @param string $data the text string to clean - * - * @return string returns the cleaned string - * - * @access public - * - */ - public function cleanString($data) { - return strtolower(rtrim($data, '.')); - } - - /** - * parses a standard RR format lines, as defined by rfc1035 (kinda) - * - * In our implementation, the domain *must* be specified- format must be - * - * [] [] - * or - * [] [] - * - * name, title, class and type are parsed by this function, rdata is passed - * to the RR specific classes for parsing. - * - * @param string $line a standard DNS config line - * - * @return mixed returns a new Net_DNS2_RR_* object for the given RR - * @throws Net_DNS2_Exception - * @access public - * - */ - public static function fromString($line) { - if (strlen($line) == 0) { - throw new Net_DNS2_Exception( - 'empty config line provided.', - Net_DNS2_Lookups::E_PARSE_ERROR - ); - } - - $name = ''; - $type = ''; - $class = 'IN'; - $ttl = 86400; - - // - // split the line by spaces - // - $values = preg_split('/[\s]+/', $line); - - if (cacti_sizeof($values) < 3) { - throw new Net_DNS2_Exception( - 'failed to parse config: minimum of name, type and rdata required.', - Net_DNS2_Lookups::E_PARSE_ERROR - ); - } - - // - // assume the first value is the name - // - $name = trim(strtolower(array_shift($values)), '.'); - - // - // The next value is either a TTL, Class or Type - // - foreach ($values as $value) { - switch(true) { - case is_numeric($value): - $ttl = array_shift($values); - - break; - // - // this is here because of a bug in is_numeric() in certain versions of - // PHP on windows. - // - case ($value === 0): - $ttl = array_shift($values); - - break; - case isset(Net_DNS2_Lookups::$classes_by_name[strtoupper($value)]): - $class = strtoupper(array_shift($values)); - - break; - case isset(Net_DNS2_Lookups::$rr_types_by_name[strtoupper($value)]): - $type = strtoupper(array_shift($values)); - - break 2; - - break; - default: - throw new Net_DNS2_Exception( - 'invalid config line provided: unknown file: ' . $value, - Net_DNS2_Lookups::E_PARSE_ERROR - ); - } - } - - // - // lookup the class to use - // - $o = null; - $class_name = Net_DNS2_Lookups::$rr_types_id_to_class[ - Net_DNS2_Lookups::$rr_types_by_name[$type] - ]; - - if (isset($class_name)) { - $o = new $class_name; - - if (!is_null($o)) { - // - // set the parsed values - // - $o->name = $name; - $o->class = $class; - $o->ttl = $ttl; - - // - // parse the rdata - // - if ($o->rrFromString($values) === false) { - throw new Net_DNS2_Exception( - 'failed to parse rdata for config: ' . $line, - Net_DNS2_Lookups::E_PARSE_ERROR - ); - } - } else { - throw new Net_DNS2_Exception( - 'failed to create new RR record for type: ' . $type, - Net_DNS2_Lookups::E_RR_INVALID - ); - } - } else { - throw new Net_DNS2_Exception( - 'un-implemented resource record type: ' . $type, - Net_DNS2_Lookups::E_RR_INVALID - ); - } - - return $o; - } -} diff --git a/Net/DNS2/RR/A.php b/Net/DNS2/RR/A.php deleted file mode 100644 index b556221d..00000000 --- a/Net/DNS2/RR/A.php +++ /dev/null @@ -1,101 +0,0 @@ -. All rights reserved. - * - * See LICENSE for more details. - * - * @category Networking - * @package Net_DNS2 - * @author Mike Pultz - * @copyright 2020 Mike Pultz - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @link https://netdns2.com/ - * @since File available since Release 0.6.0 - * - */ - -/** - * A Resource Record - RFC1035 section 3.4.1 - * - * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ - * | ADDRESS | - * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ - * - */ -class Net_DNS2_RR_A extends Net_DNS2_RR { - // The IPv4 address in quad-dotted notation - public $address; - - /** - * method to return the rdata portion of the packet as a string - * - * @return string - * @access protected - * - */ - protected function rrToString() { - return $this->address; - } - - /** - * parses the rdata portion from a standard DNS config line - * - * @param array $rdata a string split line of values for the rdata - * - * @return boolean - * @access protected - * - */ - protected function rrFromString(array $rdata) { - $value = array_shift($rdata); - - if (Net_DNS2::isIPv4($value) == true) { - $this->address = $value; - - return true; - } - - return false; - } - - /** - * parses the rdata of the Net_DNS2_Packet object - * - * @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet to parse the RR from - * - * @return boolean - * @access protected - * - */ - protected function rrSet(Net_DNS2_Packet &$packet) { - if ($this->rdlength > 0) { - $this->address = inet_ntop($this->rdata); - - if ($this->address !== false) { - return true; - } - } - - return false; - } - - /** - * returns the rdata portion of the DNS packet - * - * @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet use for - * compressed names - * - * @return mixed either returns a binary packed - * string or null on failure - * @access protected - * - */ - protected function rrGet(Net_DNS2_Packet &$packet) { - $packet->offset += 4; - - return inet_pton($this->address); - } -} diff --git a/Net/DNS2/RR/AAAA.php b/Net/DNS2/RR/AAAA.php deleted file mode 100644 index 0c5c2fdd..00000000 --- a/Net/DNS2/RR/AAAA.php +++ /dev/null @@ -1,126 +0,0 @@ -. All rights reserved. - * - * See LICENSE for more details. - * - * @category Networking - * @package Net_DNS2 - * @author Mike Pultz - * @copyright 2020 Mike Pultz - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @link https://netdns2.com/ - * @since File available since Release 0.6.0 - * - */ - -/** - * A Resource Record - RFC1035 section 3.4.1 - * - * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ - * | | - * | | - * | | - * | ADDRESS | - * | | - * | (128 bit) | - * | | - * | | - * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ - * - */ -class Net_DNS2_RR_AAAA extends Net_DNS2_RR { - /* - * the IPv6 address in the preferred hexadecimal values of the eight - * 16-bit pieces - * per RFC1884 - * - */ - public $address; - - /** - * method to return the rdata portion of the packet as a string - * - * @return string - * @access protected - * - */ - protected function rrToString() { - return $this->address; - } - - /** - * parses the rdata portion from a standard DNS config line - * - * @param array $rdata a string split line of values for the rdata - * - * @return boolean - * @access protected - * - */ - protected function rrFromString(array $rdata) { - // - // expand out compressed formats - // - $value = array_shift($rdata); - - if (Net_DNS2::isIPv6($value) == true) { - $this->address = $value; - - return true; - } - - return false; - } - - /** - * parses the rdata of the Net_DNS2_Packet object - * - * @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet to parse the RR from - * - * @return boolean - * @access protected - * - */ - protected function rrSet(Net_DNS2_Packet &$packet) { - // - // must be 8 x 16bit chunks, or 16 x 8bit - // - if ($this->rdlength == 16) { - // - // PHP's inet_ntop returns IPv6 addresses in their compressed form, - // but we want to keep with the preferred standard, so we'll parse - // it manually. - // - $x = unpack('n8', $this->rdata); - - if (cacti_sizeof($x) == 8) { - $this->address = vsprintf('%x:%x:%x:%x:%x:%x:%x:%x', $x); - - return true; - } - } - - return false; - } - - /** - * returns the rdata portion of the DNS packet - * - * @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet use for - * compressed names - * - * @return mixed either returns a binary packed - * string or null on failure - * @access protected - * - */ - protected function rrGet(Net_DNS2_Packet &$packet) { - $packet->offset += 16; - - return inet_pton($this->address); - } -} diff --git a/Net/DNS2/RR/AFSDB.php b/Net/DNS2/RR/AFSDB.php deleted file mode 100644 index 8ff3b3bf..00000000 --- a/Net/DNS2/RR/AFSDB.php +++ /dev/null @@ -1,115 +0,0 @@ -. All rights reserved. - * - * See LICENSE for more details. - * - * @category Networking - * @package Net_DNS2 - * @author Mike Pultz - * @copyright 2020 Mike Pultz - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @link https://netdns2.com/ - * @since File available since Release 0.6.0 - * - */ - -/** - * AFSDB Resource Record - RFC1183 section 1 - * - * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ - * | SUBTYPE | - * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ - * / HOSTNAME / - * / / - * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ - * - */ -class Net_DNS2_RR_AFSDB extends Net_DNS2_RR { - // The AFSDB sub type - public $subtype; - - // The AFSDB hostname - public $hostname; - - /** - * method to return the rdata portion of the packet as a string - * - * @return string - * @access protected - * - */ - protected function rrToString() { - return $this->subtype . ' ' . $this->cleanString($this->hostname) . '.'; - } - - /** - * parses the rdata portion from a standard DNS config line - * - * @param array $rdata a string split line of values for the rdata - * - * @return boolean - * @access protected - * - */ - protected function rrFromString(array $rdata) { - $this->subtype = array_shift($rdata); - $this->hostname = $this->cleanString(array_shift($rdata)); - - return true; - } - - /** - * parses the rdata of the Net_DNS2_Packet object - * - * @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet to parse the RR from - * - * @return boolean - * @access protected - * - */ - protected function rrSet(Net_DNS2_Packet &$packet) { - if ($this->rdlength > 0) { - // - // unpack the subtype - // - $x = unpack('nsubtype', $this->rdata); - - $this->subtype = $x['subtype']; - $offset = $packet->offset + 2; - - $this->hostname = Net_DNS2_Packet::expand($packet, $offset); - - return true; - } - - return false; - } - - /** - * returns the rdata portion of the DNS packet - * - * @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet use for - * compressed names - * - * @return mixed either returns a binary packed - * string or null on failure - * @access protected - * - */ - protected function rrGet(Net_DNS2_Packet &$packet) { - if (strlen($this->hostname) > 0) { - $data = pack('n', $this->subtype); - $packet->offset += 2; - - $data .= $packet->compress($this->hostname, $packet->offset); - - return $data; - } - - return null; - } -} diff --git a/Net/DNS2/RR/AMTRELAY.php b/Net/DNS2/RR/AMTRELAY.php deleted file mode 100644 index 564b0536..00000000 --- a/Net/DNS2/RR/AMTRELAY.php +++ /dev/null @@ -1,236 +0,0 @@ -. All rights reserved. - * - * See LICENSE for more details. - * - * @category Networking - * @package Net_DNS2 - * @author Mike Pultz - * @copyright 2020 Mike Pultz - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @link https://netdns2.com/ - * @since File available since Release 1.4.5 - * - */ - -/** - * AMTRELAY Resource Record - RFC8777 section 4.2 - * - * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 - * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - * | precedence |D| type | | - * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + - * ~ relay ~ - * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - * - */ -class Net_DNS2_RR_AMTRELAY extends Net_DNS2_RR { - // type definitions that match the "type" field below - const AMTRELAY_TYPE_NONE = 0; - const AMTRELAY_TYPE_IPV4 = 1; - const AMTRELAY_TYPE_IPV6 = 2; - const AMTRELAY_TYPE_DOMAIN = 3; - - // the precedence for this record - public $precedence; - - // "Discovery Optional" flag - public $discovery; - - // The type field indicates the format of the information that is stored in the relay field. - public $relay_type; - - // The relay field is the address or domain name of the AMT relay. - public $relay; - - /** - * method to return the rdata portion of the packet as a string - * - * @return string - * @access protected - * - */ - protected function rrToString() { - $out = $this->precedence . ' ' . $this->discovery . ' ' . $this->relay_type . ' ' . $this->relay; - - // - // 4.3.1 - If the relay type field is 0, the relay field MUST be ".". - // - if (($this->relay_type == self::AMTRELAY_TYPE_NONE) || ($this->relay_type == self::AMTRELAY_TYPE_DOMAIN)) { - $out .= '.'; - } - - return $out; - } - - /** - * parses the rdata portion from a standard DNS config line - * - * @param array $rdata a string split line of values for the rdata - * - * @return boolean - * @access protected - * - */ - protected function rrFromString(array $rdata) { - // - // extract the values from the array - // - $this->precedence = array_shift($rdata); - $this->discovery = array_shift($rdata); - $this->relay_type = array_shift($rdata); - $this->relay = trim(strtolower(trim(array_shift($rdata))), '.'); - - // - // if there's anything else other than 0 in the discovery value, then force it to one, so - // that it effectively is either "true" or "false". - // - if ($this->discovery != 0) { - $this->discovery = 1; - } - - // - // validate the type & relay values - // - switch($this->relay_type) { - case self::AMTRELAY_TYPE_NONE: - $this->relay = ''; - - break; - case self::AMTRELAY_TYPE_IPV4: - if (Net_DNS2::isIPv4($this->relay) == false) { - return false; - } - - break; - case self::AMTRELAY_TYPE_IPV6: - if (Net_DNS2::isIPv6($this->relay) == false) { - return false; - } - - break; - case self::AMTRELAY_TYPE_DOMAIN:; // do nothing - - break; - default: - // - // invalid type value - // - return false; - } - - return true; - } - - /** - * parses the rdata of the Net_DNS2_Packet object - * - * @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet to parse the RR from - * - * @return boolean - * @access protected - * - */ - protected function rrSet(Net_DNS2_Packet &$packet) { - if ($this->rdlength > 0) { - // - // parse off the first two octets - // - $x = unpack('Cprecedence/Csecond', $this->rdata); - - $this->precedence = $x['precedence']; - $this->discovery = ($x['second'] >> 7) & 0x1; - $this->relay_type = $x['second'] & 0xf; - - $offset = 2; - - // - // parse the relay value based on the type - // - switch($this->relay_type) { - case self::AMTRELAY_TYPE_NONE: - $this->relay = ''; - - break; - case self::AMTRELAY_TYPE_IPV4: - $this->relay = inet_ntop(substr($this->rdata, $offset, 4)); - - break; - case self::AMTRELAY_TYPE_IPV6: - // - // PHP's inet_ntop returns IPv6 addresses in their compressed form, but we want to keep - // with the preferred standard, so we'll parse it manually. - // - $ip = unpack('n8', substr($this->rdata, $offset, 16)); - - if (cacti_sizeof($ip) == 8) { - $this->relay = vsprintf('%x:%x:%x:%x:%x:%x:%x:%x', $ip); - } else { - return false; - } - - break; - case self::AMTRELAY_TYPE_DOMAIN: - $doffset = $packet->offset + $offset; - $this->relay = Net_DNS2_Packet::label($packet, $doffset); - - break; - default: - // - // invalid type value - // - return false; - } - - return true; - } - - return false; - } - - /** - * returns the rdata portion of the DNS packet - * - * @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet use for - * compressed names - * - * @return mixed either returns a binary packed - * string or null on failure - * @access protected - * - */ - protected function rrGet(Net_DNS2_Packet &$packet) { - // - // pack the precedence, discovery, and type - // - $data = pack('CC', $this->precedence, ($this->discovery << 7) | $this->relay_type); - - // - // add the relay data based on the type - // - switch($this->relay_type) { - case self::AMTRELAY_TYPE_NONE:; // add nothing - - break; - case self::AMTRELAY_TYPE_IPV4: - case self::AMTRELAY_TYPE_IPV6: - $data .= inet_pton($this->relay); - - break; - case self::AMTRELAY_TYPE_DOMAIN: - $data .= pack('Ca*', strlen($this->relay), $this->relay); - - break; - default: - return null; - } - - $packet->offset += strlen($data); - - return $data; - } -} diff --git a/Net/DNS2/RR/ANY.php b/Net/DNS2/RR/ANY.php deleted file mode 100644 index be31559d..00000000 --- a/Net/DNS2/RR/ANY.php +++ /dev/null @@ -1,76 +0,0 @@ -. All rights reserved. - * - * See LICENSE for more details. - * - * @category Networking - * @package Net_DNS2 - * @author Mike Pultz - * @copyright 2020 Mike Pultz - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @link https://netdns2.com/ - * @since File available since Release 0.6.0 - * - */ - -/** - * This is only used for generating an empty ANY RR. - * - */ -class Net_DNS2_RR_ANY extends Net_DNS2_RR { - /** - * method to return the rdata portion of the packet as a string - * - * @return string - * @access protected - * - */ - protected function rrToString() { - return ''; - } - - /** - * parses the rdata portion from a standard DNS config line - * - * @param array $rdata a string split line of values for the rdata - * - * @return boolean - * @access protected - * - */ - protected function rrFromString(array $rdata) { - return true; - } - - /** - * parses the rdata of the Net_DNS2_Packet object - * - * @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet to parse the RR from - * - * @return boolean - * @access protected - * - */ - protected function rrSet(Net_DNS2_Packet &$packet) { - return true; - } - - /** - * returns the rdata portion of the DNS packet - * - * @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet use for - * compressed names - * - * @return mixed either returns a binary packed - * string or null on failure - * @access protected - * - */ - protected function rrGet(Net_DNS2_Packet &$packet) { - return ''; - } -} diff --git a/Net/DNS2/RR/APL.php b/Net/DNS2/RR/APL.php deleted file mode 100644 index 4114b26f..00000000 --- a/Net/DNS2/RR/APL.php +++ /dev/null @@ -1,278 +0,0 @@ -. All rights reserved. - * - * See LICENSE for more details. - * - * @category Networking - * @package Net_DNS2 - * @author Mike Pultz - * @copyright 2020 Mike Pultz - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @link https://netdns2.com/ - * @since File available since Release 1.0.0 - * - */ - -/** - * APL Resource Record - RFC3123 - * - * +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+ - * | ADDRESSFAMILY | - * +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+ - * | PREFIX | N | AFDLENGTH | - * +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+ - * / AFDPART / - * | | - * +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+ - * - */ -class Net_DNS2_RR_APL extends Net_DNS2_RR { - // a list of all the address prefix list items - public $apl_items = []; - - /** - * method to return the rdata portion of the packet as a string - * - * @return string - * @access protected - * - */ - protected function rrToString() { - $out = ''; - - foreach ($this->apl_items as $item) { - if ($item['n'] == 1) { - $out .= '!'; - } - - $out .= $item['address_family'] . ':' . - $item['afd_part'] . '/' . $item['prefix'] . ' '; - } - - return trim($out); - } - - /** - * parses the rdata portion from a standard DNS config line - * - * @param array $rdata a string split line of values for the rdata - * - * @return boolean - * @access protected - * - */ - protected function rrFromString(array $rdata) { - foreach ($rdata as $item) { - if (preg_match('/^(!?)([1|2])\:([^\/]*)\/([0-9]{1,3})$/', $item, $m)) { - $i = [ - 'address_family' => $m[2], - 'prefix' => $m[4], - 'n' => ($m[1] == '!') ? 1 : 0, - 'afd_part' => strtolower($m[3]) - ]; - - $address = $this->_trimZeros( - $i['address_family'], $i['afd_part'] - ); - - $i['afd_length'] = cacti_sizeof(explode('.', $address)); - - $this->apl_items[] = $i; - } - } - - return true; - } - - /** - * parses the rdata of the Net_DNS2_Packet object - * - * @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet to parse the RR from - * - * @return boolean - * @access protected - * - */ - protected function rrSet(Net_DNS2_Packet &$packet) { - if ($this->rdlength > 0) { - $offset = 0; - - while ($offset < $this->rdlength) { - // - // unpack the family, prefix, negate and length values - // - $x = unpack( - 'naddress_family/Cprefix/Cextra', substr($this->rdata, $offset) - ); - - $item = [ - 'address_family' => $x['address_family'], - 'prefix' => $x['prefix'], - 'n' => ($x['extra'] >> 7) & 0x1, - 'afd_length' => $x['extra'] & 0xf - ]; - - switch($item['address_family']) { - case 1: - $r = unpack( - 'C*', substr($this->rdata, $offset + 4, $item['afd_length']) - ); - - if (cacti_sizeof($r) < 4) { - for ($c = cacti_sizeof($r) + 1; $c < 4 + 1; $c++) { - $r[$c] = 0; - } - } - - $item['afd_part'] = implode('.', $r); - - break; - case 2: - $r = unpack( - 'C*', substr($this->rdata, $offset + 4, $item['afd_length']) - ); - - if (cacti_sizeof($r) < 8) { - for ($c = cacti_sizeof($r) + 1; $c < 8 + 1; $c++) { - $r[$c] = 0; - } - } - - $item['afd_part'] = sprintf( - '%x:%x:%x:%x:%x:%x:%x:%x', - $r[1], $r[2], $r[3], $r[4], $r[5], $r[6], $r[7], $r[8] - ); - - break; - default: - return false; - } - - $this->apl_items[] = $item; - - $offset += 4 + $item['afd_length']; - } - - return true; - } - - return false; - } - - /** - * returns the rdata portion of the DNS packet - * - * @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet use for - * compressed names - * - * @return mixed either returns a binary packed - * string or null on failure - * @access protected - * - */ - protected function rrGet(Net_DNS2_Packet &$packet) { - if (cacti_sizeof($this->apl_items) > 0) { - $data = ''; - - foreach ($this->apl_items as $item) { - // - // pack the address_family and prefix values - // - $data .= pack( - 'nCC', - $item['address_family'], - $item['prefix'], - ($item['n'] << 7) | $item['afd_length'] - ); - - switch($item['address_family']) { - case 1: - $address = explode( - '.', - $this->_trimZeros($item['address_family'], $item['afd_part']) - ); - - foreach ($address as $b) { - $data .= chr($b); - } - - break; - case 2: - $address = explode( - ':', - $this->_trimZeros($item['address_family'], $item['afd_part']) - ); - - foreach ($address as $b) { - $data .= pack('H', $b); - } - - break; - default: - return null; - } - } - - $packet->offset += strlen($data); - - return $data; - } - - return null; - } - - /** - * returns an IP address with the right-hand zero's trimmed - * - * @param integer $family the IP address family from the rdata - * @param string $address the IP address - * - * @return string the trimmed IP addresss. - * - * @access private - * - */ - private function _trimZeros($family, $address) { - $a = []; - - switch($family) { - case 1: - $a = array_reverse(explode('.', $address)); - - break; - case 2: - $a = array_reverse(explode(':', $address)); - - break; - default: - return ''; - } - - foreach ($a as $value) { - if ($value === '0') { - array_shift($a); - } - } - - $out = ''; - - switch($family) { - case 1: - $out = implode('.', array_reverse($a)); - - break; - case 2: - $out = implode(':', array_reverse($a)); - - break; - default: - return ''; - } - - return $out; - } -} diff --git a/Net/DNS2/RR/ATMA.php b/Net/DNS2/RR/ATMA.php deleted file mode 100644 index ff19efcd..00000000 --- a/Net/DNS2/RR/ATMA.php +++ /dev/null @@ -1,139 +0,0 @@ -. All rights reserved. - * - * See LICENSE for more details. - * - * @category Networking - * @package Net_DNS2 - * @author Mike Pultz - * @copyright 2020 Mike Pultz - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @link https://netdns2.com/ - * @since File available since Release 1.1.0 - * - */ - -/** - * ATMA Resource Record - * - * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 - * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ - * | FORMAT | | - * | +--+--+--+--+--+--+--+--+ - * / ADDRESS / - * | | - * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ - * - */ -class Net_DNS2_RR_ATMA extends Net_DNS2_RR { - /* - * One octet that indicates the format of ADDRESS. The two possible values - * for FORMAT are value 0 indicating ATM End System Address (AESA) format - * and value 1 indicating E.164 format - */ - public $format; - - // The IPv4 address in quad-dotted notation - public $address; - - /** - * method to return the rdata portion of the packet as a string - * - * @return string - * @access protected - * - */ - protected function rrToString() { - return $this->address; - } - - /** - * parses the rdata portion from a standard DNS config line - * - * @param array $rdata a string split line of values for the rdata - * - * @return boolean - * @access protected - * - */ - protected function rrFromString(array $rdata) { - $value = array_shift($rdata); - - if (ctype_xdigit($value) == true) { - $this->format = 0; - $this->address = $value; - } elseif (is_numeric($value) == true) { - $this->format = 1; - $this->address = $value; - } else { - return false; - } - - return true; - } - - /** - * parses the rdata of the Net_DNS2_Packet object - * - * @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet to parse the RR from - * - * @return boolean - * @access protected - * - */ - protected function rrSet(Net_DNS2_Packet &$packet) { - if ($this->rdlength > 0) { - // - // unpack the format - // - $x = unpack('Cformat/N*address', $this->rdata); - - $this->format = $x['format']; - - if ($this->format == 0) { - $a = unpack('@1/H*address', $this->rdata); - - $this->address = $a['address']; - } elseif ($this->format == 1) { - $this->address = substr($this->rdata, 1, $this->rdlength - 1); - } else { - return false; - } - - return true; - } - - return false; - } - - /** - * returns the rdata portion of the DNS packet - * - * @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet use for - * compressed names - * - * @return mixed either returns a binary packed - * string or null on failure - * @access protected - * - */ - protected function rrGet(Net_DNS2_Packet &$packet) { - $data = chr($this->format); - - if ($this->format == 0) { - $data .= pack('H*', $this->address); - } elseif ($this->format == 1) { - $data .= $this->address; - } else { - return null; - } - - $packet->offset += strlen($data); - - return $data; - } -} diff --git a/Net/DNS2/RR/AVC.php b/Net/DNS2/RR/AVC.php deleted file mode 100644 index 9a934140..00000000 --- a/Net/DNS2/RR/AVC.php +++ /dev/null @@ -1,26 +0,0 @@ -. All rights reserved. - * - * See LICENSE for more details. - * - * @category Networking - * @package Net_DNS2 - * @author Mike Pultz - * @copyright 2020 Mike Pultz - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @link https://netdns2.com/ - * @since File available since Release 1.4.2 - * - */ - -/** - * The AVC RR is implemented exactly like the TXT record, so - * for now we just extend the TXT RR and use it. - * - */ -class Net_DNS2_RR_AVC extends Net_DNS2_RR_TXT { -} diff --git a/Net/DNS2/RR/CAA.php b/Net/DNS2/RR/CAA.php deleted file mode 100644 index 75a0774d..00000000 --- a/Net/DNS2/RR/CAA.php +++ /dev/null @@ -1,125 +0,0 @@ -. All rights reserved. - * - * See LICENSE for more details. - * - * @category Networking - * @package Net_DNS2 - * @author Mike Pultz - * @copyright 2020 Mike Pultz - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @link https://netdns2.com/ - * @since File available since Release 1.2.0 - * - */ - -/** - * CAA Resource Record - http://tools.ietf.org/html/draft-ietf-pkix-caa-03 - * - * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ - * | FLAGS | TAG LENGTH | - * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ - * / TAG / - * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ - * / DATA / - * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ - * - */ -class Net_DNS2_RR_CAA extends Net_DNS2_RR { - // The critcal flag - public $flags; - - // The property identifier - public $tag; - - // The property value - public $value; - - /** - * method to return the rdata portion of the packet as a string - * - * @return string - * @access protected - * - */ - protected function rrToString() { - return $this->flags . ' ' . $this->tag . ' "' . - trim($this->cleanString($this->value), '"') . '"'; - } - - /** - * parses the rdata portion from a standard DNS config line - * - * @param array $rdata a string split line of values for the rdata - * - * @return boolean - * @access protected - * - */ - protected function rrFromString(array $rdata) { - $this->flags = array_shift($rdata); - $this->tag = array_shift($rdata); - - $this->value = trim($this->cleanString(implode(' ', $rdata)), '"'); - - return true; - } - - /** - * parses the rdata of the Net_DNS2_Packet object - * - * @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet to parse the RR from - * - * @return boolean - * @access protected - * - */ - protected function rrSet(Net_DNS2_Packet &$packet) { - if ($this->rdlength > 0) { - // - // unpack the flags and tag length - // - $x = unpack('Cflags/Ctag_length', $this->rdata); - - $this->flags = $x['flags']; - $offset = 2; - - $this->tag = substr($this->rdata, $offset, $x['tag_length']); - $offset += $x['tag_length']; - - $this->value = substr($this->rdata, $offset); - - return true; - } - - return false; - } - - /** - * returns the rdata portion of the DNS packet - * - * @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet use for - * compressed names - * - * @return mixed either returns a binary packed - * string or null on failure - * @access protected - * - */ - protected function rrGet(Net_DNS2_Packet &$packet) { - if (strlen($this->value) > 0) { - $data = chr($this->flags); - $data .= chr(strlen($this->tag)) . $this->tag . $this->value; - - $packet->offset += strlen($data); - - return $data; - } - - return null; - } -} diff --git a/Net/DNS2/RR/CDNSKEY.php b/Net/DNS2/RR/CDNSKEY.php deleted file mode 100644 index e425b55e..00000000 --- a/Net/DNS2/RR/CDNSKEY.php +++ /dev/null @@ -1,28 +0,0 @@ -. All rights reserved. - * - * See LICENSE for more details. - * - * @category Networking - * @package Net_DNS2 - * @author Mike Pultz - * @copyright 2020 Mike Pultz - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @link https://netdns2.com/ - * @since File available since Release 1.4.0 - * - */ - -/** - * The CDNSKEY RR is implemented exactly like the DNSKEY record, so - * for now we just extend the DNSKEY RR and use it. - * - * http://www.rfc-editor.org/rfc/rfc7344.txt - * - */ -class Net_DNS2_RR_CDNSKEY extends Net_DNS2_RR_DNSKEY { -} diff --git a/Net/DNS2/RR/CDS.php b/Net/DNS2/RR/CDS.php deleted file mode 100644 index bbee076e..00000000 --- a/Net/DNS2/RR/CDS.php +++ /dev/null @@ -1,28 +0,0 @@ -. All rights reserved. - * - * See LICENSE for more details. - * - * @category Networking - * @package Net_DNS2 - * @author Mike Pultz - * @copyright 2020 Mike Pultz - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @link https://netdns2.com/ - * @since File available since Release 1.2.0 - * - */ - -/** - * The CDS RR is implemented exactly like the DS record, so - * for now we just extend the DS RR and use it. - * - * http://www.rfc-editor.org/rfc/rfc7344.txt - * - */ -class Net_DNS2_RR_CDS extends Net_DNS2_RR_DS { -} diff --git a/Net/DNS2/RR/CERT.php b/Net/DNS2/RR/CERT.php deleted file mode 100644 index 1a3ea1f7..00000000 --- a/Net/DNS2/RR/CERT.php +++ /dev/null @@ -1,221 +0,0 @@ -. All rights reserved. - * - * See LICENSE for more details. - * - * @category Networking - * @package Net_DNS2 - * @author Mike Pultz - * @copyright 2020 Mike Pultz - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @link https://netdns2.com/ - * @since File available since Release 0.6.0 - * - */ - -/** - * CERT Resource Record - RFC4398 section 2 - * - * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 - * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - * | format | key tag | - * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - * | algorithm | / - * +---------------+ certificate or CRL / - * / / - * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-| - * - */ -class Net_DNS2_RR_CERT extends Net_DNS2_RR { - // format's allowed for certificates - const CERT_FORMAT_RES = 0; - const CERT_FORMAT_PKIX = 1; - const CERT_FORMAT_SPKI = 2; - const CERT_FORMAT_PGP = 3; - const CERT_FORMAT_IPKIX = 4; - const CERT_FORMAT_ISPKI = 5; - const CERT_FORMAT_IPGP = 6; - const CERT_FORMAT_ACPKIX = 7; - const CERT_FORMAT_IACPKIX = 8; - const CERT_FORMAT_URI = 253; - const CERT_FORMAT_OID = 254; - - public $cert_format_name_to_id = []; - public $cert_format_id_to_name = [ - self::CERT_FORMAT_RES => 'Reserved', - self::CERT_FORMAT_PKIX => 'PKIX', - self::CERT_FORMAT_SPKI => 'SPKI', - self::CERT_FORMAT_PGP => 'PGP', - self::CERT_FORMAT_IPKIX => 'IPKIX', - self::CERT_FORMAT_ISPKI => 'ISPKI', - self::CERT_FORMAT_IPGP => 'IPGP', - self::CERT_FORMAT_ACPKIX => 'ACPKIX', - self::CERT_FORMAT_IACPKIX => 'IACPKIX', - self::CERT_FORMAT_URI => 'URI', - self::CERT_FORMAT_OID => 'OID' - ]; - - // certificate format - public $format; - - // key tag - public $keytag; - - // The algorithm used for the CERt - public $algorithm; - - // certificate - public $certificate; - - /** - * we have our own constructor so that we can load our certificate - * information for parsing. - * - * @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet to parse the RR from - * @param array $rr a array with parsed RR values - * - * @return - * - */ - public function __construct(Net_DNS2_Packet &$packet = null, array $rr = null) { - parent::__construct($packet, $rr); - - // - // load the lookup values - // - $this->cert_format_name_to_id = array_flip($this->cert_format_id_to_name); - } - - /** - * method to return the rdata portion of the packet as a string - * - * @return string - * @access protected - * - */ - protected function rrToString() { - return $this->format . ' ' . $this->keytag . ' ' . $this->algorithm . - ' ' . base64_encode($this->certificate); - } - - /** - * parses the rdata portion from a standard DNS config line - * - * @param array $rdata a string split line of values for the rdata - * - * @return boolean - * @access protected - * - */ - protected function rrFromString(array $rdata) { - // - // load and check the format; can be an int, or a mnemonic symbol - // - $this->format = array_shift($rdata); - - if (!is_numeric($this->format)) { - $mnemonic = strtoupper(trim($this->format)); - - if (!isset($this->cert_format_name_to_id[$mnemonic])) { - return false; - } - - $this->format = $this->cert_format_name_to_id[$mnemonic]; - } else { - if (!isset($this->cert_format_id_to_name[$this->format])) { - return false; - } - } - - $this->keytag = array_shift($rdata); - - // - // parse and check the algorithm; can be an int, or a mnemonic symbol - // - $this->algorithm = array_shift($rdata); - - if (!is_numeric($this->algorithm)) { - $mnemonic = strtoupper(trim($this->algorithm)); - - if (!isset(Net_DNS2_Lookups::$algorithm_name_to_id[$mnemonic])) { - return false; - } - - $this->algorithm = Net_DNS2_Lookups::$algorithm_name_to_id[ - $mnemonic - ]; - } else { - if (!isset(Net_DNS2_Lookups::$algorithm_id_to_name[$this->algorithm])) { - return false; - } - } - - // - // parse and base64 decode the certificate - // - // certificates MUST be provided base64 encoded, if not, everything will - // be broken after this point, as we assume it's base64 encoded. - // - $this->certificate = base64_decode(implode(' ', $rdata), true); - - return true; - } - - /** - * parses the rdata of the Net_DNS2_Packet object - * - * @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet to parse the RR from - * - * @return boolean - * @access protected - * - */ - protected function rrSet(Net_DNS2_Packet &$packet) { - if ($this->rdlength > 0) { - // - // unpack the format, keytag and algorithm - // - $x = unpack('nformat/nkeytag/Calgorithm', $this->rdata); - - $this->format = $x['format']; - $this->keytag = $x['keytag']; - $this->algorithm = $x['algorithm']; - - // - // copy the certificate - // - $this->certificate = substr($this->rdata, 5, $this->rdlength - 5); - - return true; - } - - return false; - } - - /** - * returns the rdata portion of the DNS packet - * - * @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet use for - * compressed names - * - * @return mixed either returns a binary packed - * string or null on failure - * @access protected - * - */ - protected function rrGet(Net_DNS2_Packet &$packet) { - if (strlen($this->certificate) > 0) { - $data = pack('nnC', $this->format, $this->keytag, $this->algorithm) . $this->certificate; - - $packet->offset += strlen($data); - - return $data; - } - - return null; - } -} diff --git a/Net/DNS2/RR/CNAME.php b/Net/DNS2/RR/CNAME.php deleted file mode 100644 index 6a2b6593..00000000 --- a/Net/DNS2/RR/CNAME.php +++ /dev/null @@ -1,97 +0,0 @@ -. All rights reserved. - * - * See LICENSE for more details. - * - * @category Networking - * @package Net_DNS2 - * @author Mike Pultz - * @copyright 2020 Mike Pultz - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @link https://netdns2.com/ - * @since File available since Release 0.6.0 - * - */ - -/** - * CNAME Resource Record - RFC1035 section 3.3.1 - * - * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ - * / CNAME / - * / / - * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ - * - */ -class Net_DNS2_RR_CNAME extends Net_DNS2_RR { - // The canonical name - public $cname; - - /** - * method to return the rdata portion of the packet as a string - * - * @return string - * @access protected - * - */ - protected function rrToString() { - return $this->cleanString($this->cname) . '.'; - } - - /** - * parses the rdata portion from a standard DNS config line - * - * @param array $rdata a string split line of values for the rdata - * - * @return boolean - * @access protected - * - */ - protected function rrFromString(array $rdata) { - $this->cname = $this->cleanString(array_shift($rdata)); - - return true; - } - - /** - * parses the rdata of the Net_DNS2_Packet object - * - * @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet to parse the RR from - * - * @return boolean - * @access protected - * - */ - protected function rrSet(Net_DNS2_Packet &$packet) { - if ($this->rdlength > 0) { - $offset = $packet->offset; - $this->cname = Net_DNS2_Packet::expand($packet, $offset); - - return true; - } - - return false; - } - - /** - * returns the rdata portion of the DNS packet - * - * @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet use for - * compressed names - * - * @return mixed either returns a binary packed - * string or null on failure - * @access protected - * - */ - protected function rrGet(Net_DNS2_Packet &$packet) { - if (strlen($this->cname) > 0) { - return $packet->compress($this->cname, $packet->offset); - } - - return null; - } -} diff --git a/Net/DNS2/RR/CSYNC.php b/Net/DNS2/RR/CSYNC.php deleted file mode 100644 index c4a85bcb..00000000 --- a/Net/DNS2/RR/CSYNC.php +++ /dev/null @@ -1,142 +0,0 @@ -. All rights reserved. - * - * See LICENSE for more details. - * - * @category Networking - * @package Net_DNS2 - * @author Mike Pultz - * @copyright 2020 Mike Pultz - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @link https://netdns2.com/ - * @since File available since Release 1.4.1 - * - */ - -/** - * CSYNC Resource Record - RFC 7477 seciond 2.1.1 - * - * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ - * | SOA Serial | - * | | - * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ - * | Flags | - * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ - * / Type Bit Map / - * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ - * - */ -class Net_DNS2_RR_CSYNC extends Net_DNS2_RR { - // serial number - public $serial; - - // flags - public $flags; - - // array of RR type names - public $type_bit_maps = []; - - /** - * method to return the rdata portion of the packet as a string - * - * @return string - * @access protected - * - */ - protected function rrToString() { - $out = $this->serial . ' ' . $this->flags; - - // - // show the RR's - // - foreach ($this->type_bit_maps as $rr) { - $out .= ' ' . strtoupper($rr); - } - - return $out; - } - - /** - * parses the rdata portion from a standard DNS config line - * - * @param array $rdata a string split line of values for the rdata - * - * @return boolean - * @access protected - * - */ - protected function rrFromString(array $rdata) { - $this->serial = array_shift($rdata); - $this->flags = array_shift($rdata); - - $this->type_bit_maps = $rdata; - - return true; - } - - /** - * parses the rdata of the Net_DNS2_Packet object - * - * @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet to parse the RR from - * - * @return boolean - * @access protected - * - */ - protected function rrSet(Net_DNS2_Packet &$packet) { - if ($this->rdlength > 0) { - // - // unpack the serial and flags values - // - $x = unpack('@' . $packet->offset . '/Nserial/nflags', $packet->rdata); - - $this->serial = Net_DNS2::expandUint32($x['serial']); - $this->flags = $x['flags']; - - // - // parse out the RR bitmap - // - $this->type_bit_maps = Net_DNS2_BitMap::bitMapToArray( - substr($this->rdata, 6) - ); - - return true; - } - - return false; - } - - /** - * returns the rdata portion of the DNS packet - * - * @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet use for - * compressed names - * - * @return mixed either returns a binary packed - * string or null on failure - * @access protected - * - */ - protected function rrGet(Net_DNS2_Packet &$packet) { - // - // pack the serial and flags values - // - $data = pack('Nn', $this->serial, $this->flags); - - // - // convert the array of RR names to a type bitmap - // - $data .= Net_DNS2_BitMap::arrayToBitMap($this->type_bit_maps); - - // - // advance the offset - // - $packet->offset += strlen($data); - - return $data; - } -} diff --git a/Net/DNS2/RR/DHCID.php b/Net/DNS2/RR/DHCID.php deleted file mode 100644 index c97cd2e4..00000000 --- a/Net/DNS2/RR/DHCID.php +++ /dev/null @@ -1,145 +0,0 @@ -. All rights reserved. - * - * See LICENSE for more details. - * - * @category Networking - * @package Net_DNS2 - * @author Mike Pultz - * @copyright 2020 Mike Pultz - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @link https://netdns2.com/ - * @since File available since Release 0.6.0 - * - */ - -/** - * DHCID Resource Record - RFC4701 section 3.1 - * - * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ - * | ID Type Code | - * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ - * | Digest Type | / - * +--+--+--+--+--+--+--+--+ / - * / / - * / Digest / - * / / - * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ - * - */ -class Net_DNS2_RR_DHCID extends Net_DNS2_RR { - // Identifier type - public $id_type; - - // Digest Type - public $digest_type; - - // The digest - public $digest; - - /** - * method to return the rdata portion of the packet as a string - * - * @return string - * @access protected - * - */ - protected function rrToString() { - $out = pack('nC', $this->id_type, $this->digest_type); - $out .= base64_decode($this->digest, true); - - return base64_encode($out); - } - - /** - * parses the rdata portion from a standard DNS config line - * - * @param array $rdata a string split line of values for the rdata - * - * @return boolean - * @access protected - * - */ - protected function rrFromString(array $rdata) { - $data = base64_decode(array_shift($rdata), true); - - if (strlen($data) > 0) { - // - // unpack the id type and digest type - // - $x = unpack('nid_type/Cdigest_type', $data); - - $this->id_type = $x['id_type']; - $this->digest_type = $x['digest_type']; - - // - // copy out the digest - // - $this->digest = base64_encode(substr($data, 3, strlen($data) - 3)); - - return true; - } - - return false; - } - - /** - * parses the rdata of the Net_DNS2_Packet object - * - * @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet to parse the RR from - * - * @return boolean - * @access protected - * - */ - protected function rrSet(Net_DNS2_Packet &$packet) { - if ($this->rdlength > 0) { - // - // unpack the id type and digest type - // - $x = unpack('nid_type/Cdigest_type', $this->rdata); - - $this->id_type = $x['id_type']; - $this->digest_type = $x['digest_type']; - - // - // copy out the digest - // - $this->digest = base64_encode( - substr($this->rdata, 3, $this->rdlength - 3) - ); - - return true; - } - - return false; - } - - /** - * returns the rdata portion of the DNS packet - * - * @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet use for - * compressed names - * - * @return mixed either returns a binary packed - * string or null on failure - * @access protected - * - */ - protected function rrGet(Net_DNS2_Packet &$packet) { - if (strlen($this->digest) > 0) { - $data = pack('nC', $this->id_type, $this->digest_type) . - base64_decode($this->digest, true); - - $packet->offset += strlen($data); - - return $data; - } - - return null; - } -} diff --git a/Net/DNS2/RR/DLV.php b/Net/DNS2/RR/DLV.php deleted file mode 100644 index 8f1d3693..00000000 --- a/Net/DNS2/RR/DLV.php +++ /dev/null @@ -1,26 +0,0 @@ -. All rights reserved. - * - * See LICENSE for more details. - * - * @category Networking - * @package Net_DNS2 - * @author Mike Pultz - * @copyright 2020 Mike Pultz - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @link https://netdns2.com/ - * @since File available since Release 0.6.0 - * - */ - -/** - * The DLV RR is implemented exactly like the DS RR; so we just extend that - * class, and use all of it's methods - * - */ -class Net_DNS2_RR_DLV extends Net_DNS2_RR_DS { -} diff --git a/Net/DNS2/RR/DNAME.php b/Net/DNS2/RR/DNAME.php deleted file mode 100644 index b3c35dee..00000000 --- a/Net/DNS2/RR/DNAME.php +++ /dev/null @@ -1,97 +0,0 @@ -. All rights reserved. - * - * See LICENSE for more details. - * - * @category Networking - * @package Net_DNS2 - * @author Mike Pultz - * @copyright 2020 Mike Pultz - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @link https://netdns2.com/ - * @since File available since Release 0.6.0 - * - */ - -/** - * DNAME Resource Record - RFC2672 section 3 - * - * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ - * / DNAME / - * / / - * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ - * - */ -class Net_DNS2_RR_DNAME extends Net_DNS2_RR { - // The target name - public $dname; - - /** - * method to return the rdata portion of the packet as a string - * - * @return string - * @access protected - * - */ - protected function rrToString() { - return $this->cleanString($this->dname) . '.'; - } - - /** - * parses the rdata portion from a standard DNS config line - * - * @param array $rdata a string split line of values for the rdata - * - * @return boolean - * @access protected - * - */ - protected function rrFromString(array $rdata) { - $this->dname = $this->cleanString(array_shift($rdata)); - - return true; - } - - /** - * parses the rdata of the Net_DNS2_Packet object - * - * @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet to parse the RR from - * - * @return boolean - * @access protected - * - */ - protected function rrSet(Net_DNS2_Packet &$packet) { - if ($this->rdlength > 0) { - $offset = $packet->offset; - $this->dname = Net_DNS2_Packet::expand($packet, $offset); - - return true; - } - - return false; - } - - /** - * returns the rdata portion of the DNS packet - * - * @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet use for - * compressed names - * - * @return mixed either returns a binary packed - * string or null on failure - * @access protected - * - */ - protected function rrGet(Net_DNS2_Packet &$packet) { - if (strlen($this->dname) > 0) { - return $packet->compress($this->dname, $packet->offset); - } - - return null; - } -} diff --git a/Net/DNS2/RR/DNSKEY.php b/Net/DNS2/RR/DNSKEY.php deleted file mode 100644 index ae1c04a0..00000000 --- a/Net/DNS2/RR/DNSKEY.php +++ /dev/null @@ -1,135 +0,0 @@ -. All rights reserved. - * - * See LICENSE for more details. - * - * @category Networking - * @package Net_DNS2 - * @author Mike Pultz - * @copyright 2020 Mike Pultz - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @link https://netdns2.com/ - * @since File available since Release 0.6.0 - * - */ - -/** - * DNSKEY Resource Record - RFC4034 sction 2.1 - * - * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 - * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - * | Flags | Protocol | Algorithm | - * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - * / / - * / Public Key / - * / / - * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - * - */ -class Net_DNS2_RR_DNSKEY extends Net_DNS2_RR { - // flags - public $flags; - - // protocol - public $protocol; - - // algorithm used - public $algorithm; - - // the public key - public $key; - - /** - * method to return the rdata portion of the packet as a string - * - * @return string - * @access protected - * - */ - protected function rrToString() { - return $this->flags . ' ' . $this->protocol . ' ' . - $this->algorithm . ' ' . $this->key; - } - - /** - * parses the rdata portion from a standard DNS config line - * - * @param array $rdata a string split line of values for the rdata - * - * @return boolean - * @access protected - * - */ - protected function rrFromString(array $rdata) { - $this->flags = array_shift($rdata); - $this->protocol = array_shift($rdata); - $this->algorithm = array_shift($rdata); - $this->key = implode(' ', $rdata); - - return true; - } - - /** - * parses the rdata of the Net_DNS2_Packet object - * - * @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet to parse the RR from - * - * @return boolean - * @access protected - * - */ - protected function rrSet(Net_DNS2_Packet &$packet) { - if ($this->rdlength > 0) { - // - // unpack the flags, protocol and algorithm - // - $x = unpack('nflags/Cprotocol/Calgorithm', $this->rdata); - - // - // TODO: right now we're just displaying what's in DNS; we really - // should be parsing bit 7 and bit 15 of the flags field, and store - // those separately. - // - // right now the DNSSEC implementation is really just for display, - // we don't validate or handle any of the keys - // - $this->flags = $x['flags']; - $this->protocol = $x['protocol']; - $this->algorithm = $x['algorithm']; - - $this->key = base64_encode(substr($this->rdata, 4)); - - return true; - } - - return false; - } - - /** - * returns the rdata portion of the DNS packet - * - * @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet use for - * compressed names - * - * @return mixed either returns a binary packed - * string or null on failure - * @access protected - * - */ - protected function rrGet(Net_DNS2_Packet &$packet) { - if (strlen($this->key) > 0) { - $data = pack('nCC', $this->flags, $this->protocol, $this->algorithm); - $data .= base64_decode($this->key, true); - - $packet->offset += strlen($data); - - return $data; - } - - return null; - } -} diff --git a/Net/DNS2/RR/DS.php b/Net/DNS2/RR/DS.php deleted file mode 100644 index 71499cb7..00000000 --- a/Net/DNS2/RR/DS.php +++ /dev/null @@ -1,124 +0,0 @@ -. All rights reserved. - * - * See LICENSE for more details. - * - * @category Networking - * @package Net_DNS2 - * @author Mike Pultz - * @copyright 2020 Mike Pultz - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @link https://netdns2.com/ - * @since File available since Release 0.6.0 - * - */ - -/** - * DS Resource Record - RFC4034 sction 5.1 - * - * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 - * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - * | Key Tag | Algorithm | Digest Type | - * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - * / / - * / Digest / - * / / - * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - * - */ -class Net_DNS2_RR_DS extends Net_DNS2_RR { - // key tag - public $keytag; - - // algorithm number - public $algorithm; - - // algorithm used to construct the digest - public $digesttype; - - // the digest data - public $digest; - - /** - * method to return the rdata portion of the packet as a string - * - * @return string - * @access protected - * - */ - protected function rrToString() { - return $this->keytag . ' ' . $this->algorithm . ' ' . $this->digesttype . ' ' . $this->digest; - } - - /** - * parses the rdata portion from a standard DNS config line - * - * @param array $rdata a string split line of values for the rdata - * - * @return boolean - * @access protected - * - */ - protected function rrFromString(array $rdata) { - $this->keytag = array_shift($rdata); - $this->algorithm = array_shift($rdata); - $this->digesttype = array_shift($rdata); - $this->digest = implode('', $rdata); - - return true; - } - - /** - * parses the rdata of the Net_DNS2_Packet object - * - * @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet to parse the RR from - * - * @return boolean - * @access protected - * - */ - protected function rrSet(Net_DNS2_Packet &$packet) { - if ($this->rdlength > 0) { - // - // unpack the keytag, algorithm and digesttype - // - $x = unpack('nkeytag/Calgorithm/Cdigesttype/H*digest', $this->rdata); - - $this->keytag = $x['keytag']; - $this->algorithm = $x['algorithm']; - $this->digesttype = $x['digesttype']; - $this->digest = $x['digest']; - - return true; - } - - return false; - } - - /** - * returns the rdata portion of the DNS packet - * - * @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet use for - * compressed names - * - * @return mixed either returns a binary packed - * string or null on failure - * @access protected - * - */ - protected function rrGet(Net_DNS2_Packet &$packet) { - if (strlen($this->digest) > 0) { - $data = pack('nCCH*', $this->keytag, $this->algorithm, $this->digesttype, $this->digest); - - $packet->offset += strlen($data); - - return $data; - } - - return null; - } -} diff --git a/Net/DNS2/RR/EID.php b/Net/DNS2/RR/EID.php deleted file mode 100644 index 987b2a53..00000000 --- a/Net/DNS2/RR/EID.php +++ /dev/null @@ -1,77 +0,0 @@ -. All rights reserved. - * - * See LICENSE for more details. - * - * @category Networking - * @package Net_DNS2 - * @author Mike Pultz - * @copyright 2020 Mike Pultz - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @link https://netdns2.com/ - * @since File available since Release 0.6.0 - * - */ - -/** - * EID Resource Record - undefined; the rdata is simply used as-is in it's - * binary format, so not process has to be done. - * - */ -class Net_DNS2_RR_EID extends Net_DNS2_RR { - /** - * method to return the rdata portion of the packet as a string - * - * @return string - * @access protected - * - */ - protected function rrToString() { - return ''; - } - - /** - * parses the rdata portion from a standard DNS config line - * - * @param array $rdata a string split line of values for the rdata - * - * @return boolean - * @access protected - * - */ - protected function rrFromString(array $rdata) { - return true; - } - - /** - * parses the rdata of the Net_DNS2_Packet object - * - * @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet to parse the RR from - * - * @return boolean - * @access protected - * - */ - protected function rrSet(Net_DNS2_Packet &$packet) { - return true; - } - - /** - * returns the rdata portion of the DNS packet - * - * @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet use for - * compressed names - * - * @return mixed either returns a binary packed - * string or null on failure - * @access protected - * - */ - protected function rrGet(Net_DNS2_Packet &$packet) { - return $this->rdata; - } -} diff --git a/Net/DNS2/RR/EUI48.php b/Net/DNS2/RR/EUI48.php deleted file mode 100644 index 65c1f31f..00000000 --- a/Net/DNS2/RR/EUI48.php +++ /dev/null @@ -1,133 +0,0 @@ -. All rights reserved. - * - * See LICENSE for more details. - * - * @category Networking - * @package Net_DNS2 - * @author Mike Pultz - * @copyright 2020 Mike Pultz - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @link https://netdns2.com/ - * @since File available since Release 1.3.2 - * - */ - -/** - * EUI48 Resource Record - RFC7043 section 3.1 - * - * 0 1 2 3 - * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 - * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - * | EUI-48 Address | - * | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - * | | - * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - * - */ -class Net_DNS2_RR_EUI48 extends Net_DNS2_RR { - // The EUI48 address, in hex format - public $address; - - /** - * method to return the rdata portion of the packet as a string - * - * @return string - * @access protected - * - */ - protected function rrToString() { - return $this->address; - } - - /** - * parses the rdata portion from a standard DNS config line - * - * @param array $rdata a string split line of values for the rdata - * - * @return boolean - * @access protected - * - */ - protected function rrFromString(array $rdata) { - $value = array_shift($rdata); - - // - // re: RFC 7043, the field must be represented as six two-digit hex numbers - // separated by hyphens. - // - $a = explode('-', $value); - - if (cacti_sizeof($a) != 6) { - return false; - } - - // - // make sure they're all hex values - // - foreach ($a as $i) { - if (ctype_xdigit($i) == false) { - return false; - } - } - - // - // store it - // - $this->address = strtolower($value); - - return true; - } - - /** - * parses the rdata of the Net_DNS2_Packet object - * - * @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet to parse the RR from - * - * @return boolean - * @access protected - * - */ - protected function rrSet(Net_DNS2_Packet &$packet) { - if ($this->rdlength > 0) { - $x = unpack('C6', $this->rdata); - - if (cacti_sizeof($x) == 6) { - $this->address = vsprintf('%02x-%02x-%02x-%02x-%02x-%02x', $x); - - return true; - } - } - - return false; - } - - /** - * returns the rdata portion of the DNS packet - * - * @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet use for - * compressed names - * - * @return mixed either returns a binary packed - * string or null on failure - * @access protected - * - */ - protected function rrGet(Net_DNS2_Packet &$packet) { - $data = ''; - - $a = explode('-', $this->address); - - foreach ($a as $b) { - $data .= chr(hexdec($b)); - } - - $packet->offset += 6; - - return $data; - } -} diff --git a/Net/DNS2/RR/EUI64.php b/Net/DNS2/RR/EUI64.php deleted file mode 100644 index d3b9d5c8..00000000 --- a/Net/DNS2/RR/EUI64.php +++ /dev/null @@ -1,134 +0,0 @@ -. All rights reserved. - * - * See LICENSE for more details. - * - * @category Networking - * @package Net_DNS2 - * @author Mike Pultz - * @copyright 2020 Mike Pultz - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @link https://netdns2.com/ - * @since File available since Release 1.3.2 - * - */ - -/** - * EUI64 Resource Record - RFC7043 section 4.1 - * - * 0 1 2 3 - * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 - * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - * | EUI-64 Address | - * | | - * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - * - */ -class Net_DNS2_RR_EUI64 extends Net_DNS2_RR { - // The EUI64 address, in hex format - public $address; - - /** - * method to return the rdata portion of the packet as a string - * - * @return string - * @access protected - * - */ - protected function rrToString() { - return $this->address; - } - - /** - * parses the rdata portion from a standard DNS config line - * - * @param array $rdata a string split line of values for the rdata - * - * @return boolean - * @access protected - * - */ - protected function rrFromString(array $rdata) { - $value = array_shift($rdata); - - // - // re: RFC 7043, the field must be represented as 8 two-digit hex numbers - // separated by hyphens. - // - $a = explode('-', $value); - - if (cacti_sizeof($a) != 8) { - return false; - } - - // - // make sure they're all hex values - // - foreach ($a as $i) { - if (ctype_xdigit($i) == false) { - return false; - } - } - - // - // store it - // - $this->address = strtolower($value); - - return true; - } - - /** - * parses the rdata of the Net_DNS2_Packet object - * - * @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet to parse the RR from - * - * @return boolean - * @access protected - * - */ - protected function rrSet(Net_DNS2_Packet &$packet) { - if ($this->rdlength > 0) { - $x = unpack('C8', $this->rdata); - - if (cacti_sizeof($x) == 8) { - $this->address = vsprintf( - '%02x-%02x-%02x-%02x-%02x-%02x-%02x-%02x', $x - ); - - return true; - } - } - - return false; - } - - /** - * returns the rdata portion of the DNS packet - * - * @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet use for - * compressed names - * - * @return mixed either returns a binary packed - * string or null on failure - * @access protected - * - */ - protected function rrGet(Net_DNS2_Packet &$packet) { - $data = ''; - - $a = explode('-', $this->address); - - foreach ($a as $b) { - $data .= chr(hexdec($b)); - } - - $packet->offset += 8; - - return $data; - } -} diff --git a/Net/DNS2/RR/HINFO.php b/Net/DNS2/RR/HINFO.php deleted file mode 100644 index c3409dd8..00000000 --- a/Net/DNS2/RR/HINFO.php +++ /dev/null @@ -1,114 +0,0 @@ -. All rights reserved. - * - * See LICENSE for more details. - * - * @category Networking - * @package Net_DNS2 - * @author Mike Pultz - * @copyright 2020 Mike Pultz - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @link https://netdns2.com/ - * @since File available since Release 0.6.0 - * - */ - -/** - * HINFO Resource Record - RFC1035 section 3.3.2 - * - * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ - * / CPU / - * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ - * / OS / - * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ - * - */ -class Net_DNS2_RR_HINFO extends Net_DNS2_RR { - // computer informatino - public $cpu; - - // operataing system - public $os; - - /** - * method to return the rdata portion of the packet as a string - * - * @return string - * @access protected - * - */ - protected function rrToString() { - return $this->formatString($this->cpu) . ' ' . $this->formatString($this->os); - } - - /** - * parses the rdata portion from a standard DNS config line - * - * @param array $rdata a string split line of values for the rdata - * - * @return boolean - * @access protected - * - */ - protected function rrFromString(array $rdata) { - $data = $this->buildString($rdata); - - if (cacti_sizeof($data) == 2) { - $this->cpu = trim($data[0], '"'); - $this->os = trim($data[1], '"'); - - return true; - } - - return false; - } - - /** - * parses the rdata of the Net_DNS2_Packet object - * - * @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet to parse the RR from - * - * @return boolean - * @access protected - * - */ - protected function rrSet(Net_DNS2_Packet &$packet) { - if ($this->rdlength > 0) { - $offset = $packet->offset; - - $this->cpu = Net_DNS2_Packet::label($packet, $offset); - $this->os = Net_DNS2_Packet::label($packet, $offset); - - return true; - } - - return false; - } - - /** - * returns the rdata portion of the DNS packet - * - * @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet use for - * compressed names - * - * @return mixed either returns a binary packed - * string or null on failure - * @access protected - * - */ - protected function rrGet(Net_DNS2_Packet &$packet) { - if (strlen($this->cpu) > 0) { - $data = pack('Ca*Ca*', strlen($this->cpu), $this->cpu, strlen($this->os), $this->os); - - $packet->offset += strlen($data); - - return $data; - } - - return null; - } -} diff --git a/Net/DNS2/RR/HIP.php b/Net/DNS2/RR/HIP.php deleted file mode 100644 index 6b393af4..00000000 --- a/Net/DNS2/RR/HIP.php +++ /dev/null @@ -1,216 +0,0 @@ -. All rights reserved. - * - * See LICENSE for more details. - * - * @category Networking - * @package Net_DNS2 - * @author Mike Pultz - * @copyright 2020 Mike Pultz - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @link https://netdns2.com/ - * @since File available since Release 1.0.0 - * - */ - -/** - * HIP Resource Record - RFC5205 section 5 - * - * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 - * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - * | HIT length | PK algorithm | PK length | - * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - * | | - * ~ HIT ~ - * | | - * + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - * | | | - * +-+-+-+-+-+-+-+-+-+-+-+ + - * | Public Key | - * ~ ~ - * | | - * + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - * | | | - * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + - * | | - * ~ Rendezvous Servers ~ - * | | - * + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - * | | - * +-+-+-+-+-+-+-+ - * - */ -class Net_DNS2_RR_HIP extends Net_DNS2_RR { - // The length of the HIT field - public $hit_length; - - // the public key cryptographic algorithm - public $pk_algorithm; - - // the length of the public key field - public $pk_length; - - // The HIT is stored as a binary value in network byte order. - public $hit; - - // The public key - public $public_key; - - // a list of rendezvous servers - public $rendezvous_servers = []; - - /** - * method to return the rdata portion of the packet as a string - * - * @return string - * @access protected - * - */ - protected function rrToString() { - $out = $this->pk_algorithm . ' ' . - $this->hit . ' ' . $this->public_key . ' '; - - foreach ($this->rendezvous_servers as $index => $server) { - $out .= $server . '. '; - } - - return trim($out); - } - - /** - * parses the rdata portion from a standard DNS config line - * - * @param array $rdata a string split line of values for the rdata - * - * @return boolean - * @access protected - * - */ - protected function rrFromString(array $rdata) { - $this->pk_algorithm = array_shift($rdata); - $this->hit = strtoupper(array_shift($rdata)); - $this->public_key = array_shift($rdata); - - // - // anything left on the array, must be one or more rendezevous servers. add - // them and strip off the trailing dot - // - if (cacti_sizeof($rdata) > 0) { - $this->rendezvous_servers = preg_replace('/\.$/', '', $rdata); - } - - // - // store the lengths; - // - $this->hit_length = strlen(pack('H*', $this->hit)); - $this->pk_length = strlen(base64_decode($this->public_key, true)); - - return true; - } - - /** - * parses the rdata of the Net_DNS2_Packet object - * - * @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet to parse the RR from - * - * @return boolean - * @access protected - * - */ - protected function rrSet(Net_DNS2_Packet &$packet) { - if ($this->rdlength > 0) { - // - // unpack the algorithm and length values - // - $x = unpack('Chit_length/Cpk_algorithm/npk_length', $this->rdata); - - $this->hit_length = $x['hit_length']; - $this->pk_algorithm = $x['pk_algorithm']; - $this->pk_length = $x['pk_length']; - - $offset = 4; - - // - // copy out the HIT value - // - $hit = unpack('H*', substr($this->rdata, $offset, $this->hit_length)); - - $this->hit = strtoupper($hit[1]); - $offset += $this->hit_length; - - // - // copy out the public key - // - $this->public_key = base64_encode( - substr($this->rdata, $offset, $this->pk_length) - ); - $offset += $this->pk_length; - - // - // copy out any possible rendezvous servers - // - $offset = $packet->offset + $offset; - - while (($offset - $packet->offset) < $this->rdlength) { - $this->rendezvous_servers[] = Net_DNS2_Packet::expand( - $packet, $offset - ); - } - - return true; - } - - return false; - } - - /** - * returns the rdata portion of the DNS packet - * - * @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet use for - * compressed names - * - * @return mixed either returns a binary packed - * string or null on failure - * @access protected - * - */ - protected function rrGet(Net_DNS2_Packet &$packet) { - if ((strlen($this->hit) > 0) && (strlen($this->public_key) > 0)) { - // - // pack the length, algorithm and HIT values - // - $data = pack( - 'CCnH*', - $this->hit_length, - $this->pk_algorithm, - $this->pk_length, - $this->hit - ); - - // - // add the public key - // - $data .= base64_decode($this->public_key, true); - - // - // add the offset - // - $packet->offset += strlen($data); - - // - // add each rendezvous server - // - foreach ($this->rendezvous_servers as $index => $server) { - $data .= $packet->compress($server, $packet->offset); - } - - return $data; - } - - return null; - } -} diff --git a/Net/DNS2/RR/IPSECKEY.php b/Net/DNS2/RR/IPSECKEY.php deleted file mode 100644 index fb136475..00000000 --- a/Net/DNS2/RR/IPSECKEY.php +++ /dev/null @@ -1,322 +0,0 @@ -. All rights reserved. - * - * See LICENSE for more details. - * - * @category Networking - * @package Net_DNS2 - * @author Mike Pultz - * @copyright 2020 Mike Pultz - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @link https://netdns2.com/ - * @since File available since Release 0.6.0 - * - */ - -/** - * IPSECKEY Resource Record - RFC4025 section 2.1 - * - * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 - * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - * | precedence | gateway type | algorithm | gateway | - * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-------------+ + - * ~ gateway ~ - * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - * | / - * / public key / - * / / - * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-| - * - */ -class Net_DNS2_RR_IPSECKEY extends Net_DNS2_RR { - const GATEWAY_TYPE_NONE = 0; - const GATEWAY_TYPE_IPV4 = 1; - const GATEWAY_TYPE_IPV6 = 2; - const GATEWAY_TYPE_DOMAIN = 3; - - const ALGORITHM_NONE = 0; - const ALGORITHM_DSA = 1; - const ALGORITHM_RSA = 2; - - // Precedence (used the same was as a preference field) - public $precedence; - - /* - * Gateway type - specifies the format of the gataway information - * This can be either: - * - * 0 No Gateway - * 1 IPv4 address - * 2 IPV6 address - * 3 wire-encoded domain name (not compressed) - * - */ - public $gateway_type; - - /* - * The algorithm used - * - * This can be: - * - * 0 No key is present - * 1 DSA key is present - * 2 RSA key is present - * - */ - public $algorithm; - - // The gatway information - public $gateway; - - // the public key - public $key; - - /** - * method to return the rdata portion of the packet as a string - * - * @return string - * @access protected - * - */ - protected function rrToString() { - $out = $this->precedence . ' ' . $this->gateway_type . ' ' . - $this->algorithm . ' '; - - switch($this->gateway_type) { - case self::GATEWAY_TYPE_NONE: - $out .= '. '; - - break; - case self::GATEWAY_TYPE_IPV4: - case self::GATEWAY_TYPE_IPV6: - $out .= $this->gateway . ' '; - - break; - case self::GATEWAY_TYPE_DOMAIN: - $out .= $this->gateway . '. '; - - break; - } - - $out .= $this->key; - - return $out; - } - - /** - * parses the rdata portion from a standard DNS config line - * - * @param array $rdata a string split line of values for the rdata - * - * @return boolean - * @access protected - * - */ - protected function rrFromString(array $rdata) { - // - // load the data - // - $precedence = array_shift($rdata); - $gateway_type = array_shift($rdata); - $algorithm = array_shift($rdata); - $gateway = trim(strtolower(trim(array_shift($rdata))), '.'); - $key = array_shift($rdata); - - // - // validate it - // - switch($gateway_type) { - case self::GATEWAY_TYPE_NONE: - $gateway = ''; - - break; - case self::GATEWAY_TYPE_IPV4: - if (Net_DNS2::isIPv4($gateway) == false) { - return false; - } - - break; - case self::GATEWAY_TYPE_IPV6: - if (Net_DNS2::isIPv6($gateway) == false) { - return false; - } - - break; - case self::GATEWAY_TYPE_DOMAIN:; // do nothing - - break; - default: - return false; - } - - // - // check the algorithm and key - // - switch($algorithm) { - case self::ALGORITHM_NONE: - $key = ''; - - break; - case self::ALGORITHM_DSA: - case self::ALGORITHM_RSA:; // do nothing - - break; - default: - return false; - } - - // - // store the values - // - $this->precedence = $precedence; - $this->gateway_type = $gateway_type; - $this->algorithm = $algorithm; - $this->gateway = $gateway; - $this->key = $key; - - return true; - } - - /** - * parses the rdata of the Net_DNS2_Packet object - * - * @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet to parse the RR from - * - * @return boolean - * @access protected - * - */ - protected function rrSet(Net_DNS2_Packet &$packet) { - if ($this->rdlength > 0) { - // - // parse off the precedence, gateway type and algorithm - // - $x = unpack('Cprecedence/Cgateway_type/Calgorithm', $this->rdata); - - $this->precedence = $x['precedence']; - $this->gateway_type = $x['gateway_type']; - $this->algorithm = $x['algorithm']; - - $offset = 3; - - // - // extract the gatway based on the type - // - switch($this->gateway_type) { - case self::GATEWAY_TYPE_NONE: - $this->gateway = ''; - - break; - case self::GATEWAY_TYPE_IPV4: - $this->gateway = inet_ntop(substr($this->rdata, $offset, 4)); - $offset += 4; - - break; - case self::GATEWAY_TYPE_IPV6: - $ip = unpack('n8', substr($this->rdata, $offset, 16)); - - if (cacti_sizeof($ip) == 8) { - $this->gateway = vsprintf('%x:%x:%x:%x:%x:%x:%x:%x', $ip); - $offset += 16; - } else { - return false; - } - - break; - case self::GATEWAY_TYPE_DOMAIN: - $doffset = $offset + $packet->offset; - $this->gateway = Net_DNS2_Packet::expand($packet, $doffset); - $offset = ($doffset - $packet->offset); - - break; - default: - return false; - } - - // - // extract the key - // - switch($this->algorithm) { - case self::ALGORITHM_NONE: - $this->key = ''; - - break; - case self::ALGORITHM_DSA: - case self::ALGORITHM_RSA: - $this->key = base64_encode(substr($this->rdata, $offset)); - - break; - default: - return false; - } - - return true; - } - - return false; - } - - /** - * returns the rdata portion of the DNS packet - * - * @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet use for - * compressed names - * - * @return mixed either returns a binary packed - * string or null on failure - * @access protected - * - */ - protected function rrGet(Net_DNS2_Packet &$packet) { - // - // pack the precedence, gateway type and algorithm - // - $data = pack( - 'CCC', $this->precedence, $this->gateway_type, $this->algorithm - ); - - // - // add the gateway based on the type - // - switch($this->gateway_type) { - case self::GATEWAY_TYPE_NONE:; // add nothing - - break; - case self::GATEWAY_TYPE_IPV4: - case self::GATEWAY_TYPE_IPV6: - $data .= inet_pton($this->gateway); - - break; - case self::GATEWAY_TYPE_DOMAIN: - $data .= chr(strlen($this->gateway)) . $this->gateway; - - break; - default: - return null; - } - - // - // add the key if there's one specified - // - switch($this->algorithm) { - case self::ALGORITHM_NONE:; // add nothing - - break; - case self::ALGORITHM_DSA: - case self::ALGORITHM_RSA: - $data .= base64_decode($this->key, true); - - break; - default: - return null; - } - - $packet->offset += strlen($data); - - return $data; - } -} diff --git a/Net/DNS2/RR/ISDN.php b/Net/DNS2/RR/ISDN.php deleted file mode 100644 index 42d63033..00000000 --- a/Net/DNS2/RR/ISDN.php +++ /dev/null @@ -1,129 +0,0 @@ -. All rights reserved. - * - * See LICENSE for more details. - * - * @category Networking - * @package Net_DNS2 - * @author Mike Pultz - * @copyright 2020 Mike Pultz - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @link https://netdns2.com/ - * @since File available since Release 0.6.0 - * - */ - -/** - * ISDN Resource Record - RFC1183 section 3.2 - * - * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ - * / ISDN-address / - * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ - * / SA / - * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ - * - */ -class Net_DNS2_RR_ISDN extends Net_DNS2_RR { - // ISDN Number - public $isdnaddress; - - // Sub-Address - public $sa; - - /** - * method to return the rdata portion of the packet as a string - * - * @return string - * @access protected - * - */ - protected function rrToString() { - return $this->formatString($this->isdnaddress) . ' ' . - $this->formatString($this->sa); - } - - /** - * parses the rdata portion from a standard DNS config line - * - * @param array $rdata a string split line of values for the rdata - * - * @return boolean - * @access protected - * - */ - protected function rrFromString(array $rdata) { - $data = $this->buildString($rdata); - - if (cacti_sizeof($data) >= 1) { - $this->isdnaddress = $data[0]; - - if (isset($data[1])) { - $this->sa = $data[1]; - } - - return true; - } - - return false; - } - - /** - * parses the rdata of the Net_DNS2_Packet object - * - * @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet to parse the RR from - * - * @return boolean - * @access protected - * - */ - protected function rrSet(Net_DNS2_Packet &$packet) { - if ($this->rdlength > 0) { - $this->isdnaddress = Net_DNS2_Packet::label($packet, $packet->offset); - - // - // look for a SA (sub address) - it's optional - // - if ((strlen($this->isdnaddress) + 1) < $this->rdlength) { - $this->sa = Net_DNS2_Packet::label($packet, $packet->offset); - } else { - $this->sa = ''; - } - - return true; - } - - return false; - } - - /** - * returns the rdata portion of the DNS packet - * - * @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet use for - * compressed names - * - * @return mixed either returns a binary packed - * string or null on failure - * @access protected - * - */ - protected function rrGet(Net_DNS2_Packet &$packet) { - if (strlen($this->isdnaddress) > 0) { - $data = chr(strlen($this->isdnaddress)) . $this->isdnaddress; - - if (!empty($this->sa)) { - $data .= chr(strlen($this->sa)); - $data .= $this->sa; - } - - $packet->offset += strlen($data); - - return $data; - } - - return null; - } -} diff --git a/Net/DNS2/RR/KEY.php b/Net/DNS2/RR/KEY.php deleted file mode 100644 index cf24cdd9..00000000 --- a/Net/DNS2/RR/KEY.php +++ /dev/null @@ -1,36 +0,0 @@ -. All rights reserved. - * - * See LICENSE for more details. - * - * @category Networking - * @package Net_DNS2 - * @author Mike Pultz - * @copyright 2020 Mike Pultz - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @link https://netdns2.com/ - * @since File available since Release 0.6.0 - * - */ - -/** - * the KEY RR is implemented the same as the DNSKEY RR, the only difference - * is how the flags data is parsed. - * - * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 - * +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+ - * | A/C | Z | XT| Z | Z | NAMTYP| Z | Z | Z | Z | SIG | - * +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+ - * - * DNSKEY only uses bits 7 and 15 - * - * We're not doing anything with these flags right now, so duplicating the - * class like this is fine. - * - */ -class Net_DNS2_RR_KEY extends Net_DNS2_RR_DNSKEY { -} diff --git a/Net/DNS2/RR/KX.php b/Net/DNS2/RR/KX.php deleted file mode 100644 index 3887e900..00000000 --- a/Net/DNS2/RR/KX.php +++ /dev/null @@ -1,120 +0,0 @@ -. All rights reserved. - * - * See LICENSE for more details. - * - * @category Networking - * @package Net_DNS2 - * @author Mike Pultz - * @copyright 2020 Mike Pultz - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @link https://netdns2.com/ - * @since File available since Release 0.6.0 - * - */ - -/** - * KX Resource Record - RFC2230 section 3.1 - * - * This class is almost identical to MX, except that the the exchanger - * domain is not compressed, it's added as a label - * - * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ - * | PREFERENCE | - * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ - * / EXCHANGER / - * / / - * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ - * - */ -class Net_DNS2_RR_KX extends Net_DNS2_RR { - // the preference for this mail exchanger - public $preference; - - // the hostname of the mail exchanger - public $exchange; - - /** - * method to return the rdata portion of the packet as a string - * - * @return string - * @access protected - * - */ - protected function rrToString() { - return $this->preference . ' ' . $this->cleanString($this->exchange) . '.'; - } - - /** - * parses the rdata portion from a standard DNS config line - * - * @param array $rdata a string split line of values for the rdata - * - * @return boolean - * @access protected - * - */ - protected function rrFromString(array $rdata) { - $this->preference = array_shift($rdata); - $this->exchange = $this->cleanString(array_shift($rdata)); - - return true; - } - - /** - * parses the rdata of the Net_DNS2_Packet object - * - * @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet to parse the RR from - * - * @return boolean - * @access protected - * - */ - protected function rrSet(Net_DNS2_Packet &$packet) { - if ($this->rdlength > 0) { - // - // parse the preference - // - $x = unpack('npreference', $this->rdata); - $this->preference = $x['preference']; - - // - // get the exchange entry server) - // - $offset = $packet->offset + 2; - $this->exchange = Net_DNS2_Packet::label($packet, $offset); - - return true; - } - - return false; - } - - /** - * returns the rdata portion of the DNS packet - * - * @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet use for - * compressed names - * - * @return mixed either returns a binary packed - * string or null on failure - * @access protected - * - */ - protected function rrGet(Net_DNS2_Packet &$packet) { - if (strlen($this->exchange) > 0) { - $data = pack('nC', $this->preference, strlen($this->exchange)) . - $this->exchange; - - $packet->offset += strlen($data); - - return $data; - } - - return null; - } -} diff --git a/Net/DNS2/RR/L32.php b/Net/DNS2/RR/L32.php deleted file mode 100644 index 85586fef..00000000 --- a/Net/DNS2/RR/L32.php +++ /dev/null @@ -1,121 +0,0 @@ -. All rights reserved. - * - * See LICENSE for more details. - * - * @category Networking - * @package Net_DNS2 - * @author Mike Pultz - * @copyright 2020 Mike Pultz - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @link https://netdns2.com/ - * @since File available since Release 1.3.1 - * - */ - -/** - * L32 Resource Record - RFC6742 section 2.2 - * - * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 - * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - * | Preference | Locator32 (16 MSBs) | - * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - * | Locator32 (16 LSBs) | - * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - * - */ -class Net_DNS2_RR_L32 extends Net_DNS2_RR { - // The preference - public $preference; - - // The locator32 field - public $locator32; - - /** - * method to return the rdata portion of the packet as a string - * - * @return string - * @access protected - * - */ - protected function rrToString() { - return $this->preference . ' ' . $this->locator32; - } - - /** - * parses the rdata portion from a standard DNS config line - * - * @param array $rdata a string split line of values for the rdata - * - * @return boolean - * @access protected - * - */ - protected function rrFromString(array $rdata) { - $this->preference = array_shift($rdata); - $this->locator32 = array_shift($rdata); - - return true; - } - - /** - * parses the rdata of the Net_DNS2_Packet object - * - * @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet to parse the RR from - * - * @return boolean - * @access protected - * - */ - protected function rrSet(Net_DNS2_Packet &$packet) { - if ($this->rdlength > 0) { - // - // unpack the values - // - $x = unpack('npreference/C4locator', $this->rdata); - - $this->preference = $x['preference']; - - // - // build the locator value - // - $this->locator32 = $x['locator1'] . '.' . $x['locator2'] . '.' . - $x['locator3'] . '.' . $x['locator4']; - - return true; - } - - return false; - } - - /** - * returns the rdata portion of the DNS packet - * - * @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet use for - * compressed names - * - * @return mixed either returns a binary packed - * string or null on failure - * @access protected - * - */ - protected function rrGet(Net_DNS2_Packet &$packet) { - if (strlen($this->locator32) > 0) { - // - // break out the locator value - // - $n = explode('.', $this->locator32); - - // - // pack the data - // - return pack('nC4', $this->preference, $n[0], $n[1], $n[2], $n[3]); - } - - return null; - } -} diff --git a/Net/DNS2/RR/L64.php b/Net/DNS2/RR/L64.php deleted file mode 100644 index b42a4077..00000000 --- a/Net/DNS2/RR/L64.php +++ /dev/null @@ -1,128 +0,0 @@ -. All rights reserved. - * - * See LICENSE for more details. - * - * @category Networking - * @package Net_DNS2 - * @author Mike Pultz - * @copyright 2020 Mike Pultz - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @link https://netdns2.com/ - * @since File available since Release 1.3.1 - * - */ - -/** - * L64 Resource Record - RFC6742 section 2.3 - * - * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 - * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - * | Preference | | - * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + - * | Locator64 | - * + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - * | | - * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - * - */ -class Net_DNS2_RR_L64 extends Net_DNS2_RR { - // The preference - public $preference; - - // The locator64 field - public $locator64; - - /** - * method to return the rdata portion of the packet as a string - * - * @return string - * @access protected - * - */ - protected function rrToString() { - return $this->preference . ' ' . $this->locator64; - } - - /** - * parses the rdata portion from a standard DNS config line - * - * @param array $rdata a string split line of values for the rdata - * - * @return boolean - * @access protected - * - */ - protected function rrFromString(array $rdata) { - $this->preference = array_shift($rdata); - $this->locator64 = array_shift($rdata); - - return true; - } - - /** - * parses the rdata of the Net_DNS2_Packet object - * - * @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet to parse the RR from - * - * @return boolean - * @access protected - * - */ - protected function rrSet(Net_DNS2_Packet &$packet) { - if ($this->rdlength > 0) { - // - // unpack the values - // - $x = unpack('npreference/n4locator', $this->rdata); - - $this->preference = $x['preference']; - - // - // build the locator64 - // - $this->locator64 = dechex($x['locator1']) . ':' . - dechex($x['locator2']) . ':' . - dechex($x['locator3']) . ':' . - dechex($x['locator4']); - - return true; - } - - return false; - } - - /** - * returns the rdata portion of the DNS packet - * - * @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet use for - * compressed names - * - * @return mixed either returns a binary packed - * string or null on failure - * @access protected - * - */ - protected function rrGet(Net_DNS2_Packet &$packet) { - if (strlen($this->locator64) > 0) { - // - // break out the locator64 - // - $n = explode(':', $this->locator64); - - // - // pack the data - // - return pack( - 'n5', $this->preference, hexdec($n[0]), hexdec($n[1]), - hexdec($n[2]), hexdec($n[3]) - ); - } - - return null; - } -} diff --git a/Net/DNS2/RR/LOC.php b/Net/DNS2/RR/LOC.php deleted file mode 100644 index 1e4cfb12..00000000 --- a/Net/DNS2/RR/LOC.php +++ /dev/null @@ -1,352 +0,0 @@ -. All rights reserved. - * - * See LICENSE for more details. - * - * @category Networking - * @package Net_DNS2 - * @author Mike Pultz - * @copyright 2020 Mike Pultz - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @link https://netdns2.com/ - * @since File available since Release 0.6.0 - * - */ - -/** - * LOC Resource Record - RFC1876 section 2 - * - * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ - * | VERSION | SIZE | - * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ - * | HORIZ PRE | VERT PRE | - * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ - * | LATITUDE | - * | | - * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ - * | LONGITUDE | - * | | - * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ - * | ALTITUDE | - * | | - * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ - * - */ -class Net_DNS2_RR_LOC extends Net_DNS2_RR { - // the LOC version- should only ever be 0 - public $version; - - // The diameter of a sphere enclosing the described entity - public $size; - - // The horizontal precision of the data - public $horiz_pre; - - // The vertical precision of the data - public $vert_pre; - - // The latitude - stored in decimal degrees - public $latitude; - - // The longitude - stored in decimal degrees - public $longitude; - - // The altitude - stored in decimal - public $altitude; - - // used for quick power-of-ten lookups - private $_powerOfTen = [ 1, 10, 100, 1000, 10000, 100000, - 1000000, 10000000, 100000000, 1000000000 ]; - - // some conversion values - const CONV_SEC = 1000; - const CONV_MIN = 60000; - const CONV_DEG = 3600000; - - const REFERENCE_ALT = 10000000; - const REFERENCE_LATLON = 2147483648; - - /** - * method to return the rdata portion of the packet as a string - * - * @return string - * @access protected - * - */ - protected function rrToString() { - if ($this->version == 0) { - return $this->_d2Dms($this->latitude, 'LAT') . ' ' . - $this->_d2Dms($this->longitude, 'LNG') . ' ' . - sprintf('%.2fm', $this->altitude) . ' ' . - sprintf('%.2fm', $this->size) . ' ' . - sprintf('%.2fm', $this->horiz_pre) . ' ' . - sprintf('%.2fm', $this->vert_pre); - } - - return ''; - } - - /** - * parses the rdata portion from a standard DNS config line - * - * @param array $rdata a string split line of values for the rdata - * - * @return boolean - * @access protected - * - */ - protected function rrFromString(array $rdata) { - // - // format as defined by RFC1876 section 3 - // - // d1 [m1 [s1]] {"N"|"S"} d2 [m2 [s2]] {"E"|"W"} alt["m"] - // [siz["m"] [hp["m"] [vp["m"]]]] - // - $res = preg_match( - '/^(\d+) \s+((\d+) \s+)?(([\d.]+) \s+)?(N|S) \s+(\d+) ' . - '\s+((\d+) \s+)?(([\d.]+) \s+)?(E|W) \s+(-?[\d.]+) m?(\s+ ' . - '([\d.]+) m?)?(\s+ ([\d.]+) m?)?(\s+ ([\d.]+) m?)?/ix', - implode(' ', $rdata), $x - ); - - if ($res) { - // - // latitude - // - $latdeg = $x[1]; - $latmin = (isset($x[3])) ? $x[3] : 0; - $latsec = (isset($x[5])) ? $x[5] : 0; - $lathem = strtoupper($x[6]); - - $this->latitude = $this->_dms2d($latdeg, $latmin, $latsec, $lathem); - - // - // longitude - // - $londeg = $x[7]; - $lonmin = (isset($x[9])) ? $x[9] : 0; - $lonsec = (isset($x[11])) ? $x[11] : 0; - $lonhem = strtoupper($x[12]); - - $this->longitude = $this->_dms2d($londeg, $lonmin, $lonsec, $lonhem); - - // - // the rest of teh values - // - $version = 0; - - $this->size = (isset($x[15])) ? $x[15] : 1; - $this->horiz_pre = ((isset($x[17])) ? $x[17] : 10000); - $this->vert_pre = ((isset($x[19])) ? $x[19] : 10); - $this->altitude = $x[13]; - - return true; - } - - return false; - } - - /** - * parses the rdata of the Net_DNS2_Packet object - * - * @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet to parse the RR from - * - * @return boolean - * @access protected - * - */ - protected function rrSet(Net_DNS2_Packet &$packet) { - if ($this->rdlength > 0) { - // - // unpack all the values - // - $x = unpack( - 'Cver/Csize/Choriz_pre/Cvert_pre/Nlatitude/Nlongitude/Naltitude', - $this->rdata - ); - - // - // version must be 0 per RFC 1876 section 2 - // - $this->version = $x['ver']; - - if ($this->version == 0) { - $this->size = $this->_precsizeNtoA($x['size']); - $this->horiz_pre = $this->_precsizeNtoA($x['horiz_pre']); - $this->vert_pre = $this->_precsizeNtoA($x['vert_pre']); - - // - // convert the latitude and longitude to degress in decimal - // - if ($x['latitude'] < 0) { - $this->latitude = ($x['latitude'] + - self::REFERENCE_LATLON) / self::CONV_DEG; - } else { - $this->latitude = ($x['latitude'] - - self::REFERENCE_LATLON) / self::CONV_DEG; - } - - if ($x['longitude'] < 0) { - $this->longitude = ($x['longitude'] + - self::REFERENCE_LATLON) / self::CONV_DEG; - } else { - $this->longitude = ($x['longitude'] - - self::REFERENCE_LATLON) / self::CONV_DEG; - } - - // - // convert down the altitude - // - $this->altitude = ($x['altitude'] - self::REFERENCE_ALT) / 100; - - return true; - } else { - return false; - } - - return true; - } - - return false; - } - - /** - * returns the rdata portion of the DNS packet - * - * @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet use for - * compressed names - * - * @return mixed either returns a binary packed - * string or null on failure - * @access protected - * - */ - protected function rrGet(Net_DNS2_Packet &$packet) { - if ($this->version == 0) { - $lat = 0; - $lng = 0; - - if ($this->latitude < 0) { - $lat = ($this->latitude * self::CONV_DEG) - self::REFERENCE_LATLON; - } else { - $lat = ($this->latitude * self::CONV_DEG) + self::REFERENCE_LATLON; - } - - if ($this->longitude < 0) { - $lng = ($this->longitude * self::CONV_DEG) - self::REFERENCE_LATLON; - } else { - $lng = ($this->longitude * self::CONV_DEG) + self::REFERENCE_LATLON; - } - - $packet->offset += 16; - - return pack( - 'CCCCNNN', - $this->version, - $this->_precsizeAtoN($this->size), - $this->_precsizeAtoN($this->horiz_pre), - $this->_precsizeAtoN($this->vert_pre), - $lat, $lng, - ($this->altitude * 100) + self::REFERENCE_ALT - ); - } - - return null; - } - - /** - * takes an XeY precision/size value, returns a string representation. - * shamlessly stolen from RFC1876 Appendix A - * - * @param integer $prec the value to convert - * - * @return string - * @access private - * - */ - private function _precsizeNtoA($prec) { - $mantissa = (($prec >> 4) & 0x0f) % 10; - $exponent = (($prec >> 0) & 0x0f) % 10; - - return $mantissa * $this->_powerOfTen[$exponent]; - } - - /** - * converts ascii size/precision X * 10**Y(cm) to 0xXY. - * shamlessly stolen from RFC1876 Appendix A - * - * @param string $prec the value to convert - * - * @return integer - * @access private - * - */ - private function _precsizeAtoN($prec) { - $exponent = 0; - - while ($prec >= 10) { - $prec /= 10; - ++$exponent; - } - - return ($prec << 4) | ($exponent & 0x0f); - } - - /** - * convert lat/lng in deg/min/sec/hem to decimal value - * - * @param integer $deg the degree value - * @param integer $min the minutes value - * @param integer $sec the seconds value - * @param string $hem the hemisphere (N/E/S/W) - * - * @return float the decinmal value - * @access private - * - */ - private function _dms2d($deg, $min, $sec, $hem) { - $deg = $deg - 0; - $min = $min - 0; - - $sign = ($hem == 'W' || $hem == 'S') ? -1 : 1; - - return ((($sec / 60 + $min) / 60) + $deg) * $sign; - } - - /** - * convert lat/lng in decimal to deg/min/sec/hem - * - * @param float $data the decimal value - * @param string $latlng either LAT or LNG so we can determine the HEM value - * - * @return string - * @access private - * - */ - private function _d2Dms($data, $latlng) { - $deg = 0; - $min = 0; - $sec = 0; - $msec = 0; - $hem = ''; - - if ($latlng == 'LAT') { - $hem = ($data > 0) ? 'N' : 'S'; - } else { - $hem = ($data > 0) ? 'E' : 'W'; - } - - $data = abs($data); - - $deg = (int)$data; - $min = (int)(($data - $deg) * 60); - $sec = (int)(((($data - $deg) * 60) - $min) * 60); - $msec = round((((((($data - $deg) * 60) - $min) * 60) - $sec) * 1000)); - - return sprintf('%d %02d %02d.%03d %s', $deg, $min, $sec, round($msec), $hem); - } -} diff --git a/Net/DNS2/RR/LP.php b/Net/DNS2/RR/LP.php deleted file mode 100644 index fdb0d355..00000000 --- a/Net/DNS2/RR/LP.php +++ /dev/null @@ -1,119 +0,0 @@ -. All rights reserved. - * - * See LICENSE for more details. - * - * @category Networking - * @package Net_DNS2 - * @author Mike Pultz - * @copyright 2020 Mike Pultz - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @link https://netdns2.com/ - * @since File available since Release 1.3.1 - * - */ - -/** - * LP Resource Record - RFC6742 section 2.4 - * - * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 - * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - * | Preference | / - * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ / - * / / - * / FQDN / - * / / - * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - * - */ -class Net_DNS2_RR_LP extends Net_DNS2_RR { - // The preference - public $preference; - - // The fdqn field - public $fqdn; - - /** - * method to return the rdata portion of the packet as a string - * - * @return string - * @access protected - * - */ - protected function rrToString() { - return $this->preference . ' ' . $this->fqdn . '.'; - } - - /** - * parses the rdata portion from a standard DNS config line - * - * @param array $rdata a string split line of values for the rdata - * - * @return boolean - * @access protected - * - */ - protected function rrFromString(array $rdata) { - $this->preference = array_shift($rdata); - $this->fqdn = trim(array_shift($rdata), '.'); - - return true; - } - - /** - * parses the rdata of the Net_DNS2_Packet object - * - * @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet to parse the RR from - * - * @return boolean - * @access protected - * - */ - protected function rrSet(Net_DNS2_Packet &$packet) { - if ($this->rdlength > 0) { - // - // parse the preference - // - $x = unpack('npreference', $this->rdata); - $this->preference = $x['preference']; - $offset = $packet->offset + 2; - - // - // get the hostname - // - $this->fqdn = Net_DNS2_Packet::expand($packet, $offset); - - return true; - } - - return false; - } - - /** - * returns the rdata portion of the DNS packet - * - * @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet use for - * compressed names - * - * @return mixed either returns a binary packed - * string or null on failure - * @access protected - * - */ - protected function rrGet(Net_DNS2_Packet &$packet) { - if (strlen($this->fqdn) > 0) { - $data = pack('n', $this->preference); - $packet->offset += 2; - - $data .= $packet->compress($this->fqdn, $packet->offset); - - return $data; - } - - return null; - } -} diff --git a/Net/DNS2/RR/MX.php b/Net/DNS2/RR/MX.php deleted file mode 100644 index 05b16668..00000000 --- a/Net/DNS2/RR/MX.php +++ /dev/null @@ -1,117 +0,0 @@ -. All rights reserved. - * - * See LICENSE for more details. - * - * @category Networking - * @package Net_DNS2 - * @author Mike Pultz - * @copyright 2020 Mike Pultz - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @link https://netdns2.com/ - * @since File available since Release 0.6.0 - * - */ - -/** - * MX Resource Record - RFC1035 section 3.3.9 - * - * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ - * | PREFERENCE | - * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ - * / EXCHANGE / - * / / - * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ - * - */ -class Net_DNS2_RR_MX extends Net_DNS2_RR { - // the preference for this mail exchanger - public $preference; - - // the hostname of the mail exchanger - public $exchange; - - /** - * method to return the rdata portion of the packet as a string - * - * @return string - * @access protected - * - */ - protected function rrToString() { - return $this->preference . ' ' . $this->cleanString($this->exchange) . '.'; - } - - /** - * parses the rdata portion from a standard DNS config line - * - * @param array $rdata a string split line of values for the rdata - * - * @return boolean - * @access protected - * - */ - protected function rrFromString(array $rdata) { - $this->preference = array_shift($rdata); - $this->exchange = $this->cleanString(array_shift($rdata)); - - return true; - } - - /** - * parses the rdata of the Net_DNS2_Packet object - * - * @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet to parse the RR from - * - * @return boolean - * @access protected - * - */ - protected function rrSet(Net_DNS2_Packet &$packet) { - if ($this->rdlength > 0) { - // - // parse the preference - // - $x = unpack('npreference', $this->rdata); - $this->preference = $x['preference']; - - // - // get the exchange entry server) - // - $offset = $packet->offset + 2; - $this->exchange = Net_DNS2_Packet::expand($packet, $offset); - - return true; - } - - return false; - } - - /** - * returns the rdata portion of the DNS packet - * - * @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet use for - * compressed names - * - * @return mixed either returns a binary packed - * string or null on failure - * @access protected - * - */ - protected function rrGet(Net_DNS2_Packet &$packet) { - if (strlen($this->exchange) > 0) { - $data = pack('n', $this->preference); - $packet->offset += 2; - - $data .= $packet->compress($this->exchange, $packet->offset); - - return $data; - } - - return null; - } -} diff --git a/Net/DNS2/RR/NAPTR.php b/Net/DNS2/RR/NAPTR.php deleted file mode 100644 index fd67ddde..00000000 --- a/Net/DNS2/RR/NAPTR.php +++ /dev/null @@ -1,168 +0,0 @@ -. All rights reserved. - * - * See LICENSE for more details. - * - * @category Networking - * @package Net_DNS2 - * @author Mike Pultz - * @copyright 2020 Mike Pultz - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @link https://netdns2.com/ - * @since File available since Release 0.6.0 - * - */ - -/** - * NAPTR Resource Record - RFC2915 - * - * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 - * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ - * | ORDER | - * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ - * | PREFERENCE | - * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ - * / FLAGS / - * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ - * / SERVICES / - * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ - * / REGEXP / - * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ - * / REPLACEMENT / - * / / - * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ - * - */ -class Net_DNS2_RR_NAPTR extends Net_DNS2_RR { - // the order in which the NAPTR records MUST be processed - public $order; - - /* - * specifies the order in which NAPTR records with equal "order" - * values SHOULD be processed - */ - public $preference; - - // rewrite flags - public $flags; - - // Specifies the service(s) available down this rewrite path - public $services; - - // regular expression - public $regexp; - - /* - * The next NAME to query for NAPTR, SRV, or address records - * depending on the value of the flags field - */ - public $replacement; - - /** - * method to return the rdata portion of the packet as a string - * - * @return string - * @access protected - * - */ - protected function rrToString() { - return $this->order . ' ' . $this->preference . ' ' . - $this->formatString($this->flags) . ' ' . - $this->formatString($this->services) . ' ' . - $this->formatString($this->regexp) . ' ' . - $this->cleanString($this->replacement) . '.'; - } - - /** - * parses the rdata portion from a standard DNS config line - * - * @param array $rdata a string split line of values for the rdata - * - * @return boolean - * @access protected - * - */ - protected function rrFromString(array $rdata) { - $this->order = array_shift($rdata); - $this->preference = array_shift($rdata); - - $data = $this->buildString($rdata); - - if (cacti_sizeof($data) == 4) { - $this->flags = $data[0]; - $this->services = $data[1]; - $this->regexp = $data[2]; - $this->replacement = $this->cleanString($data[3]); - - return true; - } - - return false; - } - - /** - * parses the rdata of the Net_DNS2_Packet object - * - * @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet to parse the RR from - * - * @return boolean - * @access protected - * - */ - protected function rrSet(Net_DNS2_Packet &$packet) { - if ($this->rdlength > 0) { - // - // unpack the order and preference - // - $x = unpack('norder/npreference', $this->rdata); - - $this->order = $x['order']; - $this->preference = $x['preference']; - - $offset = $packet->offset + 4; - - $this->flags = Net_DNS2_Packet::label($packet, $offset); - $this->services = Net_DNS2_Packet::label($packet, $offset); - $this->regexp = Net_DNS2_Packet::label($packet, $offset); - - $this->replacement = Net_DNS2_Packet::expand($packet, $offset); - - return true; - } - - return false; - } - - /** - * returns the rdata portion of the DNS packet - * - * @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet use for - * compressed names - * - * @return mixed either returns a binary packed - * string or null on failure - * @access protected - * - */ - protected function rrGet(Net_DNS2_Packet &$packet) { - if ((isset($this->order)) && (strlen($this->services) > 0)) { - $data = pack('nn', $this->order, $this->preference); - - $data .= chr(strlen($this->flags)) . $this->flags; - $data .= chr(strlen($this->services)) . $this->services; - $data .= chr(strlen($this->regexp)) . $this->regexp; - - $packet->offset += strlen($data); - - $data .= $packet->compress($this->replacement, $packet->offset); - - return $data; - } - - return null; - } -} diff --git a/Net/DNS2/RR/NID.php b/Net/DNS2/RR/NID.php deleted file mode 100644 index e1bda85d..00000000 --- a/Net/DNS2/RR/NID.php +++ /dev/null @@ -1,128 +0,0 @@ -. All rights reserved. - * - * See LICENSE for more details. - * - * @category Networking - * @package Net_DNS2 - * @author Mike Pultz - * @copyright 2020 Mike Pultz - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @link https://netdns2.com/ - * @since File available since Release 1.3.1 - * - */ - -/** - * NID Resource Record - RFC6742 section 2.1 - * - * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 - * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - * | Preference | | - * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + - * | NodeID | - * + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - * | | - * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - * - */ -class Net_DNS2_RR_NID extends Net_DNS2_RR { - // The preference - public $preference; - - // The node ID field - public $nodeid; - - /** - * method to return the rdata portion of the packet as a string - * - * @return string - * @access protected - * - */ - protected function rrToString() { - return $this->preference . ' ' . $this->nodeid; - } - - /** - * parses the rdata portion from a standard DNS config line - * - * @param array $rdata a string split line of values for the rdata - * - * @return boolean - * @access protected - * - */ - protected function rrFromString(array $rdata) { - $this->preference = array_shift($rdata); - $this->nodeid = array_shift($rdata); - - return true; - } - - /** - * parses the rdata of the Net_DNS2_Packet object - * - * @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet to parse the RR from - * - * @return boolean - * @access protected - * - */ - protected function rrSet(Net_DNS2_Packet &$packet) { - if ($this->rdlength > 0) { - // - // unpack the values - // - $x = unpack('npreference/n4nodeid', $this->rdata); - - $this->preference = $x['preference']; - - // - // build the node id - // - $this->nodeid = dechex($x['nodeid1']) . ':' . - dechex($x['nodeid2']) . ':' . - dechex($x['nodeid3']) . ':' . - dechex($x['nodeid4']); - - return true; - } - - return false; - } - - /** - * returns the rdata portion of the DNS packet - * - * @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet use for - * compressed names - * - * @return mixed either returns a binary packed - * string or null on failure - * @access protected - * - */ - protected function rrGet(Net_DNS2_Packet &$packet) { - if (strlen($this->nodeid) > 0) { - // - // break out the node id - // - $n = explode(':', $this->nodeid); - - // - // pack the data - // - return pack( - 'n5', $this->preference, hexdec($n[0]), hexdec($n[1]), - hexdec($n[2]), hexdec($n[3]) - ); - } - - return null; - } -} diff --git a/Net/DNS2/RR/NIMLOC.php b/Net/DNS2/RR/NIMLOC.php deleted file mode 100644 index 4b66a05c..00000000 --- a/Net/DNS2/RR/NIMLOC.php +++ /dev/null @@ -1,77 +0,0 @@ -. All rights reserved. - * - * See LICENSE for more details. - * - * @category Networking - * @package Net_DNS2 - * @author Mike Pultz - * @copyright 2020 Mike Pultz - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @link https://netdns2.com/ - * @since File available since Release 0.6.0 - * - */ - -/** - * NIMLOC Resource Record - undefined; the rdata is simply used as-is in it's - * binary format, so not process has to be done. - * - */ -class Net_DNS2_RR_NIMLOC extends Net_DNS2_RR { - /** - * method to return the rdata portion of the packet as a string - * - * @return string - * @access protected - * - */ - protected function rrToString() { - return ''; - } - - /** - * parses the rdata portion from a standard DNS config line - * - * @param array $rdata a string split line of values for the rdata - * - * @return boolean - * @access protected - * - */ - protected function rrFromString(array $rdata) { - return true; - } - - /** - * parses the rdata of the Net_DNS2_Packet object - * - * @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet to parse the RR from - * - * @return boolean - * @access protected - * - */ - protected function rrSet(Net_DNS2_Packet &$packet) { - return true; - } - - /** - * returns the rdata portion of the DNS packet - * - * @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet use for - * compressed names - * - * @return mixed either returns a binary packed - * string or null on failure - * @access protected - * - */ - protected function rrGet(Net_DNS2_Packet &$packet) { - return $this->rdata; - } -} diff --git a/Net/DNS2/RR/NS.php b/Net/DNS2/RR/NS.php deleted file mode 100644 index 710dd3cc..00000000 --- a/Net/DNS2/RR/NS.php +++ /dev/null @@ -1,97 +0,0 @@ -. All rights reserved. - * - * See LICENSE for more details. - * - * @category Networking - * @package Net_DNS2 - * @author Mike Pultz - * @copyright 2020 Mike Pultz - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @link https://netdns2.com/ - * @since File available since Release 0.6.0 - * - */ - -/** - * NS Resource Record - RFC1035 section 3.3.11 - * - * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ - * / NSDNAME / - * / / - * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ - * - */ -class Net_DNS2_RR_NS extends Net_DNS2_RR { - // the hostname of the DNS server - public $nsdname; - - /** - * method to return the rdata portion of the packet as a string - * - * @return string - * @access protected - * - */ - protected function rrToString() { - return $this->cleanString($this->nsdname) . '.'; - } - - /** - * parses the rdata portion from a standard DNS config line - * - * @param array $rdata a string split line of values for the rdata - * - * @return boolean - * @access protected - * - */ - protected function rrFromString(array $rdata) { - $this->nsdname = $this->cleanString(array_shift($rdata)); - - return true; - } - - /** - * parses the rdata of the Net_DNS2_Packet object - * - * @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet to parse the RR from - * - * @return boolean - * @access protected - * - */ - protected function rrSet(Net_DNS2_Packet &$packet) { - if ($this->rdlength > 0) { - $offset = $packet->offset; - $this->nsdname = Net_DNS2_Packet::expand($packet, $offset); - - return true; - } - - return false; - } - - /** - * returns the rdata portion of the DNS packet - * - * @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet use for - * compressed names - * - * @return mixed either returns a binary packed - * string or null on failure - * @access protected - * - */ - protected function rrGet(Net_DNS2_Packet &$packet) { - if (strlen($this->nsdname) > 0) { - return $packet->compress($this->nsdname, $packet->offset); - } - - return null; - } -} diff --git a/Net/DNS2/RR/NSAP.php b/Net/DNS2/RR/NSAP.php deleted file mode 100644 index 2c75aed2..00000000 --- a/Net/DNS2/RR/NSAP.php +++ /dev/null @@ -1,205 +0,0 @@ -. All rights reserved. - * - * See LICENSE for more details. - * - * @category Networking - * @package Net_DNS2 - * @author Mike Pultz - * @copyright 2020 Mike Pultz - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @link https://netdns2.com/ - * @since File available since Release 0.6.0 - * - */ - -/** - * NSAP Resource Record - RFC1706 - * - * |--------------| - * | <-- IDP --> | - * |--------------|-------------------------------------| - * | AFI | IDI | <-- DSP --> | - * |-----|--------|-------------------------------------| - * | 47 | 0005 | DFI | AA |Rsvd | RD |Area | ID |Sel | - * |-----|--------|-----|----|-----|----|-----|----|----| - * octets | 1 | 2 | 1 | 3 | 2 | 2 | 2 | 6 | 1 | - * |-----|--------|-----|----|-----|----|-----|----|----| - * - */ -class Net_DNS2_RR_NSAP extends Net_DNS2_RR { - public $afi; - public $idi; - public $dfi; - public $aa; - public $rsvd; - public $rd; - public $area; - public $id; - public $sel; - - /** - * method to return the rdata portion of the packet as a string - * - * @return string - * @access protected - * - */ - protected function rrToString() { - return $this->cleanString($this->afi) . '.' . - $this->cleanString($this->idi) . '.' . - $this->cleanString($this->dfi) . '.' . - $this->cleanString($this->aa) . '.' . - $this->cleanString($this->rsvd) . '.' . - $this->cleanString($this->rd) . '.' . - $this->cleanString($this->area) . '.' . - $this->cleanString($this->id) . '.' . - $this->sel; - } - - /** - * parses the rdata portion from a standard DNS config line - * - * @param array $rdata a string split line of values for the rdata - * - * @return boolean - * @access protected - * - */ - protected function rrFromString(array $rdata) { - $data = strtolower(trim(array_shift($rdata))); - - // - // there is no real standard for format, so we can't rely on the fact that - // the value will come in with periods separating the values- so strip - // them out if they're included, and parse without them. - // - $data = str_replace([ '.', '0x' ], '', $data); - - // - // unpack it as ascii characters - // - $x = unpack('A2afi/A4idi/A2dfi/A6aa/A4rsvd/A4rd/A4area/A12id/A2sel', $data); - - // - // make sure the afi value is 47 - // - if ($x['afi'] == '47') { - $this->afi = '0x' . $x['afi']; - $this->idi = $x['idi']; - $this->dfi = $x['dfi']; - $this->aa = $x['aa']; - $this->rsvd = $x['rsvd']; - $this->rd = $x['rd']; - $this->area = $x['area']; - $this->id = $x['id']; - $this->sel = $x['sel']; - - return true; - } - - return false; - } - - /** - * parses the rdata of the Net_DNS2_Packet object - * - * @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet to parse the RR from - * - * @return boolean - * @access protected - * - */ - protected function rrSet(Net_DNS2_Packet &$packet) { - if ($this->rdlength == 20) { - // - // get the AFI value - // - $this->afi = dechex(ord($this->rdata[0])); - - // - // we only support AFI 47- there arent' any others defined. - // - if ($this->afi == '47') { - // - // unpack the rest of the values - // - $x = unpack( - 'Cafi/nidi/Cdfi/C3aa/nrsvd/nrd/narea/Nidh/nidl/Csel', - $this->rdata - ); - - $this->afi = sprintf('0x%02x', $x['afi']); - $this->idi = sprintf('%04x', $x['idi']); - $this->dfi = sprintf('%02x', $x['dfi']); - $this->aa = sprintf( - '%06x', $x['aa1'] << 16 | $x['aa2'] << 8 | $x['aa3'] - ); - $this->rsvd = sprintf('%04x', $x['rsvd']); - $this->rd = sprintf('%04x', $x['rd']); - $this->area = sprintf('%04x', $x['area']); - $this->id = sprintf('%08x', $x['idh']) . - sprintf('%04x', $x['idl']); - $this->sel = sprintf('%02x', $x['sel']); - - return true; - } - } - - return false; - } - - /** - * returns the rdata portion of the DNS packet - * - * @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet use for - * compressed names - * - * @return mixed either returns a binary packed - * string or null on failure - * @access protected - * - */ - protected function rrGet(Net_DNS2_Packet &$packet) { - if ($this->afi == '0x47') { - // - // build the aa field - // - $aa = unpack('A2x/A2y/A2z', $this->aa); - - // - // build the id field - // - $id = unpack('A8a/A4b', $this->id); - - // - $data = pack( - 'CnCCCCnnnNnC', - hexdec($this->afi), - hexdec($this->idi), - hexdec($this->dfi), - hexdec($aa['x']), - hexdec($aa['y']), - hexdec($aa['z']), - hexdec($this->rsvd), - hexdec($this->rd), - hexdec($this->area), - hexdec($id['a']), - hexdec($id['b']), - hexdec($this->sel) - ); - - if (strlen($data) == 20) { - $packet->offset += 20; - - return $data; - } - } - - return null; - } -} diff --git a/Net/DNS2/RR/NSEC.php b/Net/DNS2/RR/NSEC.php deleted file mode 100644 index eea3de5b..00000000 --- a/Net/DNS2/RR/NSEC.php +++ /dev/null @@ -1,124 +0,0 @@ -. All rights reserved. - * - * See LICENSE for more details. - * - * @category Networking - * @package Net_DNS2 - * @author Mike Pultz - * @copyright 2020 Mike Pultz - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @link https://netdns2.com/ - * @since File available since Release 0.6.0 - * - */ - -/** - * NSEC Resource Record - RFC3845 section 2.1 - * - * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 - * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - * / Next Domain Name / - * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - * / List of Type Bit Map(s) / - * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - * - */ -class Net_DNS2_RR_NSEC extends Net_DNS2_RR { - // The next owner name - public $next_domain_name; - - // identifies the RRset types that exist at the NSEC RR's owner name. - public $type_bit_maps = []; - - /** - * method to return the rdata portion of the packet as a string - * - * @return string - * @access protected - * - */ - protected function rrToString() { - $data = $this->cleanString($this->next_domain_name) . '.'; - - foreach ($this->type_bit_maps as $rr) { - $data .= ' ' . $rr; - } - - return $data; - } - - /** - * parses the rdata portion from a standard DNS config line - * - * @param array $rdata a string split line of values for the rdata - * - * @return boolean - * @access protected - * - */ - protected function rrFromString(array $rdata) { - $this->next_domain_name = $this->cleanString(array_shift($rdata)); - $this->type_bit_maps = $rdata; - - return true; - } - - /** - * parses the rdata of the Net_DNS2_Packet object - * - * @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet to parse the RR from - * - * @return boolean - * @access protected - * - */ - protected function rrSet(Net_DNS2_Packet &$packet) { - if ($this->rdlength > 0) { - // - // expand the next domain name - // - $offset = $packet->offset; - $this->next_domain_name = Net_DNS2_Packet::expand($packet, $offset); - - // - // parse out the RR's from the bitmap - // - $this->type_bit_maps = Net_DNS2_BitMap::bitMapToArray( - substr($this->rdata, $offset - $packet->offset) - ); - - return true; - } - - return false; - } - - /** - * returns the rdata portion of the DNS packet - * - * @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet use for - * compressed names - * - * @return mixed either returns a binary packed - * string or null on failure - * @access protected - * - */ - protected function rrGet(Net_DNS2_Packet &$packet) { - if (strlen($this->next_domain_name) > 0) { - $data = $packet->compress($this->next_domain_name, $packet->offset); - $bitmap = Net_DNS2_BitMap::arrayToBitMap($this->type_bit_maps); - - $packet->offset += strlen($bitmap); - - return $data . $bitmap; - } - - return null; - } -} diff --git a/Net/DNS2/RR/NSEC3.php b/Net/DNS2/RR/NSEC3.php deleted file mode 100644 index 1dc8f876..00000000 --- a/Net/DNS2/RR/NSEC3.php +++ /dev/null @@ -1,235 +0,0 @@ -. All rights reserved. - * - * See LICENSE for more details. - * - * @category Networking - * @package Net_DNS2 - * @author Mike Pultz - * @copyright 2020 Mike Pultz - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @link https://netdns2.com/ - * @since File available since Release 0.6.0 - * - */ - -/** - * NSEC3 Resource Record - RFC5155 section 3.2 - * - * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 - * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - * | Hash Alg. | Flags | Iterations | - * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - * | Salt Length | Salt / - * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - * | Hash Length | Next Hashed Owner Name / - * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - * / Type Bit Maps / - * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - * - */ -class Net_DNS2_RR_NSEC3 extends Net_DNS2_RR { - // Algorithm to use - public $algorithm; - - // flags - public $flags; - - // defines the number of additional times the hash is performed. - public $iterations; - - // the length of the salt- not displayed - public $salt_length; - - // the salt - public $salt; - - // the length of the hash value - public $hash_length; - - // the hashed value of the owner name - public $hashed_owner_name; - - // array of RR type names - public $type_bit_maps = []; - - /** - * method to return the rdata portion of the packet as a string - * - * @return string - * @access protected - * - */ - protected function rrToString() { - $out = $this->algorithm . ' ' . $this->flags . ' ' . $this->iterations . ' '; - - // - // per RFC5155, the salt_length value isn't displayed, and if the salt - // is empty, the salt is displayed as '-' - // - if ($this->salt_length > 0) { - $out .= $this->salt; - } else { - $out .= '-'; - } - - // - // per RFC5255 the hash length isn't shown - // - $out .= ' ' . $this->hashed_owner_name; - - // - // show the RR's - // - foreach ($this->type_bit_maps as $rr) { - $out .= ' ' . strtoupper($rr); - } - - return $out; - } - - /** - * parses the rdata portion from a standard DNS config line - * - * @param array $rdata a string split line of values for the rdata - * - * @return boolean - * @access protected - * - */ - protected function rrFromString(array $rdata) { - $this->algorithm = array_shift($rdata); - $this->flags = array_shift($rdata); - $this->iterations = array_shift($rdata); - - // - // an empty salt is represented as '-' per RFC5155 section 3.3 - // - $salt = array_shift($rdata); - - if ($salt == '-') { - $this->salt_length = 0; - $this->salt = ''; - } else { - $this->salt_length = strlen(pack('H*', $salt)); - $this->salt = strtoupper($salt); - } - - $this->hashed_owner_name = array_shift($rdata); - $this->hash_length = strlen(base64_decode($this->hashed_owner_name, true)); - - $this->type_bit_maps = $rdata; - - return true; - } - - /** - * parses the rdata of the Net_DNS2_Packet object - * - * @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet to parse the RR from - * - * @return boolean - * @access protected - * - */ - protected function rrSet(Net_DNS2_Packet &$packet) { - if ($this->rdlength > 0) { - // - // unpack the first values - // - $x = unpack('Calgorithm/Cflags/niterations/Csalt_length', $this->rdata); - - $this->algorithm = $x['algorithm']; - $this->flags = $x['flags']; - $this->iterations = $x['iterations']; - $this->salt_length = $x['salt_length']; - - $offset = 5; - - if ($this->salt_length > 0) { - $x = unpack('H*', substr($this->rdata, $offset, $this->salt_length)); - $this->salt = strtoupper($x[1]); - $offset += $this->salt_length; - } - - // - // unpack the hash length - // - $x = unpack('@' . $offset . '/Chash_length', $this->rdata); - $offset++; - - // - // copy out the hash - // - $this->hash_length = $x['hash_length']; - - if ($this->hash_length > 0) { - $this->hashed_owner_name = base64_encode( - substr($this->rdata, $offset, $this->hash_length) - ); - $offset += $this->hash_length; - } - - // - // parse out the RR bitmap - // - $this->type_bit_maps = Net_DNS2_BitMap::bitMapToArray( - substr($this->rdata, $offset) - ); - - return true; - } - - return false; - } - - /** - * returns the rdata portion of the DNS packet - * - * @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet use for - * compressed names - * - * @return mixed either returns a binary packed - * string or null on failure - * @access protected - * - */ - protected function rrGet(Net_DNS2_Packet &$packet) { - // - // pull the salt and build the length - // - $salt = pack('H*', $this->salt); - $this->salt_length = strlen($salt); - - // - // pack the algorithm, flags, iterations and salt length - // - $data = pack( - 'CCnC', - $this->algorithm, $this->flags, $this->iterations, $this->salt_length - ); - $data .= $salt; - - // - // add the hash length and hash - // - $data .= chr($this->hash_length); - - if ($this->hash_length > 0) { - $data .= base64_decode($this->hashed_owner_name, true); - } - - // - // conver the array of RR names to a type bitmap - // - $data .= Net_DNS2_BitMap::arrayToBitMap($this->type_bit_maps); - - $packet->offset += strlen($data); - - return $data; - } -} diff --git a/Net/DNS2/RR/NSEC3PARAM.php b/Net/DNS2/RR/NSEC3PARAM.php deleted file mode 100644 index 56cce1cd..00000000 --- a/Net/DNS2/RR/NSEC3PARAM.php +++ /dev/null @@ -1,154 +0,0 @@ -. All rights reserved. - * - * See LICENSE for more details. - * - * @category Networking - * @package Net_DNS2 - * @author Mike Pultz - * @copyright 2020 Mike Pultz - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @link https://netdns2.com/ - * @since File available since Release 0.6.0 - * - */ - -/** - * NSEC3PARAM Resource Record - RFC5155 section 4.2 - * - * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 - * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - * | Hash Alg. | Flags | Iterations | - * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - * | Salt Length | Salt / - * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - * - */ -class Net_DNS2_RR_NSEC3PARAM extends Net_DNS2_RR { - /* - * Algorithm to use - * - * TODO: same as the NSEC3 - */ - public $algorithm; - - // flags - public $flags; - - // defines the number of additional times the hash is performed. - public $iterations; - - // the length of the salt- not displayed - public $salt_length; - - // the salt - public $salt; - - /** - * method to return the rdata portion of the packet as a string - * - * @return string - * @access protected - * - */ - protected function rrToString() { - $out = $this->algorithm . ' ' . $this->flags . ' ' . $this->iterations . ' '; - - // - // per RFC5155, the salt_length value isn't displayed, and if the salt - // is empty, the salt is displayed as "-" - // - if ($this->salt_length > 0) { - $out .= $this->salt; - } else { - $out .= '-'; - } - - return $out; - } - - /** - * parses the rdata portion from a standard DNS config line - * - * @param array $rdata a string split line of values for the rdata - * - * @return boolean - * @access protected - * - */ - protected function rrFromString(array $rdata) { - $this->algorithm = array_shift($rdata); - $this->flags = array_shift($rdata); - $this->iterations = array_shift($rdata); - - $salt = array_shift($rdata); - - if ($salt == '-') { - $this->salt_length = 0; - $this->salt = ''; - } else { - $this->salt_length = strlen(pack('H*', $salt)); - $this->salt = strtoupper($salt); - } - - return true; - } - - /** - * parses the rdata of the Net_DNS2_Packet object - * - * @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet to parse the RR from - * - * @return boolean - * @access protected - * - */ - protected function rrSet(Net_DNS2_Packet &$packet) { - if ($this->rdlength > 0) { - $x = unpack('Calgorithm/Cflags/niterations/Csalt_length', $this->rdata); - - $this->algorithm = $x['algorithm']; - $this->flags = $x['flags']; - $this->iterations = $x['iterations']; - $this->salt_length = $x['salt_length']; - - if ($this->salt_length > 0) { - $x = unpack('H*', substr($this->rdata, 5, $this->salt_length)); - $this->salt = strtoupper($x[1]); - } - - return true; - } - - return false; - } - - /** - * returns the rdata portion of the DNS packet - * - * @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet use for - * compressed names - * - * @return mixed either returns a binary packed - * string or null on failure - * @access protected - * - */ - protected function rrGet(Net_DNS2_Packet &$packet) { - $salt = pack('H*', $this->salt); - $this->salt_length = strlen($salt); - - $data = pack( - 'CCnC', - $this->algorithm, $this->flags, $this->iterations, $this->salt_length - ) . $salt; - - $packet->offset += strlen($data); - - return $data; - } -} diff --git a/Net/DNS2/RR/OPENPGPKEY.php b/Net/DNS2/RR/OPENPGPKEY.php deleted file mode 100644 index ee044a1c..00000000 --- a/Net/DNS2/RR/OPENPGPKEY.php +++ /dev/null @@ -1,102 +0,0 @@ -. All rights reserved. - * - * See LICENSE for more details. - * - * @category Networking - * @package Net_DNS2 - * @author Mike Pultz - * @copyright 2020 Mike Pultz - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @link https://netdns2.com/ - * @since File available since Release 1.4.0 - * - */ - -/** - * OPENPGPKEY Resource Record - https://tools.ietf.org/html/draft-ietf-dane-openpgpkey-01 - * - * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 - * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - * / / - * / OpenPGP Public KeyRing / - * / / - * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - * - */ -class Net_DNS2_RR_OPENPGPKEY extends Net_DNS2_RR { - // the public key - public $key; - - /** - * method to return the rdata portion of the packet as a string - * - * @return string - * @access protected - * - */ - protected function rrToString() { - return $this->key; - } - - /** - * parses the rdata portion from a standard DNS config line - * - * @param array $rdata a string split line of values for the rdata - * - * @return boolean - * @access protected - * - */ - protected function rrFromString(array $rdata) { - $this->key = array_shift($rdata); - - return true; - } - - /** - * parses the rdata of the Net_DNS2_Packet object - * - * @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet to parse the RR from - * - * @return boolean - * @access protected - * - */ - protected function rrSet(Net_DNS2_Packet &$packet) { - if ($this->rdlength > 0) { - $this->key = base64_encode(substr($this->rdata, 0, $this->rdlength)); - - return true; - } - - return false; - } - - /** - * returns the rdata portion of the DNS packet - * - * @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet use for - * compressed names - * - * @return mixed either returns a binary packed - * string or null on failure - * @access protected - * - */ - protected function rrGet(Net_DNS2_Packet &$packet) { - if (strlen($this->key) > 0) { - $data = base64_decode($this->key, true); - - $packet->offset += strlen($data); - - return $data; - } - - return null; - } -} diff --git a/Net/DNS2/RR/OPT.php b/Net/DNS2/RR/OPT.php deleted file mode 100644 index 1efa5295..00000000 --- a/Net/DNS2/RR/OPT.php +++ /dev/null @@ -1,220 +0,0 @@ -. All rights reserved. - * - * See LICENSE for more details. - * - * @category Networking - * @package Net_DNS2 - * @author Mike Pultz - * @copyright 2020 Mike Pultz - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @link https://netdns2.com/ - * @since File available since Release 1.0.0 - * - */ - -/** - * OPT Resource Record - RFC2929 section 3.1 - * - * +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+ - * | OPTION-CODE | - * +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+ - * | OPTION-LENGTH | - * +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+ - * | | - * / OPTION-DATA / - * / / - * +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+ - * - */ -class Net_DNS2_RR_OPT extends Net_DNS2_RR { - // option code - assigned by IANA - public $option_code; - - // the length of the option data - public $option_length; - - // the option data - public $option_data; - - // the extended response code stored in the TTL - public $extended_rcode; - - // the implementation level - public $version; - - // the DO bit used for DNSSEC - RFC3225 - public $do; - - // the extended flags - public $z; - - /** - * Constructor - builds a new Net_DNS2_RR_OPT object; normally you wouldn't call - * this directly, but OPT RR's are a little different - * - * @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet or null to create - * an empty object - * @param array $rr an array with RR parse values or null to - * create an empty object - * - * @throws Net_DNS2_Exception - * @access public - * - */ - public function __construct(Net_DNS2_Packet &$packet = null, array $rr = null) { - // - // this is for when we're manually building an OPT RR object; we aren't - // passing in binary data to parse, we just want a clean/empty object. - // - $this->type = 'OPT'; - $this->rdlength = 0; - - $this->option_length = 0; - $this->extended_rcode = 0; - $this->version = 0; - $this->do = 0; - $this->z = 0; - - // - // everthing else gets passed through to the parent. - // - if ((!is_null($packet)) && (!is_null($rr))) { - parent::__construct($packet, $rr); - } - } - - /** - * method to return the rdata portion of the packet as a string. There is no - * defintion for returning an OPT RR by string- this is just here to validate - * the binary parsing / building routines. - * - * @return string - * @access protected - * - */ - protected function rrToString() { - return $this->option_code . ' ' . $this->option_data; - } - - /** - * parses the rdata portion from a standard DNS config line. There is no - * definition for parsing a OPT RR by string- this is just here to validate - * the binary parsing / building routines. - * - * @param array $rdata a string split line of values for the rdata - * - * @return boolean - * @access protected - * - */ - protected function rrFromString(array $rdata) { - $this->option_code = array_shift($rdata); - $this->option_data = array_shift($rdata); - $this->option_length = strlen($this->option_data); - - $x = unpack('Cextended/Cversion/Cdo/Cz', pack('N', $this->ttl)); - - $this->extended_rcode = $x['extended']; - $this->version = $x['version']; - $this->do = ($x['do'] >> 7); - $this->z = $x['z']; - - return true; - } - - /** - * parses the rdata of the Net_DNS2_Packet object - * - * @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet to parse the RR from - * - * @return boolean - * @access protected - * - */ - protected function rrSet(Net_DNS2_Packet &$packet) { - // - // parse out the TTL value - // - $x = unpack('Cextended/Cversion/Cdo/Cz', pack('N', $this->ttl)); - - $this->extended_rcode = $x['extended']; - $this->version = $x['version']; - $this->do = ($x['do'] >> 7); - $this->z = $x['z']; - - // - // parse the data, if there is any - // - if ($this->rdlength > 0) { - // - // unpack the code and length - // - $x = unpack('noption_code/noption_length', $this->rdata); - - $this->option_code = $x['option_code']; - $this->option_length = $x['option_length']; - - // - // copy out the data based on the length - // - $this->option_data = substr($this->rdata, 4); - } - - return true; - } - - /** - * pre-builds the TTL value for this record; we needed to separate this out - * from the rrGet() function, as the logic in the Net_DNS2_RR packs the TTL - * value before it builds the rdata value. - * - * @return void - * @access protected - * - */ - protected function preBuild() { - // - // build the TTL value based on the local values - // - $ttl = unpack( - 'N', - pack('CCCC', $this->extended_rcode, $this->version, ($this->do << 7), 0) - ); - - $this->ttl = $ttl[1]; - - return; - } - - /** - * returns the rdata portion of the DNS packet - * - * @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet use for - * compressed names - * - * @return mixed either returns a binary packed - * string or null on failure - * @access protected - * - */ - protected function rrGet(Net_DNS2_Packet &$packet) { - // - // if there is an option code, then pack that data too - // - if ($this->option_code) { - $data = pack('nn', $this->option_code, $this->option_length) . - $this->option_data; - - $packet->offset += strlen($data); - - return $data; - } - - return null; - } -} diff --git a/Net/DNS2/RR/PTR.php b/Net/DNS2/RR/PTR.php deleted file mode 100644 index ce79bf9f..00000000 --- a/Net/DNS2/RR/PTR.php +++ /dev/null @@ -1,96 +0,0 @@ -. All rights reserved. - * - * See LICENSE for more details. - * - * @category Networking - * @package Net_DNS2 - * @author Mike Pultz - * @copyright 2020 Mike Pultz - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @link https://netdns2.com/ - * @since File available since Release 0.6.0 - * - */ - -/** - * PTR Resource Record - RFC1035 section 3.3.12 - * - * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ - * / PTRDNAME / - * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ - * - */ -class Net_DNS2_RR_PTR extends Net_DNS2_RR { - // the hostname of the PTR entry - public $ptrdname; - - /** - * method to return the rdata portion of the packet as a string - * - * @return string - * @access protected - * - */ - protected function rrToString() { - return rtrim($this->ptrdname, '.') . '.'; - } - - /** - * parses the rdata portion from a standard DNS config line - * - * @param array $rdata a string split line of values for the rdata - * - * @return boolean - * @access protected - * - */ - protected function rrFromString(array $rdata) { - $this->ptrdname = rtrim(implode(' ', $rdata), '.'); - - return true; - } - - /** - * parses the rdata of the Net_DNS2_Packet object - * - * @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet to parse the RR from - * - * @return boolean - * @access protected - * - */ - protected function rrSet(Net_DNS2_Packet &$packet) { - if ($this->rdlength > 0) { - $offset = $packet->offset; - $this->ptrdname = Net_DNS2_Packet::expand($packet, $offset); - - return true; - } - - return false; - } - - /** - * returns the rdata portion of the DNS packet - * - * @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet use for - * compressed names - * - * @return mixed either returns a binary packed - * string or null on failure - * @access protected - * - */ - protected function rrGet(Net_DNS2_Packet &$packet) { - if (strlen($this->ptrdname) > 0) { - return $packet->compress($this->ptrdname, $packet->offset); - } - - return null; - } -} diff --git a/Net/DNS2/RR/PX.php b/Net/DNS2/RR/PX.php deleted file mode 100644 index ff185105..00000000 --- a/Net/DNS2/RR/PX.php +++ /dev/null @@ -1,125 +0,0 @@ -. All rights reserved. - * - * See LICENSE for more details. - * - * @category Networking - * @package Net_DNS2 - * @author Mike Pultz - * @copyright 2020 Mike Pultz - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @link https://netdns2.com/ - * @since File available since Release 0.6.0 - * - */ - -/** - * PX Resource Record - RFC2163 section 4 - * - * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ - * | PREFERENCE | - * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ - * / MAP822 / - * / / - * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ - * / MAPX400 / - * / / - * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+-- - * - */ -class Net_DNS2_RR_PX extends Net_DNS2_RR { - // preference - public $preference; - - // the RFC822 part of the MCGAM - public $map822; - - // the X.400 part of the MCGAM - public $mapx400; - - /** - * method to return the rdata portion of the packet as a string - * - * @return string - * @access protected - * - */ - protected function rrToString() { - return $this->preference . ' ' . $this->cleanString($this->map822) . '. ' . - $this->cleanString($this->mapx400) . '.'; - } - - /** - * parses the rdata portion from a standard DNS config line - * - * @param array $rdata a string split line of values for the rdata - * - * @return boolean - * @access protected - * - */ - protected function rrFromString(array $rdata) { - $this->preference = $rdata[0]; - $this->map822 = $this->cleanString($rdata[1]); - $this->mapx400 = $this->cleanString($rdata[2]); - - return true; - } - - /** - * parses the rdata of the Net_DNS2_Packet object - * - * @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet to parse the RR from - * - * @return boolean - * @access protected - * - */ - protected function rrSet(Net_DNS2_Packet &$packet) { - if ($this->rdlength > 0) { - // - // parse the preference - // - $x = unpack('npreference', $this->rdata); - $this->preference = $x['preference']; - - $offset = $packet->offset + 2; - - $this->map822 = Net_DNS2_Packet::expand($packet, $offset); - $this->mapx400 = Net_DNS2_Packet::expand($packet, $offset); - - return true; - } - - return false; - } - - /** - * returns the rdata portion of the DNS packet - * - * @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet use for - * compressed names - * - * @return mixed either returns a binary packed - * string or null on failure - * @access protected - * - */ - protected function rrGet(Net_DNS2_Packet &$packet) { - if (strlen($this->map822) > 0) { - $data = pack('n', $this->preference); - $packet->offset += 2; - - $data .= $packet->compress($this->map822, $packet->offset); - $data .= $packet->compress($this->mapx400, $packet->offset); - - return $data; - } - - return null; - } -} diff --git a/Net/DNS2/RR/RP.php b/Net/DNS2/RR/RP.php deleted file mode 100644 index c99f1d86..00000000 --- a/Net/DNS2/RR/RP.php +++ /dev/null @@ -1,107 +0,0 @@ -. All rights reserved. - * - * See LICENSE for more details. - * - * @category Networking - * @package Net_DNS2 - * @author Mike Pultz - * @copyright 2020 Mike Pultz - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @link https://netdns2.com/ - * @since File available since Release 0.6.0 - * - */ - -/** - * RP Resource Record - RFC1183 section 2.2 - * - * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ - * / mboxdname / - * / / - * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ - * / txtdname / - * / / - * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ - * - */ -class Net_DNS2_RR_RP extends Net_DNS2_RR { - // mailbox for the responsible person - public $mboxdname; - - // is a domain name for which TXT RR's exists - public $txtdname; - - /** - * method to return the rdata portion of the packet as a string - * - * @return string - * @access protected - * - */ - protected function rrToString() { - return $this->cleanString($this->mboxdname) . '. ' . $this->cleanString($this->txtdname) . '.'; - } - - /** - * parses the rdata portion from a standard DNS config line - * - * @param array $rdata a string split line of values for the rdata - * - * @return boolean - * @access protected - * - */ - protected function rrFromString(array $rdata) { - $this->mboxdname = $this->cleanString($rdata[0]); - $this->txtdname = $this->cleanString($rdata[1]); - - return true; - } - - /** - * parses the rdata of the Net_DNS2_Packet object - * - * @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet to parse the RR from - * - * @return boolean - * @access protected - * - */ - protected function rrSet(Net_DNS2_Packet &$packet) { - if ($this->rdlength > 0) { - $offset = $packet->offset; - - $this->mboxdname = Net_DNS2_Packet::expand($packet, $offset, true); - $this->txtdname = Net_DNS2_Packet::expand($packet, $offset); - - return true; - } - - return false; - } - - /** - * returns the rdata portion of the DNS packet - * - * @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet use for - * compressed names - * - * @return mixed either returns a binary packed - * string or null on failure - * @access protected - * - */ - protected function rrGet(Net_DNS2_Packet &$packet) { - if (strlen($this->mboxdname) > 0) { - return $packet->compress($this->mboxdname, $packet->offset) . - $packet->compress($this->txtdname, $packet->offset); - } - - return null; - } -} diff --git a/Net/DNS2/RR/RRSIG.php b/Net/DNS2/RR/RRSIG.php deleted file mode 100644 index 3c49c746..00000000 --- a/Net/DNS2/RR/RRSIG.php +++ /dev/null @@ -1,254 +0,0 @@ -. All rights reserved. - * - * See LICENSE for more details. - * - * @category Networking - * @package Net_DNS2 - * @author Mike Pultz - * @copyright 2020 Mike Pultz - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @link https://netdns2.com/ - * @since File available since Release 0.6.0 - * - * This file contains code based off the Net::DNS::SEC Perl module by Olaf M. Kolkman - * - * This is the copyright notice from the PERL Net::DNS::SEC module: - * - * Copyright (c) 2001 - 2005 RIPE NCC. Author Olaf M. Kolkman - * Copyright (c) 2007 - 2008 NLnet Labs. Author Olaf M. Kolkman - * - * - * All Rights Reserved - * - * Permission to use, copy, modify, and distribute this software and its - * documentation for any purpose and without fee is hereby granted, - * provided that the above copyright notice appear in all copies and that - * both that copyright notice and this permission notice appear in - * supporting documentation, and that the name of the author not be - * used in advertising or publicity pertaining to distribution of the - * software without specific, written prior permission. - * - * THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING - * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS; IN NO EVENT SHALL - * AUTHOR BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY - * DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN - * AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - * - */ - -/** - * RRSIG Resource Record - RFC4034 sction 3.1 - * - * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 - * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - * | Type Covered | Algorithm | Labels | - * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - * | Original TTL | - * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - * | Signature Expiration | - * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - * | Signature Inception | - * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - * | Key Tag | / - * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ Signer's Name / - * / / - * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - * / / - * / Signature / - * / / - * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - * - */ -class Net_DNS2_RR_RRSIG extends Net_DNS2_RR { - // the RR type covered by this signature - public $typecovered; - - // the algorithm used for the signature - public $algorithm; - - // the number of labels in the name - public $labels; - - // the original TTL - public $origttl; - - // the signature expiration - public $sigexp; - - // the inception of the signature - public $sigincep; - - // the keytag used - public $keytag; - - // the signer's name - public $signname; - - // the signature - public $signature; - - /** - * method to return the rdata portion of the packet as a string - * - * @return string - * @access protected - * - */ - protected function rrToString() { - return $this->typecovered . ' ' . $this->algorithm . ' ' . - $this->labels . ' ' . $this->origttl . ' ' . - $this->sigexp . ' ' . $this->sigincep . ' ' . - $this->keytag . ' ' . $this->cleanString($this->signname) . '. ' . - $this->signature; - } - - /** - * parses the rdata portion from a standard DNS config line - * - * @param array $rdata a string split line of values for the rdata - * - * @return boolean - * @access protected - * - */ - protected function rrFromString(array $rdata) { - $this->typecovered = strtoupper(array_shift($rdata)); - $this->algorithm = array_shift($rdata); - $this->labels = array_shift($rdata); - $this->origttl = array_shift($rdata); - $this->sigexp = array_shift($rdata); - $this->sigincep = array_shift($rdata); - $this->keytag = array_shift($rdata); - $this->signname = $this->cleanString(array_shift($rdata)); - - foreach ($rdata as $line) { - $this->signature .= $line; - } - - $this->signature = trim($this->signature); - - return true; - } - - /** - * parses the rdata of the Net_DNS2_Packet object - * - * @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet to parse the RR from - * - * @return boolean - * @access protected - * - */ - protected function rrSet(Net_DNS2_Packet &$packet) { - if ($this->rdlength > 0) { - // - // unpack - // - $x = unpack( - 'ntc/Calgorithm/Clabels/Norigttl/Nsigexp/Nsigincep/nkeytag', - $this->rdata - ); - - $this->typecovered = Net_DNS2_Lookups::$rr_types_by_id[$x['tc']]; - $this->algorithm = $x['algorithm']; - $this->labels = $x['labels']; - $this->origttl = Net_DNS2::expandUint32($x['origttl']); - - // - // the dates are in GM time - // - $this->sigexp = gmdate('YmdHis', $x['sigexp']); - $this->sigincep = gmdate('YmdHis', $x['sigincep']); - - // - // get the keytag - // - $this->keytag = $x['keytag']; - - // - // get teh signers name and signature - // - $offset = $packet->offset + 18; - $sigoffset = $offset; - - $this->signname = strtolower( - Net_DNS2_Packet::expand($packet, $sigoffset) - ); - $this->signature = base64_encode( - substr($this->rdata, 18 + ($sigoffset - $offset)) - ); - - return true; - } - - return false; - } - - /** - * returns the rdata portion of the DNS packet - * - * @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet use for - * compressed names - * - * @return mixed either returns a binary packed - * string or null on failure - * @access protected - * - */ - protected function rrGet(Net_DNS2_Packet &$packet) { - if (strlen($this->signature) > 0) { - // - // parse the values out of the dates - // - preg_match( - '/(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})/', $this->sigexp, $e - ); - preg_match( - '/(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})/', $this->sigincep, $i - ); - - // - // pack the value - // - $data = pack( - 'nCCNNNn', - Net_DNS2_Lookups::$rr_types_by_name[$this->typecovered], - $this->algorithm, - $this->labels, - $this->origttl, - gmmktime($e[4], $e[5], $e[6], $e[2], $e[3], $e[1]), - gmmktime($i[4], $i[5], $i[6], $i[2], $i[3], $i[1]), - $this->keytag - ); - - // - // the signer name is special; it's not allowed to be compressed - // (see section 3.1.7) - // - $names = explode('.', strtolower($this->signname)); - - foreach ($names as $name) { - $data .= chr(strlen($name)); - $data .= $name; - } - $data .= "\0"; - - // - // add the signature - // - $data .= base64_decode($this->signature, true); - - $packet->offset += strlen($data); - - return $data; - } - - return null; - } -} diff --git a/Net/DNS2/RR/RT.php b/Net/DNS2/RR/RT.php deleted file mode 100644 index 5a8d57de..00000000 --- a/Net/DNS2/RR/RT.php +++ /dev/null @@ -1,116 +0,0 @@ -. All rights reserved. - * - * See LICENSE for more details. - * - * @category Networking - * @package Net_DNS2 - * @author Mike Pultz - * @copyright 2020 Mike Pultz - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @link https://netdns2.com/ - * @since File available since Release 0.6.0 - * - */ - -/** - * RT Resource Record - RFC1183 section 3.3 - * - * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ - * | preference | - * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ - * / intermediate-host / - * / / - * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ - * - */ -class Net_DNS2_RR_RT extends Net_DNS2_RR { - // the preference of this route - public $preference; - - // host which will servce as an intermediate in reaching the owner host - public $intermediatehost; - - /** - * method to return the rdata portion of the packet as a string - * - * @return string - * @access protected - * - */ - protected function rrToString() { - return $this->preference . ' ' . - $this->cleanString($this->intermediatehost) . '.'; - } - - /** - * parses the rdata portion from a standard DNS config line - * - * @param array $rdata a string split line of values for the rdata - * - * @return boolean - * @access protected - * - */ - protected function rrFromString(array $rdata) { - $this->preference = $rdata[0]; - $this->intermediatehost = $this->cleanString($rdata[1]); - - return true; - } - - /** - * parses the rdata of the Net_DNS2_Packet object - * - * @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet to parse the RR from - * - * @return boolean - * @access protected - * - */ - protected function rrSet(Net_DNS2_Packet &$packet) { - if ($this->rdlength > 0) { - // - // unpack the preference - // - $x = unpack('npreference', $this->rdata); - - $this->preference = $x['preference']; - $offset = $packet->offset + 2; - - $this->intermediatehost = Net_DNS2_Packet::expand($packet, $offset); - - return true; - } - - return false; - } - - /** - * returns the rdata portion of the DNS packet - * - * @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet use for - * compressed names - * - * @return mixed either returns a binary packed - * string or null on failure - * @access protected - * - */ - protected function rrGet(Net_DNS2_Packet &$packet) { - if (strlen($this->intermediatehost) > 0) { - $data = pack('n', $this->preference); - $packet->offset += 2; - - $data .= $packet->compress($this->intermediatehost, $packet->offset); - - return $data; - } - - return null; - } -} diff --git a/Net/DNS2/RR/SIG.php b/Net/DNS2/RR/SIG.php deleted file mode 100644 index 0d221bb6..00000000 --- a/Net/DNS2/RR/SIG.php +++ /dev/null @@ -1,374 +0,0 @@ -. All rights reserved. - * - * See LICENSE for more details. - * - * @category Networking - * @package Net_DNS2 - * @author Mike Pultz - * @copyright 2020 Mike Pultz - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @link https://netdns2.com/ - * @since File available since Release 0.6.0 - * - * This file contains code based off the Net::DNS::SEC Perl module by Olaf M. Kolkman - * - * This is the copyright notice from the PERL Net::DNS::SEC module: - * - * Copyright (c) 2001 - 2005 RIPE NCC. Author Olaf M. Kolkman - * Copyright (c) 2007 - 2008 NLnet Labs. Author Olaf M. Kolkman - * - * - * All Rights Reserved - * - * Permission to use, copy, modify, and distribute this software and its - * documentation for any purpose and without fee is hereby granted, - * provided that the above copyright notice appear in all copies and that - * both that copyright notice and this permission notice appear in - * supporting documentation, and that the name of the author not be - * used in advertising or publicity pertaining to distribution of the - * software without specific, written prior permission. - * - * THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING - * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS; IN NO EVENT SHALL - * AUTHOR BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY - * DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN - * AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - * - */ - -/** - * SIG Resource Record - RFC2535 section 4.1 - * - * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 - * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - * | Type Covered | Algorithm | Labels | - * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - * | Original TTL | - * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - * | Signature Expiration | - * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - * | Signature Inception | - * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - * | Key Tag | / - * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ Signer's Name / - * / / - * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - * / / - * / Signature / - * / / - * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - * - */ -class Net_DNS2_RR_SIG extends Net_DNS2_RR { - // and instance of a Net_DNS2_PrivateKey object - public $private_key = null; - - // the RR type covered by this signature - public $typecovered; - - // the algorithm used for the signature - public $algorithm; - - // the number of labels in the name - public $labels; - - // the original TTL - public $origttl; - - // the signature expiration - public $sigexp; - - // the inception of the signature - public $sigincep; - - // the keytag used - public $keytag; - - // the signer's name - public $signname; - - // the signature - public $signature; - - /** - * method to return the rdata portion of the packet as a string - * - * @return string - * @access protected - * - */ - protected function rrToString() { - return $this->typecovered . ' ' . $this->algorithm . ' ' . - $this->labels . ' ' . $this->origttl . ' ' . - $this->sigexp . ' ' . $this->sigincep . ' ' . - $this->keytag . ' ' . $this->cleanString($this->signname) . '. ' . - $this->signature; - } - - /** - * parses the rdata portion from a standard DNS config line - * - * @param array $rdata a string split line of values for the rdata - * - * @return boolean - * @access protected - * - */ - protected function rrFromString(array $rdata) { - $this->typecovered = strtoupper(array_shift($rdata)); - $this->algorithm = array_shift($rdata); - $this->labels = array_shift($rdata); - $this->origttl = array_shift($rdata); - $this->sigexp = array_shift($rdata); - $this->sigincep = array_shift($rdata); - $this->keytag = array_shift($rdata); - $this->signname = $this->cleanString(array_shift($rdata)); - - foreach ($rdata as $line) { - $this->signature .= $line; - } - - $this->signature = trim($this->signature); - - return true; - } - - /** - * parses the rdata of the Net_DNS2_Packet object - * - * @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet to parse the RR from - * - * @return boolean - * @access protected - * - */ - protected function rrSet(Net_DNS2_Packet &$packet) { - if ($this->rdlength > 0) { - // - // unpack - // - $x = unpack( - 'ntc/Calgorithm/Clabels/Norigttl/Nsigexp/Nsigincep/nkeytag', - $this->rdata - ); - - $this->typecovered = Net_DNS2_Lookups::$rr_types_by_id[$x['tc']]; - $this->algorithm = $x['algorithm']; - $this->labels = $x['labels']; - $this->origttl = Net_DNS2::expandUint32($x['origttl']); - - // - // the dates are in GM time - // - $this->sigexp = gmdate('YmdHis', $x['sigexp']); - $this->sigincep = gmdate('YmdHis', $x['sigincep']); - - // - // get the keytag - // - $this->keytag = $x['keytag']; - - // - // get teh signers name and signature - // - $offset = $packet->offset + 18; - $sigoffset = $offset; - - $this->signname = strtolower( - Net_DNS2_Packet::expand($packet, $sigoffset) - ); - $this->signature = base64_encode( - substr($this->rdata, 18 + ($sigoffset - $offset)) - ); - - return true; - } - - return false; - } - - /** - * returns the rdata portion of the DNS packet - * - * @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet use for - * compressed names - * - * @return mixed either returns a binary packed - * string or null on failure - * @access protected - * - */ - protected function rrGet(Net_DNS2_Packet &$packet) { - // - // parse the values out of the dates - // - preg_match( - '/(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})/', $this->sigexp, $e - ); - preg_match( - '/(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})/', $this->sigincep, $i - ); - - // - // pack the value - // - $data = pack( - 'nCCNNNn', - Net_DNS2_Lookups::$rr_types_by_name[$this->typecovered], - $this->algorithm, - $this->labels, - $this->origttl, - gmmktime($e[4], $e[5], $e[6], $e[2], $e[3], $e[1]), - gmmktime($i[4], $i[5], $i[6], $i[2], $i[3], $i[1]), - $this->keytag - ); - - // - // the signer name is special; it's not allowed to be compressed - // (see section 3.1.7) - // - $names = explode('.', strtolower($this->signname)); - - foreach ($names as $name) { - $data .= chr(strlen($name)); - $data .= $name; - } - - $data .= chr('0'); - - // - // if the signature is empty, and $this->private_key is an instance of a - // private key object, and we have access to openssl, then assume this - // is a SIG(0), and generate a new signature - // - if ((strlen($this->signature) == 0) - && ($this->private_key instanceof Net_DNS2_PrivateKey) - && (extension_loaded('openssl') === true) - ) { - // - // create a new packet for the signature- - // - $new_packet = new Net_DNS2_Packet_Request('example.com', 'SOA', 'IN'); - - // - // copy the packet data over - // - $new_packet->copy($packet); - - // - // remove the SIG object from the additional list - // - array_pop($new_packet->additional); - $new_packet->header->arcount = cacti_sizeof($new_packet->additional); - - // - // copy out the data - // - $sigdata = $data . $new_packet->get(); - - // - // based on the algorithm - // - $algorithm = 0; - - switch($this->algorithm) { - // - // MD5 - // - case Net_DNS2_Lookups::DNSSEC_ALGORITHM_RSAMD5: - $algorithm = OPENSSL_ALGO_MD5; - - break; - // - // SHA1 - // - case Net_DNS2_Lookups::DNSSEC_ALGORITHM_RSASHA1: - $algorithm = OPENSSL_ALGO_SHA1; - - break; - // - // SHA256 (PHP 5.4.8 or higher) - // - case Net_DNS2_Lookups::DNSSEC_ALGORITHM_RSASHA256: - if (version_compare(PHP_VERSION, '5.4.8', '<') == true) { - throw new Net_DNS2_Exception( - 'SHA256 support is only available in PHP >= 5.4.8', - Net_DNS2_Lookups::E_OPENSSL_INV_ALGO - ); - } - - $algorithm = OPENSSL_ALGO_SHA256; - - break; - // - // SHA512 (PHP 5.4.8 or higher) - // - case Net_DNS2_Lookups::DNSSEC_ALGORITHM_RSASHA512: - if (version_compare(PHP_VERSION, '5.4.8', '<') == true) { - throw new Net_DNS2_Exception( - 'SHA512 support is only available in PHP >= 5.4.8', - Net_DNS2_Lookups::E_OPENSSL_INV_ALGO - ); - } - - $algorithm = OPENSSL_ALGO_SHA512; - - break; - // - // unsupported at the moment - // - case Net_DNS2_Lookups::DNSSEC_ALGORITHM_DSA: - case Net_DNS2_Lookups::DSNSEC_ALGORITHM_RSASHA1NSEC3SHA1: - case Net_DNS2_Lookups::DNSSEC_ALGORITHM_DSANSEC3SHA1: - default: - throw new Net_DNS2_Exception( - 'invalid or unsupported algorithm', - Net_DNS2_Lookups::E_OPENSSL_INV_ALGO - ); - - break; - } - - // - // sign the data - // - if (openssl_sign($sigdata, $this->signature, $this->private_key->instance, $algorithm) == false) { - throw new Net_DNS2_Exception( - openssl_error_string(), - Net_DNS2_Lookups::E_OPENSSL_ERROR - ); - } - - // - // build the signature value based - // - switch($this->algorithm) { - // - // RSA- add it directly - // - case Net_DNS2_Lookups::DNSSEC_ALGORITHM_RSAMD5: - case Net_DNS2_Lookups::DNSSEC_ALGORITHM_RSASHA1: - case Net_DNS2_Lookups::DNSSEC_ALGORITHM_RSASHA256: - case Net_DNS2_Lookups::DNSSEC_ALGORITHM_RSASHA512: - $this->signature = base64_encode($this->signature); - - break; - } - } - - // - // add the signature - // - $data .= base64_decode($this->signature, true); - - $packet->offset += strlen($data); - - return $data; - } -} diff --git a/Net/DNS2/RR/SMIMEA.php b/Net/DNS2/RR/SMIMEA.php deleted file mode 100644 index 488fa47d..00000000 --- a/Net/DNS2/RR/SMIMEA.php +++ /dev/null @@ -1,26 +0,0 @@ -. All rights reserved. - * - * See LICENSE for more details. - * - * @category Networking - * @package Net_DNS2 - * @author Mike Pultz - * @copyright 2020 Mike Pultz - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @link https://netdns2.com/ - * @since File available since Release 1.4.2 - * - */ - -/** - * The SMIMEA RR is implemented exactly like the TLSA record, so - * for now we just extend the TLSA RR and use it. - * - */ -class Net_DNS2_RR_SMIMEA extends Net_DNS2_RR_TLSA { -} diff --git a/Net/DNS2/RR/SOA.php b/Net/DNS2/RR/SOA.php deleted file mode 100644 index a63894ae..00000000 --- a/Net/DNS2/RR/SOA.php +++ /dev/null @@ -1,171 +0,0 @@ -. All rights reserved. - * - * See LICENSE for more details. - * - * @category Networking - * @package Net_DNS2 - * @author Mike Pultz - * @copyright 2020 Mike Pultz - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @link https://netdns2.com/ - * @since File available since Release 0.6.0 - * - */ - -/** - * SOA Resource Record - RFC1035 section 3.3.13 - * - * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ - * / MNAME / - * / / - * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ - * / RNAME / - * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ - * | SERIAL | - * | | - * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ - * | REFRESH | - * | | - * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ - * | RETRY | - * | | - * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ - * | EXPIRE | - * | | - * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ - * | MINIMUM | - * | | - * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ - * - */ -class Net_DNS2_RR_SOA extends Net_DNS2_RR { - // The master DNS server - public $mname; - - // mailbox of the responsible person - public $rname; - - // serial number - public $serial; - - // refresh time - public $refresh; - - // retry interval - public $retry; - - // expire time - public $expire; - - // minimum TTL for any RR in this zone - public $minimum; - - /** - * method to return the rdata portion of the packet as a string - * - * @return string - * @access protected - * - */ - protected function rrToString() { - return $this->cleanString($this->mname) . '. ' . - $this->cleanString($this->rname) . '. ' . - $this->serial . ' ' . $this->refresh . ' ' . $this->retry . ' ' . - $this->expire . ' ' . $this->minimum; - } - - /** - * parses the rdata portion from a standard DNS config line - * - * @param array $rdata a string split line of values for the rdata - * - * @return boolean - * @access protected - * - */ - protected function rrFromString(array $rdata) { - $this->mname = $this->cleanString($rdata[0]); - $this->rname = $this->cleanString($rdata[1]); - - $this->serial = $rdata[2]; - $this->refresh = $rdata[3]; - $this->retry = $rdata[4]; - $this->expire = $rdata[5]; - $this->minimum = $rdata[6]; - - return true; - } - - /** - * parses the rdata of the Net_DNS2_Packet object - * - * @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet to parse the RR from - * - * @return boolean - * @access protected - * - */ - protected function rrSet(Net_DNS2_Packet &$packet) { - if ($this->rdlength > 0) { - // - // parse the - // - $offset = $packet->offset; - - $this->mname = Net_DNS2_Packet::expand($packet, $offset); - $this->rname = Net_DNS2_Packet::expand($packet, $offset, true); - - // - // get the SOA values - // - $x = unpack( - '@' . $offset . '/Nserial/Nrefresh/Nretry/Nexpire/Nminimum/', - $packet->rdata - ); - - $this->serial = Net_DNS2::expandUint32($x['serial']); - $this->refresh = Net_DNS2::expandUint32($x['refresh']); - $this->retry = Net_DNS2::expandUint32($x['retry']); - $this->expire = Net_DNS2::expandUint32($x['expire']); - $this->minimum = Net_DNS2::expandUint32($x['minimum']); - - return true; - } - - return false; - } - - /** - * returns the rdata portion of the DNS packet - * - * @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet use for - * compressed names - * - * @return mixed either returns a binary packed - * string or null on failure - * @access protected - * - */ - protected function rrGet(Net_DNS2_Packet &$packet) { - if (strlen($this->mname) > 0) { - $data = $packet->compress($this->mname, $packet->offset); - $data .= $packet->compress($this->rname, $packet->offset); - - $data .= pack( - 'N5', $this->serial, $this->refresh, $this->retry, - $this->expire, $this->minimum - ); - - $packet->offset += 20; - - return $data; - } - - return null; - } -} diff --git a/Net/DNS2/RR/SPF.php b/Net/DNS2/RR/SPF.php deleted file mode 100644 index 8ccfa8c1..00000000 --- a/Net/DNS2/RR/SPF.php +++ /dev/null @@ -1,26 +0,0 @@ -. All rights reserved. - * - * See LICENSE for more details. - * - * @category Networking - * @package Net_DNS2 - * @author Mike Pultz - * @copyright 2020 Mike Pultz - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @link https://netdns2.com/ - * @since File available since Release 0.6.0 - * - */ - -/** - * The SPF RR is implemented exactly like the TXT record, so - * for now we just extend the TXT RR and use it. - * - */ -class Net_DNS2_RR_SPF extends Net_DNS2_RR_TXT { -} diff --git a/Net/DNS2/RR/SRV.php b/Net/DNS2/RR/SRV.php deleted file mode 100644 index 7e6e53f1..00000000 --- a/Net/DNS2/RR/SRV.php +++ /dev/null @@ -1,130 +0,0 @@ -. All rights reserved. - * - * See LICENSE for more details. - * - * @category Networking - * @package Net_DNS2 - * @author Mike Pultz - * @copyright 2020 Mike Pultz - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @link https://netdns2.com/ - * @since File available since Release 0.6.0 - * - */ - -/** - * SRV Resource Record - RFC2782 - * - * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ - * | PRIORITY | - * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ - * | WEIGHT | - * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ - * | PORT | - * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ - * / TARGET / - * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ - * - */ -class Net_DNS2_RR_SRV extends Net_DNS2_RR { - // The priority of this target host. - public $priority; - - // a relative weight for entries with the same priority - public $weight; - - // The port on this target host of this service. - public $port; - - // The domain name of the target host - public $target; - - /** - * method to return the rdata portion of the packet as a string - * - * @return string - * @access protected - * - */ - protected function rrToString() { - return $this->priority . ' ' . $this->weight . ' ' . - $this->port . ' ' . $this->cleanString($this->target) . '.'; - } - - /** - * parses the rdata portion from a standard DNS config line - * - * @param array $rdata a string split line of values for the rdata - * - * @return boolean - * @access protected - * - */ - protected function rrFromString(array $rdata) { - $this->priority = $rdata[0]; - $this->weight = $rdata[1]; - $this->port = $rdata[2]; - - $this->target = $this->cleanString($rdata[3]); - - return true; - } - - /** - * parses the rdata of the Net_DNS2_Packet object - * - * @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet to parse the RR from - * - * @return boolean - * @access protected - * - */ - protected function rrSet(Net_DNS2_Packet &$packet) { - if ($this->rdlength > 0) { - // - // unpack the priority, weight and port - // - $x = unpack('npriority/nweight/nport', $this->rdata); - - $this->priority = $x['priority']; - $this->weight = $x['weight']; - $this->port = $x['port']; - - $offset = $packet->offset + 6; - $this->target = Net_DNS2_Packet::expand($packet, $offset); - - return true; - } - - return false; - } - - /** - * returns the rdata portion of the DNS packet - * - * @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet use for - * compressed names - * - * @return mixed either returns a binary packed - * string or null on failure - * @access protected - * - */ - protected function rrGet(Net_DNS2_Packet &$packet) { - if (strlen($this->target) > 0) { - $data = pack('nnn', $this->priority, $this->weight, $this->port); - $packet->offset += 6; - - $data .= $packet->compress($this->target, $packet->offset); - - return $data; - } - - return null; - } -} diff --git a/Net/DNS2/RR/SSHFP.php b/Net/DNS2/RR/SSHFP.php deleted file mode 100644 index 3bb09fbb..00000000 --- a/Net/DNS2/RR/SSHFP.php +++ /dev/null @@ -1,187 +0,0 @@ -. All rights reserved. - * - * See LICENSE for more details. - * - * @category Networking - * @package Net_DNS2 - * @author Mike Pultz - * @copyright 2020 Mike Pultz - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @link https://netdns2.com/ - * @since File available since Release 0.6.0 - * - */ - -/** - * SSHFP Resource Record - RFC4255 section 3.1 - * - * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 - * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - * | algorithm | fp type | / - * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ / - * / / - * / fingerprint / - * / / - * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - * - */ -class Net_DNS2_RR_SSHFP extends Net_DNS2_RR { - // the algorithm used - public $algorithm; - - // The finger print type - public $fp_type; - - // the finger print data - public $fingerprint; - - // Algorithms - const SSHFP_ALGORITHM_RES = 0; - const SSHFP_ALGORITHM_RSA = 1; - const SSHFP_ALGORITHM_DSS = 2; - const SSHFP_ALGORITHM_ECDSA = 3; - const SSHFP_ALGORITHM_ED25519 = 4; - - // Fingerprint Types - const SSHFP_FPTYPE_RES = 0; - const SSHFP_FPTYPE_SHA1 = 1; - const SSHFP_FPTYPE_SHA256 = 2; - - /** - * method to return the rdata portion of the packet as a string - * - * @return string - * @access protected - * - */ - protected function rrToString() { - return $this->algorithm . ' ' . $this->fp_type . ' ' . $this->fingerprint; - } - - /** - * parses the rdata portion from a standard DNS config line - * - * @param array $rdata a string split line of values for the rdata - * - * @return boolean - * @access protected - * - */ - protected function rrFromString(array $rdata) { - // - // "The use of mnemonics instead of numbers is not allowed." - // - // RFC4255 section 3.2 - // - $algorithm = array_shift($rdata); - $fp_type = array_shift($rdata); - $fingerprint = strtolower(implode('', $rdata)); - - // - // There are only two algorithm's defined - // - if (($algorithm != self::SSHFP_ALGORITHM_RSA) - && ($algorithm != self::SSHFP_ALGORITHM_DSS) - && ($algorithm != self::SSHFP_ALGORITHM_ECDSA) - && ($algorithm != self::SSHFP_ALGORITHM_ED25519) - ) { - return false; - } - - // - // there are only two fingerprints defined - // - if (($fp_type != self::SSHFP_FPTYPE_SHA1) - && ($fp_type != self::SSHFP_FPTYPE_SHA256) - ) { - return false; - } - - $this->algorithm = $algorithm; - $this->fp_type = $fp_type; - $this->fingerprint = $fingerprint; - - return true; - } - - /** - * parses the rdata of the Net_DNS2_Packet object - * - * @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet to parse the RR from - * - * @return boolean - * @access protected - * - */ - protected function rrSet(Net_DNS2_Packet &$packet) { - if ($this->rdlength > 0) { - // - // unpack the algorithm and finger print type - // - $x = unpack('Calgorithm/Cfp_type', $this->rdata); - - $this->algorithm = $x['algorithm']; - $this->fp_type = $x['fp_type']; - - // - // There are only three algorithm's defined - // - if (($this->algorithm != self::SSHFP_ALGORITHM_RSA) - && ($this->algorithm != self::SSHFP_ALGORITHM_DSS) - && ($this->algorithm != self::SSHFP_ALGORITHM_ECDSA) - && ($this->algorithm != self::SSHFP_ALGORITHM_ED25519) - ) { - return false; - } - - // - // there are only two fingerprints defined - // - if (($this->fp_type != self::SSHFP_FPTYPE_SHA1) - && ($this->fp_type != self::SSHFP_FPTYPE_SHA256) - ) { - return false; - } - - // - // parse the finger print; this assumes SHA-1 - // - $fp = unpack('H*a', substr($this->rdata, 2)); - $this->fingerprint = strtolower($fp['a']); - - return true; - } - - return false; - } - - /** - * returns the rdata portion of the DNS packet - * - * @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet use for - * compressed names - * - * @return mixed either returns a binary packed - * string or null on failure - * @access protected - * - */ - protected function rrGet(Net_DNS2_Packet &$packet) { - if (strlen($this->fingerprint) > 0) { - $data = pack( - 'CCH*', $this->algorithm, $this->fp_type, $this->fingerprint - ); - - $packet->offset += strlen($data); - - return $data; - } - - return null; - } -} diff --git a/Net/DNS2/RR/TA.php b/Net/DNS2/RR/TA.php deleted file mode 100644 index 96591a5f..00000000 --- a/Net/DNS2/RR/TA.php +++ /dev/null @@ -1,26 +0,0 @@ -. All rights reserved. - * - * See LICENSE for more details. - * - * @category Networking - * @package Net_DNS2 - * @author Mike Pultz - * @copyright 2020 Mike Pultz - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @link https://netdns2.com/ - * @since File available since Release 1.2.0 - * - */ - -/** - * The TA RR is implemented exactly like the DS record, so - * for now we just extend the DS RR and use it. - * - */ -class Net_DNS2_RR_TA extends Net_DNS2_RR_DS { -} diff --git a/Net/DNS2/RR/TALINK.php b/Net/DNS2/RR/TALINK.php deleted file mode 100644 index c41662db..00000000 --- a/Net/DNS2/RR/TALINK.php +++ /dev/null @@ -1,110 +0,0 @@ -. All rights reserved. - * - * @category Networking - * @package Net_DNS2 - * @author Mike Pultz - * @copyright 2020 Mike Pultz - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @link https://netdns2.com/ - * @since File available since Release 1.2.0 - * - */ - -/** - * TALINK Resource Record - DNSSEC Trust Anchor - * - * http://tools.ietf.org/id/draft-ietf-dnsop-dnssec-trust-history-00.txt - * - * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ - * / PREVIOUS / - * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ - * / NEXT / - * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ - * - */ -class Net_DNS2_RR_TALINK extends Net_DNS2_RR { - // the previous domain name - public $previous; - - // the next domain name - public $next; - - /** - * method to return the rdata portion of the packet as a string - * - * @return string - * @access protected - * - */ - protected function rrToString() { - return $this->cleanString($this->previous) . '. ' . - $this->cleanString($this->next) . '.'; - } - - /** - * parses the rdata portion from a standard DNS config line - * - * @param array $rdata a string split line of values for the rdata - * - * @return boolean - * @access protected - * - */ - protected function rrFromString(array $rdata) { - $this->previous = $this->cleanString($rdata[0]); - $this->next = $this->cleanString($rdata[1]); - - return true; - } - - /** - * parses the rdata of the Net_DNS2_Packet object - * - * @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet to parse the RR from - * - * @return boolean - * @access protected - * - */ - protected function rrSet(Net_DNS2_Packet &$packet) { - if ($this->rdlength > 0) { - $offset = $packet->offset; - - $this->previous = Net_DNS2_Packet::label($packet, $offset); - $this->next = Net_DNS2_Packet::label($packet, $offset); - - return true; - } - - return false; - } - - /** - * returns the rdata portion of the DNS packet - * - * @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet use for - * compressed names - * - * @return mixed either returns a binary packed - * string or null on failure - * @access protected - * - */ - protected function rrGet(Net_DNS2_Packet &$packet) { - if ((strlen($this->previous) > 0) || (strlen($this->next) > 0)) { - $data = chr(strlen($this->previous)) . $this->previous . - chr(strlen($this->next)) . $this->next; - - $packet->offset += strlen($data); - - return $data; - } - - return null; - } -} diff --git a/Net/DNS2/RR/TKEY.php b/Net/DNS2/RR/TKEY.php deleted file mode 100644 index f78efed3..00000000 --- a/Net/DNS2/RR/TKEY.php +++ /dev/null @@ -1,243 +0,0 @@ -. All rights reserved. - * - * See LICENSE for more details. - * - * @category Networking - * @package Net_DNS2 - * @author Mike Pultz - * @copyright 2020 Mike Pultz - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @link https://netdns2.com/ - * @since File available since Release 0.6.0 - * - */ - -/** - * TKEY Resource Record - RFC 2930 section 2 - * - * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ - * / ALGORITHM / - * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ - * | INCEPTION | - * | | - * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ - * | EXPIRATION | - * | | - * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ - * | MODE | - * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ - * | ERROR | - * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ - * | KEY SIZE | - * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ - * / KEY DATA / - * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ - * | OTHER SIZE | - * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ - * / OTHER DATA / - * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ - * - */ -class Net_DNS2_RR_TKEY extends Net_DNS2_RR { - public $algorithm; - public $inception; - public $expiration; - public $mode; - public $error; - public $key_size; - public $key_data; - public $other_size; - public $other_data; - - // TSIG Modes - const TSIG_MODE_RES = 0; - const TSIG_MODE_SERV_ASSIGN = 1; - const TSIG_MODE_DH = 2; - const TSIG_MODE_GSS_API = 3; - const TSIG_MODE_RESV_ASSIGN = 4; - const TSIG_MODE_KEY_DELE = 5; - - // map the mod id's to names so we can validate - public $tsgi_mode_id_to_name = [ - self::TSIG_MODE_RES => 'Reserved', - self::TSIG_MODE_SERV_ASSIGN => 'Server Assignment', - self::TSIG_MODE_DH => 'Diffie-Hellman', - self::TSIG_MODE_GSS_API => 'GSS-API', - self::TSIG_MODE_RESV_ASSIGN => 'Resolver Assignment', - self::TSIG_MODE_KEY_DELE => 'Key Deletion' - ]; - - /** - * method to return the rdata portion of the packet as a string - * - * @return string - * @access protected - * - */ - protected function rrToString() { - $out = $this->cleanString($this->algorithm) . '. ' . $this->mode; - - if ($this->key_size > 0) { - $out .= ' ' . trim($this->key_data, '.') . '.'; - } else { - $out .= ' .'; - } - - return $out; - } - - /** - * parses the rdata portion from a standard DNS config line - * - * @param array $rdata a string split line of values for the rdata - * - * @return boolean - * @access protected - * - */ - protected function rrFromString(array $rdata) { - // - // data passed in is assumed: - // - $this->algorithm = $this->cleanString(array_shift($rdata)); - $this->mode = array_shift($rdata); - $this->key_data = trim(array_shift($rdata), '.'); - - // - // the rest of the data is set manually - // - $this->inception = time(); - $this->expiration = time() + 86400; // 1 day - $this->error = 0; - $this->key_size = strlen($this->key_data); - $this->other_size = 0; - $this->other_data = ''; - - return true; - } - - /** - * parses the rdata of the Net_DNS2_Packet object - * - * @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet to parse the RR from - * - * @return boolean - * @access protected - * - */ - protected function rrSet(Net_DNS2_Packet &$packet) { - if ($this->rdlength > 0) { - // - // expand the algorithm - // - $offset = $packet->offset; - $this->algorithm = Net_DNS2_Packet::expand($packet, $offset); - - // - // unpack inception, expiration, mode, error and key size - // - $x = unpack( - '@' . $offset . '/Ninception/Nexpiration/nmode/nerror/nkey_size', - $packet->rdata - ); - - $this->inception = Net_DNS2::expandUint32($x['inception']); - $this->expiration = Net_DNS2::expandUint32($x['expiration']); - $this->mode = $x['mode']; - $this->error = $x['error']; - $this->key_size = $x['key_size']; - - $offset += 14; - - // - // if key_size > 0, then copy out the key - // - if ($this->key_size > 0) { - $this->key_data = substr($packet->rdata, $offset, $this->key_size); - $offset += $this->key_size; - } - - // - // unpack the other length - // - $x = unpack('@' . $offset . '/nother_size', $packet->rdata); - - $this->other_size = $x['other_size']; - $offset += 2; - - // - // if other_size > 0, then copy out the data - // - if ($this->other_size > 0) { - $this->other_data = substr( - $packet->rdata, $offset, $this->other_size - ); - } - - return true; - } - - return false; - } - - /** - * returns the rdata portion of the DNS packet - * - * @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet use for - * compressed names - * - * @return mixed either returns a binary packed - * string or null on failure - * @access protected - * - */ - protected function rrGet(Net_DNS2_Packet &$packet) { - if (strlen($this->algorithm) > 0) { - // - // make sure the size values are correct - // - $this->key_size = strlen($this->key_data); - $this->other_size = strlen($this->other_data); - - // - // add the algorithm without compression - // - $data = Net_DNS2_Packet::pack($this->algorithm); - - // - // pack in the inception, expiration, mode, error and key size - // - $data .= pack( - 'NNnnn', $this->inception, $this->expiration, - $this->mode, 0, $this->key_size - ); - - // - // if the key_size > 0, then add the key - // - if ($this->key_size > 0) { - $data .= $this->key_data; - } - - // - // pack in the other size - // - $data .= pack('n', $this->other_size); - - if ($this->other_size > 0) { - $data .= $this->other_data; - } - - $packet->offset += strlen($data); - - return $data; - } - - return null; - } -} diff --git a/Net/DNS2/RR/TLSA.php b/Net/DNS2/RR/TLSA.php deleted file mode 100644 index 1ddd51cb..00000000 --- a/Net/DNS2/RR/TLSA.php +++ /dev/null @@ -1,131 +0,0 @@ -. All rights reserved. - * - * See LICENSE for more details. - * - * @category Networking - * @package Net_DNS2 - * @author Mike Pultz - * @copyright 2020 Mike Pultz - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @link https://netdns2.com/ - * @since File available since Release 1.2.5 - * - */ - -/** - * TLSA Resource Record - RFC 6698 - * - * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 - * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - * | Cert. Usage | Selector | Matching Type | / - * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ / - * / / - * / Certificate Association Data / - * / / - * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - * - */ -class Net_DNS2_RR_TLSA extends Net_DNS2_RR { - // The Certificate Usage Field - public $cert_usage; - - // The Selector Field - public $selector; - - // The Matching Type Field - public $matching_type; - - // The Certificate Association Data Field - public $certificate; - - /** - * method to return the rdata portion of the packet as a string - * - * @return string - * @access protected - * - */ - protected function rrToString() { - return $this->cert_usage . ' ' . $this->selector . ' ' . - $this->matching_type . ' ' . base64_encode($this->certificate); - } - - /** - * parses the rdata portion from a standard DNS config line - * - * @param array $rdata a string split line of values for the rdata - * - * @return boolean - * @access protected - * - */ - protected function rrFromString(array $rdata) { - $this->cert_usage = array_shift($rdata); - $this->selector = array_shift($rdata); - $this->matching_type = array_shift($rdata); - $this->certificate = base64_decode(implode('', $rdata), true); - - return true; - } - - /** - * parses the rdata of the Net_DNS2_Packet object - * - * @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet to parse the RR from - * - * @return boolean - * @access protected - * - */ - protected function rrSet(Net_DNS2_Packet &$packet) { - if ($this->rdlength > 0) { - // - // unpack the format, keytag and algorithm - // - $x = unpack('Cusage/Cselector/Ctype', $this->rdata); - - $this->cert_usage = $x['usage']; - $this->selector = $x['selector']; - $this->matching_type = $x['type']; - - // - // copy the certificate - // - $this->certificate = substr($this->rdata, 3, $this->rdlength - 3); - - return true; - } - - return false; - } - - /** - * returns the rdata portion of the DNS packet - * - * @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet use for - * compressed names - * - * @return mixed either returns a binary packed - * string or null on failure - * @access protected - * - */ - protected function rrGet(Net_DNS2_Packet &$packet) { - if (strlen($this->certificate) > 0) { - $data = pack( - 'CCC', $this->cert_usage, $this->selector, $this->matching_type - ) . $this->certificate; - - $packet->offset += strlen($data); - - return $data; - } - - return null; - } -} diff --git a/Net/DNS2/RR/TSIG.php b/Net/DNS2/RR/TSIG.php deleted file mode 100644 index 611daeb0..00000000 --- a/Net/DNS2/RR/TSIG.php +++ /dev/null @@ -1,417 +0,0 @@ -. All rights reserved. - * - * See LICENSE for more details. - * - * @category Networking - * @package Net_DNS2 - * @author Mike Pultz - * @copyright 2020 Mike Pultz - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @link https://netdns2.com/ - * @since File available since Release 0.6.0 - * - */ - -/** - * TSIG Resource Record - RFC 2845 - * - * 0 1 2 3 4 5 6 7 0 1 2 3 4 5 6 7 0 1 2 3 4 5 6 7 0 1 2 3 4 5 6 7 - * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - * / algorithm / - * / / - * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - * | time signed | - * | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - * | | fudge | - * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - * | mac size | / - * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ / - * / mac / - * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - * | original id | error | - * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - * | other length | / - * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ / - * / other data / - * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - * - */ -class Net_DNS2_RR_TSIG extends Net_DNS2_RR { - // TSIG Algorithm Identifiers - const HMAC_MD5 = 'hmac-md5.sig-alg.reg.int'; // RFC 2845, required - const GSS_TSIG = 'gss-tsig'; // unsupported, optional - const HMAC_SHA1 = 'hmac-sha1'; // RFC 4635, required - const HMAC_SHA224 = 'hmac-sha224'; // RFC 4635, optional - const HMAC_SHA256 = 'hmac-sha256'; // RFC 4635, required - const HMAC_SHA384 = 'hmac-sha384'; // RFC 4635, optional - const HMAC_SHA512 = 'hmac-sha512'; // RFC 4635, optional - - // the map of hash values to names - public static $hash_algorithms = [ - self::HMAC_MD5 => 'md5', - self::HMAC_SHA1 => 'sha1', - self::HMAC_SHA224 => 'sha224', - self::HMAC_SHA256 => 'sha256', - self::HMAC_SHA384 => 'sha384', - self::HMAC_SHA512 => 'sha512' - ]; - - // algorithm used; only supports HMAC-MD5 - public $algorithm; - - // The time it was signed - public $time_signed; - - // fudge- allowed offset from the time signed - public $fudge; - - // size of the digest - public $mac_size; - - // the digest data - public $mac; - - // the original id of the request - public $original_id; - - // additional error code - public $error; - - /* - * length of the "other" data, should only ever be 0 when there is - * no error, or 6 when there is the error RCODE_BADTIME - */ - public $other_length; - - /* - * the other data; should only ever be a timestamp when there is the - * error RCODE_BADTIME - */ - public $other_data; - - // the key to use for signing - passed in, not included in the rdata - public $key; - - /** - * method to return the rdata portion of the packet as a string - * - * @return string - * @access protected - * - */ - protected function rrToString() { - $out = $this->cleanString($this->algorithm) . '. ' . - $this->time_signed . ' ' . - $this->fudge . ' ' . $this->mac_size . ' ' . - base64_encode($this->mac) . ' ' . $this->original_id . ' ' . - $this->error . ' ' . $this->other_length; - - if ($this->other_length > 0) { - $out .= ' ' . $this->other_data; - } - - return $out; - } - - /** - * parses the rdata portion from a standard DNS config line - * - * @param array $rdata a string split line of values for the rdata - * - * @return boolean - * @access protected - * - */ - protected function rrFromString(array $rdata) { - // - // the only value passed in is the key- - // - // this assumes it's passed in base64 encoded. - // - $this->key = preg_replace('/\s+/', '', array_shift($rdata)); - - // - // the rest of the data is set to default - // - $this->algorithm = self::HMAC_MD5; - $this->time_signed = time(); - $this->fudge = 300; - $this->mac_size = 0; - $this->mac = ''; - $this->original_id = 0; - $this->error = 0; - $this->other_length = 0; - $this->other_data = ''; - - // - // per RFC 2845 section 2.3 - // - $this->class = 'ANY'; - $this->ttl = 0; - - return true; - } - - /** - * parses the rdata of the Net_DNS2_Packet object - * - * @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet to parse the RR from - * - * @return boolean - * @access protected - * - */ - protected function rrSet(Net_DNS2_Packet &$packet) { - if ($this->rdlength > 0) { - // - // expand the algorithm - // - $newoffset = $packet->offset; - $this->algorithm = Net_DNS2_Packet::expand($packet, $newoffset); - $offset = $newoffset - $packet->offset; - - // - // unpack time, fudge and mac_size - // - $x = unpack( - '@' . $offset . '/ntime_high/Ntime_low/nfudge/nmac_size', - $this->rdata - ); - - $this->time_signed = Net_DNS2::expandUint32($x['time_low']); - $this->fudge = $x['fudge']; - $this->mac_size = $x['mac_size']; - - $offset += 10; - - // - // copy out the mac - // - if ($this->mac_size > 0) { - $this->mac = substr($this->rdata, $offset, $this->mac_size); - $offset += $this->mac_size; - } - - // - // unpack the original id, error, and other_length values - // - $x = unpack( - '@' . $offset . '/noriginal_id/nerror/nother_length', - $this->rdata - ); - - $this->original_id = $x['original_id']; - $this->error = $x['error']; - $this->other_length = $x['other_length']; - - // - // the only time there is actually any "other data", is when there's - // a BADTIME error code. - // - // The other length should be 6, and the other data field includes the - // servers current time - per RFC 2845 section 4.5.2 - // - if ($this->error == Net_DNS2_Lookups::RCODE_BADTIME) { - if ($this->other_length != 6) { - return false; - } - - // - // other data is a 48bit timestamp - // - $x = unpack( - 'nhigh/nlow', - substr($this->rdata, $offset + 6, $this->other_length) - ); - $this->other_data = $x['low']; - } - - return true; - } - - return false; - } - - /** - * returns the rdata portion of the DNS packet - * - * @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet use for - * compressed names - * - * @return mixed either returns a binary packed - * string or null on failure - * @access protected - * - */ - protected function rrGet(Net_DNS2_Packet &$packet) { - if (strlen($this->key) > 0) { - // - // create a new packet for the signature- - // - $new_packet = new Net_DNS2_Packet_Request('example.com', 'SOA', 'IN'); - - // - // copy the packet data over - // - $new_packet->copy($packet); - - // - // remove the TSIG object from the additional list - // - array_pop($new_packet->additional); - $new_packet->header->arcount = cacti_sizeof($new_packet->additional); - - // - // copy out the data - // - $sig_data = $new_packet->get(); - - // - // add the name without compressing - // - $sig_data .= Net_DNS2_Packet::pack($this->name); - - // - // add the class and TTL - // - $sig_data .= pack( - 'nN', Net_DNS2_Lookups::$classes_by_name[$this->class], $this->ttl - ); - - // - // add the algorithm name without compression - // - $sig_data .= Net_DNS2_Packet::pack(strtolower($this->algorithm)); - - // - // add the rest of the values - // - $sig_data .= pack( - 'nNnnn', 0, $this->time_signed, $this->fudge, - $this->error, $this->other_length - ); - - if ($this->other_length > 0) { - $sig_data .= pack('nN', 0, $this->other_data); - } - - // - // sign the data - // - $this->mac = $this->_signHMAC( - $sig_data, base64_decode($this->key, true), $this->algorithm - ); - $this->mac_size = strlen($this->mac); - - // - // compress the algorithm - // - $data = Net_DNS2_Packet::pack(strtolower($this->algorithm)); - - // - // pack the time, fudge and mac size - // - $data .= pack( - 'nNnn', 0, $this->time_signed, $this->fudge, $this->mac_size - ); - $data .= $this->mac; - - // - // check the error and other_length - // - if ($this->error == Net_DNS2_Lookups::RCODE_BADTIME) { - $this->other_length = strlen($this->other_data); - - if ($this->other_length != 6) { - return null; - } - } else { - $this->other_length = 0; - $this->other_data = ''; - } - - // - // pack the id, error and other_length - // - $data .= pack( - 'nnn', $packet->header->id, $this->error, $this->other_length - ); - - if ($this->other_length > 0) { - $data .= pack('nN', 0, $this->other_data); - } - - $packet->offset += strlen($data); - - return $data; - } - - return null; - } - - /** - * signs the given data with the given key, and returns the result - * - * @param string $data the data to sign - * @param string $key key to use for signing - * @param string $algorithm the algorithm to use; defaults to MD5 - * - * @return string the signed digest - * @throws Net_DNS2_Exception - * @access private - * - */ - private function _signHMAC($data, $key = null, $algorithm = self::HMAC_MD5) { - // - // use the hash extension; this is included by default in >= 5.1.2 which - // is our dependent version anyway- so it's easy to switch to it. - // - if (extension_loaded('hash')) { - if (!isset(self::$hash_algorithms[$algorithm])) { - throw new Net_DNS2_Exception( - 'invalid or unsupported algorithm', - Net_DNS2_Lookups::E_PARSE_ERROR - ); - } - - return hash_hmac(self::$hash_algorithms[$algorithm], $data, $key, true); - } - - // - // if the hash extension isn't loaded, and they selected something other - // than MD5, throw an exception - // - if ($algorithm != self::HMAC_MD5) { - throw new Net_DNS2_Exception( - 'only HMAC-MD5 supported. please install the php-extension ' . - '"hash" in order to use the sha-family', - Net_DNS2_Lookups::E_PARSE_ERROR - ); - } - - // - // otherwise, do it ourselves - // - if (is_null($key)) { - return pack('H*', md5($data)); - } - - $key = str_pad($key, 64, chr(0x00)); - - if (strlen($key) > 64) { - $key = pack('H*', md5($key)); - } - - $k_ipad = $key ^ str_repeat(chr(0x36), 64); - $k_opad = $key ^ str_repeat(chr(0x5c), 64); - - return $this->_signHMAC( - $k_opad . pack('H*', md5($k_ipad . $data)), null, $algorithm - ); - } -} diff --git a/Net/DNS2/RR/TXT.php b/Net/DNS2/RR/TXT.php deleted file mode 100644 index eb10cf1f..00000000 --- a/Net/DNS2/RR/TXT.php +++ /dev/null @@ -1,118 +0,0 @@ -. All rights reserved. - * - * See LICENSE for more details. - * - * @category Networking - * @package Net_DNS2 - * @author Mike Pultz - * @copyright 2020 Mike Pultz - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @link https://netdns2.com/ - * @since File available since Release 0.6.0 - * - */ - -/** - * TXT Resource Record - RFC1035 section 3.3.14 - * - * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ - * / TXT-DATA / - * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ - * - */ -class Net_DNS2_RR_TXT extends Net_DNS2_RR { - // an array of the text strings - public $text = []; - - /** - * method to return the rdata portion of the packet as a string - * - * @return string - * @access protected - * - */ - protected function rrToString() { - if (cacti_sizeof($this->text) == 0) { - return '""'; - } - - $data = ''; - - foreach ($this->text as $t) { - $data .= $this->formatString($t) . ' '; - } - - return trim($data); - } - - /** - * parses the rdata portion from a standard DNS config line - * - * @param array $rdata a string split line of values for the rdata - * - * @return boolean - * @access protected - * - */ - protected function rrFromString(array $rdata) { - $data = $this->buildString($rdata); - - if (cacti_sizeof($data) > 0) { - $this->text = $data; - } - - return true; - } - - /** - * parses the rdata of the Net_DNS2_Packet object - * - * @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet to parse the RR from - * - * @return boolean - * @access protected - * - */ - protected function rrSet(Net_DNS2_Packet &$packet) { - if ($this->rdlength > 0) { - $length = $packet->offset + $this->rdlength; - $offset = $packet->offset; - - while ($length > $offset) { - $this->text[] = Net_DNS2_Packet::label($packet, $offset); - } - - return true; - } - - return false; - } - - /** - * returns the rdata portion of the DNS packet - * - * @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet use for - * compressed names - * - * @return mixed either returns a binary packed - * string or null on failure - * @access protected - * - */ - protected function rrGet(Net_DNS2_Packet &$packet) { - $data = null; - - foreach ($this->text as $t) { - $data .= chr(strlen($t)) . $t; - } - - $packet->offset += strlen($data); - - return $data; - } -} diff --git a/Net/DNS2/RR/TYPE65534.php b/Net/DNS2/RR/TYPE65534.php deleted file mode 100644 index 2b962933..00000000 --- a/Net/DNS2/RR/TYPE65534.php +++ /dev/null @@ -1,99 +0,0 @@ -. All rights reserved. - * - * See LICENSE for more details. - * - * @category Networking - * @package Net_DNS2 - * @author Mike Pultz - * @copyright 2020 Mike Pultz - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @link https://netdns2.com/ - * @since File available since Release 1.2.5 - * - */ - -/** - * TYPE65534 - Private space - * - * Since Bind 9.8 beta, it use a private recode as documented - * in the Bind ARM, chapter 4, "Private-type records. - * Basically they store signing process state. - * - */ -class Net_DNS2_RR_TYPE65534 extends Net_DNS2_RR { - // The Private data field - public $private_data; - - /** - * method to return the rdata portion of the packet as a string - * - * @return string - * @access protected - * - */ - protected function rrToString() { - return base64_encode($this->private_data); - } - - /** - * parses the rdata portion from a standard DNS config line - * - * @param array $rdata a string split line of values for the rdata - * - * @return boolean - * @access protected - * - */ - protected function rrFromString(array $rdata) { - $this->private_data = base64_decode(implode('', $rdata), true); - - return true; - } - - /** - * parses the rdata of the Net_DNS2_Packet object - * - * @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet to parse the RR from - * - * @return boolean - * @access protected - * - */ - protected function rrSet(Net_DNS2_Packet &$packet) { - if ($this->rdlength > 0) { - $this->private_data = $this->rdata; - - return true; - } - - return false; - } - - /** - * returns the rdata portion of the DNS packet - * - * @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet use for - * compressed names - * - * @return mixed either returns a binary packed - * string or null on failure - * @access protected - * - */ - protected function rrGet(Net_DNS2_Packet &$packet) { - if (strlen($this->private_data) > 0) { - $data = $this->private_data; - - $packet->offset += strlen($data); - - return $data; - } - - return null; - } -} diff --git a/Net/DNS2/RR/URI.php b/Net/DNS2/RR/URI.php deleted file mode 100644 index 0f5a6906..00000000 --- a/Net/DNS2/RR/URI.php +++ /dev/null @@ -1,122 +0,0 @@ -. All rights reserved. - * - * See LICENSE for more details. - * - * @category Networking - * @package Net_DNS2 - * @author Mike Pultz - * @copyright 2020 Mike Pultz - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @link https://netdns2.com/ - * @since File available since Release 1.2.0 - * - */ - -/** - * URI Resource Record - http://tools.ietf.org/html/draft-faltstrom-uri-06 - * - * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 - * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - * | Priority | Weight | - * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - * / / - * / Target / - * / / - * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - * - */ -class Net_DNS2_RR_URI extends Net_DNS2_RR { - // The priority of this target host. - public $priority; - - // a relative weight for entries with the same priority - public $weight; - - // The domain name of the target host - public $target; - - /** - * method to return the rdata portion of the packet as a string - * - * @return string - * @access protected - * - */ - protected function rrToString() { - // - // presentation format has double quotes (") around the target. - // - return $this->priority . ' ' . $this->weight . ' "' . $this->target . '"'; - } - - /** - * parses the rdata portion from a standard DNS config line - * - * @param array $rdata a string split line of values for the rdata - * - * @return boolean - * @access protected - * - */ - protected function rrFromString(array $rdata) { - $this->priority = $rdata[0]; - $this->weight = $rdata[1]; - $this->target = trim(strtolower(trim($rdata[2])), '"'); - - return true; - } - - /** - * parses the rdata of the Net_DNS2_Packet object - * - * @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet to parse the RR from - * - * @return boolean - * @access protected - * - */ - protected function rrSet(Net_DNS2_Packet &$packet) { - if ($this->rdlength > 0) { - // - // unpack the priority and weight - // - $x = unpack('npriority/nweight/a*target', $this->rdata); - - $this->priority = $x['priority']; - $this->weight = $x['weight']; - $this->target = $x['target']; - - return true; - } - - return false; - } - - /** - * returns the rdata portion of the DNS packet - * - * @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet use for - * compressed names - * - * @return mixed either returns a binary packed - * string or null on failure - * @access protected - * - */ - protected function rrGet(Net_DNS2_Packet &$packet) { - if (strlen($this->target) > 0) { - $data = pack('nna*', $this->priority, $this->weight, $this->target); - - $packet->offset += strlen($data); - - return $data; - } - - return null; - } -} diff --git a/Net/DNS2/RR/WKS.php b/Net/DNS2/RR/WKS.php deleted file mode 100644 index 6d5d727b..00000000 --- a/Net/DNS2/RR/WKS.php +++ /dev/null @@ -1,174 +0,0 @@ -. All rights reserved. - * - * See LICENSE for more details. - * - * @category Networking - * @package Net_DNS2 - * @author Mike Pultz - * @copyright 2020 Mike Pultz - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @link https://netdns2.com/ - * @since File available since Release 1.0.1 - * - */ - -/** - * WKS Resource Record - RFC1035 section 3.4.2 - * - * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ - * | ADDRESS | - * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ - * | PROTOCOL | | - * +--+--+--+--+--+--+--+--+ | - * | | - * / / - * / / - * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ - * - */ -class Net_DNS2_RR_WKS extends Net_DNS2_RR { - // The IP address of the service - public $address; - - // The protocol of the service - public $protocol; - - // bitmap - public $bitmap = []; - - /** - * method to return the rdata portion of the packet as a string - * - * @return string - * @access protected - * - */ - protected function rrToString() { - $data = $this->address . ' ' . $this->protocol; - - foreach ($this->bitmap as $port) { - $data .= ' ' . $port; - } - - return $data; - } - - /** - * parses the rdata portion from a standard DNS config line - * - * @param array $rdata a string split line of values for the rdata - * - * @return boolean - * @access protected - * - */ - protected function rrFromString(array $rdata) { - $this->address = strtolower(trim(array_shift($rdata), '.')); - $this->protocol = array_shift($rdata); - $this->bitmap = $rdata; - - return true; - } - - /** - * parses the rdata of the Net_DNS2_Packet object - * - * @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet to parse the RR from - * - * @return boolean - * @access protected - * - */ - protected function rrSet(Net_DNS2_Packet &$packet) { - if ($this->rdlength > 0) { - // - // get the address and protocol value - // - $x = unpack('Naddress/Cprotocol', $this->rdata); - - $this->address = long2ip($x['address']); - $this->protocol = $x['protocol']; - - // - // unpack the port list bitmap - // - $port = 0; - - foreach (unpack('@5/C*', $this->rdata) as $set) { - $s = sprintf('%08b', $set); - - for ($i = 0; $i < 8; $i++, $port++) { - if ($s[$i] == '1') { - $this->bitmap[] = $port; - } - } - } - - return true; - } - - return false; - } - - /** - * returns the rdata portion of the DNS packet - * - * @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet use for - * compressed names - * - * @return mixed either returns a binary packed - * string or null on failure - * @access protected - * - */ - protected function rrGet(Net_DNS2_Packet &$packet) { - if (strlen($this->address) > 0) { - $data = pack('NC', ip2long($this->address), $this->protocol); - - $ports = []; - - $n = 0; - - foreach ($this->bitmap as $port) { - $ports[$port] = 1; - - if ($port > $n) { - $n = $port; - } - } - - for ($i = 0; $i < ceil($n / 8) * 8; $i++) { - if (!isset($ports[$i])) { - $ports[$i] = 0; - } - } - - ksort($ports); - - $string = ''; - $n = 0; - - foreach ($ports as $s) { - $string .= $s; - $n++; - - if ($n == 8) { - $data .= chr(bindec($string)); - $string = ''; - $n = 0; - } - } - - $packet->offset += strlen($data); - - return $data; - } - - return null; - } -} diff --git a/Net/DNS2/RR/X25.php b/Net/DNS2/RR/X25.php deleted file mode 100644 index aa2f647e..00000000 --- a/Net/DNS2/RR/X25.php +++ /dev/null @@ -1,105 +0,0 @@ -. All rights reserved. - * - * See LICENSE for more details. - * - * @category Networking - * @package Net_DNS2 - * @author Mike Pultz - * @copyright 2020 Mike Pultz - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @link https://netdns2.com/ - * @since File available since Release 0.6.0 - * - */ - -/** - * X25 Resource Record - RFC1183 section 3.1 - * - * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ - * / PSDN-address / - * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ - * - */ -class Net_DNS2_RR_X25 extends Net_DNS2_RR { - // The PSDN address - public $psdnaddress; - - /** - * method to return the rdata portion of the packet as a string - * - * @return string - * @access protected - * - */ - protected function rrToString() { - return $this->formatString($this->psdnaddress); - } - - /** - * parses the rdata portion from a standard DNS config line - * - * @param array $rdata a string split line of values for the rdata - * - * @return boolean - * @access protected - * - */ - protected function rrFromString(array $rdata) { - $data = $this->buildString($rdata); - - if (cacti_sizeof($data) == 1) { - $this->psdnaddress = $data[0]; - - return true; - } - - return false; - } - - /** - * parses the rdata of the Net_DNS2_Packet object - * - * @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet to parse the RR from - * - * @return boolean - * @access protected - * - */ - protected function rrSet(Net_DNS2_Packet &$packet) { - if ($this->rdlength > 0) { - $this->psdnaddress = Net_DNS2_Packet::label($packet, $packet->offset); - - return true; - } - - return false; - } - - /** - * returns the rdata portion of the DNS packet - * - * @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet use for - * compressed names - * - * @return mixed either returns a binary packed - * string or null on failure - * @access protected - * - */ - protected function rrGet(Net_DNS2_Packet &$packet) { - if (strlen($this->psdnaddress) > 0) { - $data = chr(strlen($this->psdnaddress)) . $this->psdnaddress; - - $packet->offset += strlen($data); - - return $data; - } - - return null; - } -} diff --git a/Net/DNS2/Resolver.php b/Net/DNS2/Resolver.php deleted file mode 100644 index 858ad014..00000000 --- a/Net/DNS2/Resolver.php +++ /dev/null @@ -1,271 +0,0 @@ -. All rights reserved. - * - * See LICENSE for more details. - * - * @category Networking - * @package Net_DNS2 - * @author Mike Pultz - * @copyright 2020 Mike Pultz - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @link https://netdns2.com/ - * @since File available since Release 0.6.0 - * - */ - -/** - * This is the main resolver class, providing DNS query functions. - * - */ -class Net_DNS2_Resolver extends Net_DNS2 { - /** - * Constructor - creates a new Net_DNS2_Resolver object - * - * @param mixed $options either an array with options or null - * - * @access public - * - */ - public function __construct(array $options = null) { - parent::__construct($options); - } - - /** - * does a basic DNS lookup query - * - * @param string $name the DNS name to loookup - * @param string $type the name of the RR type to lookup - * @param string $class the name of the RR class to lookup - * - * @return Net_DNS2_Packet_Response object - * @throws Net_DNS2_Exception - * @access public - * - */ - public function query($name, $type = 'A', $class = 'IN') { - // - // make sure we have some name servers set - // - $this->checkServers(Net_DNS2::RESOLV_CONF); - - // - // we don't support incremental zone transfers; so if it's requested, a full - // zone transfer can be returned - // - if ($type == 'IXFR') { - $type = 'AXFR'; - } - - // - // if the name *looks* too short, then append the domain from the config - // - if ((strpos($name, '.') === false) && ($type != 'PTR')) { - $name .= '.' . strtolower($this->domain); - } - - // - // create a new packet based on the input - // - $packet = new Net_DNS2_Packet_Request($name, $type, $class); - - // - // check for an authentication method; either TSIG or SIG - // - if (($this->auth_signature instanceof Net_DNS2_RR_TSIG) - || ($this->auth_signature instanceof Net_DNS2_RR_SIG) - ) { - $packet->additional[] = $this->auth_signature; - $packet->header->arcount = cacti_sizeof($packet->additional); - } - - // - // check for the DNSSEC flag, and if it's true, then add an OPT - // RR to the additional section, and set the DO flag to 1. - // - if ($this->dnssec == true) { - // - // create a new OPT RR - // - $opt = new Net_DNS2_RR_OPT(); - - // - // set the DO flag, and the other values - // - $opt->do = 1; - $opt->class = $this->dnssec_payload_size; - - // - // add the RR to the additional section. - // - $packet->additional[] = $opt; - $packet->header->arcount = cacti_sizeof($packet->additional); - } - - // - // set the DNSSEC AD or CD bits - // - if ($this->dnssec_ad_flag == true) { - $packet->header->ad = 1; - } - - if ($this->dnssec_cd_flag == true) { - $packet->header->cd = 1; - } - - // - // if caching is turned on, then check then hash the question, and - // do a cache lookup. - // - // don't use the cache for zone transfers - // - $packet_hash = ''; - - if (($this->use_cache == true) && ($this->cacheable($type) == true)) { - // - // open the cache - // - $this->cache->open( - $this->cache_file, $this->cache_size, $this->cache_serializer - ); - - // - // build the key and check for it in the cache. - // - $packet_hash = md5( - $packet->question[0]->qname . '|' . $packet->question[0]->qtype - ); - - if ($this->cache->has($packet_hash)) { - return $this->cache->get($packet_hash); - } - } - - // - // set the RD (recursion desired) bit to 1 / 0 depending on the config - // setting. - // - if ($this->recurse == false) { - $packet->header->rd = 0; - } else { - $packet->header->rd = 1; - } - - // - // send the packet and get back the response - // - // *always* use TCP for zone transfers- does this cause any problems? - // - $response = $this->sendPacket( - $packet, ($type == 'AXFR') ? true : $this->use_tcp - ); - - // - // if strict mode is enabled, then make sure that the name that was - // looked up is *actually* in the response object. - // - // only do this is strict_query_mode is turned on, AND we've received - // some answers; no point doing any else if there were no answers. - // - if (($this->strict_query_mode == true) - && ($response->header->ancount > 0) - ) { - $found = false; - - // - // look for the requested name/type/class - // - foreach ($response->answer as $index => $object) { - if ((strcasecmp(trim($object->name, '.'), trim($packet->question[0]->qname, '.')) == 0) - && ($object->type == $packet->question[0]->qtype) - && ($object->class == $packet->question[0]->qclass) - ) { - $found = true; - - break; - } - } - - // - // if it's not found, then unset the answer section; it's not correct to - // throw an exception here; if the hostname didn't exist, then - // sendPacket() would have already thrown an NXDOMAIN error- so the host - // *exists*, but just not the request type/class. - // - // the correct response in this case, is an empty answer section; the - // authority section may still have usual information, like a SOA record. - // - if ($found == false) { - $response->answer = []; - $response->header->ancount = 0; - } - } - - // - // cache the response object - // - if (($this->use_cache == true) && ($this->cacheable($type) == true)) { - $this->cache->put($packet_hash, $response); - } - - return $response; - } - - /** - * does an inverse query for the given RR; most DNS servers do not implement - * inverse queries, but they should be able to return "not implemented" - * - * @param Net_DNS2_RR $rr the RR object to lookup - * - * @return Net_DNS2_RR object - * @throws Net_DNS2_Exception - * @access public - * - */ - public function iquery(Net_DNS2_RR $rr) { - // - // make sure we have some name servers set - // - $this->checkServers(Net_DNS2::RESOLV_CONF); - - // - // create an empty packet - // - $packet = new Net_DNS2_Packet_Request($rr->name, 'A', 'IN'); - - // - // unset the question - // - $packet->question = []; - $packet->header->qdcount = 0; - - // - // set the opcode to IQUERY - // - $packet->header->opcode = Net_DNS2_Lookups::OPCODE_IQUERY; - - // - // add the given RR as the answer - // - $packet->answer[] = $rr; - $packet->header->ancount = 1; - - // - // check for an authentication method; either TSIG or SIG - // - if (($this->auth_signature instanceof Net_DNS2_RR_TSIG) - || ($this->auth_signature instanceof Net_DNS2_RR_SIG) - ) { - $packet->additional[] = $this->auth_signature; - $packet->header->arcount = cacti_sizeof($packet->additional); - } - - // - // send the packet and get back the response - // - return $this->sendPacket($packet, $this->use_tcp); - } -} diff --git a/Net/DNS2/Socket.php b/Net/DNS2/Socket.php deleted file mode 100644 index d6161f85..00000000 --- a/Net/DNS2/Socket.php +++ /dev/null @@ -1,416 +0,0 @@ -. All rights reserved. - * - * See LICENSE for more details. - * - * @category Networking - * @package Net_DNS2 - * @author Mike Pultz - * @copyright 2020 Mike Pultz - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @link https://netdns2.com/ - * @since File available since Release 0.6.0 - * - */ - -// check to see if the socket defines exist; if they don't, then define them -if (defined('SOCK_STREAM') == false) { - define('SOCK_STREAM', 1); -} - -if (defined('SOCK_DGRAM') == false) { - define('SOCK_DGRAM', 2); -} - -/** - * Socket handling class using the PHP Streams - * - */ -class Net_DNS2_Socket { - private $sock; - private $type; - private $host; - private $port; - private $timeout; - private $context; - - // the local IP and port we'll send the request from - private $local_host; - private $local_port; - - // the last error message on the object - public $last_error; - - // date the socket connection was created, and the date it was last used - public $date_created; - public $date_last_used; - - // type of sockets - const SOCK_STREAM = SOCK_STREAM; - const SOCK_DGRAM = SOCK_DGRAM; - - /** - * constructor - set the port details - * - * @param integer $type the socket type - * @param string $host the IP address of the DNS server to connect to - * @param integer $port the port of the DNS server to connect to - * @param integer $timeout the timeout value to use for socket functions - * - * @access public - * - */ - public function __construct($type, $host, $port, $timeout) { - $this->type = $type; - $this->host = $host; - $this->port = $port; - $this->timeout = $timeout; - $this->date_created = microtime(true); - } - - /** - * destructor - * - * @access public - */ - public function __destruct() { - $this->close(); - } - - /** - * sets the local address/port for the socket to bind to - * - * @param string $address the local IP address to bind to - * @param mixed $port the local port to bind to, or 0 to let the socket - * function select a port - * - * @return boolean - * @access public - * - */ - public function bindAddress($address, $port = 0) { - $this->local_host = $address; - $this->local_port = $port; - - return true; - } - - /** - * opens a socket connection to the DNS server - * - * @return boolean - * @access public - * - */ - public function open() { - // - // create a list of options for the context - // - $opts = [ 'socket' => [] ]; - - // - // bind to a local IP/port if it's set - // - if (strlen($this->local_host) > 0) { - $opts['socket']['bindto'] = $this->local_host; - - if ($this->local_port > 0) { - $opts['socket']['bindto'] .= ':' . $this->local_port; - } - } - - // - // create the context - // - $this->context = @stream_context_create($opts); - - // - // create socket - // - - switch($this->type) { - case Net_DNS2_Socket::SOCK_STREAM: - if (Net_DNS2::isIPv4($this->host) == true) { - $this->sock = @stream_socket_client( - 'tcp://' . $this->host . ':' . $this->port, - $errno, $errstr, $this->timeout, - STREAM_CLIENT_CONNECT, $this->context - ); - } elseif (Net_DNS2::isIPv6($this->host) == true) { - $this->sock = @stream_socket_client( - 'tcp://[' . $this->host . ']:' . $this->port, - $errno, $errstr, $this->timeout, - STREAM_CLIENT_CONNECT, $this->context - ); - } else { - $this->last_error = 'invalid address type: ' . $this->host; - - return false; - } - - break; - case Net_DNS2_Socket::SOCK_DGRAM: - if (Net_DNS2::isIPv4($this->host) == true) { - $this->sock = @stream_socket_client( - 'udp://' . $this->host . ':' . $this->port, - $errno, $errstr, $this->timeout, - STREAM_CLIENT_CONNECT, $this->context - ); - } elseif (Net_DNS2::isIPv6($this->host) == true) { - $this->sock = @stream_socket_client( - 'udp://[' . $this->host . ']:' . $this->port, - $errno, $errstr, $this->timeout, - STREAM_CLIENT_CONNECT, $this->context - ); - } else { - $this->last_error = 'invalid address type: ' . $this->host; - - return false; - } - - break; - default: - $this->last_error = 'Invalid socket type: ' . $this->type; - - return false; - } - - if ($this->sock === false) { - $this->last_error = $errstr; - - return false; - } - - // - // set it to non-blocking and set the timeout - // - @stream_set_blocking($this->sock, 0); - @stream_set_timeout($this->sock, $this->timeout); - - return true; - } - - /** - * closes a socket connection to the DNS server - * - * @return boolean - * @access public - * - */ - public function close() { - if (is_resource($this->sock) === true) { - @fclose($this->sock); - } - - return true; - } - - /** - * writes the given string to the DNS server socket - * - * @param string $data a binary packed DNS packet - * - * @return boolean - * @access public - * - */ - public function write($data) { - $length = strlen($data); - - if ($length == 0) { - $this->last_error = 'empty data on write()'; - - return false; - } - - $read = null; - $write = [ $this->sock ]; - $except = null; - - // - // increment the date last used timestamp - // - $this->date_last_used = microtime(true); - - // - // select on write - // - $result = stream_select($read, $write, $except, $this->timeout); - - if ($result === false) { - $this->last_error = 'failed on write select()'; - - return false; - } - - if ($result == 0) { - $this->last_error = 'timeout on write select()'; - - return false; - } - - // - // if it's a TCP socket, then we need to packet and send the length of the - // data as the first 16bit of data. - // - if ($this->type == Net_DNS2_Socket::SOCK_STREAM) { - $s = chr($length >> 8) . chr($length); - - if (@fwrite($this->sock, $s) === false) { - $this->last_error = 'failed to fwrite() 16bit length'; - - return false; - } - } - - // - // write the data to the socket - // - $size = @fwrite($this->sock, $data); - - if (($size === false) || ($size != $length)) { - $this->last_error = 'failed to fwrite() packet'; - - return false; - } - - return true; - } - - /** - * reads a response from a DNS server - * - * @param integer &$size the size of the DNS packet read is passed back - * @param integer $max_size the max data size returned. - * - * @return mixed returns the data on success and false on error - * @access public - * - */ - public function read(&$size, $max_size) { - $read = [ $this->sock ]; - $write = null; - $except = null; - - // - // increment the date last used timestamp - // - $this->date_last_used = microtime(true); - - // - // make sure our socket is non-blocking - // - @stream_set_blocking($this->sock, 0); - - // - // select on read - // - $result = stream_select($read, $write, $except, $this->timeout); - - if ($result === false) { - $this->last_error = 'error on read select()'; - - return false; - } - - if ($result == 0) { - $this->last_error = 'timeout on read select()'; - - return false; - } - - $data = ''; - $length = $max_size; - - // - // if it's a TCP socket, then the first two bytes is the length of the DNS - // packet- we need to read that off first, then use that value for the - // packet read. - // - if ($this->type == Net_DNS2_Socket::SOCK_STREAM) { - if (($data = fread($this->sock, 2)) === false) { - $this->last_error = 'failed on fread() for data length'; - - return false; - } - - if (strlen($data) == 0) { - $this->last_error = 'failed on fread() for data length'; - - return false; - } - - $length = ord($data[0]) << 8 | ord($data[1]); - - if ($length < Net_DNS2_Lookups::DNS_HEADER_SIZE) { - return false; - } - } - - // - // at this point, we know that there is data on the socket to be read, - // because we've already extracted the length from the first two bytes. - // - // so the easiest thing to do, is just turn off socket blocking, and - // wait for the data. - // - @stream_set_blocking($this->sock, 1); - - // - // read the data from the socket - // - $data = ''; - - // - // the streams socket is weird for TCP sockets; it doesn't seem to always - // return all the data properly; but the looping code I added broke UDP - // packets- my fault- - // - // the sockets library works much better. - // - if ($this->type == Net_DNS2_Socket::SOCK_STREAM) { - $chunk = ''; - $chunk_size = $length; - - // - // loop so we make sure we read all the data - // - while (1) { - $chunk = fread($this->sock, $chunk_size); - - if ($chunk === false) { - $this->last_error = 'failed on fread() for data'; - - return false; - } - - $data .= $chunk; - $chunk_size -= strlen($chunk); - - if (strlen($data) >= $length) { - break; - } - } - } else { - // - // if it's UDP, it's a single fixed-size frame, and the streams library - // doesn't seem to have a problem reading it. - // - $data = fread($this->sock, $length); - - if ($length === false) { - $this->last_error = 'failed on fread() for data'; - - return false; - } - } - - $size = strlen($data); - - return $data; - } -} diff --git a/Net/DNS2/Socket/Sockets.php b/Net/DNS2/Socket/Sockets.php deleted file mode 100644 index 580ed53b..00000000 --- a/Net/DNS2/Socket/Sockets.php +++ /dev/null @@ -1,362 +0,0 @@ -. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * * Neither the name of Mike Pultz nor the names of his contributors - * may be used to endorse or promote products derived from this - * software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRIC - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * @category Networking - * @package Net_DNS2 - * @author Mike Pultz - * @copyright 2010 Mike Pultz - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @version SVN: $Id$ - * @link http://pear.php.net/package/Net_DNS2 - * @since File available since Release 0.6.0 - * - */ - -/** - * Socket handling class using the PHP sockets extension - * - * The sockets extension is faster than the stream functions in PHP, but it's - * not standard. So if the extension is loaded, then this class is used, if - * it's not, then the Net_DNS2_Socket_Streams class is used. - * - * @category Networking - * @package Net_DNS2 - * @author Mike Pultz - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @link http://pear.php.net/package/Net_DNS2 - * @see Net_DNS2_Socket - * - */ -class Net_DNS2_Socket_Sockets extends Net_DNS2_Socket { - /** - * opens a socket connection to the DNS server - * - * @return boolean - * @access public - * - */ - public function open() { - // - // create the socket - // - if (Net_DNS2::isIPv4($this->host) == true) { - $this->sock = @socket_create( - AF_INET, $this->type, - ($this->type == Net_DNS2_Socket::SOCK_STREAM) ? SOL_TCP : SOL_UDP - ); - } elseif (Net_DNS2::isIPv6($this->host) == true) { - $this->sock = @socket_create( - AF_INET6, $this->type, - ($this->type == Net_DNS2_Socket::SOCK_STREAM) ? SOL_TCP : SOL_UDP - ); - } else { - $this->last_error = 'invalid address type: ' . $this->host; - - return false; - } - - if ($this->sock === false) { - $this->last_error = socket_strerror(socket_last_error()); - - return false; - } - - @socket_set_option($this->sock, SOL_SOCKET, SO_REUSEADDR, 1); - - // - // bind to a local IP/port if it's set - // - if (strlen($this->local_host) > 0) { - $result = @socket_bind( - $this->sock, $this->local_host, - ($this->local_port > 0) ? $this->local_port : null - ); - - if ($result === false) { - $this->last_error = socket_strerror(socket_last_error()); - - return false; - } - } - - // - // mark the socket as non-blocking - // - if (@socket_set_nonblock($this->sock) === false) { - $this->last_error = socket_strerror(socket_last_error()); - - return false; - } - - // - // connect to the socket; don't check for status here, we'll check it on the - // socket_select() call so we can handle timeouts properly - // - @socket_connect($this->sock, $this->host, $this->port); - - $read = null; - $write = [$this->sock]; - $except = null; - - // - // select on write to check if the call to connect worked - // - $result = @socket_select($read, $write, $except, $this->timeout); - - if ($result === false) { - $this->last_error = socket_strerror(socket_last_error()); - - return false; - } - - if ($result == 0) { - $this->last_error = 'timeout on write select for connect()'; - - return false; - } - - return true; - } - - /** - * closes a socket connection to the DNS server - * - * @return boolean - * @access public - * - */ - public function close() { - if (is_resource($this->sock) === true) { - @socket_close($this->sock); - } - - return true; - } - - /** - * writes the given string to the DNS server socket - * - * @param string $data a binary packed DNS packet - * - * @return boolean - * @access public - * - */ - public function write($data) { - $length = strlen($data); - - if ($length == 0) { - $this->last_error = 'empty data on write()'; - - return false; - } - - $read = null; - $write = [$this->sock]; - $except = null; - - // - // select on write - // - $result = @socket_select($read, $write, $except, $this->timeout); - - if ($result === false) { - $this->last_error = socket_strerror(socket_last_error()); - - return false; - } - - if ($result == 0) { - $this->last_error = 'timeout on write select()'; - - return false; - } - - // - // if it's a TCP socket, then we need to packet and send the length of the - // data as the first 16bit of data. - // - if ($this->type == Net_DNS2_Socket::SOCK_STREAM) { - $s = chr($length >> 8) . chr($length); - - if (@socket_write($this->sock, $s) === false) { - $this->last_error = socket_strerror(socket_last_error()); - - return false; - } - } - - // - // write the data to the socket - // - $size = @socket_write($this->sock, $data); - - if (($size === false) || ($size != $length)) { - $this->last_error = socket_strerror(socket_last_error()); - - return false; - } - - return true; - } - - /** - * reads a response from a DNS server - * - * @param integer &$size the size of the DNS packet read is passed back - * @param mixed $max_size - * - * @return mixed returns the data on success and false on error - * @access public - * - */ - public function read(&$size, $max_size) { - $read = [$this->sock]; - $write = null; - $except = null; - - // - // make sure our socket is non-blocking - // - if (@socket_set_nonblock($this->sock) === false) { - $this->last_error = socket_strerror(socket_last_error()); - - return false; - } - - // - // select on read - // - $result = @socket_select($read, $write, $except, $this->timeout); - - if ($result === false) { - $this->last_error = socket_strerror(socket_last_error()); - - return false; - } - - if ($result == 0) { - $this->last_error = 'timeout on read select()'; - - return false; - } - - $data = ''; - $length = $max_size; - - // - // if it's a TCP socket, then the first two bytes is the length of the DNS - // packet- we need to read that off first, then use that value for the - // packet read. - // - if ($this->type == Net_DNS2_Socket::SOCK_STREAM) { - if (($size = @socket_recv($this->sock, $data, 2, 0)) === false) { - $this->last_error = socket_strerror(socket_last_error()); - - return false; - } - - $length = ord($data[0]) << 8 | ord($data[1]); - - if ($length < Net_DNS2_Lookups::DNS_HEADER_SIZE) { - return false; - } - } - - // - // at this point, we know that there is data on the socket to be read, - // because we've already extracted the length from the first two bytes. - // - // so the easiest thing to do, is just turn off socket blocking, and - // wait for the data. - // - if (@socket_set_block($this->sock) === false) { - $this->last_error = socket_strerror(socket_last_error()); - - return false; - } - - // - // read the data from the socket - // - // loop while reading since some OS's (specifically Win < 2003) don't support - // MSG_WAITALL properly, so they may return with less data than is available. - // - // According to M$, XP and below don't support MSG_WAITALL at all; and there - // also seems to be some issue in 2003 and 2008 where the MSG_WAITALL is - // defined as 0, but if you actually pass 8 (which is the correct defined - // value), it works as it's supposed to- so in these cases, it's just the - // define that's incorrect- this is likely a PHP issue. - // - $data = ''; - $size = 0; - - while (1) { - $chunk_size = @socket_recv($this->sock, $chunk, $length, MSG_WAITALL); - - if ($chunk_size === false) { - $size = $chunk_size; - $this->last_error = socket_strerror(socket_last_error()); - - return false; - } - - $data .= $chunk; - $size += $chunk_size; - - $length -= $chunk_size; - - if (($length <= 0) || ($this->type == Net_DNS2_Socket::SOCK_DGRAM)) { - break; - } - } - - return $data; - } -} - -/* - * Local variables: - * tab-width: 4 - * c-basic-offset: 4 - * c-hanging-comment-ender-p: nil - * End: - */ -?> diff --git a/Net/DNS2/Socket/Streams.php b/Net/DNS2/Socket/Streams.php deleted file mode 100644 index ab4b63ca..00000000 --- a/Net/DNS2/Socket/Streams.php +++ /dev/null @@ -1,377 +0,0 @@ -. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * * Neither the name of Mike Pultz nor the names of his contributors - * may be used to endorse or promote products derived from this - * software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRIC - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * @category Networking - * @package Net_DNS2 - * @author Mike Pultz - * @copyright 2010 Mike Pultz - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @version SVN: $Id$ - * @link http://pear.php.net/package/Net_DNS2 - * @since File available since Release 0.6.0 - * - */ - -/** - * Socket handling class using the PHP Streams - * - * The sockets extension is faster than the stream functions in PHP, but it's - * not standard. So if the extension is loaded, then the Net_DNS2_Socket_Sockets - * class it used, otherwise, this class it used. - * - * @category Networking - * @package Net_DNS2 - * @author Mike Pultz - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @link http://pear.php.net/package/Net_DNS2 - * @see Net_DNS2_Socket - * - */ -class Net_DNS2_Socket_Streams extends Net_DNS2_Socket { - private $_context; - - /** - * opens a socket connection to the DNS server - * - * @return boolean - * @access public - * - */ - public function open() { - // - // create a list of options for the context - // - $opts = ['socket' => []]; - - // - // bind to a local IP/port if it's set - // - if (strlen($this->local_host) > 0) { - $opts['socket']['bindto'] = $this->local_host; - - if ($this->local_port > 0) { - $opts['socket']['bindto'] .= ':' . $this->local_port; - } - } - - // - // create the context - // - $this->_context = @stream_context_create($opts); - - // - // create socket - // - - switch($this->type) { - case Net_DNS2_Socket::SOCK_STREAM: - if (Net_DNS2::isIPv4($this->host) == true) { - $this->sock = @stream_socket_client( - 'tcp://' . $this->host . ':' . $this->port, - $errno, $errstr, $this->timeout, - STREAM_CLIENT_CONNECT, $this->_context - ); - } elseif (Net_DNS2::isIPv6($this->host) == true) { - $this->sock = @stream_socket_client( - 'tcp://[' . $this->host . ']:' . $this->port, - $errno, $errstr, $this->timeout, - STREAM_CLIENT_CONNECT, $this->_context - ); - } else { - $this->last_error = 'invalid address type: ' . $this->host; - - return false; - } - - break; - case Net_DNS2_Socket::SOCK_DGRAM: - if (Net_DNS2::isIPv4($this->host) == true) { - $this->sock = @stream_socket_client( - 'udp://' . $this->host . ':' . $this->port, - $errno, $errstr, $this->timeout, - STREAM_CLIENT_CONNECT, $this->_context - ); - } elseif (Net_DNS2::isIPv6($this->host) == true) { - $this->sock = @stream_socket_client( - 'udp://[' . $this->host . ']:' . $this->port, - $errno, $errstr, $this->timeout, - STREAM_CLIENT_CONNECT, $this->_context - ); - } else { - $this->last_error = 'invalid address type: ' . $this->host; - - return false; - } - - break; - default: - $this->last_error = 'Invalid socket type: ' . $this->type; - - return false; - } - - if ($this->sock === false) { - $this->last_error = $errstr; - - return false; - } - - // - // set it to non-blocking and set the timeout - // - @stream_set_blocking($this->sock, 0); - @stream_set_timeout($this->sock, $this->timeout); - - return true; - } - - /** - * closes a socket connection to the DNS server - * - * @return boolean - * @access public - * - */ - public function close() { - if (is_resource($this->sock) === true) { - @fclose($this->sock); - } - - return true; - } - - /** - * writes the given string to the DNS server socket - * - * @param string $data a binary packed DNS packet - * - * @return boolean - * @access public - * - */ - public function write($data) { - $length = strlen($data); - - if ($length == 0) { - $this->last_error = 'empty data on write()'; - - return false; - } - - $read = null; - $write = [$this->sock]; - $except = null; - - // - // select on write - // - $result = stream_select($read, $write, $except, $this->timeout); - - if ($result === false) { - $this->last_error = 'failed on write select()'; - - return false; - } - - if ($result == 0) { - $this->last_error = 'timeout on write select()'; - - return false; - } - - // - // if it's a TCP socket, then we need to packet and send the length of the - // data as the first 16bit of data. - // - if ($this->type == Net_DNS2_Socket::SOCK_STREAM) { - $s = chr($length >> 8) . chr($length); - - if (@fwrite($this->sock, $s) === false) { - $this->last_error = 'failed to fwrite() 16bit length'; - - return false; - } - } - - // - // write the data to the socket - // - $size = @fwrite($this->sock, $data); - - if (($size === false) || ($size != $length)) { - $this->last_error = 'failed to fwrite() packet'; - - return false; - } - - return true; - } - - /** - * reads a response from a DNS server - * - * @param integer &$size the size of the DNS packet read is passed back - * @param mixed $max_size - * - * @return mixed returns the data on success and false on error - * @access public - * - */ - public function read(&$size, $max_size) { - $read = [$this->sock]; - $write = null; - $except = null; - - // - // make sure our socket is non-blocking - // - @stream_set_blocking($this->sock, 0); - - // - // select on read - // - $result = stream_select($read, $write, $except, $this->timeout); - - if ($result === false) { - $this->last_error = 'error on read select()'; - - return false; - } - - if ($result == 0) { - $this->last_error = 'timeout on read select()'; - - return false; - } - - $data = ''; - $length = $max_size; - - // - // if it's a TCP socket, then the first two bytes is the length of the DNS - // packet- we need to read that off first, then use that value for the - // packet read. - // - if ($this->type == Net_DNS2_Socket::SOCK_STREAM) { - if (($data = fread($this->sock, 2)) === false) { - $this->last_error = 'failed on fread() for data length'; - - return false; - } - - $length = ord($data[0]) << 8 | ord($data[1]); - - if ($length < Net_DNS2_Lookups::DNS_HEADER_SIZE) { - return false; - } - } - - // - // at this point, we know that there is data on the socket to be read, - // because we've already extracted the length from the first two bytes. - // - // so the easiest thing to do, is just turn off socket blocking, and - // wait for the data. - // - @stream_set_blocking($this->sock, 1); - - // - // read the data from the socket - // - $data = ''; - - // - // the streams socket is weird for TCP sockets; it doesn't seem to always - // return all the data properly; but the looping code I added broke UDP - // packets- my fault- - // - // the sockets library works much better. - // - if ($this->type == Net_DNS2_Socket::SOCK_STREAM) { - $chunk = ''; - $chunk_size = $length; - - // - // loop so we make sure we read all the data - // - while (1) { - $chunk = fread($this->sock, $chunk_size); - - if ($chunk === false) { - $this->last_error = 'failed on fread() for data'; - - return false; - } - - $data .= $chunk; - $chunk_size -= strlen($chunk); - - if (strlen($data) >= $length) { - break; - } - } - } else { - // - // if it's UDP, it's a single fixed-size frame, and the streams library - // doesn't seem to have a problem reading it. - // - $data = fread($this->sock, $length); - - if ($length === false) { - $this->last_error = 'failed on fread() for data'; - - return false; - } - } - - $size = strlen($data); - - return $data; - } -} - -/* - * Local variables: - * tab-width: 4 - * c-basic-offset: 4 - * c-hanging-comment-ender-p: nil - * End: - */ -?> diff --git a/Net/DNS2/Updater.php b/Net/DNS2/Updater.php deleted file mode 100644 index 1373063a..00000000 --- a/Net/DNS2/Updater.php +++ /dev/null @@ -1,588 +0,0 @@ -. All rights reserved. - * - * See LICENSE for more details. - * - * @category Networking - * @package Net_DNS2 - * @author Mike Pultz - * @copyright 2020 Mike Pultz - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @link https://netdns2.com/ - * @since File available since Release 0.6.0 - * - */ - -/** - * The main dynamic DNS updater class. - * - * This class provices functions to handle all defined dynamic DNS update - * requests as defined by RFC 2136. - * - * This is separate from the Net_DNS2_Resolver class, as while the underlying - * protocol is the same, the functionality is completely different. - * - * Generally, query (recursive) lookups are done against caching server, while - * update requests are done against authoritative servers. - * - */ -class Net_DNS2_Updater extends Net_DNS2 { - // a Net_DNS2_Packet_Request object used for the update request - private $_packet; - - /** - * Constructor - builds a new Net_DNS2_Updater objected used for doing - * dynamic DNS updates - * - * @param string $zone the domain name to use for DNS updates - * @param mixed $options an array of config options or null - * - * @throws Net_DNS2_Exception - * @access public - * - */ - public function __construct($zone, array $options = null) { - parent::__construct($options); - - // - // create the packet - // - $this->_packet = new Net_DNS2_Packet_Request( - strtolower(trim($zone, " \n\r\t.")), 'SOA', 'IN' - ); - - // - // make sure the opcode on the packet is set to UPDATE - // - $this->_packet->header->opcode = Net_DNS2_Lookups::OPCODE_UPDATE; - } - - /** - * checks that the given name matches the name for the zone we're updating - * - * @param string $name The name to be checked. - * - * @return boolean - * @throws Net_DNS2_Exception - * @access private - * - */ - private function _checkName($name) { - if (!preg_match('/' . $this->_packet->question[0]->qname . '$/', $name)) { - throw new Net_DNS2_Exception( - 'name provided (' . $name . ') does not match zone name (' . - $this->_packet->question[0]->qname . ')', - Net_DNS2_Lookups::E_PACKET_INVALID - ); - } - - return true; - } - - /** - * add a signature to the request for authentication - * - * @param string $keyname the key name to use for the TSIG RR - * @param string $signature the key to sign the request. - * - * @return boolean - * @access public - * @see Net_DNS2::signTSIG() - * @deprecated function deprecated in 1.1.0 - * - */ - public function signature($keyname, $signature) { - return $this->signTSIG($keyname, $signature); - } - - /** - * 2.5.1 - Add To An RRset - * - * RRs are added to the Update Section whose NAME, TYPE, TTL, RDLENGTH - * and RDATA are those being added, and CLASS is the same as the zone - * class. Any duplicate RRs will be silently ignored by the primary - * master. - * - * @param Net_DNS2_RR $rr the Net_DNS2_RR object to be added to the zone - * - * @return boolean - * @throws Net_DNS2_Exception - * @access public - * - */ - public function add(Net_DNS2_RR $rr) { - $this->_checkName($rr->name); - - // - // add the RR to the "update" section - // - if (!in_array($rr, $this->_packet->authority, true)) { - $this->_packet->authority[] = $rr; - } - - return true; - } - - /** - * 2.5.4 - Delete An RR From An RRset - * - * RRs to be deleted are added to the Update Section. The NAME, TYPE, - * RDLENGTH and RDATA must match the RR being deleted. TTL must be - * specified as zero (0) and will otherwise be ignored by the primary - * master. CLASS must be specified as NONE to distinguish this from an - * RR addition. If no such RRs exist, then this Update RR will be - * silently ignored by the primary master. - * - * @param Net_DNS2_RR $rr the Net_DNS2_RR object to be deleted from the zone - * - * @return boolean - * @throws Net_DNS2_Exception - * @access public - * - */ - public function delete(Net_DNS2_RR $rr) { - $this->_checkName($rr->name); - - $rr->ttl = 0; - $rr->class = 'NONE'; - - // - // add the RR to the "update" section - // - if (!in_array($rr, $this->_packet->authority, true)) { - $this->_packet->authority[] = $rr; - } - - return true; - } - - /** - * 2.5.2 - Delete An RRset - * - * One RR is added to the Update Section whose NAME and TYPE are those - * of the RRset to be deleted. TTL must be specified as zero (0) and is - * otherwise not used by the primary master. CLASS must be specified as - * ANY. RDLENGTH must be zero (0) and RDATA must therefore be empty. - * If no such RRset exists, then this Update RR will be silently ignored - * by the primary master - * - * @param string $name the RR name to be removed from the zone - * @param string $type the RR type to be removed from the zone - * - * @return boolean - * @throws Net_DNS2_Exception - * @access public - * - */ - public function deleteAny($name, $type) { - $this->_checkName($name); - - $class = Net_DNS2_Lookups::$rr_types_id_to_class[ - Net_DNS2_Lookups::$rr_types_by_name[$type] - ]; - - if (!isset($class)) { - throw new Net_DNS2_Exception( - 'unknown or un-supported resource record type: ' . $type, - Net_DNS2_Lookups::E_RR_INVALID - ); - } - - $rr = new $class; - - $rr->name = $name; - $rr->ttl = 0; - $rr->class = 'ANY'; - $rr->rdlength = -1; - $rr->rdata = ''; - - // - // add the RR to the "update" section - // - if (!in_array($rr, $this->_packet->authority, true)) { - $this->_packet->authority[] = $rr; - } - - return true; - } - - /** - * 2.5.3 - Delete All RRsets From A Name - * - * One RR is added to the Update Section whose NAME is that of the name - * to be cleansed of RRsets. TYPE must be specified as ANY. TTL must - * be specified as zero (0) and is otherwise not used by the primary - * master. CLASS must be specified as ANY. RDLENGTH must be zero (0) - * and RDATA must therefore be empty. If no such RRsets exist, then - * this Update RR will be silently ignored by the primary master. - * - * @param string $name the RR name to be removed from the zone - * - * @return boolean - * @throws Net_DNS2_Exception - * @access public - * - */ - public function deleteAll($name) { - $this->_checkName($name); - - // - // the Net_DNS2_RR_ANY class is just an empty stub class used for these - // cases only - // - $rr = new Net_DNS2_RR_ANY; - - $rr->name = $name; - $rr->ttl = 0; - $rr->type = 'ANY'; - $rr->class = 'ANY'; - $rr->rdlength = -1; - $rr->rdata = ''; - - // - // add the RR to the "update" section - // - if (!in_array($rr, $this->_packet->authority, true)) { - $this->_packet->authority[] = $rr; - } - - return true; - } - - /** - * 2.4.1 - RRset Exists (Value Independent) - * - * At least one RR with a specified NAME and TYPE (in the zone and class - * specified in the Zone Section) must exist. - * - * For this prerequisite, a requester adds to the section a single RR - * whose NAME and TYPE are equal to that of the zone RRset whose - * existence is required. RDLENGTH is zero and RDATA is therefore - * empty. CLASS must be specified as ANY to differentiate this - * condition from that of an actual RR whose RDLENGTH is naturally zero - * (0) (e.g., NULL). TTL is specified as zero (0). - * - * @param string $name the RR name for the prerequisite - * @param string $type the RR type for the prerequisite - * - * @return boolean - * @throws Net_DNS2_Exception - * @access public - * - */ - public function checkExists($name, $type) { - $this->_checkName($name); - - $class = Net_DNS2_Lookups::$rr_types_id_to_class[ - Net_DNS2_Lookups::$rr_types_by_name[$type] - ]; - - if (!isset($class)) { - throw new Net_DNS2_Exception( - 'unknown or un-supported resource record type: ' . $type, - Net_DNS2_Lookups::E_RR_INVALID - ); - } - - $rr = new $class; - - $rr->name = $name; - $rr->ttl = 0; - $rr->class = 'ANY'; - $rr->rdlength = -1; - $rr->rdata = ''; - - // - // add the RR to the "prerequisite" section - // - if (!in_array($rr, $this->_packet->answer, true)) { - $this->_packet->answer[] = $rr; - } - - return true; - } - - /** - * 2.4.2 - RRset Exists (Value Dependent) - * - * A set of RRs with a specified NAME and TYPE exists and has the same - * members with the same RDATAs as the RRset specified here in this - * section. While RRset ordering is undefined and therefore not - * significant to this comparison, the sets be identical in their - * extent. - * - * For this prerequisite, a requester adds to the section an entire - * RRset whose preexistence is required. NAME and TYPE are that of the - * RRset being denoted. CLASS is that of the zone. TTL must be - * specified as zero (0) and is ignored when comparing RRsets for - * identity. - * - * @param Net_DNS2_RR $rr the RR object to be used as a prerequisite - * - * @return boolean - * @throws Net_DNS2_Exception - * @access public - * - */ - public function checkValueExists(Net_DNS2_RR $rr) { - $this->_checkName($rr->name); - - $rr->ttl = 0; - - // - // add the RR to the "prerequisite" section - // - if (!in_array($rr, $this->_packet->answer, true)) { - $this->_packet->answer[] = $rr; - } - - return true; - } - - /** - * 2.4.3 - RRset Does Not Exist - * - * No RRs with a specified NAME and TYPE (in the zone and class denoted - * by the Zone Section) can exist. - * - * For this prerequisite, a requester adds to the section a single RR - * whose NAME and TYPE are equal to that of the RRset whose nonexistence - * is required. The RDLENGTH of this record is zero (0), and RDATA - * field is therefore empty. CLASS must be specified as NONE in order - * to distinguish this condition from a valid RR whose RDLENGTH is - * naturally zero (0) (for example, the NULL RR). TTL must be specified - * as zero (0). - * - * @param string $name the RR name for the prerequisite - * @param string $type the RR type for the prerequisite - * - * @return boolean - * @throws Net_DNS2_Exception - * @access public - * - */ - public function checkNotExists($name, $type) { - $this->_checkName($name); - - $class = Net_DNS2_Lookups::$rr_types_id_to_class[ - Net_DNS2_Lookups::$rr_types_by_name[$type] - ]; - - if (!isset($class)) { - throw new Net_DNS2_Exception( - 'unknown or un-supported resource record type: ' . $type, - Net_DNS2_Lookups::E_RR_INVALID - ); - } - - $rr = new $class; - - $rr->name = $name; - $rr->ttl = 0; - $rr->class = 'NONE'; - $rr->rdlength = -1; - $rr->rdata = ''; - - // - // add the RR to the "prerequisite" section - // - if (!in_array($rr, $this->_packet->answer, true)) { - $this->_packet->answer[] = $rr; - } - - return true; - } - - /** - * 2.4.4 - Name Is In Use - * - * Name is in use. At least one RR with a specified NAME (in the zone - * and class specified by the Zone Section) must exist. Note that this - * prerequisite is NOT satisfied by empty nonterminals. - * - * For this prerequisite, a requester adds to the section a single RR - * whose NAME is equal to that of the name whose ownership of an RR is - * required. RDLENGTH is zero and RDATA is therefore empty. CLASS must - * be specified as ANY to differentiate this condition from that of an - * actual RR whose RDLENGTH is naturally zero (0) (e.g., NULL). TYPE - * must be specified as ANY to differentiate this case from that of an - * RRset existence test. TTL is specified as zero (0). - * - * @param string $name the RR name for the prerequisite - * - * @return boolean - * @throws Net_DNS2_Exception - * @access public - * - */ - public function checkNameInUse($name) { - $this->_checkName($name); - - // - // the Net_DNS2_RR_ANY class is just an empty stub class used for these - // cases only - // - $rr = new Net_DNS2_RR_ANY; - - $rr->name = $name; - $rr->ttl = 0; - $rr->type = 'ANY'; - $rr->class = 'ANY'; - $rr->rdlength = -1; - $rr->rdata = ''; - - // - // add the RR to the "prerequisite" section - // - if (!in_array($rr, $this->_packet->answer, true)) { - $this->_packet->answer[] = $rr; - } - - return true; - } - - /** - * 2.4.5 - Name Is Not In Use - * - * Name is not in use. No RR of any type is owned by a specified NAME. - * Note that this prerequisite IS satisfied by empty nonterminals. - * - * For this prerequisite, a requester adds to the section a single RR - * whose NAME is equal to that of the name whose nonownership of any RRs - * is required. RDLENGTH is zero and RDATA is therefore empty. CLASS - * must be specified as NONE. TYPE must be specified as ANY. TTL must - * be specified as zero (0). - * - * @param string $name the RR name for the prerequisite - * - * @return boolean - * @throws Net_DNS2_Exception - * @access public - * - */ - public function checkNameNotInUse($name) { - $this->_checkName($name); - - // - // the Net_DNS2_RR_ANY class is just an empty stub class used for these - // cases only - // - $rr = new Net_DNS2_RR_ANY; - - $rr->name = $name; - $rr->ttl = 0; - $rr->type = 'ANY'; - $rr->class = 'NONE'; - $rr->rdlength = -1; - $rr->rdata = ''; - - // - // add the RR to the "prerequisite" section - // - if (!in_array($rr, $this->_packet->answer, true)) { - $this->_packet->answer[] = $rr; - } - - return true; - } - - /** - * returns the current internal packet object. - * - * @return Net_DNS2_Packet_Request - * @access public - * # - */ - public function packet() { - // - // take a copy - // - $p = $this->_packet; - - // - // check for an authentication method; either TSIG or SIG - // - if (($this->auth_signature instanceof Net_DNS2_RR_TSIG) - || ($this->auth_signature instanceof Net_DNS2_RR_SIG) - ) { - $p->additional[] = $this->auth_signature; - } - - // - // update the counts - // - $p->header->qdcount = cacti_sizeof($p->question); - $p->header->ancount = cacti_sizeof($p->answer); - $p->header->nscount = cacti_sizeof($p->authority); - $p->header->arcount = cacti_sizeof($p->additional); - - return $p; - } - - /** - * executes the update request with the object information - * - * @param Net_DNS2_Packet_Response &$response ref to the response object - * - * @return boolean - * @throws Net_DNS2_Exception - * @access public - * - */ - public function update(&$response = null) { - // - // make sure we have some name servers set - // - $this->checkServers(Net_DNS2::RESOLV_CONF); - - // - // check for an authentication method; either TSIG or SIG - // - if (($this->auth_signature instanceof Net_DNS2_RR_TSIG) - || ($this->auth_signature instanceof Net_DNS2_RR_SIG) - ) { - $this->_packet->additional[] = $this->auth_signature; - } - - // - // update the counts - // - $this->_packet->header->qdcount = cacti_sizeof($this->_packet->question); - $this->_packet->header->ancount = cacti_sizeof($this->_packet->answer); - $this->_packet->header->nscount = cacti_sizeof($this->_packet->authority); - $this->_packet->header->arcount = cacti_sizeof($this->_packet->additional); - - // - // make sure we have some data to send - // - if (($this->_packet->header->qdcount == 0) - || ($this->_packet->header->nscount == 0) - ) { - throw new Net_DNS2_Exception( - 'empty headers- nothing to send!', - Net_DNS2_Lookups::E_PACKET_INVALID - ); - } - - // - // send the packet and get back the response - // - $response = $this->sendPacket($this->_packet, $this->use_tcp); - - // - // clear the internal packet so if we make another request, we don't have - // old data being sent. - // - $this->_packet->reset(); - - // - // for updates, we just need to know it worked- we don't actually need to - // return the response object - // - return true; - } -} diff --git a/Net/LICENSE b/Net/LICENSE deleted file mode 100644 index 848ae1a6..00000000 --- a/Net/LICENSE +++ /dev/null @@ -1,33 +0,0 @@ -Net_DNS2 - DNS Library for handling lookups and updates. - -Copyright (c) 2010-2020, Mike Pultz . -All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions -are met: - - * Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in - the documentation and/or other materials provided with the - distribution. - - * Neither the name of Mike Pultz nor the names of his contributors - may be used to endorse or promote products derived from this - software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS -FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE -COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, -BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN -ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -POSSIBILITY OF SUCH DAMAGE. diff --git a/Net/README.md b/Net/README.md deleted file mode 100644 index 5e4bd209..00000000 --- a/Net/README.md +++ /dev/null @@ -1,40 +0,0 @@ -# Net\_DNS2 - Native PHP DNS Resolver and Updater # - -### The main features for this package include: ### - - * Increased performance; most requests are 2-10x faster than Net\_DNS - * Near drop-in replacement for Net\_DNS - * Uses modern PHP classes and exceptions - * Support for IPv4 and IPv6, TCP and UDP sockets. - * Includes a separate, more intuitive "Updater" class for handling dynamic update - * Support zone signing using TSIG and SIG(0) for updates and zone transfers - * Includes a local cache using shared memory or flat file to improve performance - * includes many more RR's, including DNSSEC RR's. - - -## Installing Net\_DNS2 ## - -You can download it directly from PEAR: http://pear.php.net/package/Net_DNS2 - -``` -pear install Net_DNS2 -``` - -Or you can require it directly via Composer: https://packagist.org/packages/pear/net_dns2 - -``` -composer require pear/net_dns2 -``` - -Or download the source above. - -## Requirements ## - -* PHP 5.4+ -* The PHP INI setting `mbstring.func_overload` equals 0, 1, 4, or 5. - - -## Using Net\_DNS2 ## - -See the Net\_DNS2 Website for more details - https://netdns2.com/ - diff --git a/README.md b/README.md index 4f674d8e..f4b6877b 100644 --- a/README.md +++ b/README.md @@ -29,13 +29,23 @@ utilization is, where there are errors, etc within their network. ## Prerequisites -The MacTrack on GitHub requires Cacti 1.2.14 as a minimum. +Mactrack requires Cacti 1.2.31 or later and PHP 8.2 for its supported runtime and toolchain. ## Installation -Just like any Cacti plugin, untar the package to the Cacti plugins directory, -rename the directory to 'mactrack', and then from Cacti's Plugin Management -interface, Install and Enable the plugin. +Just like any Cacti plugin, untar the package to the Cacti plugins directory +and rename the directory to `mactrack`. Install production dependencies before +enabling the plugin: + +```sh +cd plugins/mactrack +composer install --no-dev --optimize-autoloader +``` + +The plugin refuses to enable when its Composer dependencies are absent. This +prevents asynchronous DNS resolution from failing later in the poller. + +Then use Cacti's Plugin Management interface to install and enable Mactrack. ## Documentation diff --git a/composer.json b/composer.json new file mode 100644 index 00000000..0bd410bb --- /dev/null +++ b/composer.json @@ -0,0 +1,31 @@ +{ + "name": "cacti/plugin-mactrack", + "description": "Cacti Mactrack plugin test tooling", + "type": "cacti-plugin", + "license": "GPL-2.0-or-later", + "require-dev": { + "pestphp/pest": "^1.23", + "phpunit/phpunit": "^9.6", + "vimeo/psalm": "^5" + }, + "scripts": { + "test": "pest", + "test:unit": "pest tests/Pest/Unit", + "test:integration": "pest tests/Pest/Integration", + "test:e2e:static": "pest tests/Pest/E2E", + "test:coverage": "pest --coverage", + "analyse": "psalm --no-progress" + }, + "config": { + "allow-plugins": { + "pestphp/pest-plugin": true + }, + "platform": { + "php": "8.2.0" + }, + "sort-packages": true + }, + "require": { + "mikepultz/netdns2": "^1.5" + } +} diff --git a/composer.lock b/composer.lock new file mode 100644 index 00000000..fa2234bc --- /dev/null +++ b/composer.lock @@ -0,0 +1,4355 @@ +{ + "_readme": [ + "This file locks the dependencies of your project to a known state", + "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", + "This file is @generated automatically" + ], + "content-hash": "ae178439af0f8248359e8fab4b5792fd", + "packages": [ + { + "name": "mikepultz/netdns2", + "version": "v1.5.5", + "source": { + "type": "git", + "url": "https://github.com/mikepultz/netdns2.git", + "reference": "ea39ef5a97d5c2b9893a8c35af7b5fd5b0e40bc9" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/mikepultz/netdns2/zipball/ea39ef5a97d5c2b9893a8c35af7b5fd5b0e40bc9", + "reference": "ea39ef5a97d5c2b9893a8c35af7b5fd5b0e40bc9", + "shasum": "" + }, + "require": { + "php": ">=7.1" + }, + "require-dev": { + "phpunit/phpunit": "^9" + }, + "type": "library", + "autoload": { + "psr-0": { + "Net_DNS2": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Mike Pultz", + "email": "mike@mikepultz.com", + "homepage": "https://mikepultz.com/", + "role": "lead" + } + ], + "description": "Native PHP DNS Resolver and Updater Library", + "homepage": "https://netdns2.com/", + "keywords": [ + "PEAR", + "dns", + "network" + ], + "support": { + "issues": "https://github.com/mikepultz/netdns2/issues", + "source": "https://github.com/mikepultz/netdns2" + }, + "funding": [ + { + "url": "https://github.com/mikepultz", + "type": "github" + } + ], + "time": "2025-05-17T20:56:28+00:00" + } + ], + "packages-dev": [ + { + "name": "amphp/amp", + "version": "v2.6.5", + "source": { + "type": "git", + "url": "https://github.com/amphp/amp.git", + "reference": "d7dda98dae26e56f3f6fcfbf1c1f819c9a993207" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/amphp/amp/zipball/d7dda98dae26e56f3f6fcfbf1c1f819c9a993207", + "reference": "d7dda98dae26e56f3f6fcfbf1c1f819c9a993207", + "shasum": "" + }, + "require": { + "php": ">=7.1" + }, + "require-dev": { + "amphp/php-cs-fixer-config": "dev-master", + "amphp/phpunit-util": "^1", + "ext-json": "*", + "jetbrains/phpstorm-stubs": "^2019.3", + "phpunit/phpunit": "^7 | ^8 | ^9", + "react/promise": "^2", + "vimeo/psalm": "^3.12" + }, + "type": "library", + "autoload": { + "files": [ + "lib/functions.php", + "lib/Internal/functions.php" + ], + "psr-4": { + "Amp\\": "lib" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Daniel Lowrey", + "email": "rdlowrey@php.net" + }, + { + "name": "Aaron Piotrowski", + "email": "aaron@trowski.com" + }, + { + "name": "Bob Weinand", + "email": "bobwei9@hotmail.com" + }, + { + "name": "Niklas Keller", + "email": "me@kelunik.com" + } + ], + "description": "A non-blocking concurrency framework for PHP applications.", + "homepage": "https://amphp.org/amp", + "keywords": [ + "async", + "asynchronous", + "awaitable", + "concurrency", + "event", + "event-loop", + "future", + "non-blocking", + "promise" + ], + "support": { + "irc": "irc://irc.freenode.org/amphp", + "issues": "https://github.com/amphp/amp/issues", + "source": "https://github.com/amphp/amp/tree/v2.6.5" + }, + "funding": [ + { + "url": "https://github.com/amphp", + "type": "github" + } + ], + "time": "2025-09-03T19:41:28+00:00" + }, + { + "name": "amphp/byte-stream", + "version": "v1.8.2", + "source": { + "type": "git", + "url": "https://github.com/amphp/byte-stream.git", + "reference": "4f0e968ba3798a423730f567b1b50d3441c16ddc" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/amphp/byte-stream/zipball/4f0e968ba3798a423730f567b1b50d3441c16ddc", + "reference": "4f0e968ba3798a423730f567b1b50d3441c16ddc", + "shasum": "" + }, + "require": { + "amphp/amp": "^2", + "php": ">=7.1" + }, + "require-dev": { + "amphp/php-cs-fixer-config": "dev-master", + "amphp/phpunit-util": "^1.4", + "friendsofphp/php-cs-fixer": "^2.3", + "jetbrains/phpstorm-stubs": "^2019.3", + "phpunit/phpunit": "^6 || ^7 || ^8", + "psalm/phar": "^3.11.4" + }, + "type": "library", + "autoload": { + "files": [ + "lib/functions.php" + ], + "psr-4": { + "Amp\\ByteStream\\": "lib" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Aaron Piotrowski", + "email": "aaron@trowski.com" + }, + { + "name": "Niklas Keller", + "email": "me@kelunik.com" + } + ], + "description": "A stream abstraction to make working with non-blocking I/O simple.", + "homepage": "https://amphp.org/byte-stream", + "keywords": [ + "amp", + "amphp", + "async", + "io", + "non-blocking", + "stream" + ], + "support": { + "issues": "https://github.com/amphp/byte-stream/issues", + "source": "https://github.com/amphp/byte-stream/tree/v1.8.2" + }, + "funding": [ + { + "url": "https://github.com/amphp", + "type": "github" + } + ], + "time": "2024-04-13T18:00:56+00:00" + }, + { + "name": "composer/pcre", + "version": "3.4.0", + "source": { + "type": "git", + "url": "https://github.com/composer/pcre.git", + "reference": "d5a341b3fb61f3001970940afb1d332968a183ed" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/composer/pcre/zipball/d5a341b3fb61f3001970940afb1d332968a183ed", + "reference": "d5a341b3fb61f3001970940afb1d332968a183ed", + "shasum": "" + }, + "require": { + "php": "^7.4 || ^8.0" + }, + "conflict": { + "phpstan/phpstan": "<2.2.2" + }, + "require-dev": { + "phpstan/phpstan": "^2", + "phpstan/phpstan-deprecation-rules": "^2", + "phpstan/phpstan-strict-rules": "^2", + "phpunit/phpunit": "^9" + }, + "type": "library", + "extra": { + "phpstan": { + "includes": [ + "extension.neon" + ] + }, + "branch-alias": { + "dev-main": "3.x-dev" + } + }, + "autoload": { + "psr-4": { + "Composer\\Pcre\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Jordi Boggiano", + "email": "j.boggiano@seld.be", + "homepage": "http://seld.be" + } + ], + "description": "PCRE wrapping library that offers type-safe preg_* replacements.", + "keywords": [ + "PCRE", + "preg", + "regex", + "regular expression" + ], + "support": { + "issues": "https://github.com/composer/pcre/issues", + "source": "https://github.com/composer/pcre/tree/3.4.0" + }, + "funding": [ + { + "url": "https://packagist.com", + "type": "custom" + }, + { + "url": "https://github.com/composer", + "type": "github" + } + ], + "time": "2026-06-07T11:47:49+00:00" + }, + { + "name": "composer/semver", + "version": "3.4.4", + "source": { + "type": "git", + "url": "https://github.com/composer/semver.git", + "reference": "198166618906cb2de69b95d7d47e5fa8aa1b2b95" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/composer/semver/zipball/198166618906cb2de69b95d7d47e5fa8aa1b2b95", + "reference": "198166618906cb2de69b95d7d47e5fa8aa1b2b95", + "shasum": "" + }, + "require": { + "php": "^5.3.2 || ^7.0 || ^8.0" + }, + "require-dev": { + "phpstan/phpstan": "^1.11", + "symfony/phpunit-bridge": "^3 || ^7" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "3.x-dev" + } + }, + "autoload": { + "psr-4": { + "Composer\\Semver\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nils Adermann", + "email": "naderman@naderman.de", + "homepage": "http://www.naderman.de" + }, + { + "name": "Jordi Boggiano", + "email": "j.boggiano@seld.be", + "homepage": "http://seld.be" + }, + { + "name": "Rob Bast", + "email": "rob.bast@gmail.com", + "homepage": "http://robbast.nl" + } + ], + "description": "Semver library that offers utilities, version constraint parsing and validation.", + "keywords": [ + "semantic", + "semver", + "validation", + "versioning" + ], + "support": { + "irc": "ircs://irc.libera.chat:6697/composer", + "issues": "https://github.com/composer/semver/issues", + "source": "https://github.com/composer/semver/tree/3.4.4" + }, + "funding": [ + { + "url": "https://packagist.com", + "type": "custom" + }, + { + "url": "https://github.com/composer", + "type": "github" + } + ], + "time": "2025-08-20T19:15:30+00:00" + }, + { + "name": "composer/xdebug-handler", + "version": "3.0.5", + "source": { + "type": "git", + "url": "https://github.com/composer/xdebug-handler.git", + "reference": "6c1925561632e83d60a44492e0b344cf48ab85ef" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/composer/xdebug-handler/zipball/6c1925561632e83d60a44492e0b344cf48ab85ef", + "reference": "6c1925561632e83d60a44492e0b344cf48ab85ef", + "shasum": "" + }, + "require": { + "composer/pcre": "^1 || ^2 || ^3", + "php": "^7.2.5 || ^8.0", + "psr/log": "^1 || ^2 || ^3" + }, + "require-dev": { + "phpstan/phpstan": "^1.0", + "phpstan/phpstan-strict-rules": "^1.1", + "phpunit/phpunit": "^8.5 || ^9.6 || ^10.5" + }, + "type": "library", + "autoload": { + "psr-4": { + "Composer\\XdebugHandler\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "John Stevenson", + "email": "john-stevenson@blueyonder.co.uk" + } + ], + "description": "Restarts a process without Xdebug.", + "keywords": [ + "Xdebug", + "performance" + ], + "support": { + "irc": "ircs://irc.libera.chat:6697/composer", + "issues": "https://github.com/composer/xdebug-handler/issues", + "source": "https://github.com/composer/xdebug-handler/tree/3.0.5" + }, + "funding": [ + { + "url": "https://packagist.com", + "type": "custom" + }, + { + "url": "https://github.com/composer", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/composer/composer", + "type": "tidelift" + } + ], + "time": "2024-05-06T16:37:16+00:00" + }, + { + "name": "dnoegel/php-xdg-base-dir", + "version": "v0.1.1", + "source": { + "type": "git", + "url": "https://github.com/dnoegel/php-xdg-base-dir.git", + "reference": "8f8a6e48c5ecb0f991c2fdcf5f154a47d85f9ffd" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/dnoegel/php-xdg-base-dir/zipball/8f8a6e48c5ecb0f991c2fdcf5f154a47d85f9ffd", + "reference": "8f8a6e48c5ecb0f991c2fdcf5f154a47d85f9ffd", + "shasum": "" + }, + "require": { + "php": ">=5.3.2" + }, + "require-dev": { + "phpunit/phpunit": "~7.0|~6.0|~5.0|~4.8.35" + }, + "type": "library", + "autoload": { + "psr-4": { + "XdgBaseDir\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "implementation of xdg base directory specification for php", + "support": { + "issues": "https://github.com/dnoegel/php-xdg-base-dir/issues", + "source": "https://github.com/dnoegel/php-xdg-base-dir/tree/v0.1.1" + }, + "time": "2019-12-04T15:06:13+00:00" + }, + { + "name": "doctrine/deprecations", + "version": "1.1.6", + "source": { + "type": "git", + "url": "https://github.com/doctrine/deprecations.git", + "reference": "d4fe3e6fd9bb9e72557a19674f44d8ac7db4c6ca" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/doctrine/deprecations/zipball/d4fe3e6fd9bb9e72557a19674f44d8ac7db4c6ca", + "reference": "d4fe3e6fd9bb9e72557a19674f44d8ac7db4c6ca", + "shasum": "" + }, + "require": { + "php": "^7.1 || ^8.0" + }, + "conflict": { + "phpunit/phpunit": "<=7.5 || >=14" + }, + "require-dev": { + "doctrine/coding-standard": "^9 || ^12 || ^14", + "phpstan/phpstan": "1.4.10 || 2.1.30", + "phpstan/phpstan-phpunit": "^1.0 || ^2", + "phpunit/phpunit": "^7.5 || ^8.5 || ^9.6 || ^10.5 || ^11.5 || ^12.4 || ^13.0", + "psr/log": "^1 || ^2 || ^3" + }, + "suggest": { + "psr/log": "Allows logging deprecations via PSR-3 logger implementation" + }, + "type": "library", + "autoload": { + "psr-4": { + "Doctrine\\Deprecations\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "A small layer on top of trigger_error(E_USER_DEPRECATED) or PSR-3 logging with options to disable all deprecations or selectively for packages.", + "homepage": "https://www.doctrine-project.org/", + "support": { + "issues": "https://github.com/doctrine/deprecations/issues", + "source": "https://github.com/doctrine/deprecations/tree/1.1.6" + }, + "time": "2026-02-07T07:09:04+00:00" + }, + { + "name": "doctrine/instantiator", + "version": "1.5.0", + "source": { + "type": "git", + "url": "https://github.com/doctrine/instantiator.git", + "reference": "0a0fa9780f5d4e507415a065172d26a98d02047b" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/doctrine/instantiator/zipball/0a0fa9780f5d4e507415a065172d26a98d02047b", + "reference": "0a0fa9780f5d4e507415a065172d26a98d02047b", + "shasum": "" + }, + "require": { + "php": "^7.1 || ^8.0" + }, + "require-dev": { + "doctrine/coding-standard": "^9 || ^11", + "ext-pdo": "*", + "ext-phar": "*", + "phpbench/phpbench": "^0.16 || ^1", + "phpstan/phpstan": "^1.4", + "phpstan/phpstan-phpunit": "^1", + "phpunit/phpunit": "^7.5 || ^8.5 || ^9.5", + "vimeo/psalm": "^4.30 || ^5.4" + }, + "type": "library", + "autoload": { + "psr-4": { + "Doctrine\\Instantiator\\": "src/Doctrine/Instantiator/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Marco Pivetta", + "email": "ocramius@gmail.com", + "homepage": "https://ocramius.github.io/" + } + ], + "description": "A small, lightweight utility to instantiate objects in PHP without invoking their constructors", + "homepage": "https://www.doctrine-project.org/projects/instantiator.html", + "keywords": [ + "constructor", + "instantiate" + ], + "support": { + "issues": "https://github.com/doctrine/instantiator/issues", + "source": "https://github.com/doctrine/instantiator/tree/1.5.0" + }, + "funding": [ + { + "url": "https://www.doctrine-project.org/sponsorship.html", + "type": "custom" + }, + { + "url": "https://www.patreon.com/phpdoctrine", + "type": "patreon" + }, + { + "url": "https://tidelift.com/funding/github/packagist/doctrine%2Finstantiator", + "type": "tidelift" + } + ], + "time": "2022-12-30T00:15:36+00:00" + }, + { + "name": "facade/ignition-contracts", + "version": "1.0.2", + "source": { + "type": "git", + "url": "https://github.com/facade/ignition-contracts.git", + "reference": "3c921a1cdba35b68a7f0ccffc6dffc1995b18267" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/facade/ignition-contracts/zipball/3c921a1cdba35b68a7f0ccffc6dffc1995b18267", + "reference": "3c921a1cdba35b68a7f0ccffc6dffc1995b18267", + "shasum": "" + }, + "require": { + "php": "^7.3|^8.0" + }, + "require-dev": { + "friendsofphp/php-cs-fixer": "^v2.15.8", + "phpunit/phpunit": "^9.3.11", + "vimeo/psalm": "^3.17.1" + }, + "type": "library", + "autoload": { + "psr-4": { + "Facade\\IgnitionContracts\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Freek Van der Herten", + "email": "freek@spatie.be", + "homepage": "https://flareapp.io", + "role": "Developer" + } + ], + "description": "Solution contracts for Ignition", + "homepage": "https://github.com/facade/ignition-contracts", + "keywords": [ + "contracts", + "flare", + "ignition" + ], + "support": { + "issues": "https://github.com/facade/ignition-contracts/issues", + "source": "https://github.com/facade/ignition-contracts/tree/1.0.2" + }, + "time": "2020-10-16T08:27:54+00:00" + }, + { + "name": "felixfbecker/advanced-json-rpc", + "version": "v3.2.1", + "source": { + "type": "git", + "url": "https://github.com/felixfbecker/php-advanced-json-rpc.git", + "reference": "b5f37dbff9a8ad360ca341f3240dc1c168b45447" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/felixfbecker/php-advanced-json-rpc/zipball/b5f37dbff9a8ad360ca341f3240dc1c168b45447", + "reference": "b5f37dbff9a8ad360ca341f3240dc1c168b45447", + "shasum": "" + }, + "require": { + "netresearch/jsonmapper": "^1.0 || ^2.0 || ^3.0 || ^4.0", + "php": "^7.1 || ^8.0", + "phpdocumentor/reflection-docblock": "^4.3.4 || ^5.0.0" + }, + "require-dev": { + "phpunit/phpunit": "^7.0 || ^8.0" + }, + "type": "library", + "autoload": { + "psr-4": { + "AdvancedJsonRpc\\": "lib/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "ISC" + ], + "authors": [ + { + "name": "Felix Becker", + "email": "felix.b@outlook.com" + } + ], + "description": "A more advanced JSONRPC implementation", + "support": { + "issues": "https://github.com/felixfbecker/php-advanced-json-rpc/issues", + "source": "https://github.com/felixfbecker/php-advanced-json-rpc/tree/v3.2.1" + }, + "time": "2021-06-11T22:34:44+00:00" + }, + { + "name": "felixfbecker/language-server-protocol", + "version": "v1.5.3", + "source": { + "type": "git", + "url": "https://github.com/felixfbecker/php-language-server-protocol.git", + "reference": "a9e113dbc7d849e35b8776da39edaf4313b7b6c9" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/felixfbecker/php-language-server-protocol/zipball/a9e113dbc7d849e35b8776da39edaf4313b7b6c9", + "reference": "a9e113dbc7d849e35b8776da39edaf4313b7b6c9", + "shasum": "" + }, + "require": { + "php": ">=7.1" + }, + "require-dev": { + "phpstan/phpstan": "*", + "squizlabs/php_codesniffer": "^3.1", + "vimeo/psalm": "^4.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.x-dev" + } + }, + "autoload": { + "psr-4": { + "LanguageServerProtocol\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "ISC" + ], + "authors": [ + { + "name": "Felix Becker", + "email": "felix.b@outlook.com" + } + ], + "description": "PHP classes for the Language Server Protocol", + "keywords": [ + "language", + "microsoft", + "php", + "server" + ], + "support": { + "issues": "https://github.com/felixfbecker/php-language-server-protocol/issues", + "source": "https://github.com/felixfbecker/php-language-server-protocol/tree/v1.5.3" + }, + "time": "2024-04-30T00:40:11+00:00" + }, + { + "name": "fidry/cpu-core-counter", + "version": "1.3.0", + "source": { + "type": "git", + "url": "https://github.com/theofidry/cpu-core-counter.git", + "reference": "db9508f7b1474469d9d3c53b86f817e344732678" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/theofidry/cpu-core-counter/zipball/db9508f7b1474469d9d3c53b86f817e344732678", + "reference": "db9508f7b1474469d9d3c53b86f817e344732678", + "shasum": "" + }, + "require": { + "php": "^7.2 || ^8.0" + }, + "require-dev": { + "fidry/makefile": "^0.2.0", + "fidry/php-cs-fixer-config": "^1.1.2", + "phpstan/extension-installer": "^1.2.0", + "phpstan/phpstan": "^2.0", + "phpstan/phpstan-deprecation-rules": "^2.0.0", + "phpstan/phpstan-phpunit": "^2.0", + "phpstan/phpstan-strict-rules": "^2.0", + "phpunit/phpunit": "^8.5.31 || ^9.5.26", + "webmozarts/strict-phpunit": "^7.5" + }, + "type": "library", + "autoload": { + "psr-4": { + "Fidry\\CpuCoreCounter\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Théo FIDRY", + "email": "theo.fidry@gmail.com" + } + ], + "description": "Tiny utility to get the number of CPU cores.", + "keywords": [ + "CPU", + "core" + ], + "support": { + "issues": "https://github.com/theofidry/cpu-core-counter/issues", + "source": "https://github.com/theofidry/cpu-core-counter/tree/1.3.0" + }, + "funding": [ + { + "url": "https://github.com/theofidry", + "type": "github" + } + ], + "time": "2025-08-14T07:29:31+00:00" + }, + { + "name": "filp/whoops", + "version": "2.18.4", + "source": { + "type": "git", + "url": "https://github.com/filp/whoops.git", + "reference": "d2102955e48b9fd9ab24280a7ad12ed552752c4d" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/filp/whoops/zipball/d2102955e48b9fd9ab24280a7ad12ed552752c4d", + "reference": "d2102955e48b9fd9ab24280a7ad12ed552752c4d", + "shasum": "" + }, + "require": { + "php": "^7.1 || ^8.0", + "psr/log": "^1.0.1 || ^2.0 || ^3.0" + }, + "require-dev": { + "mockery/mockery": "^1.0", + "phpunit/phpunit": "^7.5.20 || ^8.5.8 || ^9.3.3", + "symfony/var-dumper": "^4.0 || ^5.0" + }, + "suggest": { + "symfony/var-dumper": "Pretty print complex values better with var-dumper available", + "whoops/soap": "Formats errors as SOAP responses" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.7-dev" + } + }, + "autoload": { + "psr-4": { + "Whoops\\": "src/Whoops/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Filipe Dobreira", + "homepage": "https://github.com/filp", + "role": "Developer" + } + ], + "description": "php error handling for cool kids", + "homepage": "https://filp.github.io/whoops/", + "keywords": [ + "error", + "exception", + "handling", + "library", + "throwable", + "whoops" + ], + "support": { + "issues": "https://github.com/filp/whoops/issues", + "source": "https://github.com/filp/whoops/tree/2.18.4" + }, + "funding": [ + { + "url": "https://github.com/denis-sokolov", + "type": "github" + } + ], + "time": "2025-08-08T12:00:00+00:00" + }, + { + "name": "myclabs/deep-copy", + "version": "1.13.4", + "source": { + "type": "git", + "url": "https://github.com/myclabs/DeepCopy.git", + "reference": "07d290f0c47959fd5eed98c95ee5602db07e0b6a" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/myclabs/DeepCopy/zipball/07d290f0c47959fd5eed98c95ee5602db07e0b6a", + "reference": "07d290f0c47959fd5eed98c95ee5602db07e0b6a", + "shasum": "" + }, + "require": { + "php": "^7.1 || ^8.0" + }, + "conflict": { + "doctrine/collections": "<1.6.8", + "doctrine/common": "<2.13.3 || >=3 <3.2.2" + }, + "require-dev": { + "doctrine/collections": "^1.6.8", + "doctrine/common": "^2.13.3 || ^3.2.2", + "phpspec/prophecy": "^1.10", + "phpunit/phpunit": "^7.5.20 || ^8.5.23 || ^9.5.13" + }, + "type": "library", + "autoload": { + "files": [ + "src/DeepCopy/deep_copy.php" + ], + "psr-4": { + "DeepCopy\\": "src/DeepCopy/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "Create deep copies (clones) of your objects", + "keywords": [ + "clone", + "copy", + "duplicate", + "object", + "object graph" + ], + "support": { + "issues": "https://github.com/myclabs/DeepCopy/issues", + "source": "https://github.com/myclabs/DeepCopy/tree/1.13.4" + }, + "funding": [ + { + "url": "https://tidelift.com/funding/github/packagist/myclabs/deep-copy", + "type": "tidelift" + } + ], + "time": "2025-08-01T08:46:24+00:00" + }, + { + "name": "netresearch/jsonmapper", + "version": "v4.5.0", + "source": { + "type": "git", + "url": "https://github.com/cweiske/jsonmapper.git", + "reference": "8e76efb98ee8b6afc54687045e1b8dba55ac76e5" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/cweiske/jsonmapper/zipball/8e76efb98ee8b6afc54687045e1b8dba55ac76e5", + "reference": "8e76efb98ee8b6afc54687045e1b8dba55ac76e5", + "shasum": "" + }, + "require": { + "ext-json": "*", + "ext-pcre": "*", + "ext-reflection": "*", + "ext-spl": "*", + "php": ">=7.1" + }, + "require-dev": { + "phpunit/phpunit": "~7.5 || ~8.0 || ~9.0 || ~10.0", + "squizlabs/php_codesniffer": "~3.5" + }, + "type": "library", + "autoload": { + "psr-0": { + "JsonMapper": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "OSL-3.0" + ], + "authors": [ + { + "name": "Christian Weiske", + "email": "cweiske@cweiske.de", + "homepage": "http://github.com/cweiske/jsonmapper/", + "role": "Developer" + } + ], + "description": "Map nested JSON structures onto PHP classes", + "support": { + "email": "cweiske@cweiske.de", + "issues": "https://github.com/cweiske/jsonmapper/issues", + "source": "https://github.com/cweiske/jsonmapper/tree/v4.5.0" + }, + "time": "2024-09-08T10:13:13+00:00" + }, + { + "name": "nikic/php-parser", + "version": "v4.19.5", + "source": { + "type": "git", + "url": "https://github.com/nikic/PHP-Parser.git", + "reference": "51bd93cc741b7fc3d63d20b6bdcd99fdaa359837" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/51bd93cc741b7fc3d63d20b6bdcd99fdaa359837", + "reference": "51bd93cc741b7fc3d63d20b6bdcd99fdaa359837", + "shasum": "" + }, + "require": { + "ext-tokenizer": "*", + "php": ">=7.1" + }, + "require-dev": { + "ircmaxell/php-yacc": "^0.0.7", + "phpunit/phpunit": "^7.0 || ^8.0 || ^9.0" + }, + "bin": [ + "bin/php-parse" + ], + "type": "library", + "autoload": { + "psr-4": { + "PhpParser\\": "lib/PhpParser" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Nikita Popov" + } + ], + "description": "A PHP parser written in PHP", + "keywords": [ + "parser", + "php" + ], + "support": { + "issues": "https://github.com/nikic/PHP-Parser/issues", + "source": "https://github.com/nikic/PHP-Parser/tree/v4.19.5" + }, + "time": "2025-12-06T11:45:25+00:00" + }, + { + "name": "nunomaduro/collision", + "version": "v5.11.0", + "source": { + "type": "git", + "url": "https://github.com/nunomaduro/collision.git", + "reference": "8b610eef8582ccdc05d8f2ab23305e2d37049461" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/nunomaduro/collision/zipball/8b610eef8582ccdc05d8f2ab23305e2d37049461", + "reference": "8b610eef8582ccdc05d8f2ab23305e2d37049461", + "shasum": "" + }, + "require": { + "facade/ignition-contracts": "^1.0", + "filp/whoops": "^2.14.3", + "php": "^7.3 || ^8.0", + "symfony/console": "^5.0" + }, + "require-dev": { + "brianium/paratest": "^6.1", + "fideloper/proxy": "^4.4.1", + "fruitcake/laravel-cors": "^2.0.3", + "laravel/framework": "8.x-dev", + "nunomaduro/larastan": "^0.6.2", + "nunomaduro/mock-final-classes": "^1.0", + "orchestra/testbench": "^6.0", + "phpstan/phpstan": "^0.12.64", + "phpunit/phpunit": "^9.5.0" + }, + "type": "library", + "extra": { + "laravel": { + "providers": [ + "NunoMaduro\\Collision\\Adapters\\Laravel\\CollisionServiceProvider" + ] + } + }, + "autoload": { + "psr-4": { + "NunoMaduro\\Collision\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nuno Maduro", + "email": "enunomaduro@gmail.com" + } + ], + "description": "Cli error handling for console/command-line PHP applications.", + "keywords": [ + "artisan", + "cli", + "command-line", + "console", + "error", + "handling", + "laravel", + "laravel-zero", + "php", + "symfony" + ], + "support": { + "issues": "https://github.com/nunomaduro/collision/issues", + "source": "https://github.com/nunomaduro/collision" + }, + "funding": [ + { + "url": "https://www.paypal.com/paypalme/enunomaduro", + "type": "custom" + }, + { + "url": "https://github.com/nunomaduro", + "type": "github" + }, + { + "url": "https://www.patreon.com/nunomaduro", + "type": "patreon" + } + ], + "time": "2022-01-10T16:22:52+00:00" + }, + { + "name": "pestphp/pest", + "version": "v1.23.1", + "source": { + "type": "git", + "url": "https://github.com/pestphp/pest.git", + "reference": "5c56ad8772b89611c72a07e23f6e30aa29dc677a" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/pestphp/pest/zipball/5c56ad8772b89611c72a07e23f6e30aa29dc677a", + "reference": "5c56ad8772b89611c72a07e23f6e30aa29dc677a", + "shasum": "" + }, + "require": { + "nunomaduro/collision": "^5.11.0|^6.4.0", + "pestphp/pest-plugin": "^1.1.0", + "php": "^7.3 || ^8.0", + "phpunit/phpunit": "^9.6.10" + }, + "require-dev": { + "illuminate/console": "^8.83.27", + "illuminate/support": "^8.83.27", + "laravel/dusk": "^6.25.2", + "pestphp/pest-dev-tools": "^1.0.0", + "pestphp/pest-plugin-parallel": "^1.2.1" + }, + "bin": [ + "bin/pest" + ], + "type": "library", + "extra": { + "pest": { + "plugins": [ + "Pest\\Plugins\\Coverage", + "Pest\\Plugins\\Init", + "Pest\\Plugins\\Version", + "Pest\\Plugins\\Environment" + ] + }, + "laravel": { + "providers": [ + "Pest\\Laravel\\PestServiceProvider" + ] + }, + "branch-alias": { + "dev-1.x": "1.x-dev" + } + }, + "autoload": { + "files": [ + "src/Functions.php", + "src/Pest.php" + ], + "psr-4": { + "Pest\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nuno Maduro", + "email": "enunomaduro@gmail.com" + } + ], + "description": "An elegant PHP Testing Framework.", + "keywords": [ + "framework", + "pest", + "php", + "test", + "testing", + "unit" + ], + "support": { + "issues": "https://github.com/pestphp/pest/issues", + "source": "https://github.com/pestphp/pest/tree/v1.23.1" + }, + "funding": [ + { + "url": "https://www.paypal.com/paypalme/enunomaduro", + "type": "custom" + }, + { + "url": "https://github.com/nunomaduro", + "type": "github" + } + ], + "time": "2023-07-12T19:42:47+00:00" + }, + { + "name": "pestphp/pest-plugin", + "version": "v1.1.0", + "source": { + "type": "git", + "url": "https://github.com/pestphp/pest-plugin.git", + "reference": "606c5f79c6a339b49838ffbee0151ca519efe378" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/pestphp/pest-plugin/zipball/606c5f79c6a339b49838ffbee0151ca519efe378", + "reference": "606c5f79c6a339b49838ffbee0151ca519efe378", + "shasum": "" + }, + "require": { + "composer-plugin-api": "^1.1.0 || ^2.0.0", + "php": "^7.3 || ^8.0" + }, + "conflict": { + "pestphp/pest": "<1.0" + }, + "require-dev": { + "composer/composer": "^2.4.2", + "pestphp/pest": "^1.22.1", + "pestphp/pest-dev-tools": "^1.0.0" + }, + "type": "composer-plugin", + "extra": { + "class": "Pest\\Plugin\\Manager", + "branch-alias": { + "dev-master": "1.x-dev" + } + }, + "autoload": { + "psr-4": { + "Pest\\Plugin\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "The Pest plugin manager", + "keywords": [ + "framework", + "manager", + "pest", + "php", + "plugin", + "test", + "testing", + "unit" + ], + "support": { + "source": "https://github.com/pestphp/pest-plugin/tree/v1.1.0" + }, + "funding": [ + { + "url": "https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=66BYDWAT92N6L", + "type": "custom" + }, + { + "url": "https://github.com/nunomaduro", + "type": "github" + }, + { + "url": "https://www.patreon.com/nunomaduro", + "type": "patreon" + } + ], + "time": "2022-09-18T13:18:17+00:00" + }, + { + "name": "phar-io/manifest", + "version": "2.0.4", + "source": { + "type": "git", + "url": "https://github.com/phar-io/manifest.git", + "reference": "54750ef60c58e43759730615a392c31c80e23176" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phar-io/manifest/zipball/54750ef60c58e43759730615a392c31c80e23176", + "reference": "54750ef60c58e43759730615a392c31c80e23176", + "shasum": "" + }, + "require": { + "ext-dom": "*", + "ext-libxml": "*", + "ext-phar": "*", + "ext-xmlwriter": "*", + "phar-io/version": "^3.0.1", + "php": "^7.2 || ^8.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.0.x-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Arne Blankerts", + "email": "arne@blankerts.de", + "role": "Developer" + }, + { + "name": "Sebastian Heuer", + "email": "sebastian@phpeople.de", + "role": "Developer" + }, + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "Developer" + } + ], + "description": "Component for reading phar.io manifest information from a PHP Archive (PHAR)", + "support": { + "issues": "https://github.com/phar-io/manifest/issues", + "source": "https://github.com/phar-io/manifest/tree/2.0.4" + }, + "funding": [ + { + "url": "https://github.com/theseer", + "type": "github" + } + ], + "time": "2024-03-03T12:33:53+00:00" + }, + { + "name": "phar-io/version", + "version": "3.2.1", + "source": { + "type": "git", + "url": "https://github.com/phar-io/version.git", + "reference": "4f7fd7836c6f332bb2933569e566a0d6c4cbed74" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phar-io/version/zipball/4f7fd7836c6f332bb2933569e566a0d6c4cbed74", + "reference": "4f7fd7836c6f332bb2933569e566a0d6c4cbed74", + "shasum": "" + }, + "require": { + "php": "^7.2 || ^8.0" + }, + "type": "library", + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Arne Blankerts", + "email": "arne@blankerts.de", + "role": "Developer" + }, + { + "name": "Sebastian Heuer", + "email": "sebastian@phpeople.de", + "role": "Developer" + }, + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "Developer" + } + ], + "description": "Library for handling version information and constraints", + "support": { + "issues": "https://github.com/phar-io/version/issues", + "source": "https://github.com/phar-io/version/tree/3.2.1" + }, + "time": "2022-02-21T01:04:05+00:00" + }, + { + "name": "phpdocumentor/reflection-common", + "version": "2.2.0", + "source": { + "type": "git", + "url": "https://github.com/phpDocumentor/ReflectionCommon.git", + "reference": "1d01c49d4ed62f25aa84a747ad35d5a16924662b" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phpDocumentor/ReflectionCommon/zipball/1d01c49d4ed62f25aa84a747ad35d5a16924662b", + "reference": "1d01c49d4ed62f25aa84a747ad35d5a16924662b", + "shasum": "" + }, + "require": { + "php": "^7.2 || ^8.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-2.x": "2.x-dev" + } + }, + "autoload": { + "psr-4": { + "phpDocumentor\\Reflection\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Jaap van Otterdijk", + "email": "opensource@ijaap.nl" + } + ], + "description": "Common reflection classes used by phpdocumentor to reflect the code structure", + "homepage": "http://www.phpdoc.org", + "keywords": [ + "FQSEN", + "phpDocumentor", + "phpdoc", + "reflection", + "static analysis" + ], + "support": { + "issues": "https://github.com/phpDocumentor/ReflectionCommon/issues", + "source": "https://github.com/phpDocumentor/ReflectionCommon/tree/2.x" + }, + "time": "2020-06-27T09:03:43+00:00" + }, + { + "name": "phpdocumentor/reflection-docblock", + "version": "5.6.7", + "source": { + "type": "git", + "url": "https://github.com/phpDocumentor/ReflectionDocBlock.git", + "reference": "31a105931bc8ffa3a123383829772e832fd8d903" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phpDocumentor/ReflectionDocBlock/zipball/31a105931bc8ffa3a123383829772e832fd8d903", + "reference": "31a105931bc8ffa3a123383829772e832fd8d903", + "shasum": "" + }, + "require": { + "doctrine/deprecations": "^1.1", + "ext-filter": "*", + "php": "^7.4 || ^8.0", + "phpdocumentor/reflection-common": "^2.2", + "phpdocumentor/type-resolver": "^1.7", + "phpstan/phpdoc-parser": "^1.7|^2.0", + "webmozart/assert": "^1.9.1 || ^2" + }, + "require-dev": { + "mockery/mockery": "~1.3.5 || ~1.6.0", + "phpstan/extension-installer": "^1.1", + "phpstan/phpstan": "^1.8", + "phpstan/phpstan-mockery": "^1.1", + "phpstan/phpstan-webmozart-assert": "^1.2", + "phpunit/phpunit": "^9.5", + "psalm/phar": "^5.26" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "5.x-dev" + } + }, + "autoload": { + "psr-4": { + "phpDocumentor\\Reflection\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Mike van Riel", + "email": "me@mikevanriel.com" + }, + { + "name": "Jaap van Otterdijk", + "email": "opensource@ijaap.nl" + } + ], + "description": "With this component, a library can provide support for annotations via DocBlocks or otherwise retrieve information that is embedded in a DocBlock.", + "support": { + "issues": "https://github.com/phpDocumentor/ReflectionDocBlock/issues", + "source": "https://github.com/phpDocumentor/ReflectionDocBlock/tree/5.6.7" + }, + "time": "2026-03-18T20:47:46+00:00" + }, + { + "name": "phpdocumentor/type-resolver", + "version": "1.12.0", + "source": { + "type": "git", + "url": "https://github.com/phpDocumentor/TypeResolver.git", + "reference": "92a98ada2b93d9b201a613cb5a33584dde25f195" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phpDocumentor/TypeResolver/zipball/92a98ada2b93d9b201a613cb5a33584dde25f195", + "reference": "92a98ada2b93d9b201a613cb5a33584dde25f195", + "shasum": "" + }, + "require": { + "doctrine/deprecations": "^1.0", + "php": "^7.3 || ^8.0", + "phpdocumentor/reflection-common": "^2.0", + "phpstan/phpdoc-parser": "^1.18|^2.0" + }, + "require-dev": { + "ext-tokenizer": "*", + "phpbench/phpbench": "^1.2", + "phpstan/extension-installer": "^1.1", + "phpstan/phpstan": "^1.8", + "phpstan/phpstan-phpunit": "^1.1", + "phpunit/phpunit": "^9.5", + "rector/rector": "^0.13.9", + "vimeo/psalm": "^4.25" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-1.x": "1.x-dev" + } + }, + "autoload": { + "psr-4": { + "phpDocumentor\\Reflection\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Mike van Riel", + "email": "me@mikevanriel.com" + } + ], + "description": "A PSR-5 based resolver of Class names, Types and Structural Element Names", + "support": { + "issues": "https://github.com/phpDocumentor/TypeResolver/issues", + "source": "https://github.com/phpDocumentor/TypeResolver/tree/1.12.0" + }, + "time": "2025-11-21T15:09:14+00:00" + }, + { + "name": "phpstan/phpdoc-parser", + "version": "2.3.3", + "source": { + "type": "git", + "url": "https://github.com/phpstan/phpdoc-parser.git", + "reference": "fb19eedd2bb67ff8cf7a5502ad329e701d6398a3" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phpstan/phpdoc-parser/zipball/fb19eedd2bb67ff8cf7a5502ad329e701d6398a3", + "reference": "fb19eedd2bb67ff8cf7a5502ad329e701d6398a3", + "shasum": "" + }, + "require": { + "php": "^7.4 || ^8.0" + }, + "require-dev": { + "doctrine/annotations": "^2.0", + "nikic/php-parser": "^5.3.0", + "php-parallel-lint/php-parallel-lint": "^1.2", + "phpstan/extension-installer": "^1.0", + "phpstan/phpstan": "^2.0", + "phpstan/phpstan-phpunit": "^2.0", + "phpstan/phpstan-strict-rules": "^2.0", + "phpunit/phpunit": "^9.6", + "symfony/process": "^5.2" + }, + "type": "library", + "autoload": { + "psr-4": { + "PHPStan\\PhpDocParser\\": [ + "src/" + ] + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "PHPDoc parser with support for nullable, intersection and generic types", + "support": { + "issues": "https://github.com/phpstan/phpdoc-parser/issues", + "source": "https://github.com/phpstan/phpdoc-parser/tree/2.3.3" + }, + "time": "2026-07-08T07:01:06+00:00" + }, + { + "name": "phpunit/php-code-coverage", + "version": "9.2.32", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/php-code-coverage.git", + "reference": "85402a822d1ecf1db1096959413d35e1c37cf1a5" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/85402a822d1ecf1db1096959413d35e1c37cf1a5", + "reference": "85402a822d1ecf1db1096959413d35e1c37cf1a5", + "shasum": "" + }, + "require": { + "ext-dom": "*", + "ext-libxml": "*", + "ext-xmlwriter": "*", + "nikic/php-parser": "^4.19.1 || ^5.1.0", + "php": ">=7.3", + "phpunit/php-file-iterator": "^3.0.6", + "phpunit/php-text-template": "^2.0.4", + "sebastian/code-unit-reverse-lookup": "^2.0.3", + "sebastian/complexity": "^2.0.3", + "sebastian/environment": "^5.1.5", + "sebastian/lines-of-code": "^1.0.4", + "sebastian/version": "^3.0.2", + "theseer/tokenizer": "^1.2.3" + }, + "require-dev": { + "phpunit/phpunit": "^9.6" + }, + "suggest": { + "ext-pcov": "PHP extension that provides line coverage", + "ext-xdebug": "PHP extension that provides line coverage as well as branch and path coverage" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "9.2.x-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "lead" + } + ], + "description": "Library that provides collection, processing, and rendering functionality for PHP code coverage information.", + "homepage": "https://github.com/sebastianbergmann/php-code-coverage", + "keywords": [ + "coverage", + "testing", + "xunit" + ], + "support": { + "issues": "https://github.com/sebastianbergmann/php-code-coverage/issues", + "security": "https://github.com/sebastianbergmann/php-code-coverage/security/policy", + "source": "https://github.com/sebastianbergmann/php-code-coverage/tree/9.2.32" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2024-08-22T04:23:01+00:00" + }, + { + "name": "phpunit/php-file-iterator", + "version": "3.0.6", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/php-file-iterator.git", + "reference": "cf1c2e7c203ac650e352f4cc675a7021e7d1b3cf" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/php-file-iterator/zipball/cf1c2e7c203ac650e352f4cc675a7021e7d1b3cf", + "reference": "cf1c2e7c203ac650e352f4cc675a7021e7d1b3cf", + "shasum": "" + }, + "require": { + "php": ">=7.3" + }, + "require-dev": { + "phpunit/phpunit": "^9.3" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "lead" + } + ], + "description": "FilterIterator implementation that filters files based on a list of suffixes.", + "homepage": "https://github.com/sebastianbergmann/php-file-iterator/", + "keywords": [ + "filesystem", + "iterator" + ], + "support": { + "issues": "https://github.com/sebastianbergmann/php-file-iterator/issues", + "source": "https://github.com/sebastianbergmann/php-file-iterator/tree/3.0.6" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2021-12-02T12:48:52+00:00" + }, + { + "name": "phpunit/php-invoker", + "version": "3.1.1", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/php-invoker.git", + "reference": "5a10147d0aaf65b58940a0b72f71c9ac0423cc67" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/php-invoker/zipball/5a10147d0aaf65b58940a0b72f71c9ac0423cc67", + "reference": "5a10147d0aaf65b58940a0b72f71c9ac0423cc67", + "shasum": "" + }, + "require": { + "php": ">=7.3" + }, + "require-dev": { + "ext-pcntl": "*", + "phpunit/phpunit": "^9.3" + }, + "suggest": { + "ext-pcntl": "*" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.1-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "lead" + } + ], + "description": "Invoke callables with a timeout", + "homepage": "https://github.com/sebastianbergmann/php-invoker/", + "keywords": [ + "process" + ], + "support": { + "issues": "https://github.com/sebastianbergmann/php-invoker/issues", + "source": "https://github.com/sebastianbergmann/php-invoker/tree/3.1.1" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2020-09-28T05:58:55+00:00" + }, + { + "name": "phpunit/php-text-template", + "version": "2.0.4", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/php-text-template.git", + "reference": "5da5f67fc95621df9ff4c4e5a84d6a8a2acf7c28" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/php-text-template/zipball/5da5f67fc95621df9ff4c4e5a84d6a8a2acf7c28", + "reference": "5da5f67fc95621df9ff4c4e5a84d6a8a2acf7c28", + "shasum": "" + }, + "require": { + "php": ">=7.3" + }, + "require-dev": { + "phpunit/phpunit": "^9.3" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "lead" + } + ], + "description": "Simple template engine.", + "homepage": "https://github.com/sebastianbergmann/php-text-template/", + "keywords": [ + "template" + ], + "support": { + "issues": "https://github.com/sebastianbergmann/php-text-template/issues", + "source": "https://github.com/sebastianbergmann/php-text-template/tree/2.0.4" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2020-10-26T05:33:50+00:00" + }, + { + "name": "phpunit/php-timer", + "version": "5.0.3", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/php-timer.git", + "reference": "5a63ce20ed1b5bf577850e2c4e87f4aa902afbd2" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/php-timer/zipball/5a63ce20ed1b5bf577850e2c4e87f4aa902afbd2", + "reference": "5a63ce20ed1b5bf577850e2c4e87f4aa902afbd2", + "shasum": "" + }, + "require": { + "php": ">=7.3" + }, + "require-dev": { + "phpunit/phpunit": "^9.3" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "5.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "lead" + } + ], + "description": "Utility class for timing", + "homepage": "https://github.com/sebastianbergmann/php-timer/", + "keywords": [ + "timer" + ], + "support": { + "issues": "https://github.com/sebastianbergmann/php-timer/issues", + "source": "https://github.com/sebastianbergmann/php-timer/tree/5.0.3" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2020-10-26T13:16:10+00:00" + }, + { + "name": "phpunit/phpunit", + "version": "9.6.35", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/phpunit.git", + "reference": "0edba2f3a0c48df3553cb9b640810b30df60302b" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/0edba2f3a0c48df3553cb9b640810b30df60302b", + "reference": "0edba2f3a0c48df3553cb9b640810b30df60302b", + "shasum": "" + }, + "require": { + "doctrine/instantiator": "^1.5.0 || ^2", + "ext-dom": "*", + "ext-filter": "*", + "ext-json": "*", + "ext-libxml": "*", + "ext-mbstring": "*", + "ext-xmlwriter": "*", + "myclabs/deep-copy": "^1.13.4", + "phar-io/manifest": "^2.0.4", + "phar-io/version": "^3.2.1", + "php": ">=7.3", + "phpunit/php-code-coverage": "^9.2.32", + "phpunit/php-file-iterator": "^3.0.6", + "phpunit/php-invoker": "^3.1.1", + "phpunit/php-text-template": "^2.0.4", + "phpunit/php-timer": "^5.0.3", + "sebastian/cli-parser": "^1.0.2", + "sebastian/code-unit": "^1.0.8", + "sebastian/comparator": "^4.0.10", + "sebastian/diff": "^4.0.6", + "sebastian/environment": "^5.1.5", + "sebastian/exporter": "^4.0.8", + "sebastian/global-state": "^5.0.8", + "sebastian/object-enumerator": "^4.0.4", + "sebastian/resource-operations": "^3.0.4", + "sebastian/type": "^3.2.1", + "sebastian/version": "^3.0.2" + }, + "suggest": { + "ext-soap": "To be able to generate mocks based on WSDL files", + "ext-xdebug": "PHP extension that provides line coverage as well as branch and path coverage" + }, + "bin": [ + "phpunit" + ], + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "9.6-dev" + } + }, + "autoload": { + "files": [ + "src/Framework/Assert/Functions.php" + ], + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "lead" + } + ], + "description": "The PHP Unit Testing framework.", + "homepage": "https://phpunit.de/", + "keywords": [ + "phpunit", + "testing", + "xunit" + ], + "support": { + "issues": "https://github.com/sebastianbergmann/phpunit/issues", + "security": "https://github.com/sebastianbergmann/phpunit/security/policy", + "source": "https://github.com/sebastianbergmann/phpunit/tree/9.6.35" + }, + "funding": [ + { + "url": "https://phpunit.de/sponsoring.html", + "type": "other" + } + ], + "time": "2026-07-06T14:48:07+00:00" + }, + { + "name": "psr/container", + "version": "1.1.2", + "source": { + "type": "git", + "url": "https://github.com/php-fig/container.git", + "reference": "513e0666f7216c7459170d56df27dfcefe1689ea" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-fig/container/zipball/513e0666f7216c7459170d56df27dfcefe1689ea", + "reference": "513e0666f7216c7459170d56df27dfcefe1689ea", + "shasum": "" + }, + "require": { + "php": ">=7.4.0" + }, + "type": "library", + "autoload": { + "psr-4": { + "Psr\\Container\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "PHP-FIG", + "homepage": "https://www.php-fig.org/" + } + ], + "description": "Common Container Interface (PHP FIG PSR-11)", + "homepage": "https://github.com/php-fig/container", + "keywords": [ + "PSR-11", + "container", + "container-interface", + "container-interop", + "psr" + ], + "support": { + "issues": "https://github.com/php-fig/container/issues", + "source": "https://github.com/php-fig/container/tree/1.1.2" + }, + "time": "2021-11-05T16:50:12+00:00" + }, + { + "name": "psr/log", + "version": "1.1.4", + "source": { + "type": "git", + "url": "https://github.com/php-fig/log.git", + "reference": "d49695b909c3b7628b6289db5479a1c204601f11" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-fig/log/zipball/d49695b909c3b7628b6289db5479a1c204601f11", + "reference": "d49695b909c3b7628b6289db5479a1c204601f11", + "shasum": "" + }, + "require": { + "php": ">=5.3.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.1.x-dev" + } + }, + "autoload": { + "psr-4": { + "Psr\\Log\\": "Psr/Log/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "PHP-FIG", + "homepage": "https://www.php-fig.org/" + } + ], + "description": "Common interface for logging libraries", + "homepage": "https://github.com/php-fig/log", + "keywords": [ + "log", + "psr", + "psr-3" + ], + "support": { + "source": "https://github.com/php-fig/log/tree/1.1.4" + }, + "time": "2021-05-03T11:20:27+00:00" + }, + { + "name": "sebastian/cli-parser", + "version": "1.0.2", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/cli-parser.git", + "reference": "2b56bea83a09de3ac06bb18b92f068e60cc6f50b" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/cli-parser/zipball/2b56bea83a09de3ac06bb18b92f068e60cc6f50b", + "reference": "2b56bea83a09de3ac06bb18b92f068e60cc6f50b", + "shasum": "" + }, + "require": { + "php": ">=7.3" + }, + "require-dev": { + "phpunit/phpunit": "^9.3" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "lead" + } + ], + "description": "Library for parsing CLI options", + "homepage": "https://github.com/sebastianbergmann/cli-parser", + "support": { + "issues": "https://github.com/sebastianbergmann/cli-parser/issues", + "source": "https://github.com/sebastianbergmann/cli-parser/tree/1.0.2" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2024-03-02T06:27:43+00:00" + }, + { + "name": "sebastian/code-unit", + "version": "1.0.8", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/code-unit.git", + "reference": "1fc9f64c0927627ef78ba436c9b17d967e68e120" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/code-unit/zipball/1fc9f64c0927627ef78ba436c9b17d967e68e120", + "reference": "1fc9f64c0927627ef78ba436c9b17d967e68e120", + "shasum": "" + }, + "require": { + "php": ">=7.3" + }, + "require-dev": { + "phpunit/phpunit": "^9.3" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "lead" + } + ], + "description": "Collection of value objects that represent the PHP code units", + "homepage": "https://github.com/sebastianbergmann/code-unit", + "support": { + "issues": "https://github.com/sebastianbergmann/code-unit/issues", + "source": "https://github.com/sebastianbergmann/code-unit/tree/1.0.8" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2020-10-26T13:08:54+00:00" + }, + { + "name": "sebastian/code-unit-reverse-lookup", + "version": "2.0.3", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/code-unit-reverse-lookup.git", + "reference": "ac91f01ccec49fb77bdc6fd1e548bc70f7faa3e5" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/code-unit-reverse-lookup/zipball/ac91f01ccec49fb77bdc6fd1e548bc70f7faa3e5", + "reference": "ac91f01ccec49fb77bdc6fd1e548bc70f7faa3e5", + "shasum": "" + }, + "require": { + "php": ">=7.3" + }, + "require-dev": { + "phpunit/phpunit": "^9.3" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + } + ], + "description": "Looks up which function or method a line of code belongs to", + "homepage": "https://github.com/sebastianbergmann/code-unit-reverse-lookup/", + "support": { + "issues": "https://github.com/sebastianbergmann/code-unit-reverse-lookup/issues", + "source": "https://github.com/sebastianbergmann/code-unit-reverse-lookup/tree/2.0.3" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2020-09-28T05:30:19+00:00" + }, + { + "name": "sebastian/comparator", + "version": "4.0.10", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/comparator.git", + "reference": "e4df00b9b3571187db2831ae9aada2c6efbd715d" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/comparator/zipball/e4df00b9b3571187db2831ae9aada2c6efbd715d", + "reference": "e4df00b9b3571187db2831ae9aada2c6efbd715d", + "shasum": "" + }, + "require": { + "php": ">=7.3", + "sebastian/diff": "^4.0", + "sebastian/exporter": "^4.0" + }, + "require-dev": { + "phpunit/phpunit": "^9.3" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "4.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + }, + { + "name": "Jeff Welch", + "email": "whatthejeff@gmail.com" + }, + { + "name": "Volker Dusch", + "email": "github@wallbash.com" + }, + { + "name": "Bernhard Schussek", + "email": "bschussek@2bepublished.at" + } + ], + "description": "Provides the functionality to compare PHP values for equality", + "homepage": "https://github.com/sebastianbergmann/comparator", + "keywords": [ + "comparator", + "compare", + "equality" + ], + "support": { + "issues": "https://github.com/sebastianbergmann/comparator/issues", + "source": "https://github.com/sebastianbergmann/comparator/tree/4.0.10" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + }, + { + "url": "https://liberapay.com/sebastianbergmann", + "type": "liberapay" + }, + { + "url": "https://thanks.dev/u/gh/sebastianbergmann", + "type": "thanks_dev" + }, + { + "url": "https://tidelift.com/funding/github/packagist/sebastian/comparator", + "type": "tidelift" + } + ], + "time": "2026-01-24T09:22:56+00:00" + }, + { + "name": "sebastian/complexity", + "version": "2.0.3", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/complexity.git", + "reference": "25f207c40d62b8b7aa32f5ab026c53561964053a" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/complexity/zipball/25f207c40d62b8b7aa32f5ab026c53561964053a", + "reference": "25f207c40d62b8b7aa32f5ab026c53561964053a", + "shasum": "" + }, + "require": { + "nikic/php-parser": "^4.18 || ^5.0", + "php": ">=7.3" + }, + "require-dev": { + "phpunit/phpunit": "^9.3" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "lead" + } + ], + "description": "Library for calculating the complexity of PHP code units", + "homepage": "https://github.com/sebastianbergmann/complexity", + "support": { + "issues": "https://github.com/sebastianbergmann/complexity/issues", + "source": "https://github.com/sebastianbergmann/complexity/tree/2.0.3" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2023-12-22T06:19:30+00:00" + }, + { + "name": "sebastian/diff", + "version": "4.0.6", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/diff.git", + "reference": "ba01945089c3a293b01ba9badc29ad55b106b0bc" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/diff/zipball/ba01945089c3a293b01ba9badc29ad55b106b0bc", + "reference": "ba01945089c3a293b01ba9badc29ad55b106b0bc", + "shasum": "" + }, + "require": { + "php": ">=7.3" + }, + "require-dev": { + "phpunit/phpunit": "^9.3", + "symfony/process": "^4.2 || ^5" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "4.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + }, + { + "name": "Kore Nordmann", + "email": "mail@kore-nordmann.de" + } + ], + "description": "Diff implementation", + "homepage": "https://github.com/sebastianbergmann/diff", + "keywords": [ + "diff", + "udiff", + "unidiff", + "unified diff" + ], + "support": { + "issues": "https://github.com/sebastianbergmann/diff/issues", + "source": "https://github.com/sebastianbergmann/diff/tree/4.0.6" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2024-03-02T06:30:58+00:00" + }, + { + "name": "sebastian/environment", + "version": "5.1.5", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/environment.git", + "reference": "830c43a844f1f8d5b7a1f6d6076b784454d8b7ed" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/environment/zipball/830c43a844f1f8d5b7a1f6d6076b784454d8b7ed", + "reference": "830c43a844f1f8d5b7a1f6d6076b784454d8b7ed", + "shasum": "" + }, + "require": { + "php": ">=7.3" + }, + "require-dev": { + "phpunit/phpunit": "^9.3" + }, + "suggest": { + "ext-posix": "*" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "5.1-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + } + ], + "description": "Provides functionality to handle HHVM/PHP environments", + "homepage": "http://www.github.com/sebastianbergmann/environment", + "keywords": [ + "Xdebug", + "environment", + "hhvm" + ], + "support": { + "issues": "https://github.com/sebastianbergmann/environment/issues", + "source": "https://github.com/sebastianbergmann/environment/tree/5.1.5" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2023-02-03T06:03:51+00:00" + }, + { + "name": "sebastian/exporter", + "version": "4.0.8", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/exporter.git", + "reference": "14c6ba52f95a36c3d27c835d65efc7123c446e8c" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/exporter/zipball/14c6ba52f95a36c3d27c835d65efc7123c446e8c", + "reference": "14c6ba52f95a36c3d27c835d65efc7123c446e8c", + "shasum": "" + }, + "require": { + "php": ">=7.3", + "sebastian/recursion-context": "^4.0" + }, + "require-dev": { + "ext-mbstring": "*", + "phpunit/phpunit": "^9.3" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "4.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + }, + { + "name": "Jeff Welch", + "email": "whatthejeff@gmail.com" + }, + { + "name": "Volker Dusch", + "email": "github@wallbash.com" + }, + { + "name": "Adam Harvey", + "email": "aharvey@php.net" + }, + { + "name": "Bernhard Schussek", + "email": "bschussek@gmail.com" + } + ], + "description": "Provides the functionality to export PHP variables for visualization", + "homepage": "https://www.github.com/sebastianbergmann/exporter", + "keywords": [ + "export", + "exporter" + ], + "support": { + "issues": "https://github.com/sebastianbergmann/exporter/issues", + "source": "https://github.com/sebastianbergmann/exporter/tree/4.0.8" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + }, + { + "url": "https://liberapay.com/sebastianbergmann", + "type": "liberapay" + }, + { + "url": "https://thanks.dev/u/gh/sebastianbergmann", + "type": "thanks_dev" + }, + { + "url": "https://tidelift.com/funding/github/packagist/sebastian/exporter", + "type": "tidelift" + } + ], + "time": "2025-09-24T06:03:27+00:00" + }, + { + "name": "sebastian/global-state", + "version": "5.0.8", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/global-state.git", + "reference": "b6781316bdcd28260904e7cc18ec983d0d2ef4f6" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/global-state/zipball/b6781316bdcd28260904e7cc18ec983d0d2ef4f6", + "reference": "b6781316bdcd28260904e7cc18ec983d0d2ef4f6", + "shasum": "" + }, + "require": { + "php": ">=7.3", + "sebastian/object-reflector": "^2.0", + "sebastian/recursion-context": "^4.0" + }, + "require-dev": { + "ext-dom": "*", + "phpunit/phpunit": "^9.3" + }, + "suggest": { + "ext-uopz": "*" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "5.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + } + ], + "description": "Snapshotting of global state", + "homepage": "http://www.github.com/sebastianbergmann/global-state", + "keywords": [ + "global state" + ], + "support": { + "issues": "https://github.com/sebastianbergmann/global-state/issues", + "source": "https://github.com/sebastianbergmann/global-state/tree/5.0.8" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + }, + { + "url": "https://liberapay.com/sebastianbergmann", + "type": "liberapay" + }, + { + "url": "https://thanks.dev/u/gh/sebastianbergmann", + "type": "thanks_dev" + }, + { + "url": "https://tidelift.com/funding/github/packagist/sebastian/global-state", + "type": "tidelift" + } + ], + "time": "2025-08-10T07:10:35+00:00" + }, + { + "name": "sebastian/lines-of-code", + "version": "1.0.4", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/lines-of-code.git", + "reference": "e1e4a170560925c26d424b6a03aed157e7dcc5c5" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/lines-of-code/zipball/e1e4a170560925c26d424b6a03aed157e7dcc5c5", + "reference": "e1e4a170560925c26d424b6a03aed157e7dcc5c5", + "shasum": "" + }, + "require": { + "nikic/php-parser": "^4.18 || ^5.0", + "php": ">=7.3" + }, + "require-dev": { + "phpunit/phpunit": "^9.3" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "lead" + } + ], + "description": "Library for counting the lines of code in PHP source code", + "homepage": "https://github.com/sebastianbergmann/lines-of-code", + "support": { + "issues": "https://github.com/sebastianbergmann/lines-of-code/issues", + "source": "https://github.com/sebastianbergmann/lines-of-code/tree/1.0.4" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2023-12-22T06:20:34+00:00" + }, + { + "name": "sebastian/object-enumerator", + "version": "4.0.4", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/object-enumerator.git", + "reference": "5c9eeac41b290a3712d88851518825ad78f45c71" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/object-enumerator/zipball/5c9eeac41b290a3712d88851518825ad78f45c71", + "reference": "5c9eeac41b290a3712d88851518825ad78f45c71", + "shasum": "" + }, + "require": { + "php": ">=7.3", + "sebastian/object-reflector": "^2.0", + "sebastian/recursion-context": "^4.0" + }, + "require-dev": { + "phpunit/phpunit": "^9.3" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "4.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + } + ], + "description": "Traverses array structures and object graphs to enumerate all referenced objects", + "homepage": "https://github.com/sebastianbergmann/object-enumerator/", + "support": { + "issues": "https://github.com/sebastianbergmann/object-enumerator/issues", + "source": "https://github.com/sebastianbergmann/object-enumerator/tree/4.0.4" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2020-10-26T13:12:34+00:00" + }, + { + "name": "sebastian/object-reflector", + "version": "2.0.4", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/object-reflector.git", + "reference": "b4f479ebdbf63ac605d183ece17d8d7fe49c15c7" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/object-reflector/zipball/b4f479ebdbf63ac605d183ece17d8d7fe49c15c7", + "reference": "b4f479ebdbf63ac605d183ece17d8d7fe49c15c7", + "shasum": "" + }, + "require": { + "php": ">=7.3" + }, + "require-dev": { + "phpunit/phpunit": "^9.3" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + } + ], + "description": "Allows reflection of object attributes, including inherited and non-public ones", + "homepage": "https://github.com/sebastianbergmann/object-reflector/", + "support": { + "issues": "https://github.com/sebastianbergmann/object-reflector/issues", + "source": "https://github.com/sebastianbergmann/object-reflector/tree/2.0.4" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2020-10-26T13:14:26+00:00" + }, + { + "name": "sebastian/recursion-context", + "version": "4.0.6", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/recursion-context.git", + "reference": "539c6691e0623af6dc6f9c20384c120f963465a0" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/recursion-context/zipball/539c6691e0623af6dc6f9c20384c120f963465a0", + "reference": "539c6691e0623af6dc6f9c20384c120f963465a0", + "shasum": "" + }, + "require": { + "php": ">=7.3" + }, + "require-dev": { + "phpunit/phpunit": "^9.3" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "4.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + }, + { + "name": "Jeff Welch", + "email": "whatthejeff@gmail.com" + }, + { + "name": "Adam Harvey", + "email": "aharvey@php.net" + } + ], + "description": "Provides functionality to recursively process PHP variables", + "homepage": "https://github.com/sebastianbergmann/recursion-context", + "support": { + "issues": "https://github.com/sebastianbergmann/recursion-context/issues", + "source": "https://github.com/sebastianbergmann/recursion-context/tree/4.0.6" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + }, + { + "url": "https://liberapay.com/sebastianbergmann", + "type": "liberapay" + }, + { + "url": "https://thanks.dev/u/gh/sebastianbergmann", + "type": "thanks_dev" + }, + { + "url": "https://tidelift.com/funding/github/packagist/sebastian/recursion-context", + "type": "tidelift" + } + ], + "time": "2025-08-10T06:57:39+00:00" + }, + { + "name": "sebastian/resource-operations", + "version": "3.0.4", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/resource-operations.git", + "reference": "05d5692a7993ecccd56a03e40cd7e5b09b1d404e" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/resource-operations/zipball/05d5692a7993ecccd56a03e40cd7e5b09b1d404e", + "reference": "05d5692a7993ecccd56a03e40cd7e5b09b1d404e", + "shasum": "" + }, + "require": { + "php": ">=7.3" + }, + "require-dev": { + "phpunit/phpunit": "^9.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "3.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + } + ], + "description": "Provides a list of PHP built-in functions that operate on resources", + "homepage": "https://www.github.com/sebastianbergmann/resource-operations", + "support": { + "source": "https://github.com/sebastianbergmann/resource-operations/tree/3.0.4" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2024-03-14T16:00:52+00:00" + }, + { + "name": "sebastian/type", + "version": "3.2.1", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/type.git", + "reference": "75e2c2a32f5e0b3aef905b9ed0b179b953b3d7c7" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/type/zipball/75e2c2a32f5e0b3aef905b9ed0b179b953b3d7c7", + "reference": "75e2c2a32f5e0b3aef905b9ed0b179b953b3d7c7", + "shasum": "" + }, + "require": { + "php": ">=7.3" + }, + "require-dev": { + "phpunit/phpunit": "^9.5" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.2-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "lead" + } + ], + "description": "Collection of value objects that represent the types of the PHP type system", + "homepage": "https://github.com/sebastianbergmann/type", + "support": { + "issues": "https://github.com/sebastianbergmann/type/issues", + "source": "https://github.com/sebastianbergmann/type/tree/3.2.1" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2023-02-03T06:13:03+00:00" + }, + { + "name": "sebastian/version", + "version": "3.0.2", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/version.git", + "reference": "c6c1022351a901512170118436c764e473f6de8c" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/version/zipball/c6c1022351a901512170118436c764e473f6de8c", + "reference": "c6c1022351a901512170118436c764e473f6de8c", + "shasum": "" + }, + "require": { + "php": ">=7.3" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "lead" + } + ], + "description": "Library that helps with managing the version number of Git-hosted PHP projects", + "homepage": "https://github.com/sebastianbergmann/version", + "support": { + "issues": "https://github.com/sebastianbergmann/version/issues", + "source": "https://github.com/sebastianbergmann/version/tree/3.0.2" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2020-09-28T06:39:44+00:00" + }, + { + "name": "spatie/array-to-xml", + "version": "2.17.1", + "source": { + "type": "git", + "url": "https://github.com/spatie/array-to-xml.git", + "reference": "5cbec9c6ab17e320c58a259f0cebe88bde4a7c46" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/spatie/array-to-xml/zipball/5cbec9c6ab17e320c58a259f0cebe88bde4a7c46", + "reference": "5cbec9c6ab17e320c58a259f0cebe88bde4a7c46", + "shasum": "" + }, + "require": { + "ext-dom": "*", + "php": "^7.4|^8.0" + }, + "require-dev": { + "mockery/mockery": "^1.2", + "pestphp/pest": "^1.21", + "phpunit/phpunit": "^9.0", + "spatie/pest-plugin-snapshots": "^1.1" + }, + "type": "library", + "autoload": { + "psr-4": { + "Spatie\\ArrayToXml\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Freek Van der Herten", + "email": "freek@spatie.be", + "homepage": "https://freek.dev", + "role": "Developer" + } + ], + "description": "Convert an array to xml", + "homepage": "https://github.com/spatie/array-to-xml", + "keywords": [ + "array", + "convert", + "xml" + ], + "support": { + "source": "https://github.com/spatie/array-to-xml/tree/2.17.1" + }, + "funding": [ + { + "url": "https://spatie.be/open-source/support-us", + "type": "custom" + }, + { + "url": "https://github.com/spatie", + "type": "github" + } + ], + "time": "2022-12-26T08:22:07+00:00" + }, + { + "name": "symfony/console", + "version": "v5.4.47", + "source": { + "type": "git", + "url": "https://github.com/symfony/console.git", + "reference": "c4ba980ca61a9eb18ee6bcc73f28e475852bb1ed" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/console/zipball/c4ba980ca61a9eb18ee6bcc73f28e475852bb1ed", + "reference": "c4ba980ca61a9eb18ee6bcc73f28e475852bb1ed", + "shasum": "" + }, + "require": { + "php": ">=7.2.5", + "symfony/deprecation-contracts": "^2.1|^3", + "symfony/polyfill-mbstring": "~1.0", + "symfony/polyfill-php73": "^1.9", + "symfony/polyfill-php80": "^1.16", + "symfony/service-contracts": "^1.1|^2|^3", + "symfony/string": "^5.1|^6.0" + }, + "conflict": { + "psr/log": ">=3", + "symfony/dependency-injection": "<4.4", + "symfony/dotenv": "<5.1", + "symfony/event-dispatcher": "<4.4", + "symfony/lock": "<4.4", + "symfony/process": "<4.4" + }, + "provide": { + "psr/log-implementation": "1.0|2.0" + }, + "require-dev": { + "psr/log": "^1|^2", + "symfony/config": "^4.4|^5.0|^6.0", + "symfony/dependency-injection": "^4.4|^5.0|^6.0", + "symfony/event-dispatcher": "^4.4|^5.0|^6.0", + "symfony/lock": "^4.4|^5.0|^6.0", + "symfony/process": "^4.4|^5.0|^6.0", + "symfony/var-dumper": "^4.4|^5.0|^6.0" + }, + "suggest": { + "psr/log": "For using the console logger", + "symfony/event-dispatcher": "", + "symfony/lock": "", + "symfony/process": "" + }, + "type": "library", + "autoload": { + "psr-4": { + "Symfony\\Component\\Console\\": "" + }, + "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": "Eases the creation of beautiful and testable command line interfaces", + "homepage": "https://symfony.com", + "keywords": [ + "cli", + "command-line", + "console", + "terminal" + ], + "support": { + "source": "https://github.com/symfony/console/tree/v5.4.47" + }, + "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": "2024-11-06T11:30:55+00:00" + }, + { + "name": "symfony/deprecation-contracts", + "version": "v2.5.4", + "source": { + "type": "git", + "url": "https://github.com/symfony/deprecation-contracts.git", + "reference": "605389f2a7e5625f273b53960dc46aeaf9c62918" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/deprecation-contracts/zipball/605389f2a7e5625f273b53960dc46aeaf9c62918", + "reference": "605389f2a7e5625f273b53960dc46aeaf9c62918", + "shasum": "" + }, + "require": { + "php": ">=7.1" + }, + "type": "library", + "extra": { + "thanks": { + "url": "https://github.com/symfony/contracts", + "name": "symfony/contracts" + }, + "branch-alias": { + "dev-main": "2.5-dev" + } + }, + "autoload": { + "files": [ + "function.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "A generic function and convention to trigger deprecation notices", + "homepage": "https://symfony.com", + "support": { + "source": "https://github.com/symfony/deprecation-contracts/tree/v2.5.4" + }, + "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": "2024-09-25T14:11:13+00:00" + }, + { + "name": "symfony/filesystem", + "version": "v5.4.45", + "source": { + "type": "git", + "url": "https://github.com/symfony/filesystem.git", + "reference": "57c8294ed37d4a055b77057827c67f9558c95c54" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/filesystem/zipball/57c8294ed37d4a055b77057827c67f9558c95c54", + "reference": "57c8294ed37d4a055b77057827c67f9558c95c54", + "shasum": "" + }, + "require": { + "php": ">=7.2.5", + "symfony/polyfill-ctype": "~1.8", + "symfony/polyfill-mbstring": "~1.8", + "symfony/polyfill-php80": "^1.16" + }, + "require-dev": { + "symfony/process": "^5.4|^6.4" + }, + "type": "library", + "autoload": { + "psr-4": { + "Symfony\\Component\\Filesystem\\": "" + }, + "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": "Provides basic utilities for the filesystem", + "homepage": "https://symfony.com", + "support": { + "source": "https://github.com/symfony/filesystem/tree/v5.4.45" + }, + "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": "2024-10-22T13:05:35+00:00" + }, + { + "name": "symfony/polyfill-ctype", + "version": "v1.37.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/polyfill-ctype.git", + "reference": "141046a8f9477948ff284fa65be2095baafb94f2" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/141046a8f9477948ff284fa65be2095baafb94f2", + "reference": "141046a8f9477948ff284fa65be2095baafb94f2", + "shasum": "" + }, + "require": { + "php": ">=7.2" + }, + "provide": { + "ext-ctype": "*" + }, + "suggest": { + "ext-ctype": "For best performance" + }, + "type": "library", + "extra": { + "thanks": { + "url": "https://github.com/symfony/polyfill", + "name": "symfony/polyfill" + } + }, + "autoload": { + "files": [ + "bootstrap.php" + ], + "psr-4": { + "Symfony\\Polyfill\\Ctype\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Gert de Pagter", + "email": "BackEndTea@gmail.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony polyfill for ctype functions", + "homepage": "https://symfony.com", + "keywords": [ + "compatibility", + "ctype", + "polyfill", + "portable" + ], + "support": { + "source": "https://github.com/symfony/polyfill-ctype/tree/v1.37.0" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://github.com/nicolas-grekas", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2026-04-10T16:19:22+00:00" + }, + { + "name": "symfony/polyfill-intl-grapheme", + "version": "v1.38.1", + "source": { + "type": "git", + "url": "https://github.com/symfony/polyfill-intl-grapheme.git", + "reference": "e9247d281d694a5120554d9afaf54e070e88a603" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/polyfill-intl-grapheme/zipball/e9247d281d694a5120554d9afaf54e070e88a603", + "reference": "e9247d281d694a5120554d9afaf54e070e88a603", + "shasum": "" + }, + "require": { + "php": ">=7.2" + }, + "suggest": { + "ext-intl": "For best performance" + }, + "type": "library", + "extra": { + "thanks": { + "url": "https://github.com/symfony/polyfill", + "name": "symfony/polyfill" + } + }, + "autoload": { + "files": [ + "bootstrap.php" + ], + "psr-4": { + "Symfony\\Polyfill\\Intl\\Grapheme\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony polyfill for intl's grapheme_* functions", + "homepage": "https://symfony.com", + "keywords": [ + "compatibility", + "grapheme", + "intl", + "polyfill", + "portable", + "shim" + ], + "support": { + "source": "https://github.com/symfony/polyfill-intl-grapheme/tree/v1.38.1" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://github.com/nicolas-grekas", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2026-05-26T05:58:03+00:00" + }, + { + "name": "symfony/polyfill-intl-normalizer", + "version": "v1.38.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/polyfill-intl-normalizer.git", + "reference": "2d446c214bdbe5b71bde5011b060a05fece3ae6b" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/polyfill-intl-normalizer/zipball/2d446c214bdbe5b71bde5011b060a05fece3ae6b", + "reference": "2d446c214bdbe5b71bde5011b060a05fece3ae6b", + "shasum": "" + }, + "require": { + "php": ">=7.2" + }, + "suggest": { + "ext-intl": "For best performance" + }, + "type": "library", + "extra": { + "thanks": { + "url": "https://github.com/symfony/polyfill", + "name": "symfony/polyfill" + } + }, + "autoload": { + "files": [ + "bootstrap.php" + ], + "psr-4": { + "Symfony\\Polyfill\\Intl\\Normalizer\\": "" + }, + "classmap": [ + "Resources/stubs" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony polyfill for intl's Normalizer class and related functions", + "homepage": "https://symfony.com", + "keywords": [ + "compatibility", + "intl", + "normalizer", + "polyfill", + "portable", + "shim" + ], + "support": { + "source": "https://github.com/symfony/polyfill-intl-normalizer/tree/v1.38.0" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://github.com/nicolas-grekas", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2026-05-25T13:48:31+00:00" + }, + { + "name": "symfony/polyfill-mbstring", + "version": "v1.38.2", + "source": { + "type": "git", + "url": "https://github.com/symfony/polyfill-mbstring.git", + "reference": "d3d318bad5e7a1bfbd026009c8bfb8d8f99ae6b6" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/d3d318bad5e7a1bfbd026009c8bfb8d8f99ae6b6", + "reference": "d3d318bad5e7a1bfbd026009c8bfb8d8f99ae6b6", + "shasum": "" + }, + "require": { + "ext-iconv": "*", + "php": ">=7.2" + }, + "provide": { + "ext-mbstring": "*" + }, + "suggest": { + "ext-mbstring": "For best performance" + }, + "type": "library", + "extra": { + "thanks": { + "url": "https://github.com/symfony/polyfill", + "name": "symfony/polyfill" + } + }, + "autoload": { + "files": [ + "bootstrap.php" + ], + "psr-4": { + "Symfony\\Polyfill\\Mbstring\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony polyfill for the Mbstring extension", + "homepage": "https://symfony.com", + "keywords": [ + "compatibility", + "mbstring", + "polyfill", + "portable", + "shim" + ], + "support": { + "source": "https://github.com/symfony/polyfill-mbstring/tree/v1.38.2" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://github.com/nicolas-grekas", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2026-05-27T06:59:30+00:00" + }, + { + "name": "symfony/polyfill-php73", + "version": "v1.37.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/polyfill-php73.git", + "reference": "0f68c03565dcaaf25a890667542e8bd75fe7e5bb" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/polyfill-php73/zipball/0f68c03565dcaaf25a890667542e8bd75fe7e5bb", + "reference": "0f68c03565dcaaf25a890667542e8bd75fe7e5bb", + "shasum": "" + }, + "require": { + "php": ">=7.2" + }, + "type": "library", + "extra": { + "thanks": { + "url": "https://github.com/symfony/polyfill", + "name": "symfony/polyfill" + } + }, + "autoload": { + "files": [ + "bootstrap.php" + ], + "psr-4": { + "Symfony\\Polyfill\\Php73\\": "" + }, + "classmap": [ + "Resources/stubs" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony polyfill backporting some PHP 7.3+ features to lower PHP versions", + "homepage": "https://symfony.com", + "keywords": [ + "compatibility", + "polyfill", + "portable", + "shim" + ], + "support": { + "source": "https://github.com/symfony/polyfill-php73/tree/v1.37.0" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://github.com/nicolas-grekas", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2024-09-09T11:45:10+00:00" + }, + { + "name": "symfony/polyfill-php80", + "version": "v1.37.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/polyfill-php80.git", + "reference": "dfb55726c3a76ea3b6459fcfda1ec2d80a682411" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/polyfill-php80/zipball/dfb55726c3a76ea3b6459fcfda1ec2d80a682411", + "reference": "dfb55726c3a76ea3b6459fcfda1ec2d80a682411", + "shasum": "" + }, + "require": { + "php": ">=7.2" + }, + "type": "library", + "extra": { + "thanks": { + "url": "https://github.com/symfony/polyfill", + "name": "symfony/polyfill" + } + }, + "autoload": { + "files": [ + "bootstrap.php" + ], + "psr-4": { + "Symfony\\Polyfill\\Php80\\": "" + }, + "classmap": [ + "Resources/stubs" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Ion Bazan", + "email": "ion.bazan@gmail.com" + }, + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony polyfill backporting some PHP 8.0+ features to lower PHP versions", + "homepage": "https://symfony.com", + "keywords": [ + "compatibility", + "polyfill", + "portable", + "shim" + ], + "support": { + "source": "https://github.com/symfony/polyfill-php80/tree/v1.37.0" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://github.com/nicolas-grekas", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2026-04-10T16:19:22+00:00" + }, + { + "name": "symfony/service-contracts", + "version": "v2.5.4", + "source": { + "type": "git", + "url": "https://github.com/symfony/service-contracts.git", + "reference": "f37b419f7aea2e9abf10abd261832cace12e3300" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/service-contracts/zipball/f37b419f7aea2e9abf10abd261832cace12e3300", + "reference": "f37b419f7aea2e9abf10abd261832cace12e3300", + "shasum": "" + }, + "require": { + "php": ">=7.2.5", + "psr/container": "^1.1", + "symfony/deprecation-contracts": "^2.1|^3" + }, + "conflict": { + "ext-psr": "<1.1|>=2" + }, + "suggest": { + "symfony/service-implementation": "" + }, + "type": "library", + "extra": { + "thanks": { + "url": "https://github.com/symfony/contracts", + "name": "symfony/contracts" + }, + "branch-alias": { + "dev-main": "2.5-dev" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Contracts\\Service\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Generic abstractions related to writing services", + "homepage": "https://symfony.com", + "keywords": [ + "abstractions", + "contracts", + "decoupling", + "interfaces", + "interoperability", + "standards" + ], + "support": { + "source": "https://github.com/symfony/service-contracts/tree/v2.5.4" + }, + "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": "2024-09-25T14:11:13+00:00" + }, + { + "name": "symfony/string", + "version": "v5.4.47", + "source": { + "type": "git", + "url": "https://github.com/symfony/string.git", + "reference": "136ca7d72f72b599f2631aca474a4f8e26719799" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/string/zipball/136ca7d72f72b599f2631aca474a4f8e26719799", + "reference": "136ca7d72f72b599f2631aca474a4f8e26719799", + "shasum": "" + }, + "require": { + "php": ">=7.2.5", + "symfony/polyfill-ctype": "~1.8", + "symfony/polyfill-intl-grapheme": "~1.0", + "symfony/polyfill-intl-normalizer": "~1.0", + "symfony/polyfill-mbstring": "~1.0", + "symfony/polyfill-php80": "~1.15" + }, + "conflict": { + "symfony/translation-contracts": ">=3.0" + }, + "require-dev": { + "symfony/error-handler": "^4.4|^5.0|^6.0", + "symfony/http-client": "^4.4|^5.0|^6.0", + "symfony/translation-contracts": "^1.1|^2", + "symfony/var-exporter": "^4.4|^5.0|^6.0" + }, + "type": "library", + "autoload": { + "files": [ + "Resources/functions.php" + ], + "psr-4": { + "Symfony\\Component\\String\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Provides an object-oriented API to strings and deals with bytes, UTF-8 code points and grapheme clusters in a unified way", + "homepage": "https://symfony.com", + "keywords": [ + "grapheme", + "i18n", + "string", + "unicode", + "utf-8", + "utf8" + ], + "support": { + "source": "https://github.com/symfony/string/tree/v5.4.47" + }, + "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": "2024-11-10T20:33:58+00:00" + }, + { + "name": "theseer/tokenizer", + "version": "1.3.1", + "source": { + "type": "git", + "url": "https://github.com/theseer/tokenizer.git", + "reference": "b7489ce515e168639d17feec34b8847c326b0b3c" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/theseer/tokenizer/zipball/b7489ce515e168639d17feec34b8847c326b0b3c", + "reference": "b7489ce515e168639d17feec34b8847c326b0b3c", + "shasum": "" + }, + "require": { + "ext-dom": "*", + "ext-tokenizer": "*", + "ext-xmlwriter": "*", + "php": "^7.2 || ^8.0" + }, + "type": "library", + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Arne Blankerts", + "email": "arne@blankerts.de", + "role": "Developer" + } + ], + "description": "A small library for converting tokenized PHP source code into XML and potentially other formats", + "support": { + "issues": "https://github.com/theseer/tokenizer/issues", + "source": "https://github.com/theseer/tokenizer/tree/1.3.1" + }, + "funding": [ + { + "url": "https://github.com/theseer", + "type": "github" + } + ], + "time": "2025-11-17T20:03:58+00:00" + }, + { + "name": "vimeo/psalm", + "version": "5.26.1", + "source": { + "type": "git", + "url": "https://github.com/vimeo/psalm.git", + "reference": "d747f6500b38ac4f7dfc5edbcae6e4b637d7add0" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/vimeo/psalm/zipball/d747f6500b38ac4f7dfc5edbcae6e4b637d7add0", + "reference": "d747f6500b38ac4f7dfc5edbcae6e4b637d7add0", + "shasum": "" + }, + "require": { + "amphp/amp": "^2.4.2", + "amphp/byte-stream": "^1.5", + "composer-runtime-api": "^2", + "composer/semver": "^1.4 || ^2.0 || ^3.0", + "composer/xdebug-handler": "^2.0 || ^3.0", + "dnoegel/php-xdg-base-dir": "^0.1.1", + "ext-ctype": "*", + "ext-dom": "*", + "ext-json": "*", + "ext-libxml": "*", + "ext-mbstring": "*", + "ext-simplexml": "*", + "ext-tokenizer": "*", + "felixfbecker/advanced-json-rpc": "^3.1", + "felixfbecker/language-server-protocol": "^1.5.2", + "fidry/cpu-core-counter": "^0.4.1 || ^0.5.1 || ^1.0.0", + "netresearch/jsonmapper": "^1.0 || ^2.0 || ^3.0 || ^4.0", + "nikic/php-parser": "^4.17", + "php": "^7.4 || ~8.0.0 || ~8.1.0 || ~8.2.0 || ~8.3.0", + "sebastian/diff": "^4.0 || ^5.0 || ^6.0", + "spatie/array-to-xml": "^2.17.0 || ^3.0", + "symfony/console": "^4.1.6 || ^5.0 || ^6.0 || ^7.0", + "symfony/filesystem": "^5.4 || ^6.0 || ^7.0" + }, + "conflict": { + "nikic/php-parser": "4.17.0" + }, + "provide": { + "psalm/psalm": "self.version" + }, + "require-dev": { + "amphp/phpunit-util": "^2.0", + "bamarni/composer-bin-plugin": "^1.4", + "brianium/paratest": "^6.9", + "ext-curl": "*", + "mockery/mockery": "^1.5", + "nunomaduro/mock-final-classes": "^1.1", + "php-parallel-lint/php-parallel-lint": "^1.2", + "phpstan/phpdoc-parser": "^1.6", + "phpunit/phpunit": "^9.6", + "psalm/plugin-mockery": "^1.1", + "psalm/plugin-phpunit": "^0.18", + "slevomat/coding-standard": "^8.4", + "squizlabs/php_codesniffer": "^3.6", + "symfony/process": "^4.4 || ^5.0 || ^6.0 || ^7.0" + }, + "suggest": { + "ext-curl": "In order to send data to shepherd", + "ext-igbinary": "^2.0.5 is required, used to serialize caching data" + }, + "bin": [ + "psalm", + "psalm-language-server", + "psalm-plugin", + "psalm-refactor", + "psalter" + ], + "type": "project", + "extra": { + "branch-alias": { + "dev-1.x": "1.x-dev", + "dev-2.x": "2.x-dev", + "dev-3.x": "3.x-dev", + "dev-4.x": "4.x-dev", + "dev-master": "5.x-dev" + } + }, + "autoload": { + "psr-4": { + "Psalm\\": "src/Psalm/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Matthew Brown" + } + ], + "description": "A static analysis tool for finding errors in PHP applications", + "keywords": [ + "code", + "inspection", + "php", + "static analysis" + ], + "support": { + "docs": "https://psalm.dev/docs", + "issues": "https://github.com/vimeo/psalm/issues", + "source": "https://github.com/vimeo/psalm" + }, + "time": "2024-09-08T18:53:08+00:00" + }, + { + "name": "webmozart/assert", + "version": "1.12.1", + "source": { + "type": "git", + "url": "https://github.com/webmozarts/assert.git", + "reference": "9be6926d8b485f55b9229203f962b51ed377ba68" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/webmozarts/assert/zipball/9be6926d8b485f55b9229203f962b51ed377ba68", + "reference": "9be6926d8b485f55b9229203f962b51ed377ba68", + "shasum": "" + }, + "require": { + "ext-ctype": "*", + "ext-date": "*", + "ext-filter": "*", + "php": "^7.2 || ^8.0" + }, + "suggest": { + "ext-intl": "", + "ext-simplexml": "", + "ext-spl": "" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.10-dev" + } + }, + "autoload": { + "psr-4": { + "Webmozart\\Assert\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Bernhard Schussek", + "email": "bschussek@gmail.com" + } + ], + "description": "Assertions to validate method input/output with nice error messages.", + "keywords": [ + "assert", + "check", + "validate" + ], + "support": { + "issues": "https://github.com/webmozarts/assert/issues", + "source": "https://github.com/webmozarts/assert/tree/1.12.1" + }, + "time": "2025-10-29T15:56:20+00:00" + } + ], + "aliases": [], + "minimum-stability": "stable", + "stability-flags": {}, + "prefer-stable": false, + "prefer-lowest": false, + "platform": {}, + "platform-dev": {}, + "platform-overrides": { + "php": "8.2.0" + }, + "plugin-api-version": "2.9.0" +} diff --git a/lib/mactrack_cabletron.php b/lib/mactrack_cabletron.php index d95b2497..7e6f08f1 100644 --- a/lib/mactrack_cabletron.php +++ b/lib/mactrack_cabletron.php @@ -238,13 +238,13 @@ function get_repeater_rev4_ports($site, &$device, $lowPort, $highPort) { $previous_port = 0; while (1) { - $exec_string = trim(read_config_option('path_snmpgetnext') . - ' -c ' . $snmp_readstring . - ' -OnUQ -v ' . $snmp_version . - ' -r ' . $device['snmp_retries'] . - ' -t ' . $to . ' ' . - $device['hostname'] . ':' . $device['snmp_port'] . ' ' . - $nextOID); + $exec_string = trim(cacti_escapeshellcmd(read_config_option('path_snmpgetnext')) . + ' -c ' . cacti_escapeshellarg($snmp_readstring) . + ' -OnUQ -v ' . cacti_escapeshellarg($snmp_version) . + ' -r ' . intval($device['snmp_retries']) . + ' -t ' . intval($to) . ' ' . + cacti_escapeshellarg($device['hostname'] . ':' . intval($device['snmp_port'])) . ' ' . + cacti_escapeshellarg($nextOID)); exec($exec_string, $return_array, $return_code); diff --git a/lib/mactrack_functions.php b/lib/mactrack_functions.php index a70dfca8..030d045f 100644 --- a/lib/mactrack_functions.php +++ b/lib/mactrack_functions.php @@ -3118,8 +3118,8 @@ function mactrack_display_Octets($octets) { function mactrack_rescan($web = false) { global $config; - $device_id = get_request_var('device_id'); - $ifIndex = get_request_var('ifIndex'); + $device_id = get_filter_request_var('device_id'); + $ifIndex = get_filter_request_var('ifIndex'); $dbinfo = db_fetch_row_prepared('SELECT * FROM mac_track_devices @@ -3138,14 +3138,14 @@ function mactrack_rescan($web = false) { $extra_args = ' -id=' . $dbinfo['device_id'] . ($web ? ' --web' : ''); // print out the type, and device_id - $data['device_id'] = get_request_var('device_id'); + $data['device_id'] = $device_id; $data['ifIndex'] = $ifIndex; // add the cacti header ob_start(); // execute the command, and show the results - $command = read_config_option('path_php_binary') . ' -q ' . $command_string . $extra_args; + $command = cacti_escapeshellcmd(read_config_option('path_php_binary')) . ' -q ' . cacti_escapeshellarg($command_string) . $extra_args; passthru($command); $data['content'] = ob_get_clean(); @@ -3160,7 +3160,7 @@ function mactrack_rescan($web = false) { function mactrack_site_scan($web = false) { global $config, $web; - $site_id = get_request_var('site_id'); + $site_id = get_filter_request_var('site_id'); $dbinfo = db_fetch_row_prepared('SELECT * FROM mac_track_sites @@ -3184,7 +3184,7 @@ function mactrack_site_scan($web = false) { ob_start(); // execute the command, and show the results - $command = read_config_option('path_php_binary') . ' -q ' . $command_string . $extra_args; + $command = cacti_escapeshellcmd(read_config_option('path_php_binary')) . ' -q ' . cacti_escapeshellarg($command_string) . $extra_args; passthru($command); $data['content'] = ob_get_clean(); diff --git a/mactrack_convert.php b/mactrack_convert.php index ea5aff3a..93edf7c5 100644 --- a/mactrack_convert.php +++ b/mactrack_convert.php @@ -116,13 +116,13 @@ } if ($partitioning == 'YES' || $partitioning == 'ACTIVE') { - mactrack_create_partitioned_table($engine, $days, true); + mactrack_create_partitioned_table($engine, $charset, $collate, $days, true); } else { print "FATAL: Partitioning Not Available, Exiting!\n"; } } -function mactrack_create_partitioned_table($engine = 'InnoDB', $charset, $collate, $days = 30, $migrate = false) { +function mactrack_create_partitioned_table($engine, $charset, $collate, $days = 30, $migrate = false) { global $config; // rename the original table diff --git a/mactrack_device_types.php b/mactrack_device_types.php index 2b8f916c..3016f09a 100644 --- a/mactrack_device_types.php +++ b/mactrack_device_types.php @@ -909,13 +909,13 @@ function mactrack_get_device_types(&$sql_where, $rows, $apply_limits = true) { if (get_request_var('vendor') == 'All') { // Show all items } else { - $sql_where .= ($sql_where != '' ? ' AND ' : ' WHERE ') . "(mtdt.vendor='" . get_request_var('vendor') . "')"; + $sql_where .= ($sql_where != '' ? ' AND ' : ' WHERE ') . 'mtdt.vendor = ' . db_qstr(get_request_var('vendor')); } if (get_request_var('type_id') == '-1') { // Show all items } else { - $sql_where .= ($sql_where != '' ? ' AND ' : ' WHERE ') . '(mtdt.device_type=' . get_request_var('type_id') . ')'; + $sql_where .= ($sql_where != '' ? ' AND ' : ' WHERE ') . '(mtdt.device_type=' . (int) get_request_var('type_id') . ')'; } if (get_request_var('enabled') == '-1') { diff --git a/mactrack_devices.php b/mactrack_devices.php index 5c895ad2..cb479b28 100644 --- a/mactrack_devices.php +++ b/mactrack_devices.php @@ -202,19 +202,26 @@ function form_mactrack_actions() { if (isset($cacti_host['id'])) { reset($fields_mactrack_snmp_item); - $updates = ''; + $set_clauses = []; + $set_params = []; foreach ($fields_mactrack_snmp_item as $field_name => $field_array) { if (isset($cacti_host[$field_name])) { - $updates .= ($updates != '' ? ', ' : '') . $field_name . "='" . $cacti_host[$field_name] . "'"; + // $field_name is a trusted key from the static $fields_mactrack_snmp_item + // definition; the host-table value is bound as a parameter to avoid + // second-order SQL injection when it contains a quote. + $set_clauses[] = $field_name . ' = ?'; + $set_params[] = $cacti_host[$field_name]; } } - if ($updates != '') { + if (cacti_sizeof($set_clauses)) { + $set_params[] = $selected_items[$i]; + db_execute_prepared('UPDATE mac_track_devices - SET ' . $updates . ' - WHERE device_id=?', - [$selected_items[$i]]); + SET ' . implode(', ', $set_clauses) . ' + WHERE device_id = ?', + $set_params); } } else { // skip silently; possible enhancement: tell the user what we did @@ -970,6 +977,11 @@ function mactrack_device_edit() { } function mactrack_get_devices(&$sql_where, $rows, $apply_limits = true) { + $status = intval(get_filter_request_var('status')); + $type_id = intval(get_filter_request_var('type_id')); + $device_type_id = intval(get_filter_request_var('device_type_id')); + $site_id = intval(get_filter_request_var('site_id')); + // form the 'where' clause for our main sql query if (get_request_var('filter') != '') { $sql_where = ($sql_where != '' ? ' AND ' : 'WHERE ') . '(mtd.hostname LIKE ' . db_qstr('%' . get_request_var('filter') . '%') . ' @@ -977,36 +989,36 @@ function mactrack_get_devices(&$sql_where, $rows, $apply_limits = true) { OR mtd.notes LIKE ' . db_qstr('%' . get_request_var('filter') . '%') . ')'; } - if (get_request_var('status') == '-1') { + if ($status == -1) { // Show all items - } elseif (get_request_var('status') == '-2') { + } elseif ($status == -2) { $sql_where .= ($sql_where != '' ? ' AND ' : 'WHERE ') . "(mtd.disabled='on')"; - } elseif (get_request_var('status') == '5') { + } elseif ($status == 5) { $sql_where .= ($sql_where != '' ? ' AND ' : 'WHERE ') . '(mtd.host_id=0)'; } else { - $sql_where .= ($sql_where != '' ? ' AND ' : 'WHERE ') . '(mtd.snmp_status=' . get_request_var('status') . " AND mtd.disabled = '')"; + $sql_where .= ($sql_where != '' ? ' AND ' : 'WHERE ') . '(mtd.snmp_status=' . $status . " AND mtd.disabled = '')"; } - if (get_request_var('type_id') == '-1') { + if ($type_id == -1) { // Show all items } else { - $sql_where .= ($sql_where != '' ? ' AND ' : 'WHERE ') . '(mtd.scan_type=' . get_request_var('type_id') . ')'; + $sql_where .= ($sql_where != '' ? ' AND ' : 'WHERE ') . '(mtd.scan_type=' . $type_id . ')'; } - if (get_request_var('device_type_id') == '-1') { + if ($device_type_id == -1) { // Show all items - } elseif (get_request_var('device_type_id') == '-2') { + } elseif ($device_type_id == -2) { $sql_where .= ($sql_where != '' ? ' AND ' : 'WHERE ') . "(mtdt.description='')"; } else { - $sql_where .= ($sql_where != '' ? ' AND ' : 'WHERE ') . '(mtd.device_type_id=' . get_request_var('device_type_id') . ')'; + $sql_where .= ($sql_where != '' ? ' AND ' : 'WHERE ') . '(mtd.device_type_id=' . $device_type_id . ')'; } - if (get_request_var('site_id') == '-1') { + if ($site_id == -1) { // Show all items - } elseif (get_request_var('site_id') == '-2') { + } elseif ($site_id == -2) { $sql_where .= ($sql_where != '' ? ' AND ' : 'WHERE ') . '(mts.site_id IS NULL)'; } elseif (!isempty_request_var('site_id')) { - $sql_where .= ($sql_where != '' ? ' AND ' : 'WHERE ') . '(mtd.site_id=' . get_request_var('site_id') . ')'; + $sql_where .= ($sql_where != '' ? ' AND ' : 'WHERE ') . '(mtd.site_id=' . $site_id . ')'; } $sql_order = get_order_string(); diff --git a/mactrack_import_ouidb.php b/mactrack_import_ouidb.php index 250b8761..8f730e23 100644 --- a/mactrack_import_ouidb.php +++ b/mactrack_import_ouidb.php @@ -76,8 +76,10 @@ } if ($oui_file != '') { - if (!file_exists($oui_file)) { - print "ERROR: OUI Database file does not exist\n"; + $oui_file = mactrack_validate_oui_file($oui_file); + + if ($oui_file == '') { + print "ERROR: OUI Database file must be a readable regular file\n"; } else { import_oui_database('ui', $oui_file); } @@ -85,6 +87,20 @@ import_oui_database(); } +function mactrack_validate_oui_file(string $path): string { + if ($path === '' || strpos($path, "\0") !== false) { + return ''; + } + + $resolved = realpath($path); + + if ($resolved === false || !is_file($resolved) || !is_readable($resolved)) { + return ''; + } + + return $resolved; +} + function display_version() { global $config; diff --git a/mactrack_macauth.php b/mactrack_macauth.php index f3d774d8..23209c85 100644 --- a/mactrack_macauth.php +++ b/mactrack_macauth.php @@ -174,9 +174,10 @@ function api_mactrack_maca_save($mac_id, $mac_address, $description) { $mac_id = sql_save($save, 'mac_track_macauth', 'mac_address', false); if ($mac_id) { - db_execute('UPDATE mac_track_ports + db_execute_prepared('UPDATE mac_track_ports SET authorized=1 - WHERE mac_address LIKE "' . $mac_address . '%"'); + WHERE mac_address LIKE ?', + [$mac_address . '%']); raise_message(1); } else { @@ -198,13 +199,16 @@ function api_mactrack_maca_remove($mac_id) { [$mac_id]); db_execute_prepared('DELETE FROM mac_track_ips - WHERE mac_address="' . $mac_address . '"'); + WHERE mac_address = ?', + [$mac_address]); db_execute_prepared('DELETE FROM mac_track_ports - WHERE mac_address="' . $mac_address . '"'); + WHERE mac_address = ?', + [$mac_address]); db_execute_prepared('DELETE FROM mac_track_aggregated_ports - WHERE mac_address="' . $mac_address . '"'); + WHERE mac_address = ?', + [$mac_address]); cacti_log('AUDIT: MAC Address `' . $mac_address . '` is deleted from MacAuth by ' . db_fetch_cell_prepared('SELECT full_name FROM user_auth WHERE id = ?', [$_SESSION['sess_user_id']]), false, 'MACTRACK'); diff --git a/mactrack_resolver.php b/mactrack_resolver.php index 7f9bf7af..83ca4f1e 100644 --- a/mactrack_resolver.php +++ b/mactrack_resolver.php @@ -42,7 +42,12 @@ include('../../include/cli_check.php'); include_once($config['base_path'] . '/plugins/mactrack/lib/mactrack_functions.php'); -include_once($config['base_path'] . '/plugins/mactrack/Net/DNS2.php'); +require_once $config['base_path'] . '/plugins/mactrack/vendor/autoload.php'; + +if (!class_exists('Net_DNS2_Resolver')) { + fwrite(STDERR, "Mactrack DNS dependency is unavailable. Run composer install --no-dev in the plugin directory.\n"); + exit(1); +} // install signal handlers for UNIX only if (function_exists('pcntl_signal')) { @@ -230,8 +235,8 @@ // output updated details to database foreach ($unresolved_ips as $unresolved_ip) { $sql[] = '(' . - $unresolved_ip['site_id'] . ',' . - $unresolved_ip['device_id'] . ',' . + (int) $unresolved_ip['site_id'] . ',' . + (int) $unresolved_ip['device_id'] . ',' . db_qstr($unresolved_ip['hostname']) . ',' . db_qstr($unresolved_ip['dns_hostname']) . ',' . db_qstr($unresolved_ip['device_name']) . ',' . diff --git a/mactrack_sites.php b/mactrack_sites.php index 6294e10c..d6eb3e47 100644 --- a/mactrack_sites.php +++ b/mactrack_sites.php @@ -304,7 +304,7 @@ function mactrack_site_get_site_records(&$sql_where, $rows, $apply_limits = true } if ((get_request_var('site_id') != '-1') && (get_request_var('detail'))) { - $sql_where .= ($sql_where != '' ? ' AND ' : 'WHERE ') . '(mtd.site_id=' . get_request_var('site_id') . ')'; + $sql_where .= ($sql_where != '' ? ' AND ' : 'WHERE ') . '(mtd.site_id=' . (int) get_request_var('site_id') . ')'; } $sql_order = get_order_string(); diff --git a/mactrack_snmp.php b/mactrack_snmp.php index 90088444..09596938 100644 --- a/mactrack_snmp.php +++ b/mactrack_snmp.php @@ -297,7 +297,7 @@ function mactrack_snmp_item_movedown() { get_filter_request_var('id'); // ==================================================== - move_item_down('mac_track_snmp_items', get_request_var('item_id'), 'snmp_id=' . get_request_var('id')); + move_item_down('mac_track_snmp_items', get_request_var('item_id'), 'snmp_id=' . (int) get_request_var('id')); } function mactrack_snmp_item_moveup() { @@ -306,7 +306,7 @@ function mactrack_snmp_item_moveup() { get_filter_request_var('id'); // ==================================================== - move_item_up('mac_track_snmp_items', get_request_var('item_id'), 'snmp_id=' . get_request_var('id')); + move_item_up('mac_track_snmp_items', get_request_var('item_id'), 'snmp_id=' . (int) get_request_var('id')); } function mactrack_snmp_item_remove() { @@ -347,7 +347,7 @@ function mactrack_snmp_item_edit() { $mactrack_snmp_item = []; $mactrack_snmp_item['snmp_id'] = get_request_var('id'); - $mactrack_snmp_item['sequence'] = get_sequence('', 'sequence', 'mac_track_snmp_items', 'snmp_id=' . get_request_var('id')); + $mactrack_snmp_item['sequence'] = get_sequence('', 'sequence', 'mac_track_snmp_items', 'snmp_id=' . (int) get_request_var('id')); } form_start(get_current_page(), 'mactrack_item_edit'); diff --git a/mactrack_view_arp.php b/mactrack_view_arp.php index 49caf461..25f28ff3 100644 --- a/mactrack_view_arp.php +++ b/mactrack_view_arp.php @@ -139,7 +139,7 @@ function mactrack_view_export_ips() { } } -function mactrack_view_get_ip_records(&$sql_where, $apply_limits = true, $rows) { +function mactrack_view_get_ip_records(&$sql_where, $rows, $apply_limits = true) { // form the 'where' clause for our main sql query if (get_request_var('mac_filter') != '') { $mac_filter = str_replace(':', '', get_request_var('mac_filter')); @@ -228,12 +228,12 @@ function mactrack_view_get_ip_records(&$sql_where, $apply_limits = true, $rows) if ((get_request_var('site_id') != '-1')) { $sql_where .= ($sql_where != '' ? ' AND' : 'WHERE') . - ' mti.site_id = ' . get_request_var('site_id'); + ' mti.site_id = ' . (int) get_request_var('site_id'); } if ((get_request_var('device_id') != '-1')) { $sql_where .= ($sql_where != '' ? ' AND' : 'WHERE') . - ' mti.device_id = ' . get_request_var('device_id'); + ' mti.device_id = ' . (int) get_request_var('device_id'); } // prevent table scans, either a device or site must be selected @@ -295,7 +295,7 @@ function mactrack_view_ips() { $rows = plugin_get_rows_per_page(); - $port_results = mactrack_view_get_ip_records($sql_where, true, $rows); + $port_results = mactrack_view_get_ip_records($sql_where, $rows, true); // prevent table scans, either a device or site must be selected diff --git a/mactrack_view_devices.php b/mactrack_view_devices.php index a35f8368..162f94a8 100644 --- a/mactrack_view_devices.php +++ b/mactrack_view_devices.php @@ -140,15 +140,19 @@ function mactrack_view_export_devices() { } function mactrack_view_get_device_records(&$sql_where, $rows, $apply_limits = true) { - $device_type_info = db_fetch_row_prepared('SELECT * FROM mac_track_device_types WHERE device_type_id = ?', [get_request_var('device_type_id')]); + $status = intval(get_filter_request_var('status')); + $type_id = intval(get_filter_request_var('type_id')); + $device_type_id = intval(get_filter_request_var('device_type_id')); + $site_id = intval(get_filter_request_var('site_id')); + $device_type_info = db_fetch_row_prepared('SELECT * FROM mac_track_device_types WHERE device_type_id = ?', [$device_type_id]); // if the device type is not the same as the type_id, then reset it - if ((cacti_sizeof($device_type_info)) && (get_request_var('type_id') != -1)) { - if ($device_type_info['device_type'] != get_request_var('type_id')) { + if ((cacti_sizeof($device_type_info)) && ($type_id != -1)) { + if ($device_type_info['device_type'] != $type_id) { $device_type_info = []; } } else { - if (get_request_var('device_type_id') == 0) { + if ($device_type_id == 0) { $device_type_info = ['device_type_id' => 0, 'description' => __('Unknown Device Type', 'mactrack')]; } } @@ -165,38 +169,38 @@ function mactrack_view_get_device_records(&$sql_where, $rows, $apply_limits = tr $sql_where .= ($sql_where != '' ? ' AND ' : 'WHERE ') . '(mac_track_devices.device_type_id=' . $device_type_info['device_type_id'] . ')'; } - if (get_request_var('status') == '-1') { + if ($status == -1) { // Show all items - } elseif (get_request_var('status') == '-2') { + } elseif ($status == -2) { $sql_where .= ($sql_where != '' ? ' AND ' : 'WHERE ') . '(mac_track_devices.disabled="on")'; - } elseif (get_request_var('status') == '5') { + } elseif ($status == 5) { $sql_where .= ($sql_where != '' ? ' AND ' : 'WHERE ') . '(mac_track_devices.host_id=0)'; } else { - $sql_where .= ($sql_where != '' ? ' AND ' : 'WHERE ') . '(mac_track_devices.snmp_status=' . get_request_var('status') . ') AND (mac_track_devices.disabled = "")'; + $sql_where .= ($sql_where != '' ? ' AND ' : 'WHERE ') . '(mac_track_devices.snmp_status=' . $status . ') AND (mac_track_devices.disabled = "")'; } // scan types matching - if (get_request_var('type_id') == '-1') { + if ($type_id == -1) { // Show all items } else { - $sql_where .= ($sql_where != '' ? ' AND ' : 'WHERE ') . '(mac_track_devices.scan_type=' . get_request_var('type_id') . ')'; + $sql_where .= ($sql_where != '' ? ' AND ' : 'WHERE ') . '(mac_track_devices.scan_type=' . $type_id . ')'; } // device types matching - if (get_request_var('device_type_id') == '-1') { + if ($device_type_id == -1) { // Show all items - } elseif (get_request_var('device_type_id') == '-2') { + } elseif ($device_type_id == -2) { $sql_where .= ($sql_where != '' ? ' AND ' : 'WHERE ') . '(mac_track_device_types.description="")'; } else { - $sql_where .= ($sql_where != '' ? ' AND ' : 'WHERE ') . '(mac_track_devices.device_type_id=' . get_request_var('device_type_id') . ')'; + $sql_where .= ($sql_where != '' ? ' AND ' : 'WHERE ') . '(mac_track_devices.device_type_id=' . $device_type_id . ')'; } - if (get_request_var('site_id') == '-1') { + if ($site_id == -1) { // Show all items - } elseif (get_request_var('site_id') == '-2') { + } elseif ($site_id == -2) { $sql_where .= ($sql_where != '' ? ' AND ' : 'WHERE ') . '(mac_track_sites.site_id IS NULL)'; } elseif (!isempty_request_var('site_id')) { - $sql_where .= ($sql_where != '' ? ' AND ' : 'WHERE ') . '(mac_track_devices.site_id=' . get_request_var('site_id') . ')'; + $sql_where .= ($sql_where != '' ? ' AND ' : 'WHERE ') . '(mac_track_devices.site_id=' . $site_id . ')'; } $sql_order = get_order_string(); diff --git a/mactrack_view_dot1x.php b/mactrack_view_dot1x.php index c15d221f..135d71f5 100644 --- a/mactrack_view_dot1x.php +++ b/mactrack_view_dot1x.php @@ -164,7 +164,7 @@ function mactrack_view_export_dot1x() { } } -function mactrack_view_get_dot1x_records(&$sql_where, $apply_limits = true, $rows) { +function mactrack_view_get_dot1x_records(&$sql_where, $rows, $apply_limits = true) { // status sql where if (get_request_var('status') == '1') { // Idle $sql_where .= ($sql_where != '' ? ' AND ' : 'WHERE ') . 'mtd.status = 1'; @@ -309,15 +309,15 @@ function mactrack_view_get_dot1x_records(&$sql_where, $apply_limits = true, $row } if (get_request_var('site_id') != '-1') { - $sql_where .= ($sql_where != '' ? ' AND' : 'WHERE') . ' mtd.site_id = ' . get_request_var('site_id'); + $sql_where .= ($sql_where != '' ? ' AND' : 'WHERE') . ' mtd.site_id = ' . (int) get_request_var('site_id'); } if (get_request_var('status') != '0') { - $sql_where .= ($sql_where != '' ? ' AND' : 'WHERE') . ' mtd.status = ' . get_request_var('status'); + $sql_where .= ($sql_where != '' ? ' AND' : 'WHERE') . ' mtd.status = ' . (int) get_request_var('status'); } if (get_request_var('device_id') != '-1') { - $sql_where .= ($sql_where != '' ? ' AND' : 'WHERE') . ' mtd.device_id = ' . get_request_var('device_id'); + $sql_where .= ($sql_where != '' ? ' AND' : 'WHERE') . ' mtd.device_id = ' . (int) get_request_var('device_id'); } if ((get_request_var('scan_date') != '1') && (get_request_var('scan_date') != '2')) { @@ -389,7 +389,7 @@ function mactrack_view_dot1x() { $rows = plugin_get_rows_per_page(); - $port_results = mactrack_view_get_dot1x_records($sql_where, true, $rows); + $port_results = mactrack_view_get_dot1x_records($sql_where, $rows, true); // prevent table scans, either a device or site must be selected if ($sql_where == '') { diff --git a/mactrack_view_graphs.php b/mactrack_view_graphs.php index 8aa42268..befea287 100644 --- a/mactrack_view_graphs.php +++ b/mactrack_view_graphs.php @@ -125,12 +125,12 @@ function mactrack_view_graphs() { // Host Id sql_where if (get_filter_request_var('host_id') > 0) { - $sql_where .= ($sql_where != '' ? ' AND' : '') . ' gl.host_id=' . get_request_var('host_id'); + $sql_where .= ($sql_where != '' ? ' AND' : '') . ' gl.host_id=' . (int) get_request_var('host_id'); } // Graph Template Id sql_where if (get_filter_request_var('graph_template_id') > 0) { - $sql_where .= ($sql_where != '' ? ' AND' : '') . ' gl.graph_template_id=' . get_request_var('graph_template_id'); + $sql_where .= ($sql_where != '' ? ' AND' : '') . ' gl.graph_template_id=' . (int) get_request_var('graph_template_id'); } if (get_request_var('graphs') == '-1') { diff --git a/mactrack_view_interfaces.php b/mactrack_view_interfaces.php index d939892e..b82c1695 100644 --- a/mactrack_view_interfaces.php +++ b/mactrack_view_interfaces.php @@ -45,7 +45,8 @@ function mactrack_get_records(&$sql_where, $apply_limits = true, $rows = '30') { $match = '(Vlan|Loopback|Null)'; db_execute_prepared('REPLACE INTO settings SET name="mt_ignorePorts", value = ?', [$match]); } - $ignore = "(ifName NOT REGEXP '" . $match . "' AND ifDescr NOT REGEXP '" . $match . "')"; + $ignore = '(ifName NOT ' . db_qstr_rlike($match) . ' AND ifDescr NOT ' . db_qstr_rlike($match) . ')'; + $bwusage = intval(get_filter_request_var('bwusage')); // issues sql where if (get_request_var('issues') == '-2') { // All Interfaces @@ -66,12 +67,12 @@ function mactrack_get_records(&$sql_where, $apply_limits = true, $rows = '30') { $sql_where .= ($sql_where != '' ? ' AND ' : 'WHERE ') . "(int_discards_present=1 AND $ignore)"; } elseif (get_request_var('issues') == '7') { // Change < 24 Hours $sql_where .= ($sql_where != '' ? ' AND ' : 'WHERE ') . '(mac_track_interfaces.sysUptime-ifLastChange < 8640000) AND ifLastChange > 0 AND (mac_track_interfaces.sysUptime-ifLastChange > 0)'; - } elseif (get_request_var('issues') == '9' && get_filter_request_var('bwusage') != '-1') { // In/Out over 70% - $sql_where .= ($sql_where != '' ? ' AND ' : 'WHERE ') . '((inBound>' . get_request_var('bwusage') . ' OR outBound>' . get_request_var('bwusage') . ") AND $ignore)"; - } elseif (get_request_var('issues') == '10' && get_filter_request_var('bwusage') != '-1') { // In over 70% - $sql_where .= ($sql_where != '' ? ' AND ' : 'WHERE ') . '(inBound>' . get_request_var('bwusage') . " AND $ignore)"; - } elseif (get_request_var('issues') == '11' && get_filter_request_var('bwusage') != '-1') { // Out over 70% - $sql_where .= ($sql_where != '' ? ' AND ' : 'WHERE ') . '(outBound>' . get_request_var('bwusage') . " AND $ignore)"; + } elseif (get_request_var('issues') == '9' && $bwusage != -1) { // In/Out over 70% + $sql_where .= ($sql_where != '' ? ' AND ' : 'WHERE ') . '((inBound>' . $bwusage . ' OR outBound>' . $bwusage . ") AND $ignore)"; + } elseif (get_request_var('issues') == '10' && $bwusage != -1) { // In over 70% + $sql_where .= ($sql_where != '' ? ' AND ' : 'WHERE ') . '(inBound>' . $bwusage . " AND $ignore)"; + } elseif (get_request_var('issues') == '11' && $bwusage != -1) { // Out over 70% + $sql_where .= ($sql_where != '' ? ' AND ' : 'WHERE ') . '(outBound>' . $bwusage . " AND $ignore)"; } else { } @@ -86,21 +87,21 @@ function mactrack_get_records(&$sql_where, $apply_limits = true, $rows = '30') { if (get_filter_request_var('device_id') == '-1') { // do nothing all states } else { - $sql_where .= ($sql_where != '' ? ' AND ' : 'WHERE ') . 'mac_track_interfaces.device_id=' . get_request_var('device_id'); + $sql_where .= ($sql_where != '' ? ' AND ' : 'WHERE ') . 'mac_track_interfaces.device_id=' . intval(get_filter_request_var('device_id')); } // site sql where if (get_filter_request_var('site_id') == '-1') { // do nothing all sites } else { - $sql_where .= ($sql_where != '' ? ' AND ' : 'WHERE ') . 'mac_track_interfaces.site_id=' . get_request_var('site_id'); + $sql_where .= ($sql_where != '' ? ' AND ' : 'WHERE ') . 'mac_track_interfaces.site_id=' . intval(get_filter_request_var('site_id')); } // type sql where if (get_filter_request_var('device_type_id') == '-1') { // do nothing all states } else { - $sql_where .= ($sql_where != '' ? ' AND ' : 'WHERE ') . 'mac_track_devices.device_type_id=' . get_request_var('device_type_id'); + $sql_where .= ($sql_where != '' ? ' AND ' : 'WHERE ') . 'mac_track_devices.device_type_id=' . intval(get_filter_request_var('device_type_id')); } $sql_order = get_order_string(); @@ -566,7 +567,7 @@ function mactrack_filter_table() { $sql_where = ''; if (get_request_var('site_id') != -1) { - $sql_where .= ' WHERE mac_track_devices.site_id=' . get_request_var('site_id'); + $sql_where .= ' WHERE mac_track_devices.site_id=' . (int) get_request_var('site_id'); } else { $sql_where = ''; } @@ -601,11 +602,11 @@ function mactrack_filter_table() { $sql_where = ''; if (get_request_var('site_id') != -1) { - $sql_where .= ($sql_where != '' ? ' AND ' : 'WHERE ') . 'site_id=' . get_request_var('site_id'); + $sql_where .= ($sql_where != '' ? ' AND ' : 'WHERE ') . 'site_id=' . (int) get_request_var('site_id'); } if (get_request_var('device_type_id') != '-1') { - $sql_where .= ($sql_where != '' ? ' AND ' : 'WHERE ') . 'device_type_id=' . get_request_var('device_type_id'); + $sql_where .= ($sql_where != '' ? ' AND ' : 'WHERE ') . 'device_type_id=' . (int) get_request_var('device_type_id'); } $devices = array_rekey(db_fetch_assoc("SELECT device_id, device_name FROM mac_track_devices $sql_where ORDER BY device_name"), 'device_id', 'device_name'); diff --git a/mactrack_view_ips.php b/mactrack_view_ips.php index 992fa59b..6d9a7859 100644 --- a/mactrack_view_ips.php +++ b/mactrack_view_ips.php @@ -129,7 +129,7 @@ function mactrack_view_export_ip_ranges() { function mactrack_view_get_ip_range_records(&$sql_where, $rows, $apply_limits = true) { if (get_request_var('site_id') != '-1') { - $sql_where = 'WHERE mtir.site_id = ' . get_request_var('site_id'); + $sql_where = 'WHERE mtir.site_id = ' . (int) get_request_var('site_id'); } else { $sql_where = ''; } diff --git a/mactrack_view_macs.php b/mactrack_view_macs.php index bfcbc36d..db9c6c69 100644 --- a/mactrack_view_macs.php +++ b/mactrack_view_macs.php @@ -88,7 +88,7 @@ function form_actions() { // if we are to save this form, instead of display it if (isset_request_var('selected_items')) { - $selected_items = unserialize(get_nfilter_request_var('selected_items'), ['allowed_classes' => false]); + $selected_items = json_decode(get_nfilter_request_var('selected_items'), true); if (!is_array($selected_items)) { header('Location: mactrack_view_macs.php'); @@ -151,8 +151,8 @@ function form_actions() { $ip = str_replace('_', '.', $parts[1]); } - if (!isset($mac_address_array[$mac])) { - $mac_address_list .= '
  • ' . mactrack_format_mac($mac) . '
  • '; + if (filter_var($mac, FILTER_VALIDATE_MAC) && filter_var($ip, FILTER_VALIDATE_IP) && !isset($mac_address_array[$mac])) { + $mac_address_list .= '
  • ' . html_escape(mactrack_format_mac($mac)) . '
  • '; $mac_address_array[$mac] = $ip; } } @@ -193,8 +193,8 @@ function form_actions() { print " - - " . ($save_html != '' ? " + + " . ($save_html != '' ? " $save_html" : "') . ' @@ -207,6 +207,12 @@ function form_actions() { bottom_footer(); } +function mactrack_normalize_ids(array $ids): array { + return array_values(array_filter(array_map('intval', $ids), static function ($id) { + return $id > 0; + })); +} + function form_aggregated_actions() { global $config, $mactrack_view_agg_macs_actions; @@ -216,13 +222,12 @@ function form_aggregated_actions() { // if we are to save this form, instead of display it if (isset_request_var('selected_items')) { - $selected_items = sanitize_unserialize_selected_items(get_nfilter_request_var('selected_items')); + $selected_items = mactrack_normalize_ids((array) json_decode(get_nfilter_request_var('selected_items'), true)); - if ($selected_items != false) { + if (cacti_sizeof($selected_items)) { if (get_request_var('drp_action') == '3') { // Delete - if (cacti_sizeof($selected_items)) { - db_execute('DELETE FROM mac_track_aggregated_ports WHERE row_id IN (' . implode(',', $selected_items) . ')'); - } + $placeholders = implode(',', array_fill(0, cacti_sizeof($selected_items), '?')); + db_execute_prepared('DELETE FROM mac_track_aggregated_ports WHERE row_id IN(' . $placeholders . ')', $selected_items); } header('Location: mactrack_view_macs.php'); @@ -289,8 +294,8 @@ function form_aggregated_actions() { print " - - " . ($save_html != '' ? " + + " . ($save_html != '' ? " $save_html" : "') . ' @@ -582,19 +587,19 @@ function mactrack_view_get_mac_records(&$sql_where, $rows, $apply_limits = true) } if (get_request_var('authorized') != '-1') { - $sql_where .= ($sql_where != '' ? ' AND' : 'WHERE') . ' mtp.authorized = ' . get_request_var('authorized'); + $sql_where .= ($sql_where != '' ? ' AND' : 'WHERE') . ' mtp.authorized = ' . (int) get_request_var('authorized'); } if (get_request_var('site_id') != '-1') { - $sql_where .= ($sql_where != '' ? ' AND' : 'WHERE') . ' mtp.site_id = ' . get_request_var('site_id'); + $sql_where .= ($sql_where != '' ? ' AND' : 'WHERE') . ' mtp.site_id = ' . (int) get_request_var('site_id'); } if (get_request_var('vlan') != '-1') { - $sql_where .= ($sql_where != '' ? ' AND' : 'WHERE') . ' mtp.vlan_id = ' . get_request_var('vlan'); + $sql_where .= ($sql_where != '' ? ' AND' : 'WHERE') . ' mtp.vlan_id = ' . (int) get_request_var('vlan'); } if (get_request_var('device_id') != '-1') { - $sql_where .= ($sql_where != '' ? ' AND' : 'WHERE') . ' mtp.device_id = ' . get_request_var('device_id'); + $sql_where .= ($sql_where != '' ? ' AND' : 'WHERE') . ' mtp.device_id = ' . (int) get_request_var('device_id'); } if ((get_request_var('scan_date') != '1') && (get_request_var('scan_date') != '2') && (get_request_var('scan_date') != '3')) { @@ -1211,14 +1216,14 @@ function mactrack_mac_filter() { $sql_where = ''; if (get_request_var('device_id') != '-1') { - $sql_where = 'WHERE device_id=' . get_request_var('device_id'); + $sql_where = 'WHERE device_id=' . (int) get_request_var('device_id'); } if (get_request_var('site_id') != '-1') { if ($sql_where != '') { - $sql_where .= ' AND site_id=' . get_request_var('site_id'); + $sql_where .= ' AND site_id=' . (int) get_request_var('site_id'); } else { - $sql_where = 'WHERE site_id=' . get_request_var('site_id'); + $sql_where = 'WHERE site_id=' . (int) get_request_var('site_id'); } } diff --git a/mactrack_view_sites.php b/mactrack_view_sites.php index da53b0d5..1cbb50d2 100644 --- a/mactrack_view_sites.php +++ b/mactrack_view_sites.php @@ -106,7 +106,7 @@ function mactrack_view_get_site_records(&$sql_where, $rows, $apply_limits = true } if ((get_request_var('site_id') != '-1') && (get_request_var('detail'))) { - $sql_where = ($sql_where != '' ? ' AND ' : 'WHERE ') . '(mac_track_devices.site_id=' . get_request_var('site_id') . ')'; + $sql_where = ($sql_where != '' ? ' AND ' : 'WHERE ') . '(mac_track_devices.site_id=' . (int) get_request_var('site_id') . ')'; } $sql_order = get_order_string(); diff --git a/mise.toml b/mise.toml new file mode 100644 index 00000000..2783ecfd --- /dev/null +++ b/mise.toml @@ -0,0 +1,2 @@ +[tools] +php = "8.2" diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon new file mode 100644 index 00000000..c4a9d1ab --- /dev/null +++ b/phpstan-baseline.neon @@ -0,0 +1,5431 @@ +parameters: + ignoreErrors: + - + message: '#^Function mactrack_database_upgrade\(\) has no return type specified\.$#' + identifier: missingType.return + count: 1 + path: includes/database.php + + - + message: '#^Function mactrack_setup_database\(\) has no return type specified\.$#' + identifier: missingType.return + count: 1 + path: includes/database.php + + - + message: '#^Function complete_3com_ifName\(\) has no return type specified\.$#' + identifier: missingType.return + count: 1 + path: lib/mactrack_3com.php + + - + message: '#^Function complete_3com_ifName\(\) has parameter \$device with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: lib/mactrack_3com.php + + - + message: '#^Function complete_3com_ifName\(\) has parameter \$ifIndexes with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: lib/mactrack_3com.php + + - + message: '#^Function get_3Com_base_dot1dTpFdbEntry_ports\(\) has no return type specified\.$#' + identifier: missingType.return + count: 1 + path: lib/mactrack_3com.php + + - + message: '#^Function get_3Com_base_dot1dTpFdbEntry_ports\(\) has parameter \$device with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: lib/mactrack_3com.php + + - + message: '#^Function get_3Com_base_dot1dTpFdbEntry_ports\(\) has parameter \$highPort with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: lib/mactrack_3com.php + + - + message: '#^Function get_3Com_base_dot1dTpFdbEntry_ports\(\) has parameter \$ifInterfaces with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: lib/mactrack_3com.php + + - + message: '#^Function get_3Com_base_dot1dTpFdbEntry_ports\(\) has parameter \$lowPort with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: lib/mactrack_3com.php + + - + message: '#^Function get_3Com_base_dot1dTpFdbEntry_ports\(\) has parameter \$site with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: lib/mactrack_3com.php + + - + message: '#^Function get_3Com_base_dot1dTpFdbEntry_ports\(\) has parameter \$snmp_readstring with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: lib/mactrack_3com.php + + - + message: '#^Function get_3Com_base_dot1dTpFdbEntry_ports\(\) has parameter \$store_to_db with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: lib/mactrack_3com.php + + - + message: '#^Function get_3Com_dot1dTpFdbEntry_ports\(\) has no return type specified\.$#' + identifier: missingType.return + count: 1 + path: lib/mactrack_3com.php + + - + message: '#^Function get_3Com_dot1dTpFdbEntry_ports\(\) has parameter \$device with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: lib/mactrack_3com.php + + - + message: '#^Function get_3Com_dot1dTpFdbEntry_ports\(\) has parameter \$highPort with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: lib/mactrack_3com.php + + - + message: '#^Function get_3Com_dot1dTpFdbEntry_ports\(\) has parameter \$lowPort with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: lib/mactrack_3com.php + + - + message: '#^Function get_3Com_dot1dTpFdbEntry_ports\(\) has parameter \$site with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: lib/mactrack_3com.php + + - + message: '#^Offset ''port_number'' on array\{key\: mixed, port_number\: mixed\} on left side of \?\? always exists and is not nullable\.$#' + identifier: nullCoalesce.offset + count: 1 + path: lib/mactrack_3com.php + + - + message: '#^Parameter \#2 \$log of function db_execute expects bool, array\ given\.$#' + identifier: argument.type + count: 1 + path: lib/mactrack_3com.php + + - + message: '#^Function get_aruba_oscx_arp_table\(\) has no return type specified\.$#' + identifier: missingType.return + count: 1 + path: lib/mactrack_aruba_oscx.php + + - + message: '#^Function get_aruba_oscx_arp_table\(\) has parameter \$device with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: lib/mactrack_aruba_oscx.php + + - + message: '#^Function get_aruba_oscx_arp_table\(\) has parameter \$site with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: lib/mactrack_aruba_oscx.php + + - + message: '#^Function get_aruba_oscx_dot1dTpFdbEntry_ports\(\) has no return type specified\.$#' + identifier: missingType.return + count: 1 + path: lib/mactrack_aruba_oscx.php + + - + message: '#^Function get_aruba_oscx_dot1dTpFdbEntry_ports\(\) has parameter \$device with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: lib/mactrack_aruba_oscx.php + + - + message: '#^Function get_aruba_oscx_dot1dTpFdbEntry_ports\(\) has parameter \$highPort with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: lib/mactrack_aruba_oscx.php + + - + message: '#^Function get_aruba_oscx_dot1dTpFdbEntry_ports\(\) has parameter \$ifInterfaces with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: lib/mactrack_aruba_oscx.php + + - + message: '#^Function get_aruba_oscx_dot1dTpFdbEntry_ports\(\) has parameter \$lowPort with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: lib/mactrack_aruba_oscx.php + + - + message: '#^Function get_aruba_oscx_dot1dTpFdbEntry_ports\(\) has parameter \$site with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: lib/mactrack_aruba_oscx.php + + - + message: '#^Function get_aruba_oscx_dot1dTpFdbEntry_ports\(\) has parameter \$snmp_readstring with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: lib/mactrack_aruba_oscx.php + + - + message: '#^Function get_aruba_oscx_dot1dTpFdbEntry_ports\(\) has parameter \$store_to_db with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: lib/mactrack_aruba_oscx.php + + - + message: '#^Function get_aruba_oscx_switch_ports\(\) has no return type specified\.$#' + identifier: missingType.return + count: 1 + path: lib/mactrack_aruba_oscx.php + + - + message: '#^Function get_aruba_oscx_switch_ports\(\) has parameter \$device with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: lib/mactrack_aruba_oscx.php + + - + message: '#^Function get_aruba_oscx_switch_ports\(\) has parameter \$highPort with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: lib/mactrack_aruba_oscx.php + + - + message: '#^Function get_aruba_oscx_switch_ports\(\) has parameter \$lowPort with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: lib/mactrack_aruba_oscx.php + + - + message: '#^Function get_aruba_oscx_switch_ports\(\) has parameter \$site with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: lib/mactrack_aruba_oscx.php + + - + message: '#^Function oscx_mac\(\) has no return type specified\.$#' + identifier: missingType.return + count: 1 + path: lib/mactrack_aruba_oscx.php + + - + message: '#^Function oscx_mac\(\) has parameter \$mac with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: lib/mactrack_aruba_oscx.php + + - + message: '#^Parameter \#1 \$num of function dechex expects int, string given\.$#' + identifier: argument.type + count: 1 + path: lib/mactrack_aruba_oscx.php + + - + message: '#^Variable \$ip_mac might not be defined\.$#' + identifier: variable.undefined + count: 1 + path: lib/mactrack_aruba_oscx.php + + - + message: '#^Variable \$vlan_ids might not be defined\.$#' + identifier: variable.undefined + count: 1 + path: lib/mactrack_aruba_oscx.php + + - + message: '#^Binary operation "\-" between string and 1 results in an error\.$#' + identifier: binaryOp.invalid + count: 2 + path: lib/mactrack_cabletron.php + + - + message: '#^Function get_base_sfps_ports\(\) has no return type specified\.$#' + identifier: missingType.return + count: 1 + path: lib/mactrack_cabletron.php + + - + message: '#^Function get_base_sfps_ports\(\) has parameter \$device with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: lib/mactrack_cabletron.php + + - + message: '#^Function get_base_sfps_ports\(\) has parameter \$highPort with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: lib/mactrack_cabletron.php + + - + message: '#^Function get_base_sfps_ports\(\) has parameter \$ifInterfaces with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: lib/mactrack_cabletron.php + + - + message: '#^Function get_base_sfps_ports\(\) has parameter \$lowPort with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: lib/mactrack_cabletron.php + + - + message: '#^Function get_base_sfps_ports\(\) has parameter \$site with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: lib/mactrack_cabletron.php + + - + message: '#^Function get_base_sfps_ports\(\) has parameter \$snmp_readstring with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: lib/mactrack_cabletron.php + + - + message: '#^Function get_base_sfps_ports\(\) has parameter \$store_to_db with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: lib/mactrack_cabletron.php + + - + message: '#^Function get_cabletron_switch_ports\(\) has no return type specified\.$#' + identifier: missingType.return + count: 1 + path: lib/mactrack_cabletron.php + + - + message: '#^Function get_cabletron_switch_ports\(\) has parameter \$device with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: lib/mactrack_cabletron.php + + - + message: '#^Function get_cabletron_switch_ports\(\) has parameter \$highPort with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: lib/mactrack_cabletron.php + + - + message: '#^Function get_cabletron_switch_ports\(\) has parameter \$lowPort with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: lib/mactrack_cabletron.php + + - + message: '#^Function get_cabletron_switch_ports\(\) has parameter \$site with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: lib/mactrack_cabletron.php + + - + message: '#^Function get_repeater_rev4_ports\(\) has no return type specified\.$#' + identifier: missingType.return + count: 1 + path: lib/mactrack_cabletron.php + + - + message: '#^Function get_repeater_rev4_ports\(\) has parameter \$device with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: lib/mactrack_cabletron.php + + - + message: '#^Function get_repeater_rev4_ports\(\) has parameter \$highPort with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: lib/mactrack_cabletron.php + + - + message: '#^Function get_repeater_rev4_ports\(\) has parameter \$lowPort with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: lib/mactrack_cabletron.php + + - + message: '#^Function get_repeater_rev4_ports\(\) has parameter \$site with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: lib/mactrack_cabletron.php + + - + message: '#^Function get_repeater_snmp_readstring\(\) has no return type specified\.$#' + identifier: missingType.return + count: 1 + path: lib/mactrack_cabletron.php + + - + message: '#^Function get_repeater_snmp_readstring\(\) has parameter \$device with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: lib/mactrack_cabletron.php + + - + message: '#^Variable \$new_port_key_array might not be defined\.$#' + identifier: variable.undefined + count: 2 + path: lib/mactrack_cabletron.php + + - + message: '#^Variable \$ports_active might not be defined\.$#' + identifier: variable.undefined + count: 1 + path: lib/mactrack_cabletron.php + + - + message: '#^Variable \$temp_port_A_array might not be defined\.$#' + identifier: variable.undefined + count: 8 + path: lib/mactrack_cabletron.php + + - + message: '#^Comparison operation "\>" between int\<1, max\> and 0 is always true\.$#' + identifier: greater.alwaysTrue + count: 1 + path: lib/mactrack_cisco.php + + - + message: '#^Function get_IOS_dot1dTpFdbEntry_ports\(\) has no return type specified\.$#' + identifier: missingType.return + count: 1 + path: lib/mactrack_cisco.php + + - + message: '#^Function get_IOS_dot1dTpFdbEntry_ports\(\) has parameter \$device with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: lib/mactrack_cisco.php + + - + message: '#^Function get_IOS_dot1dTpFdbEntry_ports\(\) has parameter \$highPort with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: lib/mactrack_cisco.php + + - + message: '#^Function get_IOS_dot1dTpFdbEntry_ports\(\) has parameter \$lowPort with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: lib/mactrack_cisco.php + + - + message: '#^Function get_IOS_dot1dTpFdbEntry_ports\(\) has parameter \$site with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: lib/mactrack_cisco.php + + - + message: '#^Function get_catalyst_dot1dTpFdbEntry_ports\(\) has no return type specified\.$#' + identifier: missingType.return + count: 1 + path: lib/mactrack_cisco.php + + - + message: '#^Function get_catalyst_dot1dTpFdbEntry_ports\(\) has parameter \$device with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: lib/mactrack_cisco.php + + - + message: '#^Function get_catalyst_dot1dTpFdbEntry_ports\(\) has parameter \$highPort with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: lib/mactrack_cisco.php + + - + message: '#^Function get_catalyst_dot1dTpFdbEntry_ports\(\) has parameter \$lowPort with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: lib/mactrack_cisco.php + + - + message: '#^Function get_catalyst_dot1dTpFdbEntry_ports\(\) has parameter \$site with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: lib/mactrack_cisco.php + + - + message: '#^Function get_cisco_dhcpsnooping_table\(\) has no return type specified\.$#' + identifier: missingType.return + count: 1 + path: lib/mactrack_cisco.php + + - + message: '#^Function get_cisco_dhcpsnooping_table\(\) has parameter \$device with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: lib/mactrack_cisco.php + + - + message: '#^Function get_cisco_dhcpsnooping_table\(\) has parameter \$site with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: lib/mactrack_cisco.php + + - + message: '#^Function get_cisco_dot1x_table\(\) has no return type specified\.$#' + identifier: missingType.return + count: 1 + path: lib/mactrack_cisco.php + + - + message: '#^Function get_cisco_dot1x_table\(\) has parameter \$device with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: lib/mactrack_cisco.php + + - + message: '#^Function get_cisco_dot1x_table\(\) has parameter \$site with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: lib/mactrack_cisco.php + + - + message: '#^Function get_cisco_vrf_arp_table\(\) has no return type specified\.$#' + identifier: missingType.return + count: 1 + path: lib/mactrack_cisco.php + + - + message: '#^Function get_cisco_vrf_arp_table\(\) has parameter \$device with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: lib/mactrack_cisco.php + + - + message: '#^Function get_cisco_vrf_arp_table\(\) has parameter \$site with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: lib/mactrack_cisco.php + + - + message: '#^Undefined variable\: \$portTrunking$#' + identifier: variable.undefined + count: 1 + path: lib/mactrack_cisco.php + + - + message: '#^Variable \$portTrunking in isset\(\) is never defined\.$#' + identifier: isset.variable + count: 1 + path: lib/mactrack_cisco.php + + - + message: '#^Function dell_mac_address_convert\(\) has no return type specified\.$#' + identifier: missingType.return + count: 1 + path: lib/mactrack_dell.php + + - + message: '#^Function dell_mac_address_convert\(\) has parameter \$mac_address with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: lib/mactrack_dell.php + + - + message: '#^Function get_base_dell_dot1qFdb_ports\(\) has no return type specified\.$#' + identifier: missingType.return + count: 1 + path: lib/mactrack_dell.php + + - + message: '#^Function get_base_dell_dot1qFdb_ports\(\) has parameter \$device with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: lib/mactrack_dell.php + + - + message: '#^Function get_base_dell_dot1qFdb_ports\(\) has parameter \$highPort with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: lib/mactrack_dell.php + + - + message: '#^Function get_base_dell_dot1qFdb_ports\(\) has parameter \$ifInterfaces with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: lib/mactrack_dell.php + + - + message: '#^Function get_base_dell_dot1qFdb_ports\(\) has parameter \$lowPort with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: lib/mactrack_dell.php + + - + message: '#^Function get_base_dell_dot1qFdb_ports\(\) has parameter \$site with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: lib/mactrack_dell.php + + - + message: '#^Function get_base_dell_dot1qFdb_ports\(\) has parameter \$snmp_readstring with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: lib/mactrack_dell.php + + - + message: '#^Function get_base_dell_dot1qFdb_ports\(\) has parameter \$store_to_db with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: lib/mactrack_dell.php + + - + message: '#^Function get_dell_dot1q_switch_ports\(\) has no return type specified\.$#' + identifier: missingType.return + count: 1 + path: lib/mactrack_dell.php + + - + message: '#^Function get_dell_dot1q_switch_ports\(\) has parameter \$device with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: lib/mactrack_dell.php + + - + message: '#^Function get_dell_dot1q_switch_ports\(\) has parameter \$highPort with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: lib/mactrack_dell.php + + - + message: '#^Function get_dell_dot1q_switch_ports\(\) has parameter \$lowPort with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: lib/mactrack_dell.php + + - + message: '#^Function get_dell_dot1q_switch_ports\(\) has parameter \$site with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: lib/mactrack_dell.php + + - + message: '#^Parameter \#1 \$num of function dechex expects int, string given\.$#' + identifier: argument.type + count: 1 + path: lib/mactrack_dell.php + + - + message: '#^Function convert_dlink_data\(\) has no return type specified\.$#' + identifier: missingType.return + count: 1 + path: lib/mactrack_dlink.php + + - + message: '#^Function convert_dlink_data\(\) has parameter \$old_port_type with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: lib/mactrack_dlink.php + + - + message: '#^Function dec2hex\(\) has no return type specified\.$#' + identifier: missingType.return + count: 1 + path: lib/mactrack_dlink.php + + - + message: '#^Function dec2hex\(\) has parameter \$length with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: lib/mactrack_dlink.php + + - + message: '#^Function dec2hex\(\) has parameter \$number with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: lib/mactrack_dlink.php + + - + message: '#^Function dlink_convert_macs\(\) has no return type specified\.$#' + identifier: missingType.return + count: 1 + path: lib/mactrack_dlink.php + + - + message: '#^Function dlink_convert_macs\(\) has parameter \$oldmac with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: lib/mactrack_dlink.php + + - + message: '#^Function get_dlink_l2_dot1dTpFdbEntry_ports\(\) has no return type specified\.$#' + identifier: missingType.return + count: 1 + path: lib/mactrack_dlink.php + + - + message: '#^Function get_dlink_l2_dot1dTpFdbEntry_ports\(\) has parameter \$device with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: lib/mactrack_dlink.php + + - + message: '#^Function get_dlink_l2_dot1dTpFdbEntry_ports\(\) has parameter \$highPort with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: lib/mactrack_dlink.php + + - + message: '#^Function get_dlink_l2_dot1dTpFdbEntry_ports\(\) has parameter \$ifInterfaces with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: lib/mactrack_dlink.php + + - + message: '#^Function get_dlink_l2_dot1dTpFdbEntry_ports\(\) has parameter \$lowPort with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: lib/mactrack_dlink.php + + - + message: '#^Function get_dlink_l2_dot1dTpFdbEntry_ports\(\) has parameter \$site with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: lib/mactrack_dlink.php + + - + message: '#^Function get_dlink_l2_dot1dTpFdbEntry_ports\(\) has parameter \$snmp_readstring with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: lib/mactrack_dlink.php + + - + message: '#^Function get_dlink_l2_dot1dTpFdbEntry_ports\(\) has parameter \$store_to_db with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: lib/mactrack_dlink.php + + - + message: '#^Function get_dlink_l2_switch_ports\(\) has no return type specified\.$#' + identifier: missingType.return + count: 1 + path: lib/mactrack_dlink.php + + - + message: '#^Function get_dlink_l2_switch_ports\(\) has parameter \$device with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: lib/mactrack_dlink.php + + - + message: '#^Function get_dlink_l2_switch_ports\(\) has parameter \$highPort with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: lib/mactrack_dlink.php + + - + message: '#^Function get_dlink_l2_switch_ports\(\) has parameter \$lowPort with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: lib/mactrack_dlink.php + + - + message: '#^Function get_dlink_l2_switch_ports\(\) has parameter \$site with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: lib/mactrack_dlink.php + + - + message: '#^Function get_dlink_vlan_id\(\) has no return type specified\.$#' + identifier: missingType.return + count: 1 + path: lib/mactrack_dlink.php + + - + message: '#^Function get_dlink_vlan_id\(\) has parameter \$OID with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: lib/mactrack_dlink.php + + - + message: '#^Function stripos\(\) has no return type specified\.$#' + identifier: missingType.return + count: 1 + path: lib/mactrack_dlink.php + + - + message: '#^Function stripos\(\) has parameter \$needle with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: lib/mactrack_dlink.php + + - + message: '#^Function stripos\(\) has parameter \$str with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: lib/mactrack_dlink.php + + - + message: '#^Function xform_dlink_vlan_associations\(\) has no return type specified\.$#' + identifier: missingType.return + count: 1 + path: lib/mactrack_dlink.php + + - + message: '#^Function xform_dlink_vlan_associations\(\) has parameter \$device with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: lib/mactrack_dlink.php + + - + message: '#^Function xform_dlink_vlan_associations\(\) has parameter \$snmp_readstring with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: lib/mactrack_dlink.php + + - + message: '#^Unreachable statement \- code above always terminates\.$#' + identifier: deadCode.unreachable + count: 1 + path: lib/mactrack_dlink.php + + - + message: '#^Function get_enterasys_switch_ports\(\) has no return type specified\.$#' + identifier: missingType.return + count: 1 + path: lib/mactrack_enterasys.php + + - + message: '#^Function get_enterasys_switch_ports\(\) has parameter \$device with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: lib/mactrack_enterasys.php + + - + message: '#^Function get_enterasys_switch_ports\(\) has parameter \$highPort with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: lib/mactrack_enterasys.php + + - + message: '#^Function get_enterasys_switch_ports\(\) has parameter \$lowPort with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: lib/mactrack_enterasys.php + + - + message: '#^Function get_enterasys_switch_ports\(\) has parameter \$site with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: lib/mactrack_enterasys.php + + - + message: '#^Variable \$active_vlans might not be defined\.$#' + identifier: variable.undefined + count: 1 + path: lib/mactrack_enterasys.php + + - + message: '#^Variable \$ifInterfaces might not be defined\.$#' + identifier: variable.undefined + count: 1 + path: lib/mactrack_enterasys.php + + - + message: '#^Function enterasys_N7_convert_macs\(\) has no return type specified\.$#' + identifier: missingType.return + count: 1 + path: lib/mactrack_enterasys_N7.php + + - + message: '#^Function enterasys_N7_convert_macs\(\) has parameter \$oldmac with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: lib/mactrack_enterasys_N7.php + + - + message: '#^Function get_CTAlias_table\(\) has no return type specified\.$#' + identifier: missingType.return + count: 1 + path: lib/mactrack_enterasys_N7.php + + - + message: '#^Function get_CTAlias_table\(\) has parameter \$device with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: lib/mactrack_enterasys_N7.php + + - + message: '#^Function get_CTAlias_table\(\) has parameter \$site with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: lib/mactrack_enterasys_N7.php + + - + message: '#^Function get_enterasys_N7_dot1dTpFdbEntry_ports\(\) has no return type specified\.$#' + identifier: missingType.return + count: 1 + path: lib/mactrack_enterasys_N7.php + + - + message: '#^Function get_enterasys_N7_dot1dTpFdbEntry_ports\(\) has parameter \$device with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: lib/mactrack_enterasys_N7.php + + - + message: '#^Function get_enterasys_N7_dot1dTpFdbEntry_ports\(\) has parameter \$highPort with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: lib/mactrack_enterasys_N7.php + + - + message: '#^Function get_enterasys_N7_dot1dTpFdbEntry_ports\(\) has parameter \$ifInterfaces with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: lib/mactrack_enterasys_N7.php + + - + message: '#^Function get_enterasys_N7_dot1dTpFdbEntry_ports\(\) has parameter \$lowPort with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: lib/mactrack_enterasys_N7.php + + - + message: '#^Function get_enterasys_N7_dot1dTpFdbEntry_ports\(\) has parameter \$site with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: lib/mactrack_enterasys_N7.php + + - + message: '#^Function get_enterasys_N7_dot1dTpFdbEntry_ports\(\) has parameter \$snmp_readstring with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: lib/mactrack_enterasys_N7.php + + - + message: '#^Function get_enterasys_N7_dot1dTpFdbEntry_ports\(\) has parameter \$store_to_db with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: lib/mactrack_enterasys_N7.php + + - + message: '#^Function get_enterasys_N7_switch_ports\(\) has no return type specified\.$#' + identifier: missingType.return + count: 1 + path: lib/mactrack_enterasys_N7.php + + - + message: '#^Function get_enterasys_N7_switch_ports\(\) has parameter \$device with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: lib/mactrack_enterasys_N7.php + + - + message: '#^Function get_enterasys_N7_switch_ports\(\) has parameter \$highPort with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: lib/mactrack_enterasys_N7.php + + - + message: '#^Function get_enterasys_N7_switch_ports\(\) has parameter \$lowPort with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: lib/mactrack_enterasys_N7.php + + - + message: '#^Function get_enterasys_N7_switch_ports\(\) has parameter \$site with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: lib/mactrack_enterasys_N7.php + + - + message: '#^Function get_enterasys_N7_vlan_id\(\) has no return type specified\.$#' + identifier: missingType.return + count: 1 + path: lib/mactrack_enterasys_N7.php + + - + message: '#^Function get_enterasys_N7_vlan_id\(\) has parameter \$OID with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: lib/mactrack_enterasys_N7.php + + - + message: '#^Function xform_enterasys_N7_vlan_associations\(\) has no return type specified\.$#' + identifier: missingType.return + count: 1 + path: lib/mactrack_enterasys_N7.php + + - + message: '#^Function xform_enterasys_N7_vlan_associations\(\) has parameter \$device with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: lib/mactrack_enterasys_N7.php + + - + message: '#^Function xform_enterasys_N7_vlan_associations\(\) has parameter \$snmp_readstring with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: lib/mactrack_enterasys_N7.php + + - + message: '#^Cannot access offset int\<0, max\> on \(float\|int\)\.$#' + identifier: offsetAccess.nonOffsetAccessible + count: 2 + path: lib/mactrack_extreme.php + + - + message: '#^Function get_extreme_arp_table\(\) has no return type specified\.$#' + identifier: missingType.return + count: 1 + path: lib/mactrack_extreme.php + + - + message: '#^Function get_extreme_arp_table\(\) has parameter \$device with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: lib/mactrack_extreme.php + + - + message: '#^Function get_extreme_arp_table\(\) has parameter \$extremeware with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: lib/mactrack_extreme.php + + - + message: '#^Function get_extreme_arp_table\(\) has parameter \$site with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: lib/mactrack_extreme.php + + - + message: '#^Function get_extreme_extremeware_arp_table\(\) has no return type specified\.$#' + identifier: missingType.return + count: 1 + path: lib/mactrack_extreme.php + + - + message: '#^Function get_extreme_extremeware_arp_table\(\) has parameter \$device with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: lib/mactrack_extreme.php + + - + message: '#^Function get_extreme_extremeware_arp_table\(\) has parameter \$extremeware with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: lib/mactrack_extreme.php + + - + message: '#^Function get_extreme_extremeware_arp_table\(\) has parameter \$site with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: lib/mactrack_extreme.php + + - + message: '#^Function get_extreme_extremeware_switch_ports\(\) has no return type specified\.$#' + identifier: missingType.return + count: 1 + path: lib/mactrack_extreme.php + + - + message: '#^Function get_extreme_extremeware_switch_ports\(\) has parameter \$device with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: lib/mactrack_extreme.php + + - + message: '#^Function get_extreme_extremeware_switch_ports\(\) has parameter \$extremeware with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: lib/mactrack_extreme.php + + - + message: '#^Function get_extreme_extremeware_switch_ports\(\) has parameter \$highPort with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: lib/mactrack_extreme.php + + - + message: '#^Function get_extreme_extremeware_switch_ports\(\) has parameter \$lowPort with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: lib/mactrack_extreme.php + + - + message: '#^Function get_extreme_extremeware_switch_ports\(\) has parameter \$site with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: lib/mactrack_extreme.php + + - + message: '#^Function get_extreme_switch_ports\(\) has no return type specified\.$#' + identifier: missingType.return + count: 1 + path: lib/mactrack_extreme.php + + - + message: '#^Function get_extreme_switch_ports\(\) has parameter \$device with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: lib/mactrack_extreme.php + + - + message: '#^Function get_extreme_switch_ports\(\) has parameter \$extremeware with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: lib/mactrack_extreme.php + + - + message: '#^Function get_extreme_switch_ports\(\) has parameter \$highPort with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: lib/mactrack_extreme.php + + - + message: '#^Function get_extreme_switch_ports\(\) has parameter \$lowPort with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: lib/mactrack_extreme.php + + - + message: '#^Function get_extreme_switch_ports\(\) has parameter \$site with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: lib/mactrack_extreme.php + + - + message: '#^Variable \$active_vlans might not be defined\.$#' + identifier: variable.undefined + count: 1 + path: lib/mactrack_extreme.php + + - + message: '#^Cannot access offset int\<0, max\> on \(float\|int\)\.$#' + identifier: offsetAccess.nonOffsetAccessible + count: 2 + path: lib/mactrack_foundry.php + + - + message: '#^Function get_foundry_switch_ports\(\) has no return type specified\.$#' + identifier: missingType.return + count: 1 + path: lib/mactrack_foundry.php + + - + message: '#^Function get_foundry_switch_ports\(\) has parameter \$device with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: lib/mactrack_foundry.php + + - + message: '#^Function get_foundry_switch_ports\(\) has parameter \$highPort with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: lib/mactrack_foundry.php + + - + message: '#^Function get_foundry_switch_ports\(\) has parameter \$lowPort with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: lib/mactrack_foundry.php + + - + message: '#^Function get_foundry_switch_ports\(\) has parameter \$site with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: lib/mactrack_foundry.php + + - + message: '#^Variable \$active_vlans might not be defined\.$#' + identifier: variable.undefined + count: 1 + path: lib/mactrack_foundry.php + + - + message: '#^Variable \$ifInterfaces might not be defined\.$#' + identifier: variable.undefined + count: 2 + path: lib/mactrack_foundry.php + + - + message: '#^Binary operation "\*" between string and 3600 results in an error\.$#' + identifier: binaryOp.invalid + count: 2 + path: lib/mactrack_functions.php + + - + message: '#^Binary operation "\*" between string and 60 results in an error\.$#' + identifier: binaryOp.invalid + count: 2 + path: lib/mactrack_functions.php + + - + message: '#^Binary operation "\*" between string and 86400 results in an error\.$#' + identifier: binaryOp.invalid + count: 1 + path: lib/mactrack_functions.php + + - + message: '#^Comparison operation "\!\=" between non\-empty\-array and 0 results in an error\.$#' + identifier: notEqual.invalid + count: 1 + path: lib/mactrack_functions.php + + - + message: '#^Comparison operation "\=\=" between non\-empty\-list\ and 3 results in an error\.$#' + identifier: equal.invalid + count: 1 + path: lib/mactrack_functions.php + + - + message: '#^Function build_InterfacesTable\(\) has no return type specified\.$#' + identifier: missingType.return + count: 1 + path: lib/mactrack_functions.php + + - + message: '#^Function cacti_count\(\) has no return type specified\.$#' + identifier: missingType.return + count: 1 + path: lib/mactrack_functions.php + + - + message: '#^Function cacti_count\(\) has parameter \$array with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: lib/mactrack_functions.php + + - + message: '#^Function cacti_sizeof\(\) has no return type specified\.$#' + identifier: missingType.return + count: 1 + path: lib/mactrack_functions.php + + - + message: '#^Function cacti_sizeof\(\) has parameter \$array with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: lib/mactrack_functions.php + + - + message: '#^Function db_check_auth\(\) has no return type specified\.$#' + identifier: missingType.return + count: 1 + path: lib/mactrack_functions.php + + - + message: '#^Function db_check_auth\(\) has parameter \$mac_address with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: lib/mactrack_functions.php + + - + message: '#^Function db_check_for_ip\(\) has no return type specified\.$#' + identifier: missingType.return + count: 1 + path: lib/mactrack_functions.php + + - + message: '#^Function db_check_for_ip\(\) has parameter \$mac_address with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: lib/mactrack_functions.php + + - + message: '#^Function db_process_add\(\) has no return type specified\.$#' + identifier: missingType.return + count: 1 + path: lib/mactrack_functions.php + + - + message: '#^Function db_process_remove\(\) has no return type specified\.$#' + identifier: missingType.return + count: 1 + path: lib/mactrack_functions.php + + - + message: '#^Function db_store_device_port_results\(\) has no return type specified\.$#' + identifier: missingType.return + count: 1 + path: lib/mactrack_functions.php + + - + message: '#^Function db_update_device_status\(\) has no return type specified\.$#' + identifier: missingType.return + count: 1 + path: lib/mactrack_functions.php + + - + message: '#^Function find_scanning_function\(\) has no return type specified\.$#' + identifier: missingType.return + count: 1 + path: lib/mactrack_functions.php + + - + message: '#^Function get_base_dot1dTpFdbEntry_ports\(\) has no return type specified\.$#' + identifier: missingType.return + count: 1 + path: lib/mactrack_functions.php + + - + message: '#^Function get_base_dot1qTpFdbEntry_ports\(\) has no return type specified\.$#' + identifier: missingType.return + count: 1 + path: lib/mactrack_functions.php + + - + message: '#^Function get_base_wireless_dot1dTpFdbEntry_ports\(\) has no return type specified\.$#' + identifier: missingType.return + count: 1 + path: lib/mactrack_functions.php + + - + message: '#^Function get_generic_dot1q_switch_ports\(\) has no return type specified\.$#' + identifier: missingType.return + count: 1 + path: lib/mactrack_functions.php + + - + message: '#^Function get_generic_switch_ports\(\) has no return type specified\.$#' + identifier: missingType.return + count: 1 + path: lib/mactrack_functions.php + + - + message: '#^Function get_generic_wireless_ports\(\) has no return type specified\.$#' + identifier: missingType.return + count: 1 + path: lib/mactrack_functions.php + + - + message: '#^Function get_ios_vrf_arp_table\(\) has no return type specified\.$#' + identifier: missingType.return + count: 1 + path: lib/mactrack_functions.php + + - + message: '#^Function get_ios_vrf_arp_table\(\) has parameter \$device with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: lib/mactrack_functions.php + + - + message: '#^Function get_ios_vrf_arp_table\(\) has parameter \$hex with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: lib/mactrack_functions.php + + - + message: '#^Function get_ios_vrf_arp_table\(\) has parameter \$oid with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: lib/mactrack_functions.php + + - + message: '#^Function get_ios_vrf_arp_table\(\) has parameter \$snmp_readstring with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: lib/mactrack_functions.php + + - + message: '#^Function get_link_int_value\(\) has no return type specified\.$#' + identifier: missingType.return + count: 1 + path: lib/mactrack_functions.php + + - + message: '#^Function get_link_int_value\(\) has parameter \$bits with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: lib/mactrack_functions.php + + - + message: '#^Function get_link_int_value\(\) has parameter \$db_interface with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: lib/mactrack_functions.php + + - + message: '#^Function get_link_int_value\(\) has parameter \$divisor with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: lib/mactrack_functions.php + + - + message: '#^Function get_link_int_value\(\) has parameter \$ifIndex with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: lib/mactrack_functions.php + + - + message: '#^Function get_link_int_value\(\) has parameter \$snmp_array with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: lib/mactrack_functions.php + + - + message: '#^Function get_link_int_value\(\) has parameter \$snmp_oid with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: lib/mactrack_functions.php + + - + message: '#^Function get_link_int_value\(\) has parameter \$type with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: lib/mactrack_functions.php + + - + message: '#^Function get_link_port_status\(\) has no return type specified\.$#' + identifier: missingType.return + count: 1 + path: lib/mactrack_functions.php + + - + message: '#^Function get_link_port_status\(\) has parameter \$device with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: lib/mactrack_functions.php + + - + message: '#^Function get_netscreen_arp_table\(\) has no return type specified\.$#' + identifier: missingType.return + count: 1 + path: lib/mactrack_functions.php + + - + message: '#^Function get_netscreen_arp_table\(\) has parameter \$device with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: lib/mactrack_functions.php + + - + message: '#^Function get_netscreen_arp_table\(\) has parameter \$site with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: lib/mactrack_functions.php + + - + message: '#^Function get_standard_arp_table\(\) has no return type specified\.$#' + identifier: missingType.return + count: 1 + path: lib/mactrack_functions.php + + - + message: '#^Function import_oui_database\(\) has no return type specified\.$#' + identifier: missingType.return + count: 1 + path: lib/mactrack_functions.php + + - + message: '#^Function import_oui_database\(\) has parameter \$oui_file with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: lib/mactrack_functions.php + + - + message: '#^Function import_oui_database\(\) has parameter \$type with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: lib/mactrack_functions.php + + - + message: '#^Function mactrack_arr_key\(\) has no return type specified\.$#' + identifier: missingType.return + count: 1 + path: lib/mactrack_functions.php + + - + message: '#^Function mactrack_arr_key\(\) has parameter \$array with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: lib/mactrack_functions.php + + - + message: '#^Function mactrack_arr_key\(\) has parameter \$default with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: lib/mactrack_functions.php + + - + message: '#^Function mactrack_arr_key\(\) has parameter \$key with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: lib/mactrack_functions.php + + - + message: '#^Function mactrack_check_user_realm\(\) has no return type specified\.$#' + identifier: missingType.return + count: 1 + path: lib/mactrack_functions.php + + - + message: '#^Function mactrack_check_user_realm\(\) has parameter \$realm_id with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: lib/mactrack_functions.php + + - + message: '#^Function mactrack_create_sql_filter\(\) has no return type specified\.$#' + identifier: missingType.return + count: 1 + path: lib/mactrack_functions.php + + - + message: '#^Function mactrack_date\(\) has no return type specified\.$#' + identifier: missingType.return + count: 1 + path: lib/mactrack_functions.php + + - + message: '#^Function mactrack_date\(\) has parameter \$date with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: lib/mactrack_functions.php + + - + message: '#^Function mactrack_debug\(\) has no return type specified\.$#' + identifier: missingType.return + count: 1 + path: lib/mactrack_functions.php + + - + message: '#^Function mactrack_debug\(\) has parameter \$message with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: lib/mactrack_functions.php + + - + message: '#^Function mactrack_disable\(\) has no return type specified\.$#' + identifier: missingType.return + count: 1 + path: lib/mactrack_functions.php + + - + message: '#^Function mactrack_display_Octets\(\) has no return type specified\.$#' + identifier: missingType.return + count: 1 + path: lib/mactrack_functions.php + + - + message: '#^Function mactrack_display_Octets\(\) has parameter \$octets with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: lib/mactrack_functions.php + + - + message: '#^Function mactrack_display_hours\(\) has no return type specified\.$#' + identifier: missingType.return + count: 1 + path: lib/mactrack_functions.php + + - + message: '#^Function mactrack_display_hours\(\) has parameter \$value with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: lib/mactrack_functions.php + + - + message: '#^Function mactrack_display_stats\(\) has no return type specified\.$#' + identifier: missingType.return + count: 1 + path: lib/mactrack_functions.php + + - + message: '#^Function mactrack_dot1x_row_class\(\) has no return type specified\.$#' + identifier: missingType.return + count: 1 + path: lib/mactrack_functions.php + + - + message: '#^Function mactrack_dot1x_row_class\(\) has parameter \$port_result with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: lib/mactrack_functions.php + + - + message: '#^Function mactrack_enable\(\) has no return type specified\.$#' + identifier: missingType.return + count: 1 + path: lib/mactrack_functions.php + + - + message: '#^Function mactrack_find_host_graphs\(\) has no return type specified\.$#' + identifier: missingType.return + count: 1 + path: lib/mactrack_functions.php + + - + message: '#^Function mactrack_find_host_graphs\(\) has parameter \$device_id with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: lib/mactrack_functions.php + + - + message: '#^Function mactrack_find_host_graphs\(\) has parameter \$host_id with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: lib/mactrack_functions.php + + - + message: '#^Function mactrack_format_device_row\(\) has no return type specified\.$#' + identifier: missingType.return + count: 1 + path: lib/mactrack_functions.php + + - + message: '#^Function mactrack_format_device_row\(\) has parameter \$actions with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: lib/mactrack_functions.php + + - + message: '#^Function mactrack_format_device_row\(\) has parameter \$device with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: lib/mactrack_functions.php + + - + message: '#^Function mactrack_format_dot1x_row\(\) has no return type specified\.$#' + identifier: missingType.return + count: 1 + path: lib/mactrack_functions.php + + - + message: '#^Function mactrack_format_dot1x_row\(\) has parameter \$port_result with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: lib/mactrack_functions.php + + - + message: '#^Function mactrack_format_interface_row\(\) has no return type specified\.$#' + identifier: missingType.return + count: 1 + path: lib/mactrack_functions.php + + - + message: '#^Function mactrack_format_interface_row\(\) has parameter \$stat with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: lib/mactrack_functions.php + + - + message: '#^Function mactrack_format_mac\(\) has no return type specified\.$#' + identifier: missingType.return + count: 1 + path: lib/mactrack_functions.php + + - + message: '#^Function mactrack_format_mac\(\) has parameter \$mac with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: lib/mactrack_functions.php + + - + message: '#^Function mactrack_get_dns_from_ip\(\) has no return type specified\.$#' + identifier: missingType.return + count: 1 + path: lib/mactrack_functions.php + + - + message: '#^Function mactrack_get_vendor_name\(\) has no return type specified\.$#' + identifier: missingType.return + count: 1 + path: lib/mactrack_functions.php + + - + message: '#^Function mactrack_get_vendor_name\(\) has parameter \$mac with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: lib/mactrack_functions.php + + - + message: '#^Function mactrack_int_row_class\(\) has no return type specified\.$#' + identifier: missingType.return + count: 1 + path: lib/mactrack_functions.php + + - + message: '#^Function mactrack_int_row_class\(\) has parameter \$stat with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: lib/mactrack_functions.php + + - + message: '#^Function mactrack_interface_actions\(\) has no return type specified\.$#' + identifier: missingType.return + count: 1 + path: lib/mactrack_functions.php + + - + message: '#^Function mactrack_interface_actions\(\) has parameter \$device_id with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: lib/mactrack_functions.php + + - + message: '#^Function mactrack_interface_actions\(\) has parameter \$ifIndex with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: lib/mactrack_functions.php + + - + message: '#^Function mactrack_interface_actions\(\) has parameter \$show_rescan with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: lib/mactrack_functions.php + + - + message: '#^Function mactrack_legend_row\(\) has no return type specified\.$#' + identifier: missingType.return + count: 1 + path: lib/mactrack_functions.php + + - + message: '#^Function mactrack_legend_row\(\) has parameter \$class with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: lib/mactrack_functions.php + + - + message: '#^Function mactrack_legend_row\(\) has parameter \$text with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: lib/mactrack_functions.php + + - + message: '#^Function mactrack_log_action\(\) has no return type specified\.$#' + identifier: missingType.return + count: 1 + path: lib/mactrack_functions.php + + - + message: '#^Function mactrack_log_action\(\) has parameter \$message with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: lib/mactrack_functions.php + + - + message: '#^Function mactrack_mail\(\) has no return type specified\.$#' + identifier: missingType.return + count: 1 + path: lib/mactrack_functions.php + + - + message: '#^Function mactrack_mail\(\) has parameter \$fromemail with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: lib/mactrack_functions.php + + - + message: '#^Function mactrack_mail\(\) has parameter \$fromname with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: lib/mactrack_functions.php + + - + message: '#^Function mactrack_mail\(\) has parameter \$headers with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: lib/mactrack_functions.php + + - + message: '#^Function mactrack_mail\(\) has parameter \$message with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: lib/mactrack_functions.php + + - + message: '#^Function mactrack_mail\(\) has parameter \$subject with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: lib/mactrack_functions.php + + - + message: '#^Function mactrack_mail\(\) has parameter \$to with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: lib/mactrack_functions.php + + - + message: '#^Function mactrack_rebuild_scanning_funcs\(\) has no return type specified\.$#' + identifier: missingType.return + count: 1 + path: lib/mactrack_functions.php + + - + message: '#^Function mactrack_rescan\(\) has no return type specified\.$#' + identifier: missingType.return + count: 1 + path: lib/mactrack_functions.php + + - + message: '#^Function mactrack_rescan\(\) has parameter \$web with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: lib/mactrack_functions.php + + - + message: '#^Function mactrack_sanitize_load_report\(\) has no return type specified\.$#' + identifier: missingType.return + count: 1 + path: lib/mactrack_functions.php + + - + message: '#^Function mactrack_site_filter\(\) has no return type specified\.$#' + identifier: missingType.return + count: 1 + path: lib/mactrack_functions.php + + - + message: '#^Function mactrack_site_filter\(\) has parameter \$page with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: lib/mactrack_functions.php + + - + message: '#^Function mactrack_site_scan\(\) has no return type specified\.$#' + identifier: missingType.return + count: 1 + path: lib/mactrack_functions.php + + - + message: '#^Function mactrack_site_scan\(\) has parameter \$web with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: lib/mactrack_functions.php + + - + message: '#^Function mactrack_strip_alpha\(\) has no return type specified\.$#' + identifier: missingType.return + count: 1 + path: lib/mactrack_functions.php + + - + message: '#^Function mactrack_strip_alpha\(\) has parameter \$string with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: lib/mactrack_functions.php + + - + message: '#^Function mactrack_tabs\(\) has no return type specified\.$#' + identifier: missingType.return + count: 1 + path: lib/mactrack_functions.php + + - + message: '#^Function mactrack_timetics_to_seconds\(\) has no return type specified\.$#' + identifier: missingType.return + count: 1 + path: lib/mactrack_functions.php + + - + message: '#^Function mactrack_timetics_to_seconds\(\) has parameter \$timetics with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: lib/mactrack_functions.php + + - + message: '#^Function perform_mactrack_db_maint\(\) has no return type specified\.$#' + identifier: missingType.return + count: 1 + path: lib/mactrack_functions.php + + - + message: '#^Function port_list_to_array\(\) has no return type specified\.$#' + identifier: missingType.return + count: 1 + path: lib/mactrack_functions.php + + - + message: '#^Function valid_snmp_device\(\) has no return type specified\.$#' + identifier: missingType.return + count: 1 + path: lib/mactrack_functions.php + + - + message: '#^Function valid_snmp_device\(\) has parameter \$device with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: lib/mactrack_functions.php + + - + message: '#^Function xform_cisco_workgroup_port_data\(\) has no return type specified\.$#' + identifier: missingType.return + count: 1 + path: lib/mactrack_functions.php + + - + message: '#^Function xform_dot1q_vlan_associations\(\) has no return type specified\.$#' + identifier: missingType.return + count: 1 + path: lib/mactrack_functions.php + + - + message: '#^Function xform_indexed_data\(\) has no return type specified\.$#' + identifier: missingType.return + count: 1 + path: lib/mactrack_functions.php + + - + message: '#^Function xform_mac_address\(\) has no return type specified\.$#' + identifier: missingType.return + count: 1 + path: lib/mactrack_functions.php + + - + message: '#^Function xform_net_address\(\) has no return type specified\.$#' + identifier: missingType.return + count: 1 + path: lib/mactrack_functions.php + + - + message: '#^Function xform_net_address\(\) has parameter \$ip_address with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: lib/mactrack_functions.php + + - + message: '#^Function xform_standard_indexed_data\(\) has no return type specified\.$#' + identifier: missingType.return + count: 1 + path: lib/mactrack_functions.php + + - + message: '#^Function xform_stripped_oid\(\) has no return type specified\.$#' + identifier: missingType.return + count: 1 + path: lib/mactrack_functions.php + + - + message: '#^Function xform_stripped_oid\(\) has parameter \$device with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: lib/mactrack_functions.php + + - + message: '#^Function xform_stripped_oid\(\) has parameter \$hex with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: lib/mactrack_functions.php + + - + message: '#^Function xform_stripped_oid\(\) has parameter \$oid with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: lib/mactrack_functions.php + + - + message: '#^Function xform_stripped_oid\(\) has parameter \$snmp_readstring with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: lib/mactrack_functions.php + + - + message: '#^Loose comparison using \=\= between non\-empty\-list\ and 3 will always evaluate to false\.$#' + identifier: equal.alwaysFalse + count: 1 + path: lib/mactrack_functions.php + + - + message: '#^Parameter \#1 \$num of function round expects float\|int, string given\.$#' + identifier: argument.type + count: 3 + path: lib/mactrack_functions.php + + - + message: '#^Parameter \#1 \$string of function substr expects string, float given\.$#' + identifier: argument.type + count: 1 + path: lib/mactrack_functions.php + + - + message: '#^Parameter \#1 \$string of function substr expects string, int\<10, 99\> given\.$#' + identifier: argument.type + count: 1 + path: lib/mactrack_functions.php + + - + message: '#^Parameter \#2 \$enable of function stream_set_blocking expects bool, int given\.$#' + identifier: argument.type + count: 1 + path: lib/mactrack_functions.php + + - + message: '#^Parameter \#2 \$seconds of function stream_set_timeout expects int, float given\.$#' + identifier: argument.type + count: 1 + path: lib/mactrack_functions.php + + - + message: '#^Parameter \#3 \$div of function html_start_box expects bool, string given\.$#' + identifier: argument.type + count: 2 + path: lib/mactrack_functions.php + + - + message: '#^Parameter \#4 \$cell_padding of function html_start_box expects int, string given\.$#' + identifier: argument.type + count: 2 + path: lib/mactrack_functions.php + + - + message: '#^Undefined variable\: \$stat$#' + identifier: variable.undefined + count: 1 + path: lib/mactrack_functions.php + + - + message: '#^Unreachable statement \- code above always terminates\.$#' + identifier: deadCode.unreachable + count: 1 + path: lib/mactrack_functions.php + + - + message: '#^Variable \$atEntries might not be defined\.$#' + identifier: variable.undefined + count: 3 + path: lib/mactrack_functions.php + + - + message: '#^Variable \$brPortIfIndex might not be defined\.$#' + identifier: variable.undefined + count: 2 + path: lib/mactrack_functions.php + + - + message: '#^Variable \$brPortIfType might not be defined\.$#' + identifier: variable.undefined + count: 1 + path: lib/mactrack_functions.php + + - + message: '#^Variable \$int_ifHCInOctets might not be defined\.$#' + identifier: variable.undefined + count: 1 + path: lib/mactrack_functions.php + + - + message: '#^Variable \$int_ifHCOutOctets might not be defined\.$#' + identifier: variable.undefined + count: 1 + path: lib/mactrack_functions.php + + - + message: '#^Variable \$parts in empty\(\) always exists and is not falsy\.$#' + identifier: empty.variable + count: 1 + path: lib/mactrack_functions.php + + - + message: '#^Variable \$xformItem_piece might not be defined\.$#' + identifier: variable.undefined + count: 1 + path: lib/mactrack_functions.php + + - + message: '#^Function get_h3c_3com_arp_table\(\) has no return type specified\.$#' + identifier: missingType.return + count: 1 + path: lib/mactrack_h3c_3com.php + + - + message: '#^Function get_h3c_3com_arp_table\(\) has parameter \$device with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: lib/mactrack_h3c_3com.php + + - + message: '#^Function get_h3c_3com_arp_table\(\) has parameter \$site with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: lib/mactrack_h3c_3com.php + + - + message: '#^Function get_h3c_3com_dot1dTpFdbEntry_ports\(\) has no return type specified\.$#' + identifier: missingType.return + count: 1 + path: lib/mactrack_h3c_3com.php + + - + message: '#^Function get_h3c_3com_dot1dTpFdbEntry_ports\(\) has parameter \$device with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: lib/mactrack_h3c_3com.php + + - + message: '#^Function get_h3c_3com_dot1dTpFdbEntry_ports\(\) has parameter \$highPort with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: lib/mactrack_h3c_3com.php + + - + message: '#^Function get_h3c_3com_dot1dTpFdbEntry_ports\(\) has parameter \$ifInterfaces with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: lib/mactrack_h3c_3com.php + + - + message: '#^Function get_h3c_3com_dot1dTpFdbEntry_ports\(\) has parameter \$lowPort with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: lib/mactrack_h3c_3com.php + + - + message: '#^Function get_h3c_3com_dot1dTpFdbEntry_ports\(\) has parameter \$site with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: lib/mactrack_h3c_3com.php + + - + message: '#^Function get_h3c_3com_dot1dTpFdbEntry_ports\(\) has parameter \$snmp_readstring with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: lib/mactrack_h3c_3com.php + + - + message: '#^Function get_h3c_3com_dot1dTpFdbEntry_ports\(\) has parameter \$store_to_db with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: lib/mactrack_h3c_3com.php + + - + message: '#^Function get_h3c_3com_switch_ports\(\) has no return type specified\.$#' + identifier: missingType.return + count: 1 + path: lib/mactrack_h3c_3com.php + + - + message: '#^Function get_h3c_3com_switch_ports\(\) has parameter \$device with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: lib/mactrack_h3c_3com.php + + - + message: '#^Function get_h3c_3com_switch_ports\(\) has parameter \$highPort with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: lib/mactrack_h3c_3com.php + + - + message: '#^Function get_h3c_3com_switch_ports\(\) has parameter \$lowPort with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: lib/mactrack_h3c_3com.php + + - + message: '#^Function get_h3c_3com_switch_ports\(\) has parameter \$site with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: lib/mactrack_h3c_3com.php + + - + message: '#^Function get_procurve_switch_ports\(\) has no return type specified\.$#' + identifier: missingType.return + count: 1 + path: lib/mactrack_hp.php + + - + message: '#^Function get_procurve_switch_ports\(\) has parameter \$device with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: lib/mactrack_hp.php + + - + message: '#^Function get_procurve_switch_ports\(\) has parameter \$highPort with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: lib/mactrack_hp.php + + - + message: '#^Function get_procurve_switch_ports\(\) has parameter \$lowPort with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: lib/mactrack_hp.php + + - + message: '#^Function get_procurve_switch_ports\(\) has parameter \$site with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: lib/mactrack_hp.php + + - + message: '#^Function get_procurve_ng_switch_ports\(\) has no return type specified\.$#' + identifier: missingType.return + count: 1 + path: lib/mactrack_hp_ng.php + + - + message: '#^Function get_procurve_ng_switch_ports\(\) has parameter \$device with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: lib/mactrack_hp_ng.php + + - + message: '#^Function get_procurve_ng_switch_ports\(\) has parameter \$highPort with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: lib/mactrack_hp_ng.php + + - + message: '#^Function get_procurve_ng_switch_ports\(\) has parameter \$lowPort with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: lib/mactrack_hp_ng.php + + - + message: '#^Function get_procurve_ng_switch_ports\(\) has parameter \$site with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: lib/mactrack_hp_ng.php + + - + message: '#^Variable \$active_vlans might not be defined\.$#' + identifier: variable.undefined + count: 1 + path: lib/mactrack_hp_ng.php + + - + message: '#^Function get_base_dot1dTpFdbEntry_ports invoked with 8 parameters, 3\-7 required\.$#' + identifier: arguments.count + count: 1 + path: lib/mactrack_hp_ngi.php + + - + message: '#^Function get_procurve_ngi_switch_ports\(\) has no return type specified\.$#' + identifier: missingType.return + count: 1 + path: lib/mactrack_hp_ngi.php + + - + message: '#^Function get_procurve_ngi_switch_ports\(\) has parameter \$device with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: lib/mactrack_hp_ngi.php + + - + message: '#^Function get_procurve_ngi_switch_ports\(\) has parameter \$highPort with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: lib/mactrack_hp_ngi.php + + - + message: '#^Function get_procurve_ngi_switch_ports\(\) has parameter \$lowPort with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: lib/mactrack_hp_ngi.php + + - + message: '#^Function get_procurve_ngi_switch_ports\(\) has parameter \$site with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: lib/mactrack_hp_ngi.php + + - + message: '#^Function local_xform_indexed_data\(\) has no return type specified\.$#' + identifier: missingType.return + count: 1 + path: lib/mactrack_hp_ngi.php + + - + message: '#^Function local_xform_indexed_data\(\) has parameter \$device with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: lib/mactrack_hp_ngi.php + + - + message: '#^Function local_xform_indexed_data\(\) has parameter \$xformLevel with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: lib/mactrack_hp_ngi.php + + - + message: '#^Function local_xform_indexed_data\(\) has parameter \$xformOID with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: lib/mactrack_hp_ngi.php + + - + message: '#^Variable \$active_vlans might not be defined\.$#' + identifier: variable.undefined + count: 1 + path: lib/mactrack_hp_ngi.php + + - + message: '#^Variable \$xformItem_piece might not be defined\.$#' + identifier: variable.undefined + count: 1 + path: lib/mactrack_hp_ngi.php + + - + message: '#^Cannot access offset string on \(float\|int\)\.$#' + identifier: offsetAccess.nonOffsetAccessible + count: 2 + path: lib/mactrack_juniper.php + + - + message: '#^Function get_JEX_switch_ports\(\) has no return type specified\.$#' + identifier: missingType.return + count: 1 + path: lib/mactrack_juniper.php + + - + message: '#^Function get_JEX_switch_ports\(\) has parameter \$device with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: lib/mactrack_juniper.php + + - + message: '#^Function get_JEX_switch_ports\(\) has parameter \$highPort with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: lib/mactrack_juniper.php + + - + message: '#^Function get_JEX_switch_ports\(\) has parameter \$lowPort with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: lib/mactrack_juniper.php + + - + message: '#^Function get_JEX_switch_ports\(\) has parameter \$site with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: lib/mactrack_juniper.php + + - + message: '#^Function mach\(\) has no return type specified\.$#' + identifier: missingType.return + count: 1 + path: lib/mactrack_juniper.php + + - + message: '#^Function mach\(\) has parameter \$del with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: lib/mactrack_juniper.php + + - + message: '#^Function mach\(\) has parameter \$macd with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: lib/mactrack_juniper.php + + - + message: '#^Variable \$active_vlans might not be defined\.$#' + identifier: variable.undefined + count: 3 + path: lib/mactrack_juniper.php + + - + message: '#^Variable \$ifDesc in isset\(\) always exists and is not nullable\.$#' + identifier: isset.variable + count: 1 + path: lib/mactrack_juniper.php + + - + message: '#^Function convert_port_state_data\(\) has no return type specified\.$#' + identifier: missingType.return + count: 1 + path: lib/mactrack_linux.php + + - + message: '#^Function convert_port_state_data\(\) has parameter \$old_port_type with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: lib/mactrack_linux.php + + - + message: '#^Function get_linux_dot1dTpFdbEntry_ports\(\) has no return type specified\.$#' + identifier: missingType.return + count: 1 + path: lib/mactrack_linux.php + + - + message: '#^Function get_linux_dot1dTpFdbEntry_ports\(\) has parameter \$device with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: lib/mactrack_linux.php + + - + message: '#^Function get_linux_dot1dTpFdbEntry_ports\(\) has parameter \$highPort with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: lib/mactrack_linux.php + + - + message: '#^Function get_linux_dot1dTpFdbEntry_ports\(\) has parameter \$ifInterfaces with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: lib/mactrack_linux.php + + - + message: '#^Function get_linux_dot1dTpFdbEntry_ports\(\) has parameter \$lowPort with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: lib/mactrack_linux.php + + - + message: '#^Function get_linux_dot1dTpFdbEntry_ports\(\) has parameter \$site with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: lib/mactrack_linux.php + + - + message: '#^Function get_linux_dot1dTpFdbEntry_ports\(\) has parameter \$snmp_readstring with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: lib/mactrack_linux.php + + - + message: '#^Function get_linux_dot1dTpFdbEntry_ports\(\) has parameter \$store_to_db with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: lib/mactrack_linux.php + + - + message: '#^Function get_linux_switch_ports\(\) has no return type specified\.$#' + identifier: missingType.return + count: 1 + path: lib/mactrack_linux.php + + - + message: '#^Function get_linux_switch_ports\(\) has parameter \$device with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: lib/mactrack_linux.php + + - + message: '#^Function get_linux_switch_ports\(\) has parameter \$highPort with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: lib/mactrack_linux.php + + - + message: '#^Function get_linux_switch_ports\(\) has parameter \$lowPort with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: lib/mactrack_linux.php + + - + message: '#^Function get_linux_switch_ports\(\) has parameter \$site with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: lib/mactrack_linux.php + + - + message: '#^Variable \$ifVlan might not be defined\.$#' + identifier: variable.undefined + count: 1 + path: lib/mactrack_linux.php + + - + message: '#^Function get_norbay_accelar_switch_ports\(\) has no return type specified\.$#' + identifier: missingType.return + count: 1 + path: lib/mactrack_norbay.php + + - + message: '#^Function get_norbay_accelar_switch_ports\(\) has parameter \$device with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: lib/mactrack_norbay.php + + - + message: '#^Function get_norbay_accelar_switch_ports\(\) has parameter \$highPort with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: lib/mactrack_norbay.php + + - + message: '#^Function get_norbay_accelar_switch_ports\(\) has parameter \$lowPort with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: lib/mactrack_norbay.php + + - + message: '#^Function get_norbay_accelar_switch_ports\(\) has parameter \$site with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: lib/mactrack_norbay.php + + - + message: '#^Function get_norbay_switch_ports\(\) has no return type specified\.$#' + identifier: missingType.return + count: 1 + path: lib/mactrack_norbay.php + + - + message: '#^Function get_norbay_switch_ports\(\) has parameter \$device with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: lib/mactrack_norbay.php + + - + message: '#^Function get_norbay_switch_ports\(\) has parameter \$highPort with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: lib/mactrack_norbay.php + + - + message: '#^Function get_norbay_switch_ports\(\) has parameter \$lowPort with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: lib/mactrack_norbay.php + + - + message: '#^Function get_norbay_switch_ports\(\) has parameter \$site with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: lib/mactrack_norbay.php + + - + message: '#^Undefined variable\: \$ifindex$#' + identifier: variable.undefined + count: 2 + path: lib/mactrack_norbay.php + + - + message: '#^Variable \$active_vlans might not be defined\.$#' + identifier: variable.undefined + count: 2 + path: lib/mactrack_norbay.php + + - + message: '#^Function get_norbay_ng_switch_ports\(\) has no return type specified\.$#' + identifier: missingType.return + count: 1 + path: lib/mactrack_norbay_ng.php + + - + message: '#^Function get_norbay_ng_switch_ports\(\) has parameter \$device with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: lib/mactrack_norbay_ng.php + + - + message: '#^Function get_norbay_ng_switch_ports\(\) has parameter \$highPort with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: lib/mactrack_norbay_ng.php + + - + message: '#^Function get_norbay_ng_switch_ports\(\) has parameter \$lowPort with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: lib/mactrack_norbay_ng.php + + - + message: '#^Function get_norbay_ng_switch_ports\(\) has parameter \$site with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: lib/mactrack_norbay_ng.php + + - + message: '#^Variable \$active_vlans might not be defined\.$#' + identifier: variable.undefined + count: 1 + path: lib/mactrack_norbay_ng.php + + - + message: '#^Function get_tplink_dot1q_switch_ports\(\) has no return type specified\.$#' + identifier: missingType.return + count: 1 + path: lib/mactrack_tplink.php + + - + message: '#^Function get_tplink_dot1q_switch_ports\(\) has parameter \$device with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: lib/mactrack_tplink.php + + - + message: '#^Function get_tplink_dot1q_switch_ports\(\) has parameter \$highPort with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: lib/mactrack_tplink.php + + - + message: '#^Function get_tplink_dot1q_switch_ports\(\) has parameter \$lowPort with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: lib/mactrack_tplink.php + + - + message: '#^Function get_tplink_dot1q_switch_ports\(\) has parameter \$site with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: lib/mactrack_tplink.php + + - + message: '#^Function tp_mach\(\) has no return type specified\.$#' + identifier: missingType.return + count: 1 + path: lib/mactrack_tplink.php + + - + message: '#^Function tp_mach\(\) has parameter \$del with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: lib/mactrack_tplink.php + + - + message: '#^Function tp_mach\(\) has parameter \$macd with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: lib/mactrack_tplink.php + + - + message: '#^Variable \$nport_results might not be defined\.$#' + identifier: variable.undefined + count: 1 + path: lib/mactrack_tplink.php + + - + message: '#^Function get_base_trendnet_dot1qFdb_ports\(\) has no return type specified\.$#' + identifier: missingType.return + count: 1 + path: lib/mactrack_trendnet.php + + - + message: '#^Function get_base_trendnet_dot1qFdb_ports\(\) has parameter \$device with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: lib/mactrack_trendnet.php + + - + message: '#^Function get_base_trendnet_dot1qFdb_ports\(\) has parameter \$highPort with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: lib/mactrack_trendnet.php + + - + message: '#^Function get_base_trendnet_dot1qFdb_ports\(\) has parameter \$ifInterfaces with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: lib/mactrack_trendnet.php + + - + message: '#^Function get_base_trendnet_dot1qFdb_ports\(\) has parameter \$lowPort with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: lib/mactrack_trendnet.php + + - + message: '#^Function get_base_trendnet_dot1qFdb_ports\(\) has parameter \$site with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: lib/mactrack_trendnet.php + + - + message: '#^Function get_base_trendnet_dot1qFdb_ports\(\) has parameter \$snmp_readstring with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: lib/mactrack_trendnet.php + + - + message: '#^Function get_base_trendnet_dot1qFdb_ports\(\) has parameter \$store_to_db with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: lib/mactrack_trendnet.php + + - + message: '#^Function get_trendnet_dot1q_switch_ports\(\) has no return type specified\.$#' + identifier: missingType.return + count: 1 + path: lib/mactrack_trendnet.php + + - + message: '#^Function get_trendnet_dot1q_switch_ports\(\) has parameter \$device with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: lib/mactrack_trendnet.php + + - + message: '#^Function get_trendnet_dot1q_switch_ports\(\) has parameter \$highPort with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: lib/mactrack_trendnet.php + + - + message: '#^Function get_trendnet_dot1q_switch_ports\(\) has parameter \$lowPort with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: lib/mactrack_trendnet.php + + - + message: '#^Function get_trendnet_dot1q_switch_ports\(\) has parameter \$site with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: lib/mactrack_trendnet.php + + - + message: '#^Function api_mactrack_device_remove\(\) has no return type specified\.$#' + identifier: missingType.return + count: 1 + path: mactrack_actions.php + + - + message: '#^Function api_mactrack_device_remove\(\) has parameter \$device_id with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: mactrack_actions.php + + - + message: '#^Function api_mactrack_device_save\(\) has no return type specified\.$#' + identifier: missingType.return + count: 1 + path: mactrack_actions.php + + - + message: '#^Function api_mactrack_device_save\(\) has parameter \$device_id with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: mactrack_actions.php + + - + message: '#^Function api_mactrack_device_save\(\) has parameter \$device_name with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: mactrack_actions.php + + - + message: '#^Function api_mactrack_device_save\(\) has parameter \$device_type_id with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: mactrack_actions.php + + - + message: '#^Function api_mactrack_device_save\(\) has parameter \$disabled with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: mactrack_actions.php + + - + message: '#^Function api_mactrack_device_save\(\) has parameter \$host_id with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: mactrack_actions.php + + - + message: '#^Function api_mactrack_device_save\(\) has parameter \$hostname with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: mactrack_actions.php + + - + message: '#^Function api_mactrack_device_save\(\) has parameter \$ignorePorts with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: mactrack_actions.php + + - + message: '#^Function api_mactrack_device_save\(\) has parameter \$max_oids with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: mactrack_actions.php + + - + message: '#^Function api_mactrack_device_save\(\) has parameter \$notes with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: mactrack_actions.php + + - + message: '#^Function api_mactrack_device_save\(\) has parameter \$private_key_path with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: mactrack_actions.php + + - + message: '#^Function api_mactrack_device_save\(\) has parameter \$scan_trunk_port with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: mactrack_actions.php + + - + message: '#^Function api_mactrack_device_save\(\) has parameter \$scan_type with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: mactrack_actions.php + + - + message: '#^Function api_mactrack_device_save\(\) has parameter \$site_id with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: mactrack_actions.php + + - + message: '#^Function api_mactrack_device_save\(\) has parameter \$snmp_auth_protocol with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: mactrack_actions.php + + - + message: '#^Function api_mactrack_device_save\(\) has parameter \$snmp_context with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: mactrack_actions.php + + - + message: '#^Function api_mactrack_device_save\(\) has parameter \$snmp_engine_id with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: mactrack_actions.php + + - + message: '#^Function api_mactrack_device_save\(\) has parameter \$snmp_options with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: mactrack_actions.php + + - + message: '#^Function api_mactrack_device_save\(\) has parameter \$snmp_password with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: mactrack_actions.php + + - + message: '#^Function api_mactrack_device_save\(\) has parameter \$snmp_port with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: mactrack_actions.php + + - + message: '#^Function api_mactrack_device_save\(\) has parameter \$snmp_priv_passphrase with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: mactrack_actions.php + + - + message: '#^Function api_mactrack_device_save\(\) has parameter \$snmp_priv_protocol with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: mactrack_actions.php + + - + message: '#^Function api_mactrack_device_save\(\) has parameter \$snmp_readstring with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: mactrack_actions.php + + - + message: '#^Function api_mactrack_device_save\(\) has parameter \$snmp_retries with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: mactrack_actions.php + + - + message: '#^Function api_mactrack_device_save\(\) has parameter \$snmp_timeout with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: mactrack_actions.php + + - + message: '#^Function api_mactrack_device_save\(\) has parameter \$snmp_username with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: mactrack_actions.php + + - + message: '#^Function api_mactrack_device_save\(\) has parameter \$snmp_version with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: mactrack_actions.php + + - + message: '#^Function api_mactrack_device_save\(\) has parameter \$term_type with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: mactrack_actions.php + + - + message: '#^Function api_mactrack_device_save\(\) has parameter \$user_name with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: mactrack_actions.php + + - + message: '#^Function api_mactrack_device_save\(\) has parameter \$user_password with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: mactrack_actions.php + + - + message: '#^Function api_mactrack_site_remove\(\) has no return type specified\.$#' + identifier: missingType.return + count: 1 + path: mactrack_actions.php + + - + message: '#^Function api_mactrack_site_remove\(\) has parameter \$site_id with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: mactrack_actions.php + + - + message: '#^Function api_mactrack_site_save\(\) has no return type specified\.$#' + identifier: missingType.return + count: 1 + path: mactrack_actions.php + + - + message: '#^Function api_mactrack_site_save\(\) has parameter \$customer_contact with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: mactrack_actions.php + + - + message: '#^Function api_mactrack_site_save\(\) has parameter \$facilities_contact with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: mactrack_actions.php + + - + message: '#^Function api_mactrack_site_save\(\) has parameter \$netops_contact with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: mactrack_actions.php + + - + message: '#^Function api_mactrack_site_save\(\) has parameter \$scan_vlans with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: mactrack_actions.php + + - + message: '#^Function api_mactrack_site_save\(\) has parameter \$site_id with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: mactrack_actions.php + + - + message: '#^Function api_mactrack_site_save\(\) has parameter \$site_info with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: mactrack_actions.php + + - + message: '#^Function api_mactrack_site_save\(\) has parameter \$site_name with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: mactrack_actions.php + + - + message: '#^Function api_mactrack_site_save\(\) has parameter \$skip_vlans with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: mactrack_actions.php + + - + message: '#^Function mactrack_device_action_array\(\) has no return type specified\.$#' + identifier: missingType.return + count: 1 + path: mactrack_actions.php + + - + message: '#^Function mactrack_device_action_execute\(\) has no return type specified\.$#' + identifier: missingType.return + count: 1 + path: mactrack_actions.php + + - + message: '#^Function mactrack_device_action_prepare\(\) has no return type specified\.$#' + identifier: missingType.return + count: 1 + path: mactrack_actions.php + + - + message: '#^Function mactrack_device_action_prepare\(\) has parameter \$save with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: mactrack_actions.php + + - + message: '#^Function sync_cacti_to_mactrack\(\) has no return type specified\.$#' + identifier: missingType.return + count: 1 + path: mactrack_actions.php + + - + message: '#^Function sync_cacti_to_mactrack\(\) has parameter \$device with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: mactrack_actions.php + + - + message: '#^Function sync_mactrack_to_cacti\(\) has no return type specified\.$#' + identifier: missingType.return + count: 1 + path: mactrack_actions.php + + - + message: '#^Function sync_mactrack_to_cacti\(\) has parameter \$mt_device with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: mactrack_actions.php + + - + message: '#^Function mactrack_save_graph_settings not found\.$#' + identifier: function.notFound + count: 1 + path: mactrack_ajax.php + + - + message: '#^Path in include\(\) "\./include/auth\.php" is not a file or it does not exist\.$#' + identifier: include.fileNotFound + count: 1 + path: mactrack_ajax.php + + - + message: '#^Path in include_once\(\) "\./plugins/mactrack/lib/mactrack_functions\.php" is not a file or it does not exist\.$#' + identifier: includeOnce.fileNotFound + count: 1 + path: mactrack_ajax.php + + - + message: '#^Path in include\(\) "\./include/auth\.php" is not a file or it does not exist\.$#' + identifier: include.fileNotFound + count: 1 + path: mactrack_ajax_admin.php + + - + message: '#^Path in include_once\(\) "\./plugins/mactrack/lib/mactrack_functions\.php" is not a file or it does not exist\.$#' + identifier: includeOnce.fileNotFound + count: 1 + path: mactrack_ajax_admin.php + + - + message: '#^Function display_help\(\) has no return type specified\.$#' + identifier: missingType.return + count: 1 + path: mactrack_convert.php + + - + message: '#^Function display_version\(\) has no return type specified\.$#' + identifier: missingType.return + count: 1 + path: mactrack_convert.php + + - + message: '#^Function mactrack_create_partitioned_table\(\) has no return type specified\.$#' + identifier: missingType.return + count: 1 + path: mactrack_convert.php + + - + message: '#^Function mactrack_create_partitioned_table\(\) has parameter \$charset with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: mactrack_convert.php + + - + message: '#^Function mactrack_create_partitioned_table\(\) has parameter \$collate with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: mactrack_convert.php + + - + message: '#^Function mactrack_create_partitioned_table\(\) has parameter \$days with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: mactrack_convert.php + + - + message: '#^Function mactrack_create_partitioned_table\(\) has parameter \$engine with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: mactrack_convert.php + + - + message: '#^Function mactrack_create_partitioned_table\(\) has parameter \$migrate with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: mactrack_convert.php + + - + message: '#^Parameter \#2 \$log of function db_execute expects bool, array\ given\.$#' + identifier: argument.type + count: 1 + path: mactrack_convert.php + + - + message: '#^Path in include\(\) "\./include/cli_check\.php" is not a file or it does not exist\.$#' + identifier: include.fileNotFound + count: 1 + path: mactrack_convert.php + + - + message: '#^Variable \$config might not be defined\.$#' + identifier: variable.undefined + count: 1 + path: mactrack_convert.php + + - + message: '#^Call to function in_array\(\) with arguments int\<0, max\>, array\{\} and true will always evaluate to false\.$#' + identifier: function.impossibleType + count: 1 + path: mactrack_device_types.php + + - + message: '#^Comparison operation "\>" between int\<1, max\> and 0 is always true\.$#' + identifier: greater.alwaysTrue + count: 1 + path: mactrack_device_types.php + + - + message: '#^Function api_mactrack_device_type_remove\(\) has no return type specified\.$#' + identifier: missingType.return + count: 1 + path: mactrack_device_types.php + + - + message: '#^Function api_mactrack_device_type_remove\(\) has parameter \$device_type_id with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: mactrack_device_types.php + + - + message: '#^Function api_mactrack_device_type_save\(\) has no return type specified\.$#' + identifier: missingType.return + count: 1 + path: mactrack_device_types.php + + - + message: '#^Function api_mactrack_device_type_save\(\) has parameter \$description with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: mactrack_device_types.php + + - + message: '#^Function api_mactrack_device_type_save\(\) has parameter \$device_type with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: mactrack_device_types.php + + - + message: '#^Function api_mactrack_device_type_save\(\) has parameter \$device_type_id with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: mactrack_device_types.php + + - + message: '#^Function api_mactrack_device_type_save\(\) has parameter \$disabled with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: mactrack_device_types.php + + - + message: '#^Function api_mactrack_device_type_save\(\) has parameter \$dot1x_scanning_function with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: mactrack_device_types.php + + - + message: '#^Function api_mactrack_device_type_save\(\) has parameter \$highPort with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: mactrack_device_types.php + + - + message: '#^Function api_mactrack_device_type_save\(\) has parameter \$ip_scanning_function with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: mactrack_device_types.php + + - + message: '#^Function api_mactrack_device_type_save\(\) has parameter \$lowPort with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: mactrack_device_types.php + + - + message: '#^Function api_mactrack_device_type_save\(\) has parameter \$scanning_function with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: mactrack_device_types.php + + - + message: '#^Function api_mactrack_device_type_save\(\) has parameter \$serial_number_oid with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: mactrack_device_types.php + + - + message: '#^Function api_mactrack_device_type_save\(\) has parameter \$sysDescr_match with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: mactrack_device_types.php + + - + message: '#^Function api_mactrack_device_type_save\(\) has parameter \$sysObjectID_match with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: mactrack_device_types.php + + - + message: '#^Function api_mactrack_device_type_save\(\) has parameter \$vendor with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: mactrack_device_types.php + + - + message: '#^Function api_mactrack_duplicate_device_type\(\) has no return type specified\.$#' + identifier: missingType.return + count: 1 + path: mactrack_device_types.php + + - + message: '#^Function api_mactrack_duplicate_device_type\(\) has parameter \$device_type_id with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: mactrack_device_types.php + + - + message: '#^Function api_mactrack_duplicate_device_type\(\) has parameter \$device_type_title with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: mactrack_device_types.php + + - + message: '#^Function api_mactrack_duplicate_device_type\(\) has parameter \$dup_id with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: mactrack_device_types.php + + - + message: '#^Function form_actions\(\) has no return type specified\.$#' + identifier: missingType.return + count: 1 + path: mactrack_device_types.php + + - + message: '#^Function form_save\(\) has no return type specified\.$#' + identifier: missingType.return + count: 1 + path: mactrack_device_types.php + + - + message: '#^Function mactrack_device_type\(\) has no return type specified\.$#' + identifier: missingType.return + count: 1 + path: mactrack_device_types.php + + - + message: '#^Function mactrack_device_type_edit\(\) has no return type specified\.$#' + identifier: missingType.return + count: 1 + path: mactrack_device_types.php + + - + message: '#^Function mactrack_device_type_export\(\) has no return type specified\.$#' + identifier: missingType.return + count: 1 + path: mactrack_device_types.php + + - + message: '#^Function mactrack_device_type_filter\(\) has no return type specified\.$#' + identifier: missingType.return + count: 1 + path: mactrack_device_types.php + + - + message: '#^Function mactrack_device_type_import\(\) has no return type specified\.$#' + identifier: missingType.return + count: 1 + path: mactrack_device_types.php + + - + message: '#^Function mactrack_device_type_import_processor\(\) has no return type specified\.$#' + identifier: missingType.return + count: 1 + path: mactrack_device_types.php + + - + message: '#^Function mactrack_device_type_import_processor\(\) has parameter \$device_types with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: mactrack_device_types.php + + - + message: '#^Function mactrack_device_type_request_validation\(\) has no return type specified\.$#' + identifier: missingType.return + count: 1 + path: mactrack_device_types.php + + - + message: '#^Function mactrack_get_device_types\(\) has no return type specified\.$#' + identifier: missingType.return + count: 1 + path: mactrack_device_types.php + + - + message: '#^Function mactrack_get_device_types\(\) has parameter \$apply_limits with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: mactrack_device_types.php + + - + message: '#^Function mactrack_get_device_types\(\) has parameter \$rows with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: mactrack_device_types.php + + - + message: '#^Function mactrack_get_device_types\(\) has parameter \$sql_where with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: mactrack_device_types.php + + - + message: '#^Function mactrack_rescan_device_types\(\) has no return type specified\.$#' + identifier: missingType.return + count: 1 + path: mactrack_device_types.php + + - + message: '#^Negated boolean expression is always false\.$#' + identifier: booleanNot.alwaysFalse + count: 1 + path: mactrack_device_types.php + + - + message: '#^Parameter \#3 \$div of function html_start_box expects bool, string given\.$#' + identifier: argument.type + count: 6 + path: mactrack_device_types.php + + - + message: '#^Parameter \#4 \$cell_padding of function html_start_box expects int, string given\.$#' + identifier: argument.type + count: 7 + path: mactrack_device_types.php + + - + message: '#^Path in include\(\) "\./include/auth\.php" is not a file or it does not exist\.$#' + identifier: include.fileNotFound + count: 1 + path: mactrack_device_types.php + + - + message: '#^Path in include_once\(\) "\./lib/snmp\.php" is not a file or it does not exist\.$#' + identifier: includeOnce.fileNotFound + count: 1 + path: mactrack_device_types.php + + - + message: '#^Path in include_once\(\) "\./plugins/mactrack/lib/mactrack_functions\.php" is not a file or it does not exist\.$#' + identifier: includeOnce.fileNotFound + count: 2 + path: mactrack_device_types.php + + - + message: '#^Path in include_once\(\) "\./plugins/mactrack/lib/mactrack_vendors\.php" is not a file or it does not exist\.$#' + identifier: includeOnce.fileNotFound + count: 1 + path: mactrack_device_types.php + + - + message: '#^Undefined variable\: \$description$#' + identifier: variable.undefined + count: 5 + path: mactrack_device_types.php + + - + message: '#^Undefined variable\: \$device_type_id$#' + identifier: variable.undefined + count: 3 + path: mactrack_device_types.php + + - + message: '#^Undefined variable\: \$save_description_id$#' + identifier: variable.undefined + count: 1 + path: mactrack_device_types.php + + - + message: '#^Undefined variable\: \$save_order$#' + identifier: variable.undefined + count: 2 + path: mactrack_device_types.php + + - + message: '#^Undefined variable\: \$save_vendor_id$#' + identifier: variable.undefined + count: 1 + path: mactrack_device_types.php + + - + message: '#^Undefined variable\: \$sysDescr_match$#' + identifier: variable.undefined + count: 5 + path: mactrack_device_types.php + + - + message: '#^Undefined variable\: \$sysDescr_match_id$#' + identifier: variable.undefined + count: 3 + path: mactrack_device_types.php + + - + message: '#^Undefined variable\: \$sysObjectID_match$#' + identifier: variable.undefined + count: 5 + path: mactrack_device_types.php + + - + message: '#^Undefined variable\: \$sysObjectID_match_id$#' + identifier: variable.undefined + count: 3 + path: mactrack_device_types.php + + - + message: '#^Undefined variable\: \$update_suffix$#' + identifier: variable.undefined + count: 1 + path: mactrack_device_types.php + + - + message: '#^Undefined variable\: \$vendor$#' + identifier: variable.undefined + count: 5 + path: mactrack_device_types.php + + - + message: '#^Variable \$device_type_id might not be defined\.$#' + identifier: variable.undefined + count: 1 + path: mactrack_device_types.php + + - + message: '#^Variable \$sysDescr_match_id might not be defined\.$#' + identifier: variable.undefined + count: 1 + path: mactrack_device_types.php + + - + message: '#^Variable \$sysObjectID_match_id might not be defined\.$#' + identifier: variable.undefined + count: 1 + path: mactrack_device_types.php + + - + message: '#^Function form_mactrack_actions\(\) has no return type specified\.$#' + identifier: missingType.return + count: 1 + path: mactrack_devices.php + + - + message: '#^Function form_mactrack_save\(\) has no return type specified\.$#' + identifier: missingType.return + count: 1 + path: mactrack_devices.php + + - + message: '#^Function mactrack_device\(\) has no return type specified\.$#' + identifier: missingType.return + count: 1 + path: mactrack_devices.php + + - + message: '#^Function mactrack_device_edit\(\) has no return type specified\.$#' + identifier: missingType.return + count: 1 + path: mactrack_devices.php + + - + message: '#^Function mactrack_device_export\(\) has no return type specified\.$#' + identifier: missingType.return + count: 1 + path: mactrack_devices.php + + - + message: '#^Function mactrack_device_filter\(\) has no return type specified\.$#' + identifier: missingType.return + count: 1 + path: mactrack_devices.php + + - + message: '#^Function mactrack_device_import\(\) has no return type specified\.$#' + identifier: missingType.return + count: 1 + path: mactrack_devices.php + + - + message: '#^Function mactrack_device_import_processor\(\) has no return type specified\.$#' + identifier: missingType.return + count: 1 + path: mactrack_devices.php + + - + message: '#^Function mactrack_device_import_processor\(\) has parameter \$devices with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: mactrack_devices.php + + - + message: '#^Function mactrack_device_request_validation\(\) has no return type specified\.$#' + identifier: missingType.return + count: 1 + path: mactrack_devices.php + + - + message: '#^Function mactrack_get_devices\(\) has no return type specified\.$#' + identifier: missingType.return + count: 1 + path: mactrack_devices.php + + - + message: '#^Function mactrack_get_devices\(\) has parameter \$apply_limits with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: mactrack_devices.php + + - + message: '#^Function mactrack_get_devices\(\) has parameter \$rows with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: mactrack_devices.php + + - + message: '#^Function mactrack_get_devices\(\) has parameter \$sql_where with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: mactrack_devices.php + + - + message: '#^Parameter \#3 \$div of function html_start_box expects bool, string given\.$#' + identifier: argument.type + count: 6 + path: mactrack_devices.php + + - + message: '#^Parameter \#4 \$cell_padding of function html_start_box expects int, string given\.$#' + identifier: argument.type + count: 7 + path: mactrack_devices.php + + - + message: '#^Path in include\(\) "\./include/auth\.php" is not a file or it does not exist\.$#' + identifier: include.fileNotFound + count: 1 + path: mactrack_devices.php + + - + message: '#^Path in include_once\(\) "\./lib/snmp\.php" is not a file or it does not exist\.$#' + identifier: includeOnce.fileNotFound + count: 1 + path: mactrack_devices.php + + - + message: '#^Path in include_once\(\) "\./plugins/mactrack/lib/mactrack_functions\.php" is not a file or it does not exist\.$#' + identifier: includeOnce.fileNotFound + count: 1 + path: mactrack_devices.php + + - + message: '#^Path in include_once\(\) "\./plugins/mactrack/mactrack_actions\.php" is not a file or it does not exist\.$#' + identifier: includeOnce.fileNotFound + count: 1 + path: mactrack_devices.php + + - + message: '#^Undefined variable\: \$save_order$#' + identifier: variable.undefined + count: 2 + path: mactrack_devices.php + + - + message: '#^Undefined variable\: \$update_suffix$#' + identifier: variable.undefined + count: 1 + path: mactrack_devices.php + + - + message: '#^Variable \$device_array might not be defined\.$#' + identifier: variable.undefined + count: 1 + path: mactrack_devices.php + + - + message: '#^Variable \$device_name might not be defined\.$#' + identifier: variable.undefined + count: 5 + path: mactrack_devices.php + + - + message: '#^Variable \$hostname might not be defined\.$#' + identifier: variable.undefined + count: 5 + path: mactrack_devices.php + + - + message: '#^Variable \$insert_columns might not be defined\.$#' + identifier: variable.undefined + count: 1 + path: mactrack_devices.php + + - + message: '#^Variable \$save_device_name_id might not be defined\.$#' + identifier: variable.undefined + count: 1 + path: mactrack_devices.php + + - + message: '#^Variable \$save_host_id might not be defined\.$#' + identifier: variable.undefined + count: 4 + path: mactrack_devices.php + + - + message: '#^Variable \$save_site_id_id might not be defined\.$#' + identifier: variable.undefined + count: 4 + path: mactrack_devices.php + + - + message: '#^Variable \$save_snmp_port_id might not be defined\.$#' + identifier: variable.undefined + count: 4 + path: mactrack_devices.php + + - + message: '#^Variable \$site_id might not be defined\.$#' + identifier: variable.undefined + count: 5 + path: mactrack_devices.php + + - + message: '#^Variable \$snmp_port might not be defined\.$#' + identifier: variable.undefined + count: 5 + path: mactrack_devices.php + + - + message: '#^Function display_help\(\) has no return type specified\.$#' + identifier: missingType.return + count: 1 + path: mactrack_import_ouidb.php + + - + message: '#^Function display_version\(\) has no return type specified\.$#' + identifier: missingType.return + count: 1 + path: mactrack_import_ouidb.php + + - + message: '#^Path in include\(\) "\./include/cli_check\.php" is not a file or it does not exist\.$#' + identifier: include.fileNotFound + count: 1 + path: mactrack_import_ouidb.php + + - + message: '#^Variable \$config might not be defined\.$#' + identifier: variable.undefined + count: 1 + path: mactrack_import_ouidb.php + + - + message: '#^Function api_mactrack_maca_remove\(\) has no return type specified\.$#' + identifier: missingType.return + count: 1 + path: mactrack_macauth.php + + - + message: '#^Function api_mactrack_maca_remove\(\) has parameter \$mac_id with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: mactrack_macauth.php + + - + message: '#^Function api_mactrack_maca_save\(\) has no return type specified\.$#' + identifier: missingType.return + count: 1 + path: mactrack_macauth.php + + - + message: '#^Function api_mactrack_maca_save\(\) has parameter \$description with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: mactrack_macauth.php + + - + message: '#^Function api_mactrack_maca_save\(\) has parameter \$mac_address with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: mactrack_macauth.php + + - + message: '#^Function api_mactrack_maca_save\(\) has parameter \$mac_id with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: mactrack_macauth.php + + - + message: '#^Function form_actions\(\) has no return type specified\.$#' + identifier: missingType.return + count: 1 + path: mactrack_macauth.php + + - + message: '#^Function form_save\(\) has no return type specified\.$#' + identifier: missingType.return + count: 1 + path: mactrack_macauth.php + + - + message: '#^Function mactrack_maca\(\) has no return type specified\.$#' + identifier: missingType.return + count: 1 + path: mactrack_macauth.php + + - + message: '#^Function mactrack_maca_edit\(\) has no return type specified\.$#' + identifier: missingType.return + count: 1 + path: mactrack_macauth.php + + - + message: '#^Function mactrack_maca_filter\(\) has no return type specified\.$#' + identifier: missingType.return + count: 1 + path: mactrack_macauth.php + + - + message: '#^Function mactrack_maca_get_maca_records\(\) has no return type specified\.$#' + identifier: missingType.return + count: 1 + path: mactrack_macauth.php + + - + message: '#^Function mactrack_maca_get_maca_records\(\) has parameter \$apply_limits with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: mactrack_macauth.php + + - + message: '#^Function mactrack_maca_get_maca_records\(\) has parameter \$rows with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: mactrack_macauth.php + + - + message: '#^Function mactrack_maca_get_maca_records\(\) has parameter \$sql_where with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: mactrack_macauth.php + + - + message: '#^Parameter \#3 \$div of function html_start_box expects bool, string given\.$#' + identifier: argument.type + count: 4 + path: mactrack_macauth.php + + - + message: '#^Parameter \#4 \$cell_padding of function html_start_box expects int, string given\.$#' + identifier: argument.type + count: 4 + path: mactrack_macauth.php + + - + message: '#^Path in include\(\) "\./include/auth\.php" is not a file or it does not exist\.$#' + identifier: include.fileNotFound + count: 1 + path: mactrack_macauth.php + + - + message: '#^Path in include_once\(\) "\./plugins/mactrack/lib/mactrack_functions\.php" is not a file or it does not exist\.$#' + identifier: includeOnce.fileNotFound + count: 1 + path: mactrack_macauth.php + + - + message: '#^Function api_mactrack_macw_remove\(\) has no return type specified\.$#' + identifier: missingType.return + count: 1 + path: mactrack_macwatch.php + + - + message: '#^Function api_mactrack_macw_remove\(\) has parameter \$mac_id with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: mactrack_macwatch.php + + - + message: '#^Function api_mactrack_macw_save\(\) has no return type specified\.$#' + identifier: missingType.return + count: 1 + path: mactrack_macwatch.php + + - + message: '#^Function api_mactrack_macw_save\(\) has parameter \$description with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: mactrack_macwatch.php + + - + message: '#^Function api_mactrack_macw_save\(\) has parameter \$email_addresses with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: mactrack_macwatch.php + + - + message: '#^Function api_mactrack_macw_save\(\) has parameter \$mac_address with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: mactrack_macwatch.php + + - + message: '#^Function api_mactrack_macw_save\(\) has parameter \$mac_id with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: mactrack_macwatch.php + + - + message: '#^Function api_mactrack_macw_save\(\) has parameter \$name with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: mactrack_macwatch.php + + - + message: '#^Function api_mactrack_macw_save\(\) has parameter \$notify_schedule with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: mactrack_macwatch.php + + - + message: '#^Function api_mactrack_macw_save\(\) has parameter \$ticket_number with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: mactrack_macwatch.php + + - + message: '#^Function form_actions\(\) has no return type specified\.$#' + identifier: missingType.return + count: 1 + path: mactrack_macwatch.php + + - + message: '#^Function form_save\(\) has no return type specified\.$#' + identifier: missingType.return + count: 1 + path: mactrack_macwatch.php + + - + message: '#^Function mactrack_macw\(\) has no return type specified\.$#' + identifier: missingType.return + count: 1 + path: mactrack_macwatch.php + + - + message: '#^Function mactrack_macw_edit\(\) has no return type specified\.$#' + identifier: missingType.return + count: 1 + path: mactrack_macwatch.php + + - + message: '#^Function mactrack_macw_filter\(\) has no return type specified\.$#' + identifier: missingType.return + count: 1 + path: mactrack_macwatch.php + + - + message: '#^Function mactrack_macw_get_macw_records\(\) has no return type specified\.$#' + identifier: missingType.return + count: 1 + path: mactrack_macwatch.php + + - + message: '#^Function mactrack_macw_get_macw_records\(\) has parameter \$apply_limits with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: mactrack_macwatch.php + + - + message: '#^Function mactrack_macw_get_macw_records\(\) has parameter \$rows with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: mactrack_macwatch.php + + - + message: '#^Function mactrack_macw_get_macw_records\(\) has parameter \$sql_where with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: mactrack_macwatch.php + + - + message: '#^Parameter \#3 \$div of function html_start_box expects bool, string given\.$#' + identifier: argument.type + count: 4 + path: mactrack_macwatch.php + + - + message: '#^Parameter \#4 \$cell_padding of function html_start_box expects int, string given\.$#' + identifier: argument.type + count: 4 + path: mactrack_macwatch.php + + - + message: '#^Path in include\(\) "\./include/auth\.php" is not a file or it does not exist\.$#' + identifier: include.fileNotFound + count: 1 + path: mactrack_macwatch.php + + - + message: '#^Path in include_once\(\) "\./plugins/mactrack/lib/mactrack_functions\.php" is not a file or it does not exist\.$#' + identifier: includeOnce.fileNotFound + count: 1 + path: mactrack_macwatch.php + + - + message: '#^Variable \$macw_array in isset\(\) always exists and is not nullable\.$#' + identifier: isset.variable + count: 1 + path: mactrack_macwatch.php + + - + message: '#^Caught class Net_DNS2_Exception not found\.$#' + identifier: class.notFound + count: 1 + path: mactrack_resolver.php + + - + message: '#^Function display_help\(\) has no return type specified\.$#' + identifier: missingType.return + count: 1 + path: mactrack_resolver.php + + - + message: '#^Function display_version\(\) has no return type specified\.$#' + identifier: missingType.return + count: 1 + path: mactrack_resolver.php + + - + message: '#^Unreachable statement \- code above always terminates\.$#' + identifier: deadCode.unreachable + count: 1 + path: mactrack_resolver.php + + - + message: '#^Variable \$config might not be defined\.$#' + identifier: variable.undefined + count: 2 + path: mactrack_resolver.php + + - + message: '#^Binary operation "\." between ''802\.1x Scanning…'' and callable\(\)\: mixed results in an error\.$#' + identifier: binaryOp.invalid + count: 1 + path: mactrack_scanner.php + + - + message: '#^Binary operation "\." between ''IP Scanning…'' and callable\(\)\: mixed results in an error\.$#' + identifier: binaryOp.invalid + count: 1 + path: mactrack_scanner.php + + - + message: '#^Binary operation "\." between ''Scanning function…'' and callable\(\)\: mixed results in an error\.$#' + identifier: binaryOp.invalid + count: 1 + path: mactrack_scanner.php + + - + message: '#^Function display_help\(\) has no return type specified\.$#' + identifier: missingType.return + count: 1 + path: mactrack_scanner.php + + - + message: '#^Function display_version\(\) has no return type specified\.$#' + identifier: missingType.return + count: 1 + path: mactrack_scanner.php + + - + message: '#^Path in include\(\) "\./include/cli_check\.php" is not a file or it does not exist\.$#' + identifier: include.fileNotFound + count: 1 + path: mactrack_scanner.php + + - + message: '#^Variable \$config might not be defined\.$#' + identifier: variable.undefined + count: 5 + path: mactrack_scanner.php + + - + message: '#^Variable \$device_id might not be defined\.$#' + identifier: variable.undefined + count: 1 + path: mactrack_scanner.php + + - + message: '#^Function form_actions\(\) has no return type specified\.$#' + identifier: missingType.return + count: 1 + path: mactrack_sites.php + + - + message: '#^Function form_save\(\) has no return type specified\.$#' + identifier: missingType.return + count: 1 + path: mactrack_sites.php + + - + message: '#^Function mactrack_site\(\) has no return type specified\.$#' + identifier: missingType.return + count: 1 + path: mactrack_sites.php + + - + message: '#^Function mactrack_site_edit\(\) has no return type specified\.$#' + identifier: missingType.return + count: 1 + path: mactrack_sites.php + + - + message: '#^Function mactrack_site_export\(\) has no return type specified\.$#' + identifier: missingType.return + count: 1 + path: mactrack_sites.php + + - + message: '#^Function mactrack_site_get_site_records\(\) has no return type specified\.$#' + identifier: missingType.return + count: 1 + path: mactrack_sites.php + + - + message: '#^Function mactrack_site_get_site_records\(\) has parameter \$apply_limits with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: mactrack_sites.php + + - + message: '#^Function mactrack_site_get_site_records\(\) has parameter \$rows with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: mactrack_sites.php + + - + message: '#^Function mactrack_site_get_site_records\(\) has parameter \$sql_where with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: mactrack_sites.php + + - + message: '#^Function mactrack_site_validate_req_vars\(\) has no return type specified\.$#' + identifier: missingType.return + count: 1 + path: mactrack_sites.php + + - + message: '#^Parameter \#3 \$div of function html_start_box expects bool, string given\.$#' + identifier: argument.type + count: 5 + path: mactrack_sites.php + + - + message: '#^Parameter \#4 \$cell_padding of function html_start_box expects int, string given\.$#' + identifier: argument.type + count: 5 + path: mactrack_sites.php + + - + message: '#^Path in include\(\) "\./include/auth\.php" is not a file or it does not exist\.$#' + identifier: include.fileNotFound + count: 1 + path: mactrack_sites.php + + - + message: '#^Path in include_once\(\) "\./lib/snmp\.php" is not a file or it does not exist\.$#' + identifier: includeOnce.fileNotFound + count: 1 + path: mactrack_sites.php + + - + message: '#^Path in include_once\(\) "\./plugins/mactrack/lib/mactrack_functions\.php" is not a file or it does not exist\.$#' + identifier: includeOnce.fileNotFound + count: 1 + path: mactrack_sites.php + + - + message: '#^Path in include_once\(\) "\./plugins/mactrack/mactrack_actions\.php" is not a file or it does not exist\.$#' + identifier: includeOnce.fileNotFound + count: 1 + path: mactrack_sites.php + + - + message: '#^Function duplicate_mactrack\(\) has no return type specified\.$#' + identifier: missingType.return + count: 1 + path: mactrack_snmp.php + + - + message: '#^Function duplicate_mactrack\(\) has parameter \$new_name with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: mactrack_snmp.php + + - + message: '#^Function duplicate_mactrack\(\) has parameter \$snmp_id with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: mactrack_snmp.php + + - + message: '#^Function form_mactrack_snmp_actions\(\) has no return type specified\.$#' + identifier: missingType.return + count: 1 + path: mactrack_snmp.php + + - + message: '#^Function form_mactrack_snmp_save\(\) has no return type specified\.$#' + identifier: missingType.return + count: 1 + path: mactrack_snmp.php + + - + message: '#^Function mactrack_snmp\(\) has no return type specified\.$#' + identifier: missingType.return + count: 1 + path: mactrack_snmp.php + + - + message: '#^Function mactrack_snmp_edit\(\) has no return type specified\.$#' + identifier: missingType.return + count: 1 + path: mactrack_snmp.php + + - + message: '#^Function mactrack_snmp_item_edit\(\) has no return type specified\.$#' + identifier: missingType.return + count: 1 + path: mactrack_snmp.php + + - + message: '#^Function mactrack_snmp_item_movedown\(\) has no return type specified\.$#' + identifier: missingType.return + count: 1 + path: mactrack_snmp.php + + - + message: '#^Function mactrack_snmp_item_moveup\(\) has no return type specified\.$#' + identifier: missingType.return + count: 1 + path: mactrack_snmp.php + + - + message: '#^Function mactrack_snmp_item_remove\(\) has no return type specified\.$#' + identifier: missingType.return + count: 1 + path: mactrack_snmp.php + + - + message: '#^Function snmp_options_filter\(\) has no return type specified\.$#' + identifier: missingType.return + count: 1 + path: mactrack_snmp.php + + - + message: '#^Parameter \#3 \$div of function html_start_box expects bool, string given\.$#' + identifier: argument.type + count: 6 + path: mactrack_snmp.php + + - + message: '#^Parameter \#4 \$cell_padding of function html_start_box expects int, string given\.$#' + identifier: argument.type + count: 6 + path: mactrack_snmp.php + + - + message: '#^Path in include\(\) "\./include/auth\.php" is not a file or it does not exist\.$#' + identifier: include.fileNotFound + count: 1 + path: mactrack_snmp.php + + - + message: '#^Path in include_once\(\) "\./lib/snmp\.php" is not a file or it does not exist\.$#' + identifier: includeOnce.fileNotFound + count: 1 + path: mactrack_snmp.php + + - + message: '#^Path in include_once\(\) "\./plugins/mactrack/lib/mactrack_functions\.php" is not a file or it does not exist\.$#' + identifier: includeOnce.fileNotFound + count: 1 + path: mactrack_snmp.php + + - + message: '#^Undefined variable\: \$item_id$#' + identifier: variable.undefined + count: 1 + path: mactrack_snmp.php + + - + message: '#^Variable \$item_id in empty\(\) is never defined\.$#' + identifier: empty.variable + count: 1 + path: mactrack_snmp.php + + - + message: '#^Variable \$mactrack_snmp_item on left side of \?\? always exists and is not nullable\.$#' + identifier: nullCoalesce.variable + count: 1 + path: mactrack_snmp.php + + - + message: '#^Function mactrack_display_run_status\(\) has no return type specified\.$#' + identifier: missingType.return + count: 1 + path: mactrack_utilities.php + + - + message: '#^Function mactrack_utilities\(\) has no return type specified\.$#' + identifier: missingType.return + count: 1 + path: mactrack_utilities.php + + - + message: '#^Function mactrack_utilities_db_maint\(\) has no return type specified\.$#' + identifier: missingType.return + count: 1 + path: mactrack_utilities.php + + - + message: '#^Function mactrack_utilities_ports_clear\(\) has no return type specified\.$#' + identifier: missingType.return + count: 1 + path: mactrack_utilities.php + + - + message: '#^Function mactrack_utilities_purge_aggregated_data\(\) has no return type specified\.$#' + identifier: missingType.return + count: 1 + path: mactrack_utilities.php + + - + message: '#^Function mactrack_utilities_purge_scanning_funcs\(\) has no return type specified\.$#' + identifier: missingType.return + count: 1 + path: mactrack_utilities.php + + - + message: '#^Function mactrack_utilities_recreate_aggregated_data\(\) has no return type specified\.$#' + identifier: missingType.return + count: 1 + path: mactrack_utilities.php + + - + message: '#^Parameter \#3 \$div of function html_start_box expects bool, string given\.$#' + identifier: argument.type + count: 9 + path: mactrack_utilities.php + + - + message: '#^Parameter \#4 \$cell_padding of function html_start_box expects int, string given\.$#' + identifier: argument.type + count: 9 + path: mactrack_utilities.php + + - + message: '#^Path in include\(\) "\./include/auth\.php" is not a file or it does not exist\.$#' + identifier: include.fileNotFound + count: 1 + path: mactrack_utilities.php + + - + message: '#^Path in include_once\(\) "\./plugins/mactrack/lib/mactrack_functions\.php" is not a file or it does not exist\.$#' + identifier: includeOnce.fileNotFound + count: 3 + path: mactrack_utilities.php + + - + message: '#^Variable \$completed_date might not be defined\.$#' + identifier: variable.undefined + count: 1 + path: mactrack_utilities.php + + - + message: '#^Variable \$completed_processes might not be defined\.$#' + identifier: variable.undefined + count: 1 + path: mactrack_utilities.php + + - + message: '#^Variable \$running_date might not be defined\.$#' + identifier: variable.undefined + count: 1 + path: mactrack_utilities.php + + - + message: '#^Variable \$waiting_date might not be defined\.$#' + identifier: variable.undefined + count: 1 + path: mactrack_utilities.php + + - + message: '#^Variable \$waiting_processes might not be defined\.$#' + identifier: variable.undefined + count: 1 + path: mactrack_utilities.php + + - + message: '#^Function mactrack_vmac_filter\(\) has no return type specified\.$#' + identifier: missingType.return + count: 1 + path: mactrack_vendormacs.php + + - + message: '#^Function mactrack_vmacs\(\) has no return type specified\.$#' + identifier: missingType.return + count: 1 + path: mactrack_vendormacs.php + + - + message: '#^Function mactrack_vmacs_export\(\) has no return type specified\.$#' + identifier: missingType.return + count: 1 + path: mactrack_vendormacs.php + + - + message: '#^Function mactrack_vmacs_get_vmac_records\(\) has no return type specified\.$#' + identifier: missingType.return + count: 1 + path: mactrack_vendormacs.php + + - + message: '#^Function mactrack_vmacs_get_vmac_records\(\) has parameter \$apply_limits with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: mactrack_vendormacs.php + + - + message: '#^Function mactrack_vmacs_get_vmac_records\(\) has parameter \$rows with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: mactrack_vendormacs.php + + - + message: '#^Function mactrack_vmacs_get_vmac_records\(\) has parameter \$sql_where with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: mactrack_vendormacs.php + + - + message: '#^Function mactrack_vmacs_validate_request_vars\(\) has no return type specified\.$#' + identifier: missingType.return + count: 1 + path: mactrack_vendormacs.php + + - + message: '#^Parameter \#3 \$div of function html_start_box expects bool, string given\.$#' + identifier: argument.type + count: 2 + path: mactrack_vendormacs.php + + - + message: '#^Parameter \#4 \$cell_padding of function html_start_box expects int, string given\.$#' + identifier: argument.type + count: 2 + path: mactrack_vendormacs.php + + - + message: '#^Path in include\(\) "\./include/auth\.php" is not a file or it does not exist\.$#' + identifier: include.fileNotFound + count: 1 + path: mactrack_vendormacs.php + + - + message: '#^Path in include_once\(\) "\./plugins/mactrack/lib/mactrack_functions\.php" is not a file or it does not exist\.$#' + identifier: includeOnce.fileNotFound + count: 1 + path: mactrack_vendormacs.php + + - + message: '#^Function format_mac_address not found\.$#' + identifier: function.notFound + count: 1 + path: mactrack_view_arp.php + + - + message: '#^Function mactrack_ip_address_filter\(\) has no return type specified\.$#' + identifier: missingType.return + count: 1 + path: mactrack_view_arp.php + + - + message: '#^Function mactrack_view_export_ips\(\) has no return type specified\.$#' + identifier: missingType.return + count: 1 + path: mactrack_view_arp.php + + - + message: '#^Function mactrack_view_get_ip_records\(\) has no return type specified\.$#' + identifier: missingType.return + count: 1 + path: mactrack_view_arp.php + + - + message: '#^Function mactrack_view_get_ip_records\(\) has parameter \$apply_limits with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: mactrack_view_arp.php + + - + message: '#^Function mactrack_view_get_ip_records\(\) has parameter \$rows with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: mactrack_view_arp.php + + - + message: '#^Function mactrack_view_get_ip_records\(\) has parameter \$sql_where with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: mactrack_view_arp.php + + - + message: '#^Function mactrack_view_ips\(\) has no return type specified\.$#' + identifier: missingType.return + count: 1 + path: mactrack_view_arp.php + + - + message: '#^Function mactrack_view_ips_validate_request_vars\(\) has no return type specified\.$#' + identifier: missingType.return + count: 1 + path: mactrack_view_arp.php + + - + message: '#^Parameter \#3 \$div of function html_start_box expects bool, string given\.$#' + identifier: argument.type + count: 2 + path: mactrack_view_arp.php + + - + message: '#^Parameter \#4 \$cell_padding of function html_start_box expects int, string given\.$#' + identifier: argument.type + count: 2 + path: mactrack_view_arp.php + + - + message: '#^Path in include\(\) "\./include/auth\.php" is not a file or it does not exist\.$#' + identifier: include.fileNotFound + count: 1 + path: mactrack_view_arp.php + + - + message: '#^Path in include_once\(\) "\./plugins/mactrack/lib/mactrack_functions\.php" is not a file or it does not exist\.$#' + identifier: includeOnce.fileNotFound + count: 1 + path: mactrack_view_arp.php + + - + message: '#^Function mactrack_device_filter2\(\) has no return type specified\.$#' + identifier: missingType.return + count: 1 + path: mactrack_view_devices.php + + - + message: '#^Function mactrack_device_request_validation\(\) has no return type specified\.$#' + identifier: missingType.return + count: 1 + path: mactrack_view_devices.php + + - + message: '#^Function mactrack_view_devices\(\) has no return type specified\.$#' + identifier: missingType.return + count: 1 + path: mactrack_view_devices.php + + - + message: '#^Function mactrack_view_export_devices\(\) has no return type specified\.$#' + identifier: missingType.return + count: 1 + path: mactrack_view_devices.php + + - + message: '#^Function mactrack_view_get_device_records\(\) has no return type specified\.$#' + identifier: missingType.return + count: 1 + path: mactrack_view_devices.php + + - + message: '#^Function mactrack_view_get_device_records\(\) has parameter \$apply_limits with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: mactrack_view_devices.php + + - + message: '#^Function mactrack_view_get_device_records\(\) has parameter \$rows with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: mactrack_view_devices.php + + - + message: '#^Function mactrack_view_get_device_records\(\) has parameter \$sql_where with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: mactrack_view_devices.php + + - + message: '#^Parameter \#3 \$div of function html_start_box expects bool, string given\.$#' + identifier: argument.type + count: 2 + path: mactrack_view_devices.php + + - + message: '#^Parameter \#4 \$cell_padding of function html_start_box expects int, string given\.$#' + identifier: argument.type + count: 2 + path: mactrack_view_devices.php + + - + message: '#^Path in include\(\) "\./include/auth\.php" is not a file or it does not exist\.$#' + identifier: include.fileNotFound + count: 1 + path: mactrack_view_devices.php + + - + message: '#^Path in include_once\(\) "\./plugins/mactrack/lib/mactrack_functions\.php" is not a file or it does not exist\.$#' + identifier: includeOnce.fileNotFound + count: 1 + path: mactrack_view_devices.php + + - + message: '#^Function mactrack_dot1x_filter\(\) has no return type specified\.$#' + identifier: missingType.return + count: 1 + path: mactrack_view_dot1x.php + + - + message: '#^Function mactrack_view_dot1x\(\) has no return type specified\.$#' + identifier: missingType.return + count: 1 + path: mactrack_view_dot1x.php + + - + message: '#^Function mactrack_view_dot1x_validate_request_vars\(\) has no return type specified\.$#' + identifier: missingType.return + count: 1 + path: mactrack_view_dot1x.php + + - + message: '#^Function mactrack_view_export_dot1x\(\) has no return type specified\.$#' + identifier: missingType.return + count: 1 + path: mactrack_view_dot1x.php + + - + message: '#^Function mactrack_view_get_dot1x_records\(\) has no return type specified\.$#' + identifier: missingType.return + count: 1 + path: mactrack_view_dot1x.php + + - + message: '#^Function mactrack_view_get_dot1x_records\(\) has parameter \$apply_limits with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: mactrack_view_dot1x.php + + - + message: '#^Function mactrack_view_get_dot1x_records\(\) has parameter \$rows with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: mactrack_view_dot1x.php + + - + message: '#^Function mactrack_view_get_dot1x_records\(\) has parameter \$sql_where with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: mactrack_view_dot1x.php + + - + message: '#^Parameter \#3 \$div of function html_start_box expects bool, string given\.$#' + identifier: argument.type + count: 3 + path: mactrack_view_dot1x.php + + - + message: '#^Parameter \#4 \$cell_padding of function html_start_box expects int, string given\.$#' + identifier: argument.type + count: 3 + path: mactrack_view_dot1x.php + + - + message: '#^Path in include\(\) "\./include/auth\.php" is not a file or it does not exist\.$#' + identifier: include.fileNotFound + count: 1 + path: mactrack_view_dot1x.php + + - + message: '#^Path in include_once\(\) "\./include/global_arrays\.php" is not a file or it does not exist\.$#' + identifier: includeOnce.fileNotFound + count: 1 + path: mactrack_view_dot1x.php + + - + message: '#^Path in include_once\(\) "\./plugins/mactrack/lib/mactrack_functions\.php" is not a file or it does not exist\.$#' + identifier: includeOnce.fileNotFound + count: 1 + path: mactrack_view_dot1x.php + + - + message: '#^Function mactrack_view_graphs\(\) has no return type specified\.$#' + identifier: missingType.return + count: 1 + path: mactrack_view_graphs.php + + - + message: '#^Parameter \#3 \$div of function html_start_box expects bool, string given\.$#' + identifier: argument.type + count: 2 + path: mactrack_view_graphs.php + + - + message: '#^Parameter \#4 \$cell_padding of function html_start_box expects int, string given\.$#' + identifier: argument.type + count: 2 + path: mactrack_view_graphs.php + + - + message: '#^Path in include\(\) "\./include/auth\.php" is not a file or it does not exist\.$#' + identifier: include.fileNotFound + count: 1 + path: mactrack_view_graphs.php + + - + message: '#^Path in include\(\) "\./lib/html_graph\.php" is not a file or it does not exist\.$#' + identifier: include.fileNotFound + count: 1 + path: mactrack_view_graphs.php + + - + message: '#^Path in include\(\) "\./lib/html_tree\.php" is not a file or it does not exist\.$#' + identifier: include.fileNotFound + count: 1 + path: mactrack_view_graphs.php + + - + message: '#^Path in include\(\) "\./lib/timespan_settings\.php" is not a file or it does not exist\.$#' + identifier: include.fileNotFound + count: 1 + path: mactrack_view_graphs.php + + - + message: '#^Path in include\(\) "\./plugins/mactrack/lib/mactrack_functions\.php" is not a file or it does not exist\.$#' + identifier: include.fileNotFound + count: 1 + path: mactrack_view_graphs.php + + - + message: '#^Function db_qstr_rlike not found\.$#' + identifier: function.notFound + count: 2 + path: mactrack_view_interfaces.php + + - + message: '#^Function mactrack_display_array\(\) has no return type specified\.$#' + identifier: missingType.return + count: 1 + path: mactrack_view_interfaces.php + + - + message: '#^Function mactrack_export_records\(\) has no return type specified\.$#' + identifier: missingType.return + count: 1 + path: mactrack_view_interfaces.php + + - + message: '#^Function mactrack_filter_table\(\) has no return type specified\.$#' + identifier: missingType.return + count: 1 + path: mactrack_view_interfaces.php + + - + message: '#^Function mactrack_get_records\(\) has no return type specified\.$#' + identifier: missingType.return + count: 1 + path: mactrack_view_interfaces.php + + - + message: '#^Function mactrack_get_records\(\) has parameter \$apply_limits with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: mactrack_view_interfaces.php + + - + message: '#^Function mactrack_get_records\(\) has parameter \$rows with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: mactrack_view_interfaces.php + + - + message: '#^Function mactrack_get_records\(\) has parameter \$sql_where with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: mactrack_view_interfaces.php + + - + message: '#^Function mactrack_interfaces_request_validation\(\) has no return type specified\.$#' + identifier: missingType.return + count: 1 + path: mactrack_view_interfaces.php + + - + message: '#^Function mactrack_view\(\) has no return type specified\.$#' + identifier: missingType.return + count: 1 + path: mactrack_view_interfaces.php + + - + message: '#^Parameter \#3 \$div of function html_start_box expects bool, string given\.$#' + identifier: argument.type + count: 3 + path: mactrack_view_interfaces.php + + - + message: '#^Parameter \#4 \$cell_padding of function html_start_box expects int, string given\.$#' + identifier: argument.type + count: 3 + path: mactrack_view_interfaces.php + + - + message: '#^Path in include\(\) "\./include/auth\.php" is not a file or it does not exist\.$#' + identifier: include.fileNotFound + count: 1 + path: mactrack_view_interfaces.php + + - + message: '#^Path in include_once\(\) "\./plugins/mactrack/lib/mactrack_functions\.php" is not a file or it does not exist\.$#' + identifier: includeOnce.fileNotFound + count: 1 + path: mactrack_view_interfaces.php + + - + message: '#^Function mactrack_ips_filter\(\) has no return type specified\.$#' + identifier: missingType.return + count: 1 + path: mactrack_view_ips.php + + - + message: '#^Function mactrack_view_export_ip_ranges\(\) has no return type specified\.$#' + identifier: missingType.return + count: 1 + path: mactrack_view_ips.php + + - + message: '#^Function mactrack_view_get_ip_range_records\(\) has no return type specified\.$#' + identifier: missingType.return + count: 1 + path: mactrack_view_ips.php + + - + message: '#^Function mactrack_view_get_ip_range_records\(\) has parameter \$apply_limits with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: mactrack_view_ips.php + + - + message: '#^Function mactrack_view_get_ip_range_records\(\) has parameter \$rows with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: mactrack_view_ips.php + + - + message: '#^Function mactrack_view_get_ip_range_records\(\) has parameter \$sql_where with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: mactrack_view_ips.php + + - + message: '#^Function mactrack_view_ip_ranges\(\) has no return type specified\.$#' + identifier: missingType.return + count: 1 + path: mactrack_view_ips.php + + - + message: '#^Function mactrack_view_ips_validate_request_vars\(\) has no return type specified\.$#' + identifier: missingType.return + count: 1 + path: mactrack_view_ips.php + + - + message: '#^Parameter \#3 \$div of function html_start_box expects bool, string given\.$#' + identifier: argument.type + count: 2 + path: mactrack_view_ips.php + + - + message: '#^Parameter \#4 \$cell_padding of function html_start_box expects int, string given\.$#' + identifier: argument.type + count: 2 + path: mactrack_view_ips.php + + - + message: '#^Path in include\(\) "\./include/auth\.php" is not a file or it does not exist\.$#' + identifier: include.fileNotFound + count: 1 + path: mactrack_view_ips.php + + - + message: '#^Path in include_once\(\) "\./plugins/mactrack/lib/mactrack_functions\.php" is not a file or it does not exist\.$#' + identifier: includeOnce.fileNotFound + count: 1 + path: mactrack_view_ips.php + + - + message: '#^Function api_mactrack_authorize_mac_addresses\(\) has no return type specified\.$#' + identifier: missingType.return + count: 1 + path: mactrack_view_macs.php + + - + message: '#^Function api_mactrack_authorize_mac_addresses\(\) has parameter \$ip_address with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: mactrack_view_macs.php + + - + message: '#^Function api_mactrack_authorize_mac_addresses\(\) has parameter \$mac_address with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: mactrack_view_macs.php + + - + message: '#^Function api_mactrack_revoke_mac_addresses\(\) has no return type specified\.$#' + identifier: missingType.return + count: 1 + path: mactrack_view_macs.php + + - + message: '#^Function api_mactrack_revoke_mac_addresses\(\) has parameter \$mac_address with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: mactrack_view_macs.php + + - + message: '#^Function form_actions\(\) has no return type specified\.$#' + identifier: missingType.return + count: 1 + path: mactrack_view_macs.php + + - + message: '#^Function form_aggregated_actions\(\) has no return type specified\.$#' + identifier: missingType.return + count: 1 + path: mactrack_view_macs.php + + - + message: '#^Function mactrack_mac_filter\(\) has no return type specified\.$#' + identifier: missingType.return + count: 1 + path: mactrack_view_macs.php + + - + message: '#^Function mactrack_view_aggregated_macs\(\) has no return type specified\.$#' + identifier: missingType.return + count: 1 + path: mactrack_view_macs.php + + - + message: '#^Function mactrack_view_export_macs\(\) has no return type specified\.$#' + identifier: missingType.return + count: 1 + path: mactrack_view_macs.php + + - + message: '#^Function mactrack_view_get_mac_records\(\) has no return type specified\.$#' + identifier: missingType.return + count: 1 + path: mactrack_view_macs.php + + - + message: '#^Function mactrack_view_get_mac_records\(\) has parameter \$apply_limits with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: mactrack_view_macs.php + + - + message: '#^Function mactrack_view_get_mac_records\(\) has parameter \$rows with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: mactrack_view_macs.php + + - + message: '#^Function mactrack_view_get_mac_records\(\) has parameter \$sql_where with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: mactrack_view_macs.php + + - + message: '#^Function mactrack_view_macs\(\) has no return type specified\.$#' + identifier: missingType.return + count: 1 + path: mactrack_view_macs.php + + - + message: '#^Function mactrack_view_macs_validate_request_vars\(\) has no return type specified\.$#' + identifier: missingType.return + count: 1 + path: mactrack_view_macs.php + + - + message: '#^Parameter \#3 \$div of function html_start_box expects bool, string given\.$#' + identifier: argument.type + count: 6 + path: mactrack_view_macs.php + + - + message: '#^Parameter \#4 \$cell_padding of function html_start_box expects int, string given\.$#' + identifier: argument.type + count: 6 + path: mactrack_view_macs.php + + - + message: '#^Path in include\(\) "\./include/auth\.php" is not a file or it does not exist\.$#' + identifier: include.fileNotFound + count: 1 + path: mactrack_view_macs.php + + - + message: '#^Path in include_once\(\) "\./plugins/mactrack/lib/mactrack_functions\.php" is not a file or it does not exist\.$#' + identifier: includeOnce.fileNotFound + count: 1 + path: mactrack_view_macs.php + + - + message: '#^Variable \$matches in isset\(\) always exists and is not nullable\.$#' + identifier: isset.variable + count: 1 + path: mactrack_view_macs.php + + - + message: '#^Variable \$row_array in isset\(\) always exists and is not nullable\.$#' + identifier: isset.variable + count: 1 + path: mactrack_view_macs.php + + - + message: '#^Variable \$rows_info in isset\(\) always exists and is not nullable\.$#' + identifier: isset.variable + count: 1 + path: mactrack_view_macs.php + + - + message: '#^Function mactrack_sites_request_validation\(\) has no return type specified\.$#' + identifier: missingType.return + count: 1 + path: mactrack_view_sites.php + + - + message: '#^Function mactrack_view_export_sites\(\) has no return type specified\.$#' + identifier: missingType.return + count: 1 + path: mactrack_view_sites.php + + - + message: '#^Function mactrack_view_get_site_records\(\) has no return type specified\.$#' + identifier: missingType.return + count: 1 + path: mactrack_view_sites.php + + - + message: '#^Function mactrack_view_get_site_records\(\) has parameter \$apply_limits with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: mactrack_view_sites.php + + - + message: '#^Function mactrack_view_get_site_records\(\) has parameter \$rows with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: mactrack_view_sites.php + + - + message: '#^Function mactrack_view_get_site_records\(\) has parameter \$sql_where with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: mactrack_view_sites.php + + - + message: '#^Function mactrack_view_sites\(\) has no return type specified\.$#' + identifier: missingType.return + count: 1 + path: mactrack_view_sites.php + + - + message: '#^Parameter \#3 \$div of function html_start_box expects bool, string given\.$#' + identifier: argument.type + count: 3 + path: mactrack_view_sites.php + + - + message: '#^Parameter \#4 \$cell_padding of function html_start_box expects int, string given\.$#' + identifier: argument.type + count: 3 + path: mactrack_view_sites.php + + - + message: '#^Path in include\(\) "\./include/auth\.php" is not a file or it does not exist\.$#' + identifier: include.fileNotFound + count: 1 + path: mactrack_view_sites.php + + - + message: '#^Path in include_once\(\) "\./plugins/mactrack/lib/mactrack_functions\.php" is not a file or it does not exist\.$#' + identifier: includeOnce.fileNotFound + count: 1 + path: mactrack_view_sites.php + + - + message: '#^Function clear_old_processes\(\) has no return type specified\.$#' + identifier: missingType.return + count: 1 + path: poller_mactrack.php + + - + message: '#^Function clear_old_processes\(\) has parameter \$site_id with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: poller_mactrack.php + + - + message: '#^Function collect_mactrack_data\(\) has no return type specified\.$#' + identifier: missingType.return + count: 1 + path: poller_mactrack.php + + - + message: '#^Function collect_mactrack_data\(\) has parameter \$site_id with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: poller_mactrack.php + + - + message: '#^Function collect_mactrack_data\(\) has parameter \$start with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: poller_mactrack.php + + - + message: '#^Function display_help\(\) has no return type specified\.$#' + identifier: missingType.return + count: 1 + path: poller_mactrack.php + + - + message: '#^Function display_version\(\) has no return type specified\.$#' + identifier: missingType.return + count: 1 + path: poller_mactrack.php + + - + message: '#^Function errors_disable\(\) has no return type specified\.$#' + identifier: missingType.return + count: 1 + path: poller_mactrack.php + + - + message: '#^Function errors_restore\(\) has no return type specified\.$#' + identifier: missingType.return + count: 1 + path: poller_mactrack.php + + - + message: '#^Function log_mactrack_statistics\(\) has no return type specified\.$#' + identifier: missingType.return + count: 1 + path: poller_mactrack.php + + - + message: '#^Function log_mactrack_statistics\(\) has parameter \$type with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: poller_mactrack.php + + - + message: '#^Function mactrack_debug invoked with 3 parameters, 1 required\.$#' + identifier: arguments.count + count: 2 + path: poller_mactrack.php + + - + message: '#^Function mactrack_error_handler\(\) has no return type specified\.$#' + identifier: missingType.return + count: 1 + path: poller_mactrack.php + + - + message: '#^Function mactrack_error_handler\(\) has parameter \$context with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: poller_mactrack.php + + - + message: '#^Function mactrack_error_handler\(\) has parameter \$file with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: poller_mactrack.php + + - + message: '#^Function mactrack_error_handler\(\) has parameter \$level with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: poller_mactrack.php + + - + message: '#^Function mactrack_error_handler\(\) has parameter \$line with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: poller_mactrack.php + + - + message: '#^Function mactrack_error_handler\(\) has parameter \$message with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: poller_mactrack.php + + - + message: '#^Function mactrack_process_mac_auth_report\(\) has no return type specified\.$#' + identifier: missingType.return + count: 1 + path: poller_mactrack.php + + - + message: '#^Function mactrack_process_mac_auth_report\(\) has parameter \$last_macauth_time with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: poller_mactrack.php + + - + message: '#^Function mactrack_process_mac_auth_report\(\) has parameter \$mac_auth_frequency with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: poller_mactrack.php + + - + message: '#^Parameter \#1 \$callback of function set_error_handler expects \(callable\(int, string, string, int\)\: bool\)\|null, ''mactrack_error…'' given\.$#' + identifier: argument.type + count: 1 + path: poller_mactrack.php + + - + message: '#^Path in include\(\) "\./include/cli_check\.php" is not a file or it does not exist\.$#' + identifier: include.fileNotFound + count: 1 + path: poller_mactrack.php + + - + message: '#^Unreachable statement \- code above always terminates\.$#' + identifier: deadCode.unreachable + count: 1 + path: poller_mactrack.php + + - + message: '#^Variable \$config might not be defined\.$#' + identifier: variable.undefined + count: 2 + path: poller_mactrack.php + + - + message: '#^Variable \$error_count might not be defined\.$#' + identifier: variable.undefined + count: 1 + path: poller_mactrack.php + + - + message: '#^Variable \$mac_ip_dns might not be defined\.$#' + identifier: variable.undefined + count: 1 + path: poller_mactrack.php + + - + message: '#^Function convert_readstrings\(\) has no return type specified\.$#' + identifier: missingType.return + count: 1 + path: setup.php + + - + message: '#^Function mactrack_add_column\(\) has no return type specified\.$#' + identifier: missingType.return + count: 1 + path: setup.php + + - + message: '#^Function mactrack_add_column\(\) has parameter \$column with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: setup.php + + - + message: '#^Function mactrack_add_column\(\) has parameter \$syntax with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: setup.php + + - + message: '#^Function mactrack_add_column\(\) has parameter \$table with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: setup.php + + - + message: '#^Function mactrack_add_index\(\) has no return type specified\.$#' + identifier: missingType.return + count: 1 + path: setup.php + + - + message: '#^Function mactrack_add_index\(\) has parameter \$index with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: setup.php + + - + message: '#^Function mactrack_add_index\(\) has parameter \$syntax with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: setup.php + + - + message: '#^Function mactrack_add_index\(\) has parameter \$table with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: setup.php + + - + message: '#^Function mactrack_check_dependencies\(\) has no return type specified\.$#' + identifier: missingType.return + count: 1 + path: setup.php + + - + message: '#^Function mactrack_check_upgrade\(\) has no return type specified\.$#' + identifier: missingType.return + count: 1 + path: setup.php + + - + message: '#^Function mactrack_config_arrays\(\) has no return type specified\.$#' + identifier: missingType.return + count: 1 + path: setup.php + + - + message: '#^Function mactrack_config_form\(\) has no return type specified\.$#' + identifier: missingType.return + count: 1 + path: setup.php + + - + message: '#^Function mactrack_config_settings\(\) has no return type specified\.$#' + identifier: missingType.return + count: 1 + path: setup.php + + - + message: '#^Function mactrack_create_table\(\) has no return type specified\.$#' + identifier: missingType.return + count: 1 + path: setup.php + + - + message: '#^Function mactrack_create_table\(\) has parameter \$syntax with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: setup.php + + - + message: '#^Function mactrack_create_table\(\) has parameter \$table with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: setup.php + + - + message: '#^Function mactrack_db_column_exists\(\) has no return type specified\.$#' + identifier: missingType.return + count: 1 + path: setup.php + + - + message: '#^Function mactrack_db_column_exists\(\) has parameter \$column with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: setup.php + + - + message: '#^Function mactrack_db_column_exists\(\) has parameter \$table with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: setup.php + + - + message: '#^Function mactrack_db_key_exists\(\) has no return type specified\.$#' + identifier: missingType.return + count: 1 + path: setup.php + + - + message: '#^Function mactrack_db_key_exists\(\) has parameter \$index with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: setup.php + + - + message: '#^Function mactrack_db_key_exists\(\) has parameter \$table with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: setup.php + + - + message: '#^Function mactrack_db_table_exists\(\) has no return type specified\.$#' + identifier: missingType.return + count: 1 + path: setup.php + + - + message: '#^Function mactrack_db_table_exists\(\) has parameter \$table with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: setup.php + + - + message: '#^Function mactrack_delete_column\(\) has no return type specified\.$#' + identifier: missingType.return + count: 1 + path: setup.php + + - + message: '#^Function mactrack_delete_column\(\) has parameter \$column with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: setup.php + + - + message: '#^Function mactrack_delete_column\(\) has parameter \$syntax with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: setup.php + + - + message: '#^Function mactrack_delete_column\(\) has parameter \$table with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: setup.php + + - + message: '#^Function mactrack_draw_navigation_text\(\) has no return type specified\.$#' + identifier: missingType.return + count: 1 + path: setup.php + + - + message: '#^Function mactrack_draw_navigation_text\(\) has parameter \$nav with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: setup.php + + - + message: '#^Function mactrack_execute_sql\(\) has no return type specified\.$#' + identifier: missingType.return + count: 1 + path: setup.php + + - + message: '#^Function mactrack_execute_sql\(\) has parameter \$message with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: setup.php + + - + message: '#^Function mactrack_execute_sql\(\) has parameter \$syntax with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: setup.php + + - + message: '#^Function mactrack_modify_column\(\) has no return type specified\.$#' + identifier: missingType.return + count: 1 + path: setup.php + + - + message: '#^Function mactrack_modify_column\(\) has parameter \$column with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: setup.php + + - + message: '#^Function mactrack_modify_column\(\) has parameter \$syntax with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: setup.php + + - + message: '#^Function mactrack_modify_column\(\) has parameter \$table with no type specified\.$#' + identifier: missingType.parameter + count: 1 + path: setup.php + + - + message: '#^Function mactrack_page_head\(\) has no return type specified\.$#' + identifier: missingType.return + count: 1 + path: setup.php + + - + message: '#^Function mactrack_poller_bottom\(\) has no return type specified\.$#' + identifier: missingType.return + count: 1 + path: setup.php + + - + message: '#^Function mactrack_setup_table_new\(\) has no return type specified\.$#' + identifier: missingType.return + count: 1 + path: setup.php + + - + message: '#^Function mactrack_show_tab\(\) has no return type specified\.$#' + identifier: missingType.return + count: 1 + path: setup.php + + - + message: '#^Function plugin_mactrack_check_config\(\) has no return type specified\.$#' + identifier: missingType.return + count: 1 + path: setup.php + + - + message: '#^Function plugin_mactrack_install\(\) has no return type specified\.$#' + identifier: missingType.return + count: 1 + path: setup.php + + - + message: '#^Function plugin_mactrack_uninstall\(\) has no return type specified\.$#' + identifier: missingType.return + count: 1 + path: setup.php + + - + message: '#^Function plugin_mactrack_upgrade\(\) has no return type specified\.$#' + identifier: missingType.return + count: 1 + path: setup.php + + - + message: '#^Function plugin_mactrack_version\(\) has no return type specified\.$#' + identifier: missingType.return + count: 1 + path: setup.php diff --git a/phpunit.xml.dist b/phpunit.xml.dist new file mode 100644 index 00000000..e572c4d7 --- /dev/null +++ b/phpunit.xml.dist @@ -0,0 +1,17 @@ + + + + + tests/Pest + + + + + . + + + tests + vendor + + + diff --git a/poller_mactrack.php b/poller_mactrack.php index 3a6ad8bd..dcc8c86c 100644 --- a/poller_mactrack.php +++ b/poller_mactrack.php @@ -386,22 +386,31 @@ function clear_old_processes($site_id) { // get the max script runtime and kill old scripts $max_script_runtime = read_config_option('mt_script_runtime'); $delete_time = date('Y-m-d H:i:s', strtotime('-' . $max_script_runtime . ' Minutes')); - - // remove old processes from the system if they exist - $old_procs = db_fetch_assoc_prepared('SELECT mtp.* + $site_id = intval($site_id); + $sql = 'SELECT mtp.* FROM mac_track_processes AS mtp INNER JOIN mac_track_devices AS mtd ON mtp.device_id=mtd.device_id - WHERE start_date < ?' . ($site_id > 0 ? ' AND site_id=' . $site_id : ''), - [$delete_time]); + WHERE start_date < ?'; + $params = [$delete_time]; + + if ($site_id > 0) { + $sql .= ' AND mtd.site_id = ?'; + $params[] = $site_id; + } + + // remove old processes from the system if they exist + $old_procs = db_fetch_assoc_prepared($sql, $params); if (cacti_sizeof($old_procs)) { foreach ($old_procs as $p) { - if ($p['process_id'] > 0) { + $process_id = intval($p['process_id']); + + if ($process_id > 0) { if (strstr(PHP_OS, 'WIN')) { - exec('taskkill /pid ' . $p['process_id']); + exec('taskkill /pid ' . $process_id); } else { - exec('kill ' . $p['process_id']); + exec('kill ' . $process_id); } cacti_log("WARNING: Removing Hung Mactrack Process for Device '" . $p['device_id'] . "' With Status '" . $p['status'] . "'"); @@ -411,7 +420,7 @@ function clear_old_processes($site_id) { db_execute_prepared('DELETE FROM mac_track_processes WHERE process_id = ?', - [$p['process_id']]); + [$process_id]); } } } @@ -1007,7 +1016,7 @@ function collect_mactrack_data($start, $site_id = 0) { // process aggregated data db_execute('UPDATE mac_track_aggregated_ports SET active_last=0'); - db_execute('INSERT INTO mac_track_aggregated_ports + db_execute_prepared('INSERT INTO mac_track_aggregated_ports (site_id, device_id, hostname, device_name, vlan_id, vlan_name, mac_address, vendor_mac, ip_address, dns_hostname, port_number, port_name, date_last, first_scan_date, count_rec, active_last, authorized) @@ -1019,8 +1028,9 @@ function collect_mactrack_data($start, $site_id = 0) { ON (t1.mac_address = t2.mac_address AND t1.site_id = t2.site_id AND t1.port_number <> "" - AND t2.scan_date = "' . $scan_date . '") - ON DUPLICATE KEY UPDATE count_rec=count_rec+1, active_last=1, date_last=t1.scan_date,port_name=t1.port_name'); + AND t2.scan_date = ?) + ON DUPLICATE KEY UPDATE count_rec=count_rec+1, active_last=1, date_last=t1.scan_date,port_name=t1.port_name', + [$scan_date]); // purge the ip address and temp port table db_execute('TRUNCATE TABLE mac_track_temp_ports'); diff --git a/psalm.xml b/psalm.xml new file mode 100644 index 00000000..c8e4feac --- /dev/null +++ b/psalm.xml @@ -0,0 +1,50 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/setup.php b/setup.php index 81ffe04b..f31cca5a 100644 --- a/setup.php +++ b/setup.php @@ -60,6 +60,24 @@ function plugin_mactrack_version() { } function plugin_mactrack_check_config() { + global $config; + + $autoload = $config['base_path'] . '/plugins/mactrack/vendor/autoload.php'; + + if (!is_file($autoload)) { + cacti_log('ERROR: Mactrack requires Composer dependencies. Run composer install --no-dev in plugins/mactrack before enabling the plugin.', false, 'MACTRACK'); + + return false; + } + + require_once $autoload; + + if (!class_exists('Net_DNS2_Resolver')) { + cacti_log('ERROR: Mactrack DNS dependency is unavailable. Run composer install --no-dev in plugins/mactrack before enabling the plugin.', false, 'MACTRACK'); + + return false; + } + // Here we will check to ensure everything is configured mactrack_check_upgrade(); diff --git a/tests/Pest.php b/tests/Pest.php new file mode 100644 index 00000000..4dbdf60a --- /dev/null +++ b/tests/Pest.php @@ -0,0 +1,8 @@ +group('mactrack'); diff --git a/tests/Pest/E2E/StaticEndpointSafetyTest.php b/tests/Pest/E2E/StaticEndpointSafetyTest.php new file mode 100644 index 00000000..68d739f6 --- /dev/null +++ b/tests/Pest/E2E/StaticEndpointSafetyTest.php @@ -0,0 +1,8 @@ +toBe(0); +}); diff --git a/tests/Pest/Integration/FilterOutputWiringTest.php b/tests/Pest/Integration/FilterOutputWiringTest.php new file mode 100644 index 00000000..a1c60f73 --- /dev/null +++ b/tests/Pest/Integration/FilterOutputWiringTest.php @@ -0,0 +1,8 @@ +toBe(0); +}); diff --git a/tests/Pest/Unit/SecurityRegressionTest.php b/tests/Pest/Unit/SecurityRegressionTest.php new file mode 100644 index 00000000..0f17fb8e --- /dev/null +++ b/tests/Pest/Unit/SecurityRegressionTest.php @@ -0,0 +1,15 @@ +toBe(0); +}); + +it('escapes filter option labels before rendering', function () { + $command = escapeshellarg(PHP_BINARY) . ' ' . escapeshellarg(__DIR__ . '/../../Unit/test_filter_option_escaping.php'); + exec($command, $output, $result); + + expect($result)->toBe(0); +}); diff --git a/tests/Support/CactiStubs.php b/tests/Support/CactiStubs.php new file mode 100644 index 00000000..7ddf816a --- /dev/null +++ b/tests/Support/CactiStubs.php @@ -0,0 +1,78 @@ + /usr/local/etc/php/conf.d/mactrack-e2e.ini diff --git a/tests/e2e/bootstrap-mactrack.sh b/tests/e2e/bootstrap-mactrack.sh new file mode 100755 index 00000000..f764d059 --- /dev/null +++ b/tests/e2e/bootstrap-mactrack.sh @@ -0,0 +1,32 @@ +#!/usr/bin/env bash +set -euo pipefail + +CACTI_PATH=/var/www/html/cacti + +mkdir -p "$CACTI_PATH/cache/boost" "$CACTI_PATH/cache/mibcache" "$CACTI_PATH/cache/realtime" "$CACTI_PATH/cache/spikekill" +chown -R www-data:www-data "$CACTI_PATH/cache" "$CACTI_PATH/log" "$CACTI_PATH/rra" + +# The Cacti source checkout can have been used by another disposable suite. +# Start from the distributed configuration so credentials cannot leak between +# independently named Compose projects. +cp "$CACTI_PATH/include/config.php.dist" "$CACTI_PATH/include/config.php" +sed -i \ + -e "s/\$database_hostname *=.*/\$database_hostname = 'db';/" \ + -e "s/\$database_default *=.*/\$database_default = 'cacti';/" \ + -e "s/\$database_username *=.*/\$database_username = 'cacti';/" \ + -e "s/\$database_password *=.*/\$database_password = 'mactrack-test';/" \ + "$CACTI_PATH/include/config.php" + +test -f "$CACTI_PATH/plugins/mactrack/vendor/autoload.php" + +# The plugin lifecycle does not need Cacti's optional device-template imports. +# Explicitly skip them to keep this disposable install focused and fast enough +# for CI while preserving the normal core install and plugin-management paths. +template_args=() +for template in "$CACTI_PATH"/install/templates/*.xml.gz; do + template_args+=("--template=$(basename "$template"):0") +done + +php "$CACTI_PATH/cli/install_cacti.php" --accept-eula --install --force "${template_args[@]}" +php "$CACTI_PATH/cli/plugin_manage.php" --plugin=mactrack --install --enable --allperms +php "$CACTI_PATH/plugins/mactrack/tests/e2e/mactrack_smoke.php" diff --git a/tests/e2e/docker-compose.yml b/tests/e2e/docker-compose.yml new file mode 100644 index 00000000..50838280 --- /dev/null +++ b/tests/e2e/docker-compose.yml @@ -0,0 +1,47 @@ +services: + db: + image: mariadb:10.11 + environment: + MARIADB_ROOT_PASSWORD: ${DB_ROOT_PASSWORD:-mactrack-test-root} + MARIADB_DATABASE: ${DB_NAME:-cacti} + MARIADB_USER: ${DB_USER:-cacti} + MARIADB_PASSWORD: ${DB_PASSWORD:-mactrack-test} + TZ: UTC + volumes: + - ${CACTI_SOURCE:?Set CACTI_SOURCE to a Cacti checkout}/cacti.sql:/docker-entrypoint-initdb.d/cacti.sql:ro + command: + - --character-set-server=utf8mb4 + - --collation-server=utf8mb4_unicode_ci + healthcheck: + test: ["CMD", "healthcheck.sh", "--connect", "--innodb_initialized"] + interval: 5s + timeout: 5s + retries: 24 + + web: + build: + context: ${CACTI_SOURCE:?Set CACTI_SOURCE to a Cacti checkout} + dockerfile: ${MACTRACK_SOURCE:?Set MACTRACK_SOURCE to this plugin checkout}/tests/e2e/Dockerfile + environment: + DB_HOST: db + DB_PORT: 3306 + DB_NAME: ${DB_NAME:-cacti} + DB_USER: ${DB_USER:-cacti} + DB_PASS: ${DB_PASSWORD:-mactrack-test} + TIMEZONE: UTC + ports: + - "${MACTRACK_E2E_PORT:-18082}:80" + volumes: + - ${CACTI_SOURCE}:/var/www/html/cacti + - ../..:/var/www/html/cacti/plugins/mactrack + - mactrack_cache:/var/www/html/cacti/cache + - mactrack_log:/var/www/html/cacti/log + - mactrack_rra:/var/www/html/cacti/rra + depends_on: + db: + condition: service_healthy + +volumes: + mactrack_cache: + mactrack_log: + mactrack_rra: diff --git a/tests/e2e/mactrack_smoke.php b/tests/e2e/mactrack_smoke.php new file mode 100644 index 00000000..4977c12e --- /dev/null +++ b/tests/e2e/mactrack_smoke.php @@ -0,0 +1,35 @@ +/dev/null 2>&1 || true +} +trap cleanup EXIT + +cd "$SCRIPT_DIR" +docker compose -p "$PROJECT" up -d --build + +for attempt in $(seq 1 36); do + if docker compose -p "$PROJECT" exec -T db mariadb-admin ping -h 127.0.0.1 -ucacti -pmactrack-test --silent; then + break + fi + sleep 5 +done + +docker compose -p "$PROJECT" exec -T web bash /var/www/html/cacti/plugins/mactrack/tests/e2e/bootstrap-mactrack.sh +curl --fail --silent --show-error "http://localhost:${MACTRACK_E2E_PORT:-18082}/cacti/plugins/mactrack/mactrack_view_devices.php" >/dev/null