Skip to content

Instantly share code, notes, and snippets.

View bestickley's full-sized avatar
🎯
Focusing

Ben Stickley bestickley

🎯
Focusing
View GitHub Profile
@bestickley
bestickley / README.md
Last active March 17, 2023 19:41
DoD CAC SSL Local Dev Setup

DoD CAC SSL Local Dev Setup

Requirements: Docker

  1. Create a working directory
  2. Download PKI CA Certificate Bundle from https://dl.dod.cyber.mil/wp-content/uploads/pki-pke/zip/certificates_pkcs7_v5-6_dod.zip
  3. Unzip the downloaded zip file
  4. Copy Certificates_PKCS7_v5.6_DoD.pem.p7b into the working directory
  5. Add csr.conf (below) to working directory
  6. docker run -it -v "/absolute/path/to/working/directory:/home" --entrypoint /bin/ash frapsoft/openssl
    • if using windows, make sure to start your absolute path with /c/...
import { SignatureV4 } from "@aws-sdk/signature-v4";
import { HttpRequest } from "@aws-sdk/protocol-http";
import { HttpRequest as IHttpRequest } from "@aws-sdk/types";
import { Sha256 } from "@aws-crypto/sha256-js";
import { defaultProvider } from "@aws-sdk/credential-provider-node";
interface CreateSignHttpRequestParams {
body?: string;
headers?: Record<string, string>;
hostname: string;
enum LogLevel {
debug = 1,
log = 2,
warn = 3,
error = 4,
}
export class Logger {
#logLevel: LogLevel = 1;
constructor(logLevel?: LogLevel) {
import got, { BeforeRequestHook } from "got";
import { SignatureV4 } from "@aws-sdk/signature-v4";
import { HttpRequest } from "@aws-sdk/protocol-http";
import { Sha256 } from "@aws-crypto/sha256-js";
import { defaultProvider } from "@aws-sdk/credential-provider-node";
import HttpAgent from "agentkeepalive";
export function getSigV4BeforeHook(service: string): BeforeRequestHook {
const beforeHook: BeforeRequestHook = async (options) => {
console.log(JSON.stringify(options));
@bestickley
bestickley / .zshrc
Last active August 25, 2023 17:58
zsh Config
# Path to your oh-my-zsh installation.
export ZSH="/Users/stickb/.oh-my-zsh"
# Which plugins would you like to load?
# Standard plugins can be found in $ZSH/plugins/
# Custom plugins may be added to $ZSH_CUSTOM/plugins/
# Example format: plugins=(rails git textmate ruby lighthouse)
# Add wisely, as too many plugins slow down shell startup.
plugins=(git)
@bestickley
bestickley / debug.txt
Created March 25, 2022 10:35
Terraform S3 Bucket Object Error Debug Output
Action=DescribeAccountAttributes&AttributeName.1=supported-platforms&Version=2016-11-15
-----------------------------------------------------: timestamp=2022-03-25T06:26:25.722-0400
2022-03-25T06:26:25.876-0400 [INFO] provider.terraform-provider-aws_v3.75.0_x5.exe: 2022/03/25 06:26:25 [DEBUG] [aws-sdk-go] DEBUG: Response ec2/DescribeAccountAttributes Details:
---[ RESPONSE ]--------------------------------------
HTTP/1.1 200 OK
Connection: close
Content-Length: 540
Cache-Control: no-cache, no-store
Content-Type: text/xml;charset=UTF-8
Date: Fri, 25 Mar 2022 10:26:17 GMT
@bestickley
bestickley / debug.txt
Created March 25, 2022 15:26
cdktf ESM S3BucketUpload Error
```bash
PS C:\Users\555959\Code\tdmp-edge-mgmt-ui\infra> cdktf synth
⠙ synthesizing...
[2022-03-25T10:28:39.291] [ERROR] default - C:\Users\555959\Code\tdmp-edge-mgmt-ui\node_modules\.pnpm\[ts-node@10.7.0_a82480146a1b470a40cf96b3f35ca37a](mailto:ts-node@10.7.0_a82480146a1b470a40cf96b3f35ca37a)\node_modules\ts-node\dist-raw\node-esm-resolve-implementation.js:379
const err = new ERR_UNSUPPORTED_DIR_IMPORT(path, fileURLToPath(base));
^
[2022-03-25T10:28:39.304] [ERROR] default - CustomError: ERR_UNSUPPORTED_DIR_IMPORT C:\Users\555959\Code\tdmp-edge-mgmt-ui\infra\node_modules\@cdktf\provider-aws\lib\s3 C:\Users\555959\Code\tdmp-edge-mgmt-ui\infra\src\front-end-stack.ts
at finalizeResolution (C:\Users\555959\Code\tdmp-edge-mgmt-ui\node_modules\.pnpm\[ts-node@10.7.0_a82480146a1b470a40cf96b3f35ca37a](mailto:ts-node@10.7.0_a82480146a1b470a40cf96b3f35ca37a)\node_modules\ts-node\dist-raw\node-esm-resolve-implementation.js:379:17)
at moduleResolve (C:\Users\555959\Code\tdmp-edge-mgmt-ui\nod
@bestickley
bestickley / getUrlsSync.ts
Created March 29, 2022 20:21
Node.js Recursively Get URLs
export function getUrlsSync(rootUrl: URL): URL[] {
const dirents = readdirSync(rootUrl, { withFileTypes: true });
const urls = dirents.map((dirent) => {
const url = new URL(rootUrl + "/" + dirent.name);
return dirent.isDirectory() ? getUrlsSync(url) : url;
});
return urls.flat();
}
@bestickley
bestickley / compute-meta-hash.ts
Created July 31, 2023 18:19
Compute Meta Hash
import { Hash, createHash } from "node:crypto";
import { readdirSync, statSync } from "node:fs";
import { join } from "node:path";
/**
* Creates hash of given files/folders.
*/
export function computeMetaHash(paths: string[], inputHash?: Hash) {
const hash = inputHash ? inputHash : createHash("sha1");
for (const path of paths) {