diff --git a/.tool-versions b/.tool-versions index e3d09926..13b6acde 100644 --- a/.tool-versions +++ b/.tool-versions @@ -2,8 +2,8 @@ act 0.2.64 gitleaks 8.18.4 pre-commit 3.6.0 terraform 1.9.2 -vale 3.6.0 tfsec 1.28.10 +vale 3.6.0 # ============================================================================== # The section below is reserved for Docker image versions. diff --git a/scripts/config/gitleaks.toml b/scripts/config/gitleaks.toml index e4b6bc15..188bfdf0 100644 --- a/scripts/config/gitleaks.toml +++ b/scripts/config/gitleaks.toml @@ -22,3 +22,9 @@ paths = [ '''yarn.lock''', '''Gemfile.lock''', ] + +# Exclude Chrome version in user agent +regexTarget = "line" +regexes = [ + '''Chrome/[\d.]+''' +] diff --git a/scripts/config/pre-commit.yaml b/scripts/config/pre-commit.yaml index 41dafe77..5a5ba09e 100644 --- a/scripts/config/pre-commit.yaml +++ b/scripts/config/pre-commit.yaml @@ -15,6 +15,13 @@ repos: - id: pretty-format-json args: ['--autofix'] # - id: ... + - repo: local + hooks: + - id: sort-dictionary + name: Sort dictionary + entry: ./scripts/githooks/sort-dictionary.sh + language: script + pass_filenames: false - repo: local hooks: - id: scan-secrets diff --git a/scripts/githooks/sort-dictionary.sh b/scripts/githooks/sort-dictionary.sh new file mode 100755 index 00000000..45a39529 --- /dev/null +++ b/scripts/githooks/sort-dictionary.sh @@ -0,0 +1,48 @@ +#!/bin/bash + +set -euo pipefail + +# Pre-commit git hook to sort the Vale dictionary in a consistent manner to avoid future merge conflicts and aid insertion of new terms +# +# Usage: +# $ [options] ./sort-dictionary.sh +# +# Options: +# +# +# Exit codes: +# 0 - Successfully sorted the dictionary +# non-zero - failed to sort dictionary + +# ============================================================================== + +function main() { + root=scripts/config/vale/styles/config/vocabularies/words + opts="--dictionary-order --ignore-case -s" + sort $opts $root/accept.txt > $root/accept.sorted.txt + sort $opts $root/reject.txt > $root/reject.sorted.txt + + mv $root/accept.sorted.txt $root/accept.txt + mv $root/reject.sorted.txt $root/reject.txt + + git add -uv $root/* +} + +# ============================================================================== + +function is-arg-true() { + + if [[ "$1" =~ ^(true|yes|y|on|1|TRUE|YES|Y|ON)$ ]]; then + return 0 + else + return 1 + fi +} + +# ============================================================================== + +is-arg-true "${VERBOSE:-false}" && set -x + +main "$@" + +exit 0