Skip to content

Commit

Permalink
Enable new SNMP cryptographic protocols.
Browse files Browse the repository at this point in the history
ZEN-28951
  • Loading branch information
jpeacock-zenoss committed Sep 12, 2024
1 parent 908c24b commit 6fcdf79
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 52 deletions.
18 changes: 0 additions & 18 deletions Products/ZenModel/Device.py
Original file line number Diff line number Diff line change
Expand Up @@ -2474,24 +2474,6 @@ def exportXmlHook(self, ofile, ignorerels):
"""
map(lambda o: o.exportXml(ofile, ignorerels), (self.hw, self.os))

def zenPropertyOptions(self, propname):
"""
Returns a list of possible options for a given zProperty
"""
if propname == "zCollectorPlugins":
from Products.DataCollector.Plugins import loadPlugins

return sorted(ldr.pluginName for ldr in loadPlugins(self.dmd))
if propname == "zCommandProtocol":
return ["ssh", "telnet"]
if propname == "zSnmpVer":
return ["v1", "v2c", "v3"]
if propname == "zSnmpAuthType":
return ["", "MD5", "SHA"]
if propname == "zSnmpPrivType":
return ["", "DES", "AES"]
return ManagedEntity.zenPropertyOptions(self, propname)

security.declareProtected(ZEN_MANAGE_DEVICE, "pushConfig")

def pushConfig(self, REQUEST=None):
Expand Down
23 changes: 0 additions & 23 deletions Products/ZenModel/DeviceClass.py
Original file line number Diff line number Diff line change
Expand Up @@ -832,29 +832,6 @@ def buildDeviceTreeProperties(self):
if not devs.hasProperty(id):
devs._setProperty(id, defaultValue, type)

def zenPropertyOptions(self, propname):
"""
Provide a set of default options for a zProperty
@param propname: zProperty name
@type propname: string
@return: list of zProperty options
@rtype: list
"""
if propname == 'zCollectorPlugins':
from Products.DataCollector.Plugins import loadPlugins
return sorted(ldr.pluginName for ldr in loadPlugins(self.dmd))
if propname == 'zCommandProtocol':
return ['ssh', 'telnet']
if propname == 'zSnmpVer':
return ['v1', 'v2c', 'v3']
if propname == 'zSnmpAuthType':
return ['', 'MD5', 'SHA']
if propname == 'zSnmpPrivType':
return ['', 'DES', 'AES']
return DeviceOrganizer.zenPropertyOptions(self, propname)


def pushConfig(self, REQUEST=None):
"""
This will result in a push of all the devices to live collectors
Expand Down
27 changes: 21 additions & 6 deletions Products/ZenRelations/ZenPropertyManager.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
ZEN_ZPROPERTIES_EDIT,
ZEN_ZPROPERTIES_VIEW,
)
from Products.ZenUtils.snmp import authentication_protocols, privacy_protocols
from Products.ZenUtils.Utils import getDisplayType
from Products.ZenWidgets.interfaces import IMessageSender

Expand Down Expand Up @@ -173,15 +174,15 @@
"zSnmpAuthType",
"",
"string",
"SNMP Auth Type",
'Use "MD5" or "SHA" signatures to authenticate SNMP requests',
"SNMP Authentication Protocol",
'The cryptographic protocol used to authenticate SNMP requests.',
),
(
"zSnmpPrivType",
"",
"string",
"SNMP Priv Type",
'"DES" or "AES" cryptographic algorithms.',
"SNMP Privacy Protocol",
'The cryptographic protocol used to encrypt SNMP packets.',
),
(
"zSnmpContext",
Expand Down Expand Up @@ -1005,8 +1006,22 @@ def deleteZenProperty(self, propname=None, REQUEST=None):
security.declareProtected(ZEN_ZPROPERTIES_VIEW, "zenPropertyOptions")

def zenPropertyOptions(self, propname):
"""Provide a set of default options for a ZProperty."""
return []
"""
Returns a list of possible options for a given zProperty
"""
if propname == "zCollectorPlugins":
from Products.DataCollector.Plugins import loadPlugins

return tuple(sorted(p.pluginName for p in loadPlugins(self.dmd)))
if propname == "zCommandProtocol":
return ("ssh", "telnet")
if propname == "zSnmpVer":
return ("v1", "v2c", "v3")
if propname == "zSnmpAuthType":
return ("",) + authentication_protocols
if propname == "zSnmpPrivType":
return ("",) + privacy_protocols
return ()

security.declareProtected(ZEN_ZPROPERTIES_VIEW, "isLocal")

Expand Down
6 changes: 6 additions & 0 deletions Products/ZenUtils/snmp.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,14 @@
from twisted.internet.defer import Deferred
from pynetsnmp.twistedsnmp import AgentProxy

authentication_protocols = (
"MD5", "SHA", "SHA-224", "SHA-256", "SHA-384", "SHA-512"
)
privacy_protocols = ("DES", "AES", "AES-192", "AES-256")

_LOG = logging.getLogger("zen.ZenUtils.snmp")


class SnmpConfig(object):
succeeded = None
sysName = None
Expand Down
12 changes: 7 additions & 5 deletions Products/Zuul/interfaces/actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#
##############################################################################


from Products.ZenUtils.snmp import authentication_protocols, privacy_protocols
from Products.Zuul.interfaces import IInfo
from Products.Zuul.form import schema
from Products.Zuul.utils import ZuulMessageFactory as _t
Expand Down Expand Up @@ -198,15 +198,17 @@ class ISNMPv3ActionContentInfo(ISnmpTrapActionContentInfo):
contextName = schema.TextLine(title=_t(u'Context Name'))

authProto = schema.Choice(title=_t(u"Authentication Protocol"),
vocabulary=SimpleVocabulary.fromValues(['None', 'MD5', 'SHA']),
default = _t(u'None')
vocabulary=SimpleVocabulary.fromValues(
('None',) + authentication_protocols
),
default=_t(u'None'),
)
securityName = schema.TextLine(title=_t(u'Security Name'))
securityPassphrase = schema.Password(title=_t(u'Security Passphrase'))

privProto = schema.Choice(title=_t(u"Privacy Protocol"),
vocabulary=SimpleVocabulary.fromValues(['None', 'DES', 'AES']),
default = _t(u'None')
vocabulary=SimpleVocabulary.fromValues(('None',) + privacy_protocols),
default=_t(u'None'),
)
privacyPassphrase = schema.Password(title=_t(u'Privacy Passphrase'))

Expand Down

0 comments on commit 6fcdf79

Please sign in to comment.