Skip to content

Commit

Permalink
Make sure P&E API is called correctly with Headers
Browse files Browse the repository at this point in the history
  • Loading branch information
aloftus23 committed Dec 13, 2024
1 parent 790034e commit 074fcaf
Show file tree
Hide file tree
Showing 2 changed files with 76 additions and 39 deletions.
75 changes: 50 additions & 25 deletions src/pe_reports/data/db_query.py
Original file line number Diff line number Diff line change
Expand Up @@ -536,8 +536,9 @@ def query_domMasq_alerts(org_uid, start_date, end_date):
# Endpoint info
endpoint_url = pe_api_url + "domain_alerts_by_org_date"
headers = {
"Content-Type": "application/json",
"access_token": pe_api_key,
"Authorization": cf_api_key,
'Content-Type': ''
}
data = json.dumps(
{"org_uid": org_uid, "start_date": start_date, "end_date": end_date}
Expand Down Expand Up @@ -593,8 +594,9 @@ def query_domMasq(org_uid, start_date, end_date):
# Endpoint info
endpoint_url = pe_api_url + "domain_permu_by_org_date"
headers = {
"Content-Type": "application/json",
"access_token": pe_api_key,
"Authorization": cf_api_key,
'Content-Type': ''
}
data = json.dumps(
{"org_uid": org_uid, "start_date": start_date, "end_date": end_date}
Expand Down Expand Up @@ -645,8 +647,9 @@ def insert_roots(org, domain_list):
# Endpoint info
endpoint_url = pe_api_url + "root_domains_insert"
headers = {
"Content-Type": "application/json",
"access_token": pe_api_key,
"Authorization": cf_api_key,
'Content-Type': ''
}
data = json.dumps({"org_dict": org_dict, "domain_list": domain_list})
try:
Expand Down Expand Up @@ -677,8 +680,9 @@ def get_orgs_contacts():
# Endpoint info
endpoint_url = pe_api_url + "orgs_report_on_contacts"
headers = {
"Content-Type": "application/json",
"access_token": pe_api_key,
"Authorization": cf_api_key,
'Content-Type': ''
}
try:
# Call endpoint
Expand Down Expand Up @@ -714,8 +718,9 @@ def get_org_assets_count_past(org_uid, date):
# Endpoint info
endpoint_url = pe_api_url + "past_asset_counts_by_org"
headers = {
"Content-Type": "application/json",
"access_token": pe_api_key,
"Authorization": cf_api_key,
'Content-Type': ''
}
data = json.dumps({"org_uid": org_uid, "date": date})
try:
Expand Down Expand Up @@ -761,8 +766,9 @@ def get_org_assets_count(org_uid):
# Endpoint info
endpoint_url = pe_api_url + "asset_counts_by_org"
headers = {
"Content-Type": "application/json",
"access_token": pe_api_key,
"Authorization": cf_api_key,
'Content-Type': ''
}
data = json.dumps({"org_uid": org_uid})
try:
Expand Down Expand Up @@ -816,8 +822,9 @@ def get_new_orgs():
# Endpoint info
endpoint_url = pe_api_url + "orgs_report_on_false"
headers = {
"Content-Type": "application/json",
"access_token": pe_api_key,
"Authorization": cf_api_key,
'Content-Type': ''
}
data = None
try:
Expand Down Expand Up @@ -874,8 +881,9 @@ def set_org_to_report_on(cyhy_db_id, premium: bool = False):
# Endpoint info
endpoint_url = pe_api_url + "orgs_set_report_on"
headers = {
"Content-Type": "application/json",
"access_token": pe_api_key,
"Authorization": cf_api_key,
'Content-Type': ''
}
data = json.dumps({"cyhy_db_name": cyhy_db_id, "premium": premium})
try:
Expand Down Expand Up @@ -927,8 +935,9 @@ def set_org_to_demo(cyhy_db_id, premium):
# Endpoint info
endpoint_url = pe_api_url + "orgs_set_demo"
headers = {
"Content-Type": "application/json",
"access_token": pe_api_key,
"Authorization": cf_api_key,
'Content-Type': ''
}
data = json.dumps({"cyhy_db_name": cyhy_db_id, "premium": premium})
try:
Expand Down Expand Up @@ -980,8 +989,9 @@ def query_cyhy_assets(org_cyhy_name):
# Endpoint info
endpoint_url = pe_api_url + "cyhy_assets_by_org"
headers = {
"Content-Type": "application/json",
"access_token": pe_api_key,
"Authorization": cf_api_key,
'Content-Type': ''
}
data = json.dumps({"org_cyhy_name": org_cyhy_name})
try:
Expand Down Expand Up @@ -1027,8 +1037,9 @@ def get_cidrs_and_ips(org_uid):
# Endpoint info
endpoint_url = pe_api_url + "cidrs_ips_by_org"
headers = {
"Content-Type": "application/json",
"access_token": pe_api_key,
"Authorization": cf_api_key,
'Content-Type': ''
}
data = json.dumps({"org_uid": org_uid})
try:
Expand Down Expand Up @@ -1066,8 +1077,9 @@ def query_ips(org_uid):
# Endpoint info
endpoint_url = pe_api_url + "ips_by_org"
headers = {
"Content-Type": "application/json",
"access_token": pe_api_key,
"Authorization": cf_api_key,
'Content-Type': ''
}
data = json.dumps({"org_uid": org_uid})
try:
Expand Down Expand Up @@ -1107,8 +1119,9 @@ def query_extra_ips(org_uid):
# Endpoint info
endpoint_url = pe_api_url + "extra_ips_by_org"
headers = {
"Content-Type": "application/json",
"access_token": pe_api_key,
"Authorization": cf_api_key,
'Content-Type': ''
}
data = json.dumps({"org_uid": org_uid})
try:
Expand Down Expand Up @@ -1155,8 +1168,9 @@ def query_cidrs_by_org(org_uid):
# Endpoint info
endpoint_url = pe_api_url + "cidrs_by_org"
headers = {
"Content-Type": "application/json",
"access_token": pe_api_key,
"Authorization": cf_api_key,
'Content-Type': ''
}
data = json.dumps({"org_uid": org_uid})
try:
Expand Down Expand Up @@ -1203,8 +1217,9 @@ def query_ports_protocols(org_uid):
# Endpoint info
endpoint_url = pe_api_url + "ports_protocols_by_org"
headers = {
"Content-Type": "application/json",
"access_token": pe_api_key,
"Authorization": cf_api_key,
'Content-Type': ''
}
data = json.dumps({"org_uid": org_uid})
try:
Expand Down Expand Up @@ -1242,8 +1257,9 @@ def query_software(org_uid):
# Endpoint info
endpoint_url = pe_api_url + "software_by_org"
headers = {
"Content-Type": "application/json",
"access_token": pe_api_key,
"Authorization": cf_api_key,
'Content-Type': ''
}
data = json.dumps({"org_uid": org_uid})
try:
Expand Down Expand Up @@ -1281,8 +1297,9 @@ def query_foreign_IPs(org_uid):
# Endpoint info
endpoint_url = pe_api_url + "foreign_ips_by_org"
headers = {
"Content-Type": "application/json",
"access_token": pe_api_key,
"Authorization": cf_api_key,
'Content-Type': ''
}
data = json.dumps({"org_uid": org_uid})
try:
Expand Down Expand Up @@ -1327,8 +1344,9 @@ def query_roots(org_uid):
# Endpoint info
endpoint_url = pe_api_url + "root_domains_by_org"
headers = {
"Content-Type": "application/json",
"access_token": pe_api_key,
"Authorization": cf_api_key,
'Content-Type': ''
}
data = json.dumps({"org_uid": org_uid})
try:
Expand Down Expand Up @@ -1372,8 +1390,9 @@ def query_creds_view(org_uid, start_date, end_date):
# Endpoint info
endpoint_url = pe_api_url + "breachcomp_by_org"
headers = {
"Content-Type": "application/json",
"access_token": pe_api_key,
"Authorization": cf_api_key,
'Content-Type': ''
}
data = json.dumps(
{
Expand Down Expand Up @@ -1428,8 +1447,9 @@ def query_credsbyday_view(org_uid, start_date, end_date):
# Endpoint info
endpoint_url = pe_api_url + "credsbydate_by_org"
headers = {
"Content-Type": "application/json",
"access_token": pe_api_key,
"Authorization": cf_api_key,
'Content-Type': ''
}
data = json.dumps(
{
Expand Down Expand Up @@ -1480,8 +1500,9 @@ def query_breachdetails_view(org_uid, start_date, end_date):
# Endpoint info
endpoint_url = pe_api_url + "breachdetails_by_org"
headers = {
"Content-Type": "application/json",
"access_token": pe_api_key,
"Authorization": cf_api_key,
'Content-Type': ''
}
data = json.dumps(
{
Expand Down Expand Up @@ -1538,8 +1559,9 @@ def query_darkweb(org_uid, start_date, end_date, table):
# Endpoint info
endpoint_url = pe_api_url + "darkweb_data"
headers = {
"Content-Type": "application/json",
"access_token": pe_api_key,
"Authorization": cf_api_key,
'Content-Type': ''
}
# Check table name is valid
if table in [
Expand Down Expand Up @@ -1656,8 +1678,9 @@ def execute_scorecard(summary_dict):
# Endpoint info
endpoint_url = pe_api_url + "rss_insert"
headers = {
"Content-Type": "application/json",
"access_token": pe_api_key,
"Authorization": cf_api_key,
'Content-Type': ''
}
data = json.dumps(input_dict)
try:
Expand Down Expand Up @@ -1746,8 +1769,9 @@ def query_previous_period(org_uid, prev_end_date):
# Endpoint info
endpoint_url = pe_api_url + "rss_prev_period"
headers = {
"Content-Type": "application/json",
"access_token": pe_api_key,
"Authorization": cf_api_key,
'Content-Type': ''
}
data = json.dumps(
{
Expand Down Expand Up @@ -2105,8 +2129,9 @@ def get_new_cves_list():
# Endpoint info
endpoint_url = pe_api_url + "pescore_check_new_cve"
headers = {
"Content-Type": "application/json",
"access_token": pe_api_key,
"Authorization": cf_api_key,
'Content-Type': ''
}
try:
# Call endpoint
Expand Down
Loading

0 comments on commit 074fcaf

Please sign in to comment.