@financebuddha/standards 0.1.2 → 0.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/husky/pre-commit +9 -8
- package/package.json +1 -1
package/husky/pre-commit
CHANGED
|
@@ -10,15 +10,16 @@ if [ ! -f "$PATTERNS" ]; then
|
|
|
10
10
|
PATTERNS="$ROOT/node_modules/@financebuddha/standards/secrets-patterns.txt"
|
|
11
11
|
fi
|
|
12
12
|
|
|
13
|
-
# Secrets scan on staged changes.
|
|
14
|
-
#
|
|
15
|
-
#
|
|
13
|
+
# Secrets scan on staged changes. Build a cleaned patterns file (drop comment/
|
|
14
|
+
# blank lines) and match with `grep -Ef` so each line stays its own regex —
|
|
15
|
+
# more robust than inlining patterns into a single `-E` argument. `|| true`
|
|
16
|
+
# guards grep's exit-1-on-no-match from aborting the hook under husky's `set -e`.
|
|
16
17
|
if [ -f "$PATTERNS" ]; then
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
if [ -
|
|
21
|
-
SECRETS=$(git diff --cached -U0 | grep -
|
|
18
|
+
CLEAN_FILE=$(mktemp)
|
|
19
|
+
trap 'rm -f "$CLEAN_FILE"' EXIT
|
|
20
|
+
grep -vE '^[[:space:]]*#|^[[:space:]]*$' "$PATTERNS" > "$CLEAN_FILE" || true
|
|
21
|
+
if [ -s "$CLEAN_FILE" ]; then
|
|
22
|
+
SECRETS=$(git diff --cached -U0 | grep -Ef "$CLEAN_FILE" 2>/dev/null || true)
|
|
22
23
|
if [ -n "$SECRETS" ]; then
|
|
23
24
|
echo "❌ Possible secrets detected in staged changes:"
|
|
24
25
|
echo "$SECRETS"
|
package/package.json
CHANGED