コード例 #1
0
def activeEventsTable(action):
    findActiveEvents = event._event().getAsClass(
        sessionData=api.g.sessionData,
        query={"expiryTime": {
            "$gt": time.time()
        }})
    total = len(findActiveEvents)
    columns = ["id", "Title", "Score"]
    table = ui.table(columns, total, total)
    if action == "build":
        return table.getColumns(), 200
    elif action == "poll":
        # Custom table data so it can be vertical
        data = []
        for activeEvent in findActiveEvents:
            data.append([
                ui.safe(activeEvent._id),
                ui.dictTable(activeEvent.eventTitle),
                ui.dictTable(activeEvent.score)
            ])
        table.data = data
        return {
            "draw": int(jimi.api.request.args.get('draw')),
            "recordsTable": 0,
            "recordsFiltered": 0,
            "recordsTotal": 0,
            "data": data
        }, 200
コード例 #2
0
def activeCorrelationTable(action):
    findActiveCorrelations = event._eventCorrelation().aggregate(
        sessionData=api.g.sessionData,
        aggregateStatement=[{
            "$project": {
                "_id": 1,
                "expiryTime": 1,
                "types": 1,
                "subTypes": 1,
                "score": 1,
                "idsSize": {
                    "$cond": {
                        "if": {
                            "$isArray": "$ids"
                        },
                        "then": {
                            "$size": "$ids"
                        },
                        "else": 0
                    }
                }
            }
        }, {
            "$match": {
                "expiryTime": {
                    "$gt": time.time()
                },
                "idsSize": {
                    "$gt": 1
                }
            }
        }])
    total = len(findActiveCorrelations)
    columns = ["id", "Types", "Sub Types", "Score"]
    table = ui.table(columns, total, total)
    if action == "build":
        return table.getColumns(), 200
    elif action == "poll":
        # Custom table data so it can be vertical
        data = []
        for activeCorrelation in findActiveCorrelations:
            data.append([
                "<a href='/plugin/event/eventCorrelations/{0}/'>{0}</a>".
                format(activeCorrelation["_id"]),
                ui.dictTable(activeCorrelation["types"]),
                ui.dictTable(activeCorrelation["subTypes"]),
                ui.dictTable(activeCorrelation["score"])
            ])
        table.data = data

        return {
            "draw": int(jimi.api.request.args.get('draw')),
            "recordsTable": 0,
            "recordsFiltered": 0,
            "recordsTotal": 0,
            "data": data
        }, 200
コード例 #3
0
def tableScans(action):
    scans = inga._inga().groupby(sessionData=api.g.sessionData,field="scanName")
    total = len(scans)
    columns = [ "Scan Name", "Total Hosts" ]
    table = ui.table(columns,total,total)
    if action == "build":
        return table.getColumns() ,200
    elif action == "poll":
        # Custom table data so it can be vertical
        data = []
        for source in scans:
            data.append(["<a href=\"{0}{1}/\">{2}</a>".format("scan/",source["_id"],ui.safe(source["_id"])),ui.safe(source["_count"])])
        table.data = data
        return { "draw" : int(jimi.api.request.args.get('draw')), "recordsTable" : total, "recordsFiltered" : total, "recordsTotal" : total, "data" : data } ,200
