[prev in list] [next in list] [prev in thread] [next in thread] 

List:       net-snmp-bugs
Subject:    [ net-snmp-Bugs-2074817 ] python Varbind doesn't separate iid from
From:       "SourceForge.net" <noreply () sourceforge ! net>
Date:       2008-09-04 22:44:12
Message-ID: E1KbNYi-00068x-5b () d45xhf1 ! ch3 ! sourceforge ! com
[Download RAW message or body]

Bugs item #2074817, was opened at 2008-08-26 04:54
Message generated for change (Settings changed) made by tanders
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=112694&aid=2074817&group_id=12694

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
> Category: python
Group: None
Status: Open
Resolution: None
Priority: 5
Private: No
Submitted By: Bill Fenner (fenner)
Assigned to: Nobody/Anonymous (nobody)
Summary: python Varbind doesn't separate iid from tag properly

Initial Comment:
The regexp for parsing out the iid is still broken, even after the bug fix for bug \
1877840.  The original version can match *all* of an oid, including the whole iid:

> > > tag='tcpConnTable.130.129.16.250.80.130.129.16.250.32700'
> > > regex = re.compile(r'^((?:\.\d+)+|(?:\.?\w+(?:\-*\w+)+)+)\.?(.*)$')
> > > m = regex.match(tag)
> > > print m.groups()
('tcpConnTable.130.129.16.250.80.130.129.16.250.32700', '')

The updated version fixes that bug, but not by much:

> > > regex = re.compile(r'^((?:\.\d+)+|(?:\.?\w+(?:\-*\w+)+)+)\.(\d*?)$')
> > > m = regex.match(tag)
> > > print m.groups()
('tcpConnTable.130.129.16.250.80.130.129.16.250', '32700')

So this fix is good for single-subID matches, e.g., ifIndex.32700, but no good for \
complex table indexes.

My proposal is to drastically simplify the regexp, since right now it's so complex \
that it's hard to tell what it matches or what it's intended to match.  There's no \
need to match fully-numeric OIDs here, since self.tag will remain set to the \
fully-numeric value.

My proposed regexp is r'([a-z]\w+)\.([0-9.]+)$':

# parse iid out of tag if needed
if iid == None and tag != None:
    regex = re.compile(r'^((?:\.\d+)+|(?:\.?\w+(?:\-*\w+)+)+)\.(\d*?)$')
    match = regex.match(tag)
    if match:
        (self.tag, self.iid) = match.group(1,2)

->

# parse iid out of tag if needed
if iid is None and tag is not None:
    match = re.match(r'([a-z]\w+)\.([0-9.]+)$', tag)
    if match:
        (self.tag, self.iid) = match.groups()

This provides the desired result in all the test cases I could come up with:

> > > tag='tcpConnTable.130.129.16.250.80.130.129.16.250.32700'
> > > match = re.match(r'([a-z]\w+)\.([0-9.]+)$', tag)
> > > print match.groups()
('tcpConnTable', '130.129.16.250.80.130.129.16.250.32700')
> > > tag='ifIndex.42'
> > > match = re.match(r'([a-z]\w+)\.([0-9.]+)$', tag)
> > > print match.groups()
('ifIndex', '42')
> > > tag='1.3.6.1.2.1.6.13.130.129.16.250.80.130.129.16.250.32700'
> > > match = re.match(r'([a-z]\w+)\.([0-9.]+)$', tag)
> > > print match
None

(since match is None, it will not trigger the assignment.)

Are there other cases that the complicated regexp was trying to handle?  Maybe trying \
to handle iso.org.dod.internet.mgmt.mib-2.tcp.tcpConnTable.130.129.16.250.80.130.129.16.250.32700 \
?

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=112694&aid=2074817&group_id=12694

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Net-snmp-bugs mailing list
Net-snmp-bugs@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/net-snmp-bugs


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic