Skip to content

Commit

Permalink
updates indentions
Browse files Browse the repository at this point in the history
Updates indentions to four space standard
  • Loading branch information
georgestarcher committed Jan 23, 2015
1 parent 478b3f8 commit 331f26c
Showing 1 changed file with 60 additions and 60 deletions.
120 changes: 60 additions & 60 deletions targetlist.py
Original file line number Diff line number Diff line change
@@ -1,96 +1,96 @@
"""targetlist.py
Target List Class file
Yeah it is overkill for just flipping through a list. But may want to add some self validation later for the types
of addresses.
Target List Class file
Yeah it is overkill for just flipping through a list. But may want to add some self validation later for the types
of addresses.
"""

# define target object
class target:
"""target List Object:
"""target List Object:
Attributes:
Attributes:
target -- the target value
type -- fqdn, ipv6 or ipv4
"""
target -- the target value
type -- fqdn, ipv6 or ipv4
"""

def __init__(self,target,type='ipv4'):
# default type to ipv4 assuming incoming ipv4 ip address
self.target = target
self.type = type
def __init__(self,target,type='ipv4'):
# default type to ipv4 assuming incoming ipv4 ip address
self.target = target
self.type = type

def __str__(self):
"""Function Override: return target value
"""
return self.target
def __str__(self):
"""Function Override: return target value
"""
return self.target

# define targetlist object
class targetlist:
"""Target List object:
"""Target List object:
Attributes:
Attributes:
targetlist -- the list of all contained targets
description -- description of the list
targetlist -- the list of all contained targets
description -- description of the list
"""
"""

def __init__(self, eventResultsPath, skip="yes", desc="unknown"):
def __init__(self, eventResultsPath, skip="yes", desc="unknown"):

import csv
import gzip
import csv
import gzip

self.targetlist = []
self.filepath = eventResultsPath
self.description = desc
self.skipheader = skip
self.targetlist = []
self.filepath = eventResultsPath
self.description = desc
self.skipheader = skip

# Handle to the csv contents of the alerts events compressed file
# Handle to the csv contents of the alerts events compressed file

try:
eventContents = csv.reader(gzip.open(self.filepath, 'rb'))
try:
eventContents = csv.reader(gzip.open(self.filepath, 'rb'))

except Exception, e:
raise Exception, "%s" % str(e)
except Exception, e:
raise Exception, "%s" % str(e)

eventIterator = iter(eventContents)
#skip header makes it skip past the first row to account for column header coming from Splunk search results
eventIterator = iter(eventContents)
#skip header makes it skip past the first row to account for column header coming from Splunk search results

if self.skipheader == "yes":
eventIterator.next()
if self.skipheader == "yes":
eventIterator.next()

# Send a notification for each source ip in the alert results table
for line in eventIterator:
self.targetlist.append(target(line[0]))
# Send a notification for each source ip in the alert results table
for line in eventIterator:
self.targetlist.append(target(line[0]))

def __str__(self):
"""Function Override: Print Target List Object
"""
def __str__(self):
"""Function Override: Print Target List Object
"""

return self.targetlist
return self.targetlist

def main():

import sys
import sys

if len(sys.argv) < 2:
raise Exception, "Missing arguments"
else:
filePath = sys.argv[1]
skip = "no"
desc = "test"
if len(sys.argv) < 2:
raise Exception, "Missing arguments"
else:
filePath = sys.argv[1]
skip = "no"
desc = "test"

try:
testList = targetlist(filePath, skip, desc)
except Exception, e:
raise Exception, "'%s'" % str(e)
try:
testList = targetlist(filePath, skip, desc)
except Exception, e:
raise Exception, "'%s'" % str(e)

for ip in testList.targetlist:
print str(ip)
for ip in testList.targetlist:
print str(ip)

if __name__ == "__main__":

main()
main()

0 comments on commit 331f26c

Please sign in to comment.