コード例 #1
0
def writer(vulns, **params):
    csvfile = params['fobj']

    debug.write('.')

    for vuln in vulns:
        csvfile.writerow([vuln['name'], vuln['count']])
コード例 #2
0
def gen_csv(sc, filename, field_list, source, filters):
    '''csv SecurityCenterObj, AssetListName, CSVFields, EmailAddress
    '''

    # First thing we need to do is initialize the csvfile and build the header
    # for the file.
    datafile = open(filename, 'wb')
    csvfile = csv.writer(datafile)
    header = []
    for field in field_list:
        header.append(fields.fields[field]['name'])
    csvfile.writerow(header)

    debug.write('Generating %s: ' % filename)
    # Next we will run the Security Center query.  because this could be a
    # potentially very large dataset that is returned, we don't want to run out
    # of memory.  To get around this, we will pass the query function the writer
    # function with the appropriate fields so that it is parsed inline.
    fparams = {'fobj': csvfile, 'flist': field_list}
    sc.query('vulndetails', source=source, 
             func=writer, func_params=fparams, **filters)
    debug.write('\n')

    # Lastly we need to close the datafile.
    datafile.close()
コード例 #3
0
def writer(vulns, **params):
    csvfile = params['fobj']

    debug.write('.')

    for vuln in vulns:
        csvfile.writerow([vuln['name'], vuln['count']])
コード例 #4
0
def tree_search(states, goal_test, successors, combiner):
    """Find a state in STATES that satisfies GOAL_TEST. Start with
    STATES and search according to the SUCCESSOR and COMBINER functions"""
    debug.write("tree-search", "Searching: " + str(states).strip('[]'))

    if len(states) == 0:
        return None
    elif goal_test(states[0]):
        return states[0]
    else:
        return tree_search(
            combiner(successors(states[0]), states[1:]),
            goal_test,
            successors,
            combiner)
コード例 #5
0
ファイル: elevation.py プロジェクト: krist10an/threedee
def readhgt(filename):
	debug.write("Opening %s" % (filename))
	f = open(filename, "rb")
	hgt_string = f.read()

	tilesize = int(math.sqrt(len(hgt_string) / 2))
	if tilesize == 1201:
		resolution = 3
	elif tilesize == 3601:
		resolution = 1
	else:
		raise Exception('Error: Can only support 3" and 1" data')

	debug.write(" Tile size %d Resolution %d\"" % (tilesize, resolution))

	hgt_2darray = numpy.flipud(((numpy.fromstring(string=hgt_string, dtype='int16')).byteswap()).reshape(tilesize, tilesize))
	return tilesize, hgt_2darray
コード例 #6
0
def gen_csv(sc, filename):
    '''csv SecurityCenterObj, EmailAddress
    '''

    # First thing we need to do is initialize the csvfile and build the header
    # for the file.
    datafile = open(filename, 'wb')
    csvfile = csv.writer(datafile)
    csvfile.writerow(['Software Package Name', 'Count'])

    debug.write('Generating %s: ' % filename)
    # Next we will run the Security Center query.  because this could be a
    # potentially very large dataset that is returned, we don't want to run out
    # of memory.  To get around this, we will pass the query function the writer
    # function with the appropriate fields so that it is parsed inline.
    fparams = {'fobj': csvfile}
    sc.query('listsoftware', func=writer, func_params=fparams)
    debug.write('\n')

    # Lastly we need to close the datafile.
    datafile.close()
コード例 #7
0
def gen_csv(sc, filename):
    '''csv SecurityCenterObj, EmailAddress
    '''

    # First thing we need to do is initialize the csvfile and build the header
    # for the file.
    datafile = open(filename, 'wb')
    csvfile = csv.writer(datafile)
    csvfile.writerow(['Software Package Name', 'Count'])

    debug.write('Generating %s: ' % filename)
    # Next we will run the Security Center query.  because this could be a
    # potentially very large dataset that is returned, we don't want to run out
    # of memory.  To get around this, we will pass the query function the writer
    # function with the appropriate fields so that it is parsed inline.
    fparams = {'fobj': csvfile}
    sc.query('listsoftware', func=writer, func_params=fparams)
    debug.write('\n')

    # Lastly we need to close the datafile.
    datafile.close()
コード例 #8
0
def writer(vulns, **params):
    csvfile = params['fobj']
    flist = params['flist']

    debug.write('.')

    for vuln in vulns:
        # First thing before we do any parsing is we need to generate the
        # firstSeenDate and lastSeenDate fields into the vulnerability
        # dictionary.  These may be requested by the field listing later on.
        fsd = datetime.date.fromtimestamp(int(vuln['firstSeen'])).strftime('%D')
        lsd = datetime.date.fromtimestamp(int(vuln['lastSeen'])).strftime('%D')
        vuln['firstSeenDate'] = fsd
        vuln['lastSeenDate'] = lsd

        # Next we will expand the vulnerability dictionary further thanks to the
        # regexes in the fields dictionary.
        for field in flist:
            if field not in vuln and 'rex' in fields.fields[field]:
                for rex in fields.fields[field]['rex']:
                    res = rex.findall(vuln['pluginText'])
                    if len(res) > 0:
                        break
                if len(res) > 0:
                    vdata = ', '.join(res)
                else:
                    vdata = ''
                vuln[field] = vdata

        # Now that we have everything populated, lets go ahead and build and
        # then write the row to disk.
        row = []
        for field in flist:
            row.append(vuln[field].replace('\\n', '\n').replace('<br/>', '\n')\
                .encode('ascii', 'ignore'))
        csvfile.writerow(row)