Added new authalgo support for SNMPv3 (#11966)

* Added new authalgo support for SNMPv3

* Update 2020_07_27_00522_alter_authalgo_column.php

Fixed case

* Update addhost.inc.php

Fixed case

* Update snmp.inc.php

Fixed case

* Update db_schema.yaml

Fixed case

* Fixed SHA-* order to ascending

* Update 2020_07_27_00522_alter_authalgo_column.php

Fixed space

* Update db_schema.yaml

Fixed line to be of type string

* Update config_definitions.json

Fixed sorting

* Fixed test file case sensitivity

* Fixed rollback function

* SourceDoctor code for checks

* Fixed indentation issues on Travis test

* Update to re-trigger testing stuck on CLA step

* Added crypto-algo updates

* Incorporated suggestions from Jellyfrog

* Added documentation entry

* Fixed travis spacing error

* Fixed validations

* Delete snmpv3_version_compare.patch

Sorry, this one was not supposed to be there.

* Added poller evaluation

* Added poller comparison

* Fixed merge-conflicts

* Fixed typo in test unit

* code refinements
only can check on webui that it supports the algorithms, hopefully, the eventlog is enough to notify users of distributed pollers.

* style fixes and remove openssl setting

* fix device access

* fix missing migration column

Co-authored-by: Tony Murray <murraytony@gmail.com>
This commit is contained in:
Hans Erasmus
2020-10-29 20:02:26 +02:00
committed by GitHub
parent 7239d4fc5f
commit 6c4596d1b9
9 changed files with 98 additions and 12 deletions

View File

@@ -17,11 +17,13 @@
*/
use LibreNMS\Config;
use LibreNMS\Enum\Alert;
use LibreNMS\Exceptions\InvalidIpException;
use LibreNMS\Util\Git;
use LibreNMS\Util\IP;
use LibreNMS\Util\Laravel;
use LibreNMS\Util\OS;
use Symfony\Component\Process\Process;
function generate_priority_label($priority)
{
@@ -87,7 +89,9 @@ function external_exec($command)
{
global $debug, $vdebug;
$proc = new \Symfony\Component\Process\Process($command);
$device = DeviceCache::getPrimary();
$proc = new Process($command);
$proc->setTimeout(Config::get('snmp.exec_timeout', 1200));
if ($debug && ! $vdebug) {
@@ -121,6 +125,12 @@ function external_exec($command)
$proc->run();
$output = $proc->getOutput();
if ($proc->getExitCode()) {
Log::event('Unsupported SNMP Algorithm - ' . $proc->getExitCode(), optional($device)->device_id, 'poller', Alert::ERROR);
d_echo('Exitcode: ' . $proc->getExitCode());
d_echo($proc->getErrorOutput());
}
if ($debug && ! $vdebug) {
$ip_regex = '/(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)/';
$debug_output = preg_replace($ip_regex, '*', $output);
@@ -832,6 +842,18 @@ function version_info($remote = false)
return $output;
}//end version_info()
/**
* checks if System is SNMPv3 SHA2 Capable for Auth Algorithms (SHA-224,SHA-256,SHA-384,SHA-512)
* @return bool
*/
function snmpv3_sha2_capable()
{
$process = new Process([Config::get('snmpget', 'snmpget'), '--help']);
$process->run();
return Str::contains($process->getErrorOutput(), 'SHA-512');
}
/**
* Convert a MySQL binary v4 (4-byte) or v6 (16-byte) IP address to a printable string.
* @param string $ip A binary string containing an IP address, as returned from MySQL's INET6_ATON function