Skip to content

Instantly share code, notes, and snippets.

@op-ct
op-ct / security_environment_report.sh
Created June 6, 2019 16:31
Report security environment info from Facter and sshd
#!/bin/bash
awk_list() {
while read data; do
printf "%s" "$data" | awk -F, '{ for(i =1; i<=NF; i++){ print "- `"$i"`"; } }'
done
}
fact() {
name=${1:-NONAME}
@op-ct
op-ct / http_request.rb
Last active August 21, 2019 21:26
MRI-compatible Ruby method to use as an HTTP/S swiss army knife
require 'json'
require 'open-uri'
require 'net/http'
require 'openssl'
# A fit-for-most-purposes, MRI-compatible HTTP/S swiss army knife method
#
# @param [URI] uri
# @param [Hash] opts options to configure the connection
# @option opts [String] :content_type
@op-ct
op-ct / travis-env-vars-api.rb
Last active August 30, 2019 17:26
Set a common Travis env var across all repos in a GitHub organization
#!/usr/bin/env ruby
#
# Set/delete a common env var across all Travis CI repos in an organization
#
# * Requires a Travis CI token set in environment variable `TRAVIS_TOKEN`
# * Uses Travis CI API v3 (https://developer.travis-ci.org)
#
# @author Name Chris Tessmer <chris.tessmer@onyxpoint.com>
# @license https://apache.org/licenses/LICENSE-2.0
#
@op-ct
op-ct / README.md
Created March 18, 2019 17:01 — forked from openscript/README.md
This bash script can be used to encrypt secrets for a Travis CI configuration (`.travis.yml`) with the project specific public key.

Usage

  • Download script travis-encrypt.sh
  • Make it executable chmod +x travis-encrypt.sh
  • Run the script with ./travis-encrypt.sh -r username/repositoryname -e example
    • It will return something like O+woVD9K+PeFrcyu5GCjKSFvfcSPwDW0kyDYEQnNbwt/iSkqjpl2OPA9W//KEKEB9UUSZD+XmQ3Ij0gnvJnOowcWY5sSeJlVEVTrSer0kW6uWpa/uWzDHCBz2YhBnI6u9SfYfMkhDl22pcaCEwaUkmK2gjcVo+v0bS8vAQFz0Na5/WiKj0GkSX50iIGgfaXheuC8KgIC25T0h+czpap7vb13OlblMnClfyTH9+TmAwTlcV7ljXpv1QY+K72L8jK1/CQVZ8quBYrBwwxO2V6cpXRMMCIw4m4lqxUyN4FBGnq7cJ7BWLzeqSMpFBoP+ZxAqS5yem8KLh1VkEo7PVjCkZE6M+2meFf2VJEVUs/KJY9xnH3eDzipWkwXon2qVpCkT7FDEzGFs/DapYsSo7eCO6pUYYhcpaYpWeYV9DSSV0QcrOeZp664iJMHWPSmrs/lESbbHpKWsM/AFVB9X75q/OB+QU0tQxpReZmKw3ZHbDVMlmlwhP8VSiQ05LV2W6gYzADGiUiL6n1X8teeHEVDSZnD7nrxMD/FchnWI5La3tZeFovRMf6hH3NItW+QZaGaGNftJrP488J/F2hCycPJk3+YrxbBCGHE2X379QbkMz3S0B5UiAcJKmwuTstF6X3CCurZVYIkUGGXhnmalPtVpEqxeTiLw5RU6C9z2qSwhhw=
  • Use the encrypted secret in your .travis.yml according to https://docs.travis-ci.com/user/encryption-keys/#Usage
@op-ct
op-ct / fix_r10k_files.sh
Last active December 17, 2018 23:46
safe r10k wrapper and postrun script to make/keep permissions safe and avoid server problems
#!/bin/bash
# ------------------------------------------------------------------------------
# Ensure various things are correct after r10k is finished running
#
# To save time, this script only attempts to run a blanket fix permission fix
# if it has NOT been run with the same effective gid as the Puppet Server.
#
# NOTE: To use this script, specify it as the `postrun` in the r10k.yaml file
#
# NOTE: r10k does not provide the deployed environment to postrun scripts.
@op-ct
op-ct / stig_egrep.rb
Last active June 5, 2018 19:34
STIG egrep helper
require 'json'
require 'yaml'
require 'tmpdir'
require 'rake'
require 'rake/file_utils'
require 'optparse'
require 'fileutils'
class StigJsonEgrepper
@op-ct
op-ct / README.md
Last active June 7, 2024 23:10
Creating signed TPM 2.0 endorsement key x.509v3 certificates with openssl

This script uses openssl to mock a TPM 2.0 manufacturer's [Endorsement Key credentials][r4] enough to use in acceptance tests starting with fresh EKs from a newly-instantiated [TPM 2.0 simulator][tpm2sim].

Usage

bash -e  tpm2_ekcert_sign.sh  [public.ek.portion.cer]

Input

@op-ct
op-ct / codesign.sh
Created May 9, 2018 14:07 — forked from vszakats/codesign.sh
Code-signing PE executables using OpenSSL, osslsigncode (and more)
#!/bin/sh -e
# To the extent possible under law, Viktor Szakats (vszakats.net)
# has waived all copyright and related or neighboring rights to this
# script.
# CC0 - https://creativecommons.org/publicdomain/zero/1.0/
# This script will create a self-signed root certificate, along with a code
# signing certificate in various formats, trying to use the best available
# crypto/practice all along. Then, it will create a test executable and code
@op-ct
op-ct / vagrant_rsync
Created April 30, 2018 16:44
rsync Puppet module changes to Beaker Vagrant hosts
require 'json'
require 'yaml'
require 'rake/file_utils'
module Simp; end
module Simp::BeakerSuites; end
module Simp::BeakerSuites::Helpers
include FileUtils
@beaker_suites_rpath = 'spec/acceptance/suites'
@op-ct
op-ct / Vagrantfile
Created March 15, 2018 19:36
SIMP-4074 safety-save
# -*- mode: ruby -*-
# vi: set ft=ruby :
# All Vagrant configuration is done below. The "2" in Vagrant.configure
# configures the configuration version (we support older styles for
# backwards compatibility). Please don't change it unless you know what
# you're doing.
Vagrant.configure("2") do |c|
c.vm.define 'r10k-install-test', primary: true do |v|
v.vm.box = 'centos/7'