Skip to content

Instantly share code, notes, and snippets.

@gcmurphy
gcmurphy / fastly.py
Created August 14, 2022 03:29
check if ip address in fastly public address block
import argparse
import requests
import ipaddress
import sys
parser = argparse.ArgumentParser(description="checks if ip address in fastly ip range")
parser.add_argument("ip", metavar='IP', type=ipaddress.IPv4Address, nargs='+',
help="ip addresses to check")
args = parser.parse_args()
@gcmurphy
gcmurphy / fiber_rego_authz.go
Created February 21, 2022 03:25
experiment using rego as authorization middleware
package main
import(
"context"
"log"
"time"
"os"
"github.com/gofiber/fiber/v2"
"github.com/open-policy-agent/opa/ast"
@gcmurphy
gcmurphy / gen-iac-gh-action.py
Created December 15, 2021 05:17
Generate a IAC step for all the teraform files in a given directory.
import glob
import os
def generate_github_action(source, filename):
"""
Snyk IAC scanning tool currently has the limitation of only scanning
a single file at a time. This script will generate the github
action steps needed to scan all our IAC code.
"""
@gcmurphy
gcmurphy / index.js
Created March 27, 2020 02:03
lighthouse to extract librarie versions
const lighthouse = require('lighthouse');
const chromeLauncher = require('chrome-launcher');
function launchChromeAndRunLighthouse(url, opts, config = null) {
return chromeLauncher.launch({chromeFlags: opts.chromeFlags}).then(chrome => {
opts.port = chrome.port;
return lighthouse(url, opts, config).then(results => {
// use results.lhr for the JS-consumable output
// https://github.com/GoogleChrome/lighthouse/blob/master/types/lhr.d.ts
// use results.report for the HTML/JSON/CSV output as a string
import argparse
import datetime
import random
import socket
import ssl
import string
import time
import traceback
from urllib.parse import urlparse
from pprint import pprint
@gcmurphy
gcmurphy / detect_secrets_assessment.py
Created January 29, 2020 22:30
Harness for recording responses for each finding made by Yelps detect secrets tool.
import argparse
import json
import subprocess
import linecache
import os
import sys
from pprint import pprint
import tempfile
import csv
@gcmurphy
gcmurphy / xprofile.sh
Last active May 23, 2019 20:45
xprofie setup for linux + dwm + st
~/src/st master ✗ 5m ◒
▶ cat ~/.xprofile
xcompmgr -c -C -t-5 -l-5 -r4.2 -o.55 &
~/src/st master ✗ 6m ◒
▶ cat ~/.xinitrc
[ -f ~/.xprofile ] && . ~/.xprofile
exec nitrogen --restore &
exec slstatus &
exec dwm
@gcmurphy
gcmurphy / hi.py
Created September 21, 2018 01:20
print("o hai")
@gcmurphy
gcmurphy / reproducer.py
Created October 31, 2016 21:52
Stack trace when listing repositories. Reproducer below.
import github3
from os import environ as env
client = github3.GitHubEnterprise(env['GH_ENDPOINT'], token=env['GH_TOKEN'])
for repository in client.iter_all_repos():
if repository:
print("{}/{}".format(repository.owner, repository.name))
@gcmurphy
gcmurphy / dotfiles.py
Created August 23, 2016 18:49
dotfile grabber
import os
import tarfile
__MAX_SIZE_THRESHOLD = 10240000 # ~10MB
def is_dotfile(path):
return (os.path.isfile(path) and
os.path.basename(path).startswith('.') and
os.stat(path).st_size < __MAX_SIZE_THRESHOLD)