Skip to content

Instantly share code, notes, and snippets.

View andrewgross's full-sized avatar

Andrew Gross andrewgross

View GitHub Profile
Multiple vulnerabilities have been discovered in the PHP language:
CVE-2015-4598
thoger at redhat dot com discovered that paths containing a NUL
character were improperly handled, thus allowing an attacker to
manipulate unexpected files on the server.
CVE-2015-4643
@andrewgross
andrewgross / gist:8922636
Last active August 29, 2015 13:56
api.py using requests.
import copy
import datetime
import itertools
import logging
import os
import re
import socket
import subprocess
import threading
import urllib2
def _parse_block_device_mappings(user_input):
"""
Parse block device mappings per AWS CLI tools syntax (modified to add IOPS)
http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/block-device-mapping-concepts.html
Syntax:
/dev/xvd[a-z]=[snapshot-id|ephemeral]:[size in GB]:[Delete on Term]:[IOPS]
- Leave inapplicable fields blank
- Delete on Termination defaults to True
@andrewgross
andrewgross / gist:9261189
Created February 27, 2014 22:41
Suble AWS API Trolling
# Describe Launch Config formatting
<BlockDeviceMappings>
<member>
<DeviceName>/dev/xvdp</DeviceName>
<Ebs>
<SnapshotId>snap-1234abcd</SnapshotId>
<Iops>1000</Iops>
<DeleteOnTermination>true</DeleteOnTermination>
<VolumeType>io1</VolumeType>
<VolumeSize>100</VolumeSize>
@andrewgross
andrewgross / gist:11183809
Created April 22, 2014 15:33
Whos the dumbest GoT character
This isn't even close. Catelyn Stark.
Did she make a single good decision during her lifespan? She chased away Jon Snow when another strong male would have been a huge asset. She went to pieces when Bran fell, and left the family in the hands of an inexperienced teenager. She convinced Ned to trust Littlefinger, which got him killed. She captured Tyrion, which started a war and made Sansa into a hostage. She didn't convince her teenaged son that marrying his new girlfriend was a horrible idea, which got all of them killed. She betrayed her own son.
This is a woman who claimed to care about her family more than anything, but managed to get almost the entire clan killed in under three years.
Cersei isn't a rocket scientist, and Viserys was an idiot, but he got himself killed before he could do much damage to anyone else. Joffrey wasn't stupid, he was batshit insane.
deploy_cookbook ()
{
EXPECTED_ARGS=2;
BAD_ARGS_ERROR_CODE=65;
if [ $# -ne $EXPECTED_ARGS ]; then
echo 'Usage: deploy_cookbook ${ENV} ${COOKBOOK}';
return $BAD_ARGS_ERROR_CODE;
fi;
environment=$1;
cookbook=$2;

I was curious if there were any plans to update or modify the JSON query API in ES 2.0+?

While I find the API to very powerful, it is confusing to construct a valid request and requires special casing a lot of rules. I have some thoughts below on what I see as the current issues, and some suggestions to correct them. I don't intend for this to be a rant, just to provoke discussion. This is done purely from the point of view of constructing queries (not parsing them), and only for the JSON DSL query syntax for searching (not percolate or aggregators).

It is currently hard to construct small parts of a JSON query without knowing all of the elements involved. Looking at a simple query and a filtered query:

Simple Query:

@andrewgross
andrewgross / event_watch.py
Last active August 29, 2015 14:07
event_watch.py
import boto.ec2
ec2_conn = boto.ec2.connect_to_region('us-east-1')
def check_events():
statuses = ec2_conn.get_all_instance_status(filters={"event.description": "Scheduled reboot"})
for status in statuses:
if status.events:
for event in status.events:
print "{}: {}".format(status.id, event.description)
<DescribeSecurityGroupsResponse xmlns="http://ec2.amazonaws.com/doc/2014-09-01/">
<requestId>59dbff89-35bd-4eac-99ed-be587EXAMPLE</requestId>
<securityGroupInfo>
<item>
<ownerId>111122223333</ownerId>
<groupId>sg-1a2b3c4d</groupId>
<groupName>WebServers</groupName>
<groupDescription>Web Servers</groupDescription>
<vpcId/>
<ipPermissions>
{
"DescribeSecurityGroupsResponse": {
"-xmlns": "http://ec2.amazonaws.com/doc/2014-09-01/",
"requestId": "59dbff89-35bd-4eac-99ed-be587EXAMPLE",
"securityGroupInfo": {
"item": [
{
"ownerId": "111122223333",
"groupId": "sg-1a2b3c4d",
"groupName": "WebServers",