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

Remove custom MIB compile logic #495

Merged
merged 6 commits into from Jul 5, 2020
Merged

Remove custom MIB compile logic #495

merged 6 commits into from Jul 5, 2020

Conversation

srenfo
Copy link
Contributor

@srenfo srenfo commented Jun 3, 2020

Removes the custom MIB dependency resolution and compiler logic and makes PySNMP do the heavy lifting. PySNMP will compile the MIBs on demand, including dependency resolution.

The previous MIB compilation logic was broken: missing files were correctly compiled, but the compiled files were (by default) put into a directory that wasn't actually searched by PySNMP.

The following lines in CommandResponder are the most relevant change in this PR. They replace the custom logic in build_pysnmp_mib_wrapper.py.

        # Configure SNMP compiler
        mib_builder = self.snmpEngine.getMibBuilder()
        addMibCompiler(mib_builder, destination=compiled_mibs)
        mib_builder.getMibCompiler().addSources(FileReader(raw_mibs))
        mib_builder.getMibCompiler().addSources(HttpReader('mibs.snmplabs.com', 80, '/asn1/@mib@'))

Other minor changes:

  • Two new tests for said on demand compilation.
  • There was no indication (outside of --verbose) when a symbol from the template configuration was skipped. You were left wondering why nothing would show up in snmpwalk. This produces a warning now.
  • DeprecationWarnings in the old code are fixed... since the code doesn't exist any more.
  • Fixed a parsing error in the IEC104 template's SNMP config.

Other functional changes:

  • Removed --raw_mib. Bundle the files inside the template instead, e. g. conpot/templates/foobar/snmp/mibs/my.mib.
  • Renamed --mibpaths to the more appropriate --mibcache. This now falls back to PySNMP's default of ~/.pysnmp/mibs, though I have opened an issue that this would be more appropriate under ~/.cache.
  • Removed SNMP-related dependencies from the installation docs and from Travis. Those appear to be obsolete.

@srenfo srenfo changed the title Remove redundant MIB dependency resolution Remove custom MIB compile logic Jun 18, 2020
@srenfo
Copy link
Contributor Author

srenfo commented Jun 18, 2020

FYI this PR has been updated considerably. It now removes ALL the custom MIB logic. I have updated the PR description accordingly.

Copy link
Member

@glaslos glaslos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Well done, love those PRs that simplify the code base. If you are up for chatting a bit about conpot, shoot me an email to glaslos@gmail.com

@glaslos glaslos merged commit c0319e9 into mushorg:master Jul 5, 2020
t3chn0m4g3 added a commit to t3chn0m4g3/conpot that referenced this pull request Aug 24, 2020
Pysnmp-mibs is needed to fix a deps issue after mushorg#495 with IEC104 crashing after not finding uncompiled MIBs.
@t3chn0m4g3 t3chn0m4g3 mentioned this pull request Aug 24, 2020
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

Successfully merging this pull request may close these issues.

None yet

2 participants