Skip to content

Instantly share code, notes, and snippets.

View jmhale's full-sized avatar

James Hale jmhale

View GitHub Profile
import boto3
from prettytable import PrettyTable
def get_unencrypted_volumes():
ec2 = boto3.client('ec2')
# Retrieve all EBS volumes in the AWS account
response = ec2.describe_volumes()
volumes = response['Volumes']
-----BEGIN CERTIFICATE-----
MIIBmjCCAUGgAwIBAgIQd+fPMrhLpyhDsvVxt7vFxjAKBggqhkjOPQQDAjAsMRAw
DgYDVQQKEwdIYWxlTGFiMRgwFgYDVQQDEw9IYWxlTGFiIFJvb3QgQ0EwHhcNMjEx
MjExMTQzNTU5WhcNMzExMjA5MTQzNTU5WjAsMRAwDgYDVQQKEwdIYWxlTGFiMRgw
FgYDVQQDEw9IYWxlTGFiIFJvb3QgQ0EwWTATBgcqhkjOPQIBBggqhkjOPQMBBwNC
AAQ9p/w81fRL3b0iJRKV5dbvZHiExMmpmMM3FnRIjm2Rsp5VCxG3ApI6/i2F+Lvb
FqNLbQpowwckKQ+3KTNEkO5+o0UwQzAOBgNVHQ8BAf8EBAMCAQYwEgYDVR0TAQH/
BAgwBgEB/wIBATAdBgNVHQ4EFgQUltQxmEX8Z57c+F7QKjNP59iCVbowCgYIKoZI
zj0EAwIDRwAwRAIgDXzAE1p5zyMH6jnBtDX5xHas5UU3lwHLwjGmHMss3OgCIAMA
Iy774y3w2SAQ6u83tC2BkJ0NoufyU6/S2MetSRzQ
@jmhale
jmhale / metar-taf.sh
Created December 21, 2022 17:20
METAR/TAR Functions
# Functions to get METAR/TAFs from checkwx.com. Defaults to KDCA for both.
function metar() {
if [ "$1" != "" ]
then
curl "https://api.checkwx.com/bot/metar/$1?x-api-key=$CHECK_WX_API_KEY"
else
curl "https://api.checkwx.com/bot/metar/KDCA?x-api-key=$CHECK_WX_API_KEY"
fi
}
@jmhale
jmhale / gist:805a85e6b3b7762041c92dea8d3da95f
Created April 27, 2022 11:22
Convert between Pihole and Unbound custom DNS lists
# Unbound to Pihole
cat unbound/etc-unbound/a-records.conf | awk '{print $4 " " $2}'| tr -d \" | sed 's/\.$//' > pihole/etc-pihole/custom.list
# Pihole to Unbound
cat pihole/etc-pihole/custom.list | awk '{print "local-data: \""$2". A "$1"\""}' > unbound/etc-unbound/a-records.conf
{
"basics": {
"name": "James Hale",
"label": "Security Engineering Manager at Salesforce",
"image": "https://hale.dev/assets/images/profile.jpg",
"email": "james@hale.dev",
"url": "https://hale.dev",
"summary": "Cloud security engineer with over fourteen years of experience, specializing in architecting and deploying secure and scalable systems with high availability, using cloud-based and on-premises infrastructure resources, including hybrid solutions.\n\nDevOps and security-focused. Experienced in Agile methodologies, including Scrum and Kanban.\n\nSpecialties include: AWS, VMware, networking, automation and security.",
"profiles": [
{
@jmhale
jmhale / install-doh.sh
Created April 25, 2019 10:24
Installs cloudflared and configures it to use Quad9's DNS-over-HTTPS (DoH)
wget https://bin.equinox.io/c/VdrWdbjqyF/cloudflared-stable-linux-arm.tgz
tar -xvzf cloudflared-stable-linux-arm.tgz
sudo cp ./cloudflared /usr/local/bin
sudo chmod +x /usr/local/bin/cloudflared
useradd -s /usr/sbin/nologin -r -M cloudflared
cat
cat <<EOF > /etc/default/cloudflared
# Commandline args for cloudflared
@jmhale
jmhale / parse_junitxml.py
Created March 19, 2021 00:10
Parse Checkov JUnitXML output
'''
Parses JUnit XML results from Checkov
'''
import os
import html
from junitparser import JUnitXml, Failure, Skipped, Error
PRINT_NO_FAILS = False
@jmhale
jmhale / aws_instances_with_events.sh
Created January 4, 2021 19:45
Returns all AWS EC2 Instance IDs with pending service events
aws ec2 describe-instance-status --query 'InstanceStatuses[?length(Events || `[]`) > `0`]' | jq -r '.[] | "\(.InstanceId)\t\(.Events[].Code)"'
@jmhale
jmhale / gist:6b699c6523a89f8a3b941198b5fd3d90
Created July 22, 2020 13:29
EC2 describe instances in table
aws ec2 describe-instances --query "Reservations[*].Instances[*].{IPAddress:PrivateIpAddress,Name:Tags[?Key=='Name']|[0].Value,Status:State.Name}" --filters Name=instance-state-name,Values=running --output table
@jmhale
jmhale / git-check.sh
Last active October 18, 2019 10:52
Recursively check all local git repos for uncommited changes
find . -type d -name '.git' | while read dir ; do sh -c "cd $dir/../ && git status -s | grep -q [azAZ09] && echo ---- ${dir//\.git/} ---- && git status -s" ; done