Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MIB parser breaks on unexpected whitespace #24

Closed
sponeil opened this issue Jun 8, 2021 · 8 comments
Closed

MIB parser breaks on unexpected whitespace #24

sponeil opened this issue Jun 8, 2021 · 8 comments

Comments

@sponeil
Copy link

sponeil commented Jun 8, 2021

I encountered over a dozen Cisco MIB files that this parser fails to parse. (All Cisco MIBs can be downloaded in a zip file from their site, but I will include some examples in this post.)

Note: I had been using a slightly older version of gosmi, so I just updated to v0.4.2, but it still has the same issues.

Example 1:
CISCO-AAA-SERVER-MIB has some tabs in unexpected places, and the tab between "OBJECT" and "IDENTIFIER" breaks the parser (replace all instances of that tab with a space, and it parses successfully):

cAAAServerMIBObjects\t OBJECT\tIDENTIFIER ::= { ciscoAAAServerMIB 1 }

Example 2:
DS3-MIB has some line-feeds in unexpected places, and they break the parser (clean up the line-feeds, and it parses successfully):

             ds3Conformance OBJECT IDENTIFIER ::= { ds3 14 }

             ds3Groups      OBJECT IDENTIFIER ::= {
             ds3Conformance 1 } ds3Compliances OBJECT
             IDENTIFIER ::= { ds3Conformance 2 }

It's been a while (1991) since I've had to write my own parser/compiler, but unless the language definition prohibits it, the parser is supposed to be able to handle unusual whitespace like this.

Thanks in advance,
Sean

CISCO-AAA-SERVER-MIB.txt
DS3-MIB.txt

@sleepinggenius2
Copy link
Owner

I'm going to be honest, the syntax in the ASN.1 specification is not always the clearest thing, but reading through it again, it does look like any non-zero amount of whitespace should be allowed between those tokens. I believe that would affect OBJECT IDENTIFIER and OCTET STRING with the current parser implementation. I have tested an updated implementation that correctly parses the two attached files. If you can confirm that is where you are seeing all these whitespace issues, then I would be happy to commit the changes.

@sponeil
Copy link
Author

sponeil commented Jun 9, 2021 via email

@sponeil
Copy link
Author

sponeil commented Jun 9, 2021 via email

@sleepinggenius2
Copy link
Owner

CISCO-XGCP-CAPABILITY.my:141:17: unexpected "deprecated" (expected ("current" | "obsolete") ...)

There is an obscure reference in RFC1444 Section 5.2 to a "deprecated" value, though it is not part of the formal AGENT-CAPABILITIES macro definition. As such, I will add that as a valid option.

ADMIN-AUTH-STATS-MIB.my:106:27: unexpected ".." (expected ")")

RFC2578 Appendix A specifically forbids the use of MIN and MAX in refinements within SMI, though they are valid ASN.1. I will add a comment in the code to that effect.

CISCO-LES-MIB.my:645:23: unexpected "0" (expected ")")

Every version of the ASN.1 specification (ITU-T X.680) from 07/1994 (Section 9.8), all the way through 02/2021 (Section 12.8) states: The first digit shall not be zero unless the "number" is a single digit. I will add a comment in the code to that effect.

I will get a new release out shortly with these changes.

@sponeil
Copy link
Author

sponeil commented Jun 9, 2021 via email

@sponeil
Copy link
Author

sponeil commented Jun 11, 2021 via email

@sleepinggenius2
Copy link
Owner

Sorry, I was out of town for a few days. In reviewing that MIB file, the error is valid. An SMI macro (AGENT-CAPABILITIES in this case) only supports a single value assignment at the end, so including one after each module variation not only makes no sense, but is syntactically incorrect. See CISCO-SONET-CAPABILITY for an example of the correct syntax. In practice, I've never actually used the agent capabilities definitions, as most equipment does not seem to populate the sysORTable, though Cisco does for a lot of their equipment.

@sponeil
Copy link
Author

sponeil commented Jun 16, 2021 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants