Skip to content

Instantly share code, notes, and snippets.

View squizzi's full-sized avatar

Kyle Squizzato squizzi

View GitHub Profile
@squizzi
squizzi / images.sh
Last active December 16, 2022 19:40
Pull MSR 3 images and package as tarball
#!/bin/sh
MSR_TAG=3.0.5
ENZI_TAG=1.0.5
OUTPUT_FILE="/tmp/msr-${MSR_TAG}.tar"
echo "Pulling all MSR images for version: ${MSR_TAG}, enzi version: ${ENZI_TAG}"
declare -a IMAGES=(
registry.mirantis.com/msr/msr-api:$MSR_TAG
@squizzi
squizzi / reset_cve_db.sh
Created July 21, 2021 17:31
Reset a MSR CVE DB for testing.
docker exec -it -u postgres $(docker ps -aq --filter name=dtr-scanningstore) psql -d fuzzomatic -c "UPDATE public.appcheck_nvdfeed set summary=0 where cve='NOT-ACTUAL-CVE'"
REPLICA_ID=$(docker ps -lf name='^/dtr-rethinkdb-.{12}$' --format '{{.Names}}' | cut -d- -f3)
echo "r.db('dtr2').table('properties').get('scan_info').update({value : '{"scannerFingerprint":{"scannerType":0,"version":["0","0"]},"scannerUpdatedAt":"2021-01-01T01:00:00.000000000Z","lastDBUpdateFailed":false,"lastVulnOverridesDBUpdateFailed":false}'})" | docker run -e DTR_REPLICA_ID=$REPLICA_ID -i --rm --net dtr-ol -v dtr-ca-$REPLICA_ID:/ca dockerhubenterprise/rethinkcli:v2.2.0-ni non-interactive; echo
echo -e "CVE DB reset to version 0"
{"lastUpload":"2020-09-30T16:53:06.954Z","extensionVersion":"v3.4.3"}
@squizzi
squizzi / load_env.py
Last active September 26, 2019 18:54
Load a UCP client bundle in python3
"""
load_env is the functional equivalent of loading a UCP client bundle
"""
def load_env(client_bundle="/client-bundle"):
logging.info("Loading UCP client bundle...")
try:
# Open the extracted, mounted client_bundle directory and use its
# contents
bundle_env = client_bundle + "/env.sh"
with open(bundle_env) as f:
@squizzi
squizzi / download_lotsa_images.sh
Last active August 23, 2018 21:58
when you need to download a silly amount of images for a silly reproducer
#!/bin/bash
# Search terms are of images and their derivatives that should be
# relatively small in size it's a total guessing game but whatever
declare -a searchTerms=(
"alpine" "fedora" "ubuntu" "python" "small" "curl" "busybox" "mini" "hello-world" "graphql" "tiny"
"cirros" "opensuse" "dind" "maven" "multistage"
)
for element in "${searchTerms[@]}"
do
for each in $(docker search $element --limit 100 | awk '{print $1}')
@squizzi
squizzi / tcpdump-watch_docker-log.sh
Created July 27, 2018 21:06
tcpdump watch modified to work with docker logs -f
#!/bin/bash
## tcpdump-watch
## Maintainer: Kyle Squizzato - ksquizz@gmail.com
## Simple tool to capture tcpdump until certain log message is matched.
## Fill in each of the variables in the SETUP section then invoke the script and wait
## for the issue to occur, the script will stop on it's own when the $match is seen
## in the desired $container_name.
@squizzi
squizzi / populate-dtr.sh
Last active October 26, 2022 22:42
Populate an MSR (Mirantis Secure Registry) for testing.
#!/bin/sh
# Available on hub: docker pull squizzi/populate-dtr:latest
# Script to quickly and easily populate a DTR test environment with some images and tags
# Usage/help text
usage_text () {
echo -e "Usage: docker run --rm -it -v /var/run/docker.sock:/var/run/docker.sock squizzi/populate-dtr -H <hostname>:<port> -u <username> -p <password>"
exit 1
}
@squizzi
squizzi / api-spec.js
Created June 11, 2018 22:06
Replace tests/api-spec.js with this file
var request = require('request');
var base_url = "http://api:8080/";
describe("When testing 'api/pet'", function(){
it("should respond with the URL of a cat GIF", function(done) {
request(base_url + 'api/pet', function(error, response, body){
expect(body).toMatch(/\{"imageId":\d+,"url":"http(s?):/);
done();
});
});
@squizzi
squizzi / capture-host-performance-docker
Last active February 15, 2018 19:28
capture host performance following a docker logs $container_name match
#!/bin/bash
## capture-host-performance
## docker logs edition
## Maintainer: Kyle Squizzato - kyle.squizzato@docker.com
## Simple tool to capture performance statistics around a docker logs match.
## Invoke the script and wait for the issue to occur, the script will stop
## on it's own when $match is seen in the $container_name log file.
@squizzi
squizzi / calendars_are_fun.sh
Created January 30, 2018 17:04
stupid script to make my calendar icon reflect the date
# Replace the calendar icon with the correct date daily
string=$(date +%d)
if [ ${#string} -le 2 ]; then
string=$(printf %02d $string)
fi
sed -i "s/calendar-blue-[0-9][0-9]*/calendar-blue-$string/" ~/.local/share/applications/chrome-ejjicmeblgpmajnghnpcppodonldlgfn-Profile_2.desktop