Skip to content

Instantly share code, notes, and snippets.

@mafux777
mafux777 / explanation.md
Last active December 23, 2021 07:22
Use nginx as a reverse proxy to add API key to datahub

Installation

1)

brew install nginx
sudo cp /usr/local/Cellar/nginx/1.8.0/homebrew.mxcl.nginx.plist /Library/LaunchAgents

2)

Replace /usr/local/etc/nginx/nginx.conf with the nginx.conf in this gist. I'm using port 8081 for my current project.

@mafux777
mafux777 / grab_hashmask.py
Created January 30, 2021 20:45
Grab images for hashmasks
import re
import requests
with open("Hashmasks Provenance Record") as hash:
while(hash):
t = hash.readline()
t0 = t.split("|")
if len(t0)==3:
t2 = t0[2]
t3 = re.search("[a-zA-Z0-9]+", t2)
@mafux777
mafux777 / cloudtrail_4.py
Created December 5, 2020 17:33
Cloud Trail Query Test
query_text = f"""
SELECT eventname, substr(eventtime, 1, 10) as eventdate,count(*)
FROM {database}.{cloudtrail_table}
WHERE region='{region}'
and year=date_format(date_add('day',-1,current_date),'%Y')
and month=date_format(date_add('day',-1,current_date),'%m')
and day=date_format(date_add('day',-1,current_date),'%d')
and eventname='StartQueryExecution'
GROUP BY 1, 2
ORDER BY 1, 2
@mafux777
mafux777 / cloudtrail_1.py
Last active December 5, 2020 18:05
Add Partitions to CloudTrail Logs (1)
import boto3
import time
start = time.time()
# Location should not end with a slash, just CloudTrail
location = "s3://aws-cloudtrail-logs-255149284406-4cec155e/AWSLogs/255149284406/CloudTrail"
# results only needed for the last part (where we validate the query worked)
results = "s3://com.alationpro/athena"
region = "us-west-2"
database = "default"