Skip to content

Instantly share code, notes, and snippets.

View thedude42's full-sized avatar

Johnny Schmidt thedude42

View GitHub Profile
@thedude42
thedude42 / bootstrap_vault_pki_trust_yubikey_piv.sh
Last active February 14, 2024 05:53
Steps to establish the trust chain for Hashicorp's Vault, including storing the self-signed ROOT on a yubikey in a PIV slot
###############################################################################
###############################################################################
##
## Bootstrap a Vault PKI with an offline Root CA
##
## This document outlines the required steps to establish a PKI starting
## with an offline, self-signed root CA. After creating the root CA the next
## step establishes the Vault PKI back-end configuration and generates a
## signing request for an intermediate CA that is then signed by the root CA.
## Finally after the full-chain is uploaded to Vault, we create a Vault PKI
@thedude42
thedude42 / usefulHeaders.js
Created June 11, 2015 18:19
Insert some OWASP useful headers in LineRate Precision
"use strict";
var vsm = require("lrs/virtualServerModule"),
virtualServerName = "myVirtualServer";
vsm.on("exist", virtualServerName, function(vs) {
vs.on("request", insertUsefulHeaders);
});
function insertUsefulHeaders(servReq, servResp, cliReq) {
@thedude42
thedude42 / cors_server.js
Last active August 29, 2015 14:18
cors_server.js
"use strict";
var vsm = require("lrs/virtualServerModule"),
async = require("async"),
CORS_PREFLIGHT_HEADERS = "Access-Control-Request-Headers";
function CorsService(vs, defaultOrigin, uriAccessList) {
// Constructor, takes the name of a virtual server, default origin value and a configuration object
var self = this;
@thedude42
thedude42 / corsService.js
Created March 31, 2015 21:52
CORS inline script
script corsService
source inline "ENDWORD_corsService"
"use strict";
var cors = require("./cors_server.js"),
service = new cors.CorsService("MyVirtualServerName", "our-default-origin.com",
{"/api/v1.0/json":
{"origins":["our-default-origin.com", "another-allowed-origin.com"],
"allowCreds":false,
"allowHeaders":["X-special-header"],
"methods":['GET','HEAD']
virtual-server test-virtual
service http
attach virtual-ip test-vip default
attach real-server some-server
!
script appender
source inline "ENDWORD_appender"
"use strict";
var vsm = require('lrs/virtualServerModule'),
Appender = require('./response_appender.js'),
"use strict";
var vsm = require('lrs/virtualServerModule'),
FIX_HEADER = true;
function ResponseAppender(vsname, appendString, fixContentLength) {
var self = this;
self.virtualServer = vsname;
@thedude42
thedude42 / xml_to_json.js
Last active August 29, 2015 14:13
lr_response_xml_to_json
"use strict";
var xml2js = require('xml2js'),
vsm = require('lrs/virtualServerModule');
// callback function that implements the xml-to-json gateway
function xml2json_converter(servReq, servRes, cliReq) {
cliReq.on('response', function(response) {
var body = [],
body_len = 0;