Advertisement
byt3_m3

Untitled

Oct 10th, 2017
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.79 KB | None | 0 0
  1. def check_net1665(PARSED_CONFIG):
  2.  #Extracts SNMP configuration, the re.complie, uses the re compile functon to create a REGEX pattern to be used with cisco conf parse
  3.  snmp_pattern = re.compile("snmp-server.community.(public|private)", re.I|re.M)
  4.  
  5.  net1665_config_lines = PARSED_CONFIG.find_lines(snmp_pattern)
  6.  
  7.  #Stores Human Readable List in VAR
  8.  net1665_config = "{0}".format("   ".join(str(i) for i in net1665_config_lines))
  9.  
  10.  #Conditional to test if  the private or public communty is there
  11.  if len(net1665_config_lines) > 0:
  12.   print "NET1665 Results: \"Device must not use the default or well-known SNMP community strings public and private.\" \n  Remidiation  for" + NET1665[0] +  ": \n  Remove lines: \n   {0}".format(net1665_config)
  13.  else:
  14.   print "No violations were detected"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement