def getRecordsForDefaultDashboardTable(username, tableName): """ Called by createTableObject to retrieve the proper records from the database for the default dashboard tables. These queries are different then the saved searches which is why it is needed. This is also called via ajax on the saved_search.html page by get_dashboard_table_data in Views.py. This is to get the records when editing the default tables. """ from crits.core.handlers import data_query, generate_counts_jtable if tableName == "Recent_Samples" or tableName == "Recent Samples": obj_type = "Sample" response = data_query(Sample, username, query={}, sort=["-created"], limit=5) elif tableName == "Recent_Emails" or tableName == "Recent Emails": obj_type = "Email" response = data_query(Email, username, query={}, sort=["-isodate"], limit=5) elif tableName == "Recent_Indicators" or tableName == "Recent Indicators": obj_type = "Indicator" response = data_query(Indicator, username, query={}, sort=["-created"], limit=5) elif tableName == "Top_Campaigns" or tableName == "Top Campaigns": obj_type = "Campaign" response = data_query(Campaign, username, query={}, limit=5) elif tableName == "Top_Backdoors" or tableName == "Top Backdoors": obj_type = "Backdoor" response = data_query(Backdoor, username, query={}, limit=5) elif tableName == "Counts": response = generate_counts_jtable(None, "jtlist") records = json.loads(response.content)["Records"] for record in records: record["recid"] = record.pop("id") return records return parseDocumentsForW2ui(response, obj_type)
def getRecordsForDefaultDashboardTable(user, tableName): """ Called by createTableObject to retrieve the proper records from the database for the default dashboard tables. These queries are different then the saved searches which is why it is needed. This is also called via ajax on the saved_search.html page by get_dashboard_table_data in Views.py. This is to get the records when editing the default tables. """ from crits.core.handlers import data_query, generate_counts_jtable if tableName == "Recent_Samples" or tableName == "Recent Samples" and user.has_access_to( SampleACL.READ): obj_type = "Sample" response = data_query(Sample, user, query={}, sort=["-created"], limit=5) elif tableName == "Recent_Emails" or tableName == "Recent Emails" and user.has_access_to( EmailACL.READ): obj_type = "Email" response = data_query(Email, user, query={}, sort=["-isodate"], limit=5) elif tableName == "Recent_Indicators" or tableName == "Recent Indicators" and user.has_access_to( IndicatorACL.READ): obj_type = "Indicator" response = data_query(Indicator, user, query={}, sort=["-created"], limit=5) elif tableName == "Top_Campaigns" or tableName == "Top Campaigns" and user.has_access_to( CampaignACL.READ): obj_type = "Campaign" response = data_query(Campaign, user, query={}, limit=5) elif tableName == "Counts": response = generate_counts_jtable(None, "jtlist") records = json.loads(response.content)["Records"] for record in records: record["recid"] = record.pop("id") return records else: # This only happens if we have a dashboard which is no longer valid. # For example, after Backdoor and Exploit were added the "Top_Backdoors" # dashboard is no longer valid. Produce an "empty" response. response = {'data': []} obj_type = None return parseDocumentsForW2ui(response, obj_type)
def getRecordsForDefaultDashboardTable(user, tableName): """ Called by createTableObject to retrieve the proper records from the database for the default dashboard tables. These queries are different then the saved searches which is why it is needed. This is also called via ajax on the saved_search.html page by get_dashboard_table_data in Views.py. This is to get the records when editing the default tables. """ from crits.core.handlers import data_query, generate_counts_jtable if tableName == "Recent_Samples" or tableName == "Recent Samples" and user.has_access_to(SampleACL.READ): obj_type = "Sample" response = data_query(Sample, user, query={}, sort=["-created"], limit=5) elif tableName == "Recent_Emails" or tableName == "Recent Emails" and user.has_access_to(EmailACL.READ): obj_type = "Email" response = data_query(Email, user, query={}, sort=["-isodate"], limit=5) elif tableName == "Recent_Indicators" or tableName == "Recent Indicators" and user.has_access_to(IndicatorACL.READ): obj_type = "Indicator" response = data_query(Indicator, user, query={}, sort=["-created"], limit=5) elif tableName == "Top_Campaigns" or tableName == "Top Campaigns" and user.has_access_to(CampaignACL.READ): obj_type = "Campaign" response = data_query(Campaign, user, query={}, limit=5) elif tableName == "Counts": response = generate_counts_jtable(None, "jtlist") records = json.loads(response.content)["Records"] for record in records: record["recid"] = record.pop("id") return records else: # This only happens if we have a dashboard which is no longer valid. # For example, after Backdoor and Exploit were added the "Top_Backdoors" # dashboard is no longer valid. Produce an "empty" response. response = {'data': []} obj_type = None return parseDocumentsForW2ui(response, obj_type)