From fd44bd54a50a81ab79c1b6fb7ebe5839dacce479 Mon Sep 17 00:00:00 2001 From: aleidk Date: Mon, 10 Feb 2025 13:16:28 -0300 Subject: [PATCH] chore: add files from base_repo template --- .devfiles/hooks/.gitkeep | 0 .devfiles/hooks/commit-msg.sh | 5 ++++ .devfiles/hooks/pre-commit.sh | 16 ++++++++++ .devfiles/justfile | 22 ++++++++++---- .devfiles/scripts/.gitkeep | 0 .devfiles/scripts/dependecy-check.sh | 30 +++++++++++++++++++ .devfiles/scripts/gitignore.sh | 42 +++++++++++++++++++++++++++ .env.agebox | Bin 0 -> 462 bytes .gitleaksignore | 3 ++ .justfile | 3 +- cog.toml | 31 ++++++++++++++++++++ roles/common/files/robo_key | 25 ---------------- roles/common/files/robo_key.agebox | 5 ++++ 13 files changed, 151 insertions(+), 31 deletions(-) create mode 100644 .devfiles/hooks/.gitkeep create mode 100644 .devfiles/hooks/commit-msg.sh create mode 100644 .devfiles/hooks/pre-commit.sh create mode 100644 .devfiles/scripts/.gitkeep create mode 100755 .devfiles/scripts/dependecy-check.sh create mode 100755 .devfiles/scripts/gitignore.sh create mode 100644 .env.agebox create mode 100644 .gitleaksignore create mode 100644 cog.toml delete mode 100644 roles/common/files/robo_key create mode 100644 roles/common/files/robo_key.agebox diff --git a/.devfiles/hooks/.gitkeep b/.devfiles/hooks/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/.devfiles/hooks/commit-msg.sh b/.devfiles/hooks/commit-msg.sh new file mode 100644 index 0000000..1c54b90 --- /dev/null +++ b/.devfiles/hooks/commit-msg.sh @@ -0,0 +1,5 @@ +#!/usr/bin/env bash + +set -euxo pipefail + +cog verify --file "$1" diff --git a/.devfiles/hooks/pre-commit.sh b/.devfiles/hooks/pre-commit.sh new file mode 100644 index 0000000..c8d84f5 --- /dev/null +++ b/.devfiles/hooks/pre-commit.sh @@ -0,0 +1,16 @@ +#!/usr/bin/env bash + +set -euxo pipefail + +root="$(git rev-parse --show-toplevel)" + +cd "$root" + +export PATH=$PATH:.devfiles/bin + +gitleaks git + +# Only validate encrypted files if we are tracking any +if [[ -e .ageboxreg.yml ]]; then + agebox validate --no-decrypt +fi diff --git a/.devfiles/justfile b/.devfiles/justfile index 1833382..2d9a105 100644 --- a/.devfiles/justfile +++ b/.devfiles/justfile @@ -1,14 +1,22 @@ set dotenv-load := true +export PATH := source_dir() + "/bin:" + source_dir() + "/scripts:" + env("PATH") export AGEBOX_DEBUG := "0" export AGEBOX_PUBLIC_KEYS := source_dir() + "/public_keys.txt" -fetch-deps: - .devfiles/scripts/fetch_gh_release.sh "slok/agebox" "agebox-linux-amd64" "agebox" +# Install agebox from the latest github realse +install-agebox: + curl -sSL "https://github.com/slok/agebox/releases/latest/download/agebox-linux-amd64" -o .devfiles/bin/agebox + chmod + x .devfiles/bin/agebox + +[no-cd] +install-hooks: + cog install-hook --all # Easy and simple file repository encryption tool based on Age. +[working-directory('..')] agebox +ARGS="--help": - @.devfiles/bin/agebox {{ ARGS }} + @agebox {{ ARGS }} # Encrypt the provided files, relative to project root. encrypt +FILES: (agebox "encrypt " + FILES) @@ -26,7 +34,11 @@ decrypt-all: (agebox "decrypt --all --force") reencrypt: (agebox "reencrypt") # Show the content of an encrypted file to stdout. -peek +FILES: (agebox "cat " + FILES) +crypt-peek +FILES: (agebox "cat " + FILES) # Validate that all tracked files are encrypted. -check:(agebox "validate --no-decrypt ") +crypt-check:(agebox "validate --no-decrypt ") + +# Validate no credentials are pushed to git +leaks: + @gitleaks git --verbose --redact diff --git a/.devfiles/scripts/.gitkeep b/.devfiles/scripts/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/.devfiles/scripts/dependecy-check.sh b/.devfiles/scripts/dependecy-check.sh new file mode 100755 index 0000000..684a14b --- /dev/null +++ b/.devfiles/scripts/dependecy-check.sh @@ -0,0 +1,30 @@ +#!/usr/bin/env bash + +set -euo pipefail + +root="$(git rev-parse --show-toplevel)" + +export PATH=$root/.devfiles/bin:$root/.devfiles/scripts:$PATH + +devtools=( + age + agebox + cog + gitleaks +) + +missing_tools=() + +for cmd in "${devtools[@]}"; do + if ! command -v "$cmd" &>/dev/null; then + missing_tools+=("$cmd") + fi +done + +if [[ ${#missing_tools[@]} != 0 ]]; then + echo "The following tools where not found:" + printf "%s\n" "${missing_tools[@]}" + exit 1 +else + echo -e "All tools are installed!" +fi diff --git a/.devfiles/scripts/gitignore.sh b/.devfiles/scripts/gitignore.sh new file mode 100755 index 0000000..0b5100d --- /dev/null +++ b/.devfiles/scripts/gitignore.sh @@ -0,0 +1,42 @@ +#!/usr/bin/env bash + +set -euo pipefail + +root="$(git rev-parse --show-toplevel)" + +base_url="https://git.alecodes.page/api/v1/gitignore/templates" + +query="$*" + +list_available() { + curl -Ssl $base_url | jq -r '.[]' +} + +if [[ -z $query ]]; then + list_available + exit 0 +fi + +tmp_file="$(mktemp)" + +for template in $query; do + # Capitalize the string + template=${template,,} + template=${template^} + + response="$(curl -Ssl "$base_url/$template")" + name="$(echo "$response" | jq -r '.name')" + content="$(echo "$response" | jq -r '.source')" + + if [[ "$content" == "null" ]]; then + echo "Template not found, available options:" + list_available + exit 1 + fi + + printf "\n### %s\n\n%s\n\n" "$name" "$content" >>"$tmp_file" +done + +sed -i -ne "/#### -- TEMPLATES BEGIN -- ####/ {p; r $tmp_file" -e ':a; n; /#### -- TEMPLATES END -- ####/ {p; b}; ba}; p' "$root/.gitignore" + +rm "$tmp_file" diff --git a/.env.agebox b/.env.agebox new file mode 100644 index 0000000000000000000000000000000000000000..ae7ac752cbbcba1333f0bfd9bb5a3fe26dbf7df0 GIT binary patch literal 462 zcmV;<0WtnzXJsvAZewzJaCB*JZZ2ymSura}OiFJ}Q%X-yFmYN`Z+T>JZFgojQcVg{S9wK4ZF)gyZESNgQfo9ZS3-9+ zQa5E;GHOeBbZc5#R7gU1NK9BWL`e!QEiE8YF+wypQ$=9dxFscG>A|Ti2hR9A+Nm$c~(ZM1n<^D X25519 gYcsPablv8DX5YR2YElCe9IYxd4jACU30GaL97JfETM +PSYUSaAkiHBtprz6qUKqP8RFPkgHCwwnFCACzKlsGU0 +--- giGOMUX2iMWaixyGM7ZxyCPMz10xFxNIJA9vpsJEW+4 +JvtpT(~AnfL3$PyU !]oޘב/׏L S:b-frql=@wrq6{eۃlg u{bL_>cb4?e})Pp|D,oIX_cpG%yG)`sR7PRKu% z0aԮXKr>'SLwppIo/M /2:@.n9 cXG_-ObOPTDƙ`p:F{,xULa1erB\J BqesBѽ="X70=vyWǁ }U'!: ;pnr2D*nQv4%|KxH\1:D40r{ \ No newline at end of file