From facdf5b7a74ba9e269f3b1a224e3cdd14f76e10d Mon Sep 17 00:00:00 2001 From: "Eric A. Miller" Date: Sun, 1 Apr 2018 21:50:26 -0400 Subject: [PATCH] Relax validation of MIB access checks until we have broader test coverage that this is a non-breaking change Mark corresponding test TODO in Info test class --- Changes | 4 ++-- lib/SNMP/Info.pm | 8 +++----- xt/lib/Test/SNMP/Info.pm | 14 ++++++++++---- 3 files changed, 15 insertions(+), 11 deletions(-) diff --git a/Changes b/Changes index 46b35aa2..cf732ecf 100644 --- a/Changes +++ b/Changes @@ -17,8 +17,8 @@ Version 3.54 * Don't use MIB leafs that are not-accessible according to MIB * Fix logic for determining if MIB leaf supports set operations NOTE: Fixing this logic now results in methods starting with set_ on MIB - leafs without Write or Create access and ANY method on a MIB leaf that is - not-accessible failing validation in _validate_autoload_method() + leafs without Write or Create access failing validation in + _validate_autoload_method() Version 3.53 (2018-03-22) diff --git a/lib/SNMP/Info.pm b/lib/SNMP/Info.pm index 122ee9f4..eb94a339 100644 --- a/lib/SNMP/Info.pm +++ b/lib/SNMP/Info.pm @@ -4626,15 +4626,13 @@ sub _validate_autoload_method { # If we were given a fully qualified OID because we don't have the MIB # file, it will translate above but we won't be able to check access so # skip the check and return - if ($access) { - unless ( ( $method =~ /^set/ && $access =~ /Write|Create/ ) - || ($method !~ /^set/ && $access =~ /Read|Create/) ) - { + if ($access && $method =~ /^set/ && $access !~ /Write|Create/) { + print "SNMP::Info::_validate_autoload_method($attr : $oid) Not accessable for requested operation.\n" if $self->debug(); return; - } + } # If the parent of the leaf has indexes it is contained within a table diff --git a/xt/lib/Test/SNMP/Info.pm b/xt/lib/Test/SNMP/Info.pm index 0996dcdc..7847ea8e 100644 --- a/xt/lib/Test/SNMP/Info.pm +++ b/xt/lib/Test/SNMP/Info.pm @@ -188,6 +188,7 @@ sub loopdetect : Tests(4) { sub device_type : Tests(+6) { my $test = shift; + $test->SUPER::device_type(); # No sysServices and unknown sysDescr results in SNMP::Info my $cache_data @@ -252,7 +253,7 @@ sub device_type : Tests(+6) { }; $test->{info}->cache($cache_data); is($test->{info}->device_type, - 'SNMP::Info::Layer7::APC', 'Layer 1 device type by sysObjectID'); + 'SNMP::Info::Layer7::APC', 'Layer 7 device type by sysObjectID'); $test->{info}->clear_cache(); # We will test each specific subclass, so no need to check that logic here @@ -1597,10 +1598,15 @@ sub private_validate_autoload_method : Tests(8) { q(Func 'ifPromiscuousMode_raw' validates) ); }; +TODO: { + local $TODO + = "Check MIB access for non set methods in _validate_autoload_method" + if 1; - # Test that not-accessible leaf returns undef IF-MIB::ifStackHigherLayer - is($test->{info}->_validate_autoload_method('ifStackHigherLayer'), - undef, q(MIB leaf 'ifStackHigherLayer' not-accessible, returns undef)); + # Test that not-accessible leaf returns undef IF-MIB::ifStackHigherLayer + is($test->{info}->_validate_autoload_method('ifStackHigherLayer'), + undef, q(MIB leaf 'ifStackHigherLayer' not-accessible, returns undef)); + } # Test that read-only leaf won't validate set_ is($test->{info}->_validate_autoload_method('set_i_lastchange'),