コード例 #4
0
ファイル: asset.py プロジェクト: z1pti3/jimiPlugin-asset
def table(action):
    fields = ["name", "entity", "assetType"]
    searchValue = jimi.api.request.args.get('search[value]')
    if searchValue:
        searchFilter = {
            "$or": [{
                "name": {
                    "$regex": ".*{0}.*".format(searchValue)
                }
            }, {
                "entity": {
                    "$regex": ".*{0}.*".format(searchValue)
                }
            }, {
                "assetType": {
                    "$regex": ".*{0}.*".format(searchValue)
                }
            }, {
                "fields.ip": {
                    "$regex": ".*{0}.*".format(searchValue)
                }
            }]
        }
    else:
        searchFilter = {}
    pagedData = jimi.db._paged(asset._asset,
                               sessionData=api.g.sessionData,
                               fields=fields,
                               query=searchFilter,
                               maxResults=200)
    table = ui.table(fields, 200, pagedData.total)
    if action == "build":
        return table.getColumns(), 200
    elif action == "poll":
        start = int(jimi.api.request.args.get('start'))
        data = pagedData.getOffset(start, queryMode=1)
        table.setRows(data,
                      links=[{
                          "field": "name",
                          "url": "/plugin/asset/assetItem/",
                          "fieldValue": "_id"
                      }, {
                          "field": "assetType",
                          "url": "/plugin/asset/assetType/",
                          "fieldValue": "assetType"
                      }])
        return table.generate(int(jimi.api.request.args.get('draw'))), 200
コード例 #5
0
def tableScansDomains(action):
    scans = inga._inga().getAsClass(sessionData=api.g.sessionData,query={})
    columns = [ "Domain Name", "IP", "Scan Name" ]
    table = ui.table(columns,0,0)
    if action == "build":
        return table.getColumns() ,200
    elif action == "poll":
        data = []
        for scan in scans:
            for domain in scan.domains:
                data.append([ui.safe(domain["domain"]),ui.safe(domain["ip"]),ui.safe(scan.scanName)])
        total = len(data)
        start = int(jimi.api.request.args.get('start'))
        if start + 200 > len(data):
            data = data[start:]
        else:
            data = data[start:start+200]
        return { "draw" : int(jimi.api.request.args.get('draw')), "recordsTable" : len(data), "recordsFiltered" : total, "recordsTotal" : total, "data" : data } ,200
コード例 #6
0
ファイル: asset.py プロジェクト: z1pti3/jimiPlugin-asset
def singleAssetTableFieldsSources(assetID, action):
    assetObject = asset._asset().getAsClass(sessionData=api.g.sessionData,
                                            id=assetID)[0]
    total = len(assetObject.fields)
    columns = ["Source", "Fields"]
    table = ui.table(columns, total, total)
    if action == "build":
        return table.getColumns(), 200
    elif action == "poll":
        # Custom table data so it can be vertical
        data = []
        for source in assetObject.lastSeen:
            data.append([ui.safe(source["source"]), ui.dictTable(source)])
        table.data = data
        return {
            "draw": int(jimi.api.request.args.get('draw')),
            "recordsTable": 0,
            "recordsFiltered": 0,
            "recordsTotal": 0,
            "data": data
        }, 200
コード例 #7
0
def activeEventsTable(playbookName, action):
    playbookName = unquote(playbookName)
    foundPlays = playbook._playbook().getAsClass(sessionData=api.g.sessionData,
                                                 query={"name": playbookName})
    total = len(foundPlays)
    columns = [
        "_id", "name", "sequence", "version", "occurrence", "playbookData",
        "startTime", "endTime", "attempt", "result", "resultData", "options"
    ]
    table = ui.table(columns, total, total)
    if action == "build":
        return table.getColumns(), 200
    elif action == "poll":
        # Custom table data so it can be vertical
        data = []
        for play in foundPlays:
            data.append([
                '<a href="/modelEditor/?modelName-playbook&id=' + play._id +
                '/">' + play._id + '</a>',
                ui.dictTable(play.name),
                ui.dictTable(play.sequence),
                ui.dictTable(play.version),
                ui.dictTable(play.occurrence),
                ui.dictTable(play.playbookData),
                ui.dictTable(play.startTime),
                ui.dictTable(play.endTime),
                ui.dictTable(play.attempt),
                ui.dictTable(play.result),
                ui.dictTable(play.resultData),
                '<button class="btn btn-primary button clearPlay" id="' +
                play._id + '">Delete</button>'
            ])
        table.data = data
        return {
            "draw": int(jimi.api.request.args.get('draw')),
            "recordsTable": 0,
            "recordsFiltered": 0,
            "recordsTotal": 0,
            "data": data
        }, 200