|
Bogdan Timofte
authored
3 months ago
|
1
|
#!/usr/bin/env bash
|
|
|
2
|
# Quick verifier to ensure this repository contains only AutoNAS artifacts
|
|
|
3
|
# Scans for common autoSMART markers and suspicious files.
|
|
|
4
|
|
|
|
5
|
set -euo pipefail
|
|
|
6
|
|
|
|
7
|
ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
|
|
8
|
cd "$ROOT_DIR"
|
|
|
9
|
|
|
|
10
|
echo "[verify-project] Repository: $ROOT_DIR"
|
|
|
11
|
|
|
|
12
|
patterns=(
|
|
|
13
|
'autoSMART'
|
|
|
14
|
'autosmart'
|
|
|
15
|
'smart-collector'
|
|
|
16
|
'SmartCollector'
|
|
|
17
|
'smartctl .*postgres' # autosmart DB pipelines pattern
|
|
|
18
|
)
|
|
|
19
|
|
|
|
20
|
exclude_dirs=(
|
|
|
21
|
'.git'
|
|
|
22
|
'.venv'
|
|
|
23
|
'node_modules'
|
|
|
24
|
'dist'
|
|
|
25
|
'build'
|
|
|
26
|
)
|
|
|
27
|
|
|
|
28
|
found=0
|
|
|
29
|
|
|
|
30
|
# Build a find command that prunes excluded directories
|
|
|
31
|
find_cmd=(find .)
|
|
|
32
|
for d in "${exclude_dirs[@]}"; do
|
|
|
33
|
find_cmd+=( -path "*/$d/*" -prune -o )
|
|
|
34
|
done
|
|
|
35
|
find_cmd+=( -type f ! -path "*/scripts/verify-project.sh" -print0 )
|
|
|
36
|
|
|
|
37
|
for pat in "${patterns[@]}"; do
|
|
|
38
|
if "${find_cmd[@]}" | xargs -0 grep -EIn --color=never "$pat" > /tmp/_verify_hits 2>/dev/null; then
|
|
|
39
|
if [ -s /tmp/_verify_hits ]; then
|
|
|
40
|
echo "[verify-project] Suspicious matches for pattern: $pat"
|
|
|
41
|
cat /tmp/_verify_hits
|
|
|
42
|
echo ""
|
|
|
43
|
found=1
|
|
|
44
|
fi
|
|
|
45
|
fi
|
|
|
46
|
done
|
|
|
47
|
|
|
|
48
|
rm -f /tmp/_verify_hits || true
|
|
|
49
|
|
|
|
50
|
# Also check for suspicious filenames accidentally copied over
|
|
|
51
|
suspect_files=(
|
|
|
52
|
'smart-collector-daemon.pl'
|
|
|
53
|
'deploy-production.sh'
|
|
|
54
|
'monitor-cluster.sh'
|
|
|
55
|
)
|
|
|
56
|
|
|
|
57
|
for name in "${suspect_files[@]}"; do
|
|
|
58
|
if find . -type f -name "$name" | grep -q .; then
|
|
|
59
|
echo "[verify-project] Suspicious file present: $name"
|
|
|
60
|
found=1
|
|
|
61
|
fi
|
|
|
62
|
done
|
|
|
63
|
|
|
|
64
|
if [ "$found" -eq 0 ]; then
|
|
|
65
|
echo "[verify-project] OK: No autoSMART contamination detected."
|
|
|
66
|
exit 0
|
|
|
67
|
else
|
|
|
68
|
echo "[verify-project] WARNING: Potential contamination detected. Review above matches."
|
|
|
69
|
exit 2
|
|
|
70
|
fi
|