Skip to content

Instantly share code, notes, and snippets.

@carhartl
carhartl / trivy-report-junit.tpl
Created November 15, 2023 08:05
JUnit report template for trivy
<?xml version="1.0" ?>
<testsuites name="trivy">
{{- range . -}}
{{- $failures := len .Vulnerabilities }}
<testsuite tests="{{ $failures }}" failures="{{ $failures }}" name="{{ .Target }}" errors="0" skipped="0" time="">
{{- if not (eq .Type "") }}
<properties>
<property name="type" value="{{ .Type }}"></property>
</properties>
{{- end -}}
@carhartl
carhartl / update-git-repos.sh
Created November 2, 2023 14:49
Update all git repos within directory
#!/bin/sh
dirs="$(
find . -name .devbox -prune -o -name .terragrunt-cache -prune -o -name lefthook-remotes -prune -o -type d -exec test -d '{}'/.git \; -print
)"
for dir in $dirs; do
cd "$dir" || exit
git config user.email klaus.hartl@test.com
cd -
done
@carhartl
carhartl / devbox.json
Last active August 15, 2023 07:24
Devbox IaC
{
"packages": [
"commitlint@latest",
"go@1.20",
"golangci-lint@latest",
"gotest@latest",
"hadolint@latest",
"kubectl@1.25.5",
"lefthook@latest",
"nodejs@20.5",
@carhartl
carhartl / ingress.yaml
Created November 16, 2022 08:29
Kubernetes nginx-ingress rewriting for SPA
# The rewrite rule for nginx is to pick the first capture group’s match $1 from the path matcher.
#
# In the path matcher regex there are 2 capture groups (the inner groups are not captured):
# /(...)|(.*)
# ^$1 ^$2
#
# So when we match anything that starts with "/api/" or ends with one of "css"/"js"/"png" this will
# populate $1 and nginx passes the url unaltered upstream (-> /$1). If there is no such match, we match
# everything else through the alternation: (.*) to populate $2, but we throw $2 away (we don't make use
# of it in the rewrite target! An empty capture group, in this second scenario $1, will turn into an
pre-commit:
parallel: true
commands:
shellcheck:
glob: "*.sh"
run: shellcheck {staged_files}
actionlint:
glob: ".github/workflows/*.yml"
run: actionlint {staged_files}
@carhartl
carhartl / lefthook.yml
Created September 23, 2021 14:27
Lefthook pre-push script with Talisman
pre-push:
scripts:
secrets-audit:
runner: sh
@carhartl
carhartl / Hyper.itermcolors
Created September 11, 2019 10:43
iTerm2 Hyper Theme
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Ansi 0 Color</key>
<dict>
<key>Alpha Component</key>
<real>1</real>
<key>Blue Component</key>
<real>0.0</real>
@carhartl
carhartl / Hyper.terminal
Last active February 17, 2023 15:05
Hyper like Terminal theme + settings
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>ANSIBlueColor</key>
<data>
YnBsaXN0MDDUAQIDBAUGBwpYJHZlcnNpb25ZJGFyY2hpdmVyVCR0b3BYJG9iamVjdHMS
AAGGoF8QD05TS2V5ZWRBcmNoaXZlctEICVRyb290gAGjCwwTVSRudWxs0w0ODxARElVO
U1JHQlxOU0NvbG9yU3BhY2VWJGNsYXNzSDAgMC40IDEAEAKAAtIUFRYXWiRjbGFzc25h
bWVYJGNsYXNzZXNXTlNDb2xvcqIWGFhOU09iamVjdAgRGiQpMjdJTFFTV11kand+h4mL
@carhartl
carhartl / terraform.rb
Last active February 27, 2018 18:06
Brew Terraform 0.10.8
require "language/go"
class Terraform < Formula
desc "Tool to build, change, and version infrastructure"
homepage "https://www.terraform.io/"
url "https://github.com/hashicorp/terraform/archive/v0.10.8.tar.gz"
sha256 "b076726f00b0488fc95bb041e982cb6aeaf280395d31f322017dd143bbabd7c4"
head "https://github.com/hashicorp/terraform.git"
bottle do
@carhartl
carhartl / autoenv.rb
Created November 10, 2016 18:53
Patched autoenv Homebrew formula
class Autoenv < Formula
desc "Per-project, per-directory shell environments"
homepage "https://github.com/kennethreitz/autoenv"
url "https://github.com/kennethreitz/autoenv/archive/v0.2.1.tar.gz"
sha256 "d10ee4d916a11a664453e60864294fec221c353f8ad798aa0aa6a2d2c5d5b318"
head "https://github.com/kennethreitz/autoenv.git"
bottle :unneeded
devel do