Skip to content

Commit 71782c3

Browse files
authored
chore(deps): update lando (#2388)
* Add CI Github Action to verify that Github hashes used as dependencies in package.json are of full 40-char length * Use 40-char hash to reference Github dependency * Fix formatting
1 parent fc1d6e7 commit 71782c3

3 files changed

Lines changed: 120 additions & 3 deletions

File tree

Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
name: Git Hash Security Check
2+
3+
on:
4+
pull_request:
5+
push:
6+
branches:
7+
- develop
8+
- trunk
9+
workflow_dispatch:
10+
11+
permissions:
12+
contents: read
13+
14+
jobs:
15+
check-git-hash-security:
16+
name: Verify Full Git Commit Hashes
17+
runs-on: ubuntu-latest
18+
steps:
19+
- name: Check out the source code
20+
uses: actions/checkout@v4
21+
22+
- name: Check for short git hashes in package.json
23+
run: |
24+
echo "🔍 Checking package.json for short git commit hashes..."
25+
26+
# Find all github: dependencies
27+
if grep -q "github:" package.json; then
28+
echo "Found git dependencies in package.json:"
29+
30+
# Check each github dependency line
31+
grep "github:" package.json | while IFS= read -r line; do
32+
echo "Checking: $line"
33+
34+
# Extract the hash part after #
35+
if [[ $line =~ github:[^#]*#([0-9a-f]+) ]]; then
36+
hash="${BASH_REMATCH[1]}"
37+
hash_length=${#hash}
38+
dep_name=$(echo "$line" | sed 's/.*"\([^"]*\)".*/\1/')
39+
40+
echo " Found hash: $hash (length: $hash_length)"
41+
42+
if [ $hash_length -lt 40 ]; then
43+
echo "❌ SECURITY VULNERABILITY: Short git hash detected!"
44+
echo " Dependency: $dep_name"
45+
echo " Hash '$hash' is only $hash_length characters"
46+
echo " REQUIRED: Use full 40-character commit hash"
47+
echo ""
48+
echo "🛡️ SECURITY REQUIREMENT:"
49+
echo " All git dependencies must use full 40-character commit hashes"
50+
echo " Short hashes are vulnerable to collision attacks"
51+
echo ""
52+
echo "📖 Why this matters:"
53+
echo " • 7-character hashes have only 268M possibilities"
54+
echo " • Attackers can create colliding commits in forks"
55+
echo " • This breaks builds and enables supply chain attacks"
56+
echo " • Only full 40-character hashes provide security"
57+
exit 1
58+
elif [ $hash_length -eq 40 ]; then
59+
echo "✅ $dep_name: Secure 40-character hash"
60+
else
61+
echo "⚠️ $dep_name: Hash longer than 40 characters: $hash_length"
62+
fi
63+
elif [[ $line =~ github:[^#]*#([^\",:]+) ]]; then
64+
# Non-hex hash (might be tag/branch)
65+
ref="${BASH_REMATCH[1]}"
66+
echo " Found non-hex reference: $ref (likely tag/branch - OK)"
67+
else
68+
echo " No hash found in line (may resolve to latest)"
69+
fi
70+
done
71+
else
72+
echo "No github: dependencies found in package.json"
73+
fi
74+
75+
echo "✅ package.json validation complete"
76+
77+
- name: Check for short git hashes in npm-shrinkwrap.json
78+
run: |
79+
echo "🔍 Checking npm-shrinkwrap.json for short git commit hashes..."
80+
81+
if [ -f "npm-shrinkwrap.json" ]; then
82+
# Look for git+ssh URLs with hashes
83+
if grep -q "git+ssh:" npm-shrinkwrap.json; then
84+
echo "Found git+ssh dependencies, checking hash lengths..."
85+
86+
# Extract git+ssh lines and check hashes
87+
grep "git+ssh:" npm-shrinkwrap.json | while IFS= read -r line; do
88+
if [[ $line =~ git\+ssh://[^#]*#([0-9a-f]+) ]]; then
89+
hash="${BASH_REMATCH[1]}"
90+
hash_length=${#hash}
91+
92+
if [ $hash_length -lt 40 ]; then
93+
echo "❌ SECURITY VULNERABILITY: Short git hash in npm-shrinkwrap.json!"
94+
echo " Hash '$hash' is only $hash_length characters"
95+
echo ""
96+
echo "🔧 To fix this:"
97+
echo " 1. Update package.json to use full 40-character hashes"
98+
echo " 2. Delete npm-shrinkwrap.json"
99+
echo " 3. Run 'npm install' to regenerate with full hashes"
100+
exit 1
101+
fi
102+
fi
103+
done
104+
fi
105+
106+
echo "✅ npm-shrinkwrap.json: No short git hashes found"
107+
else
108+
echo "ℹ️ npm-shrinkwrap.json not found, skipping check"
109+
fi
110+
111+
- name: Security check summary
112+
run: |
113+
echo ""
114+
echo "🎉 Git Hash Security Check Complete!"
115+
echo "✅ All git dependencies use secure 40-character commit hashes"
116+
echo "✅ No collision-vulnerable short hashes detected"
117+
echo "🛡️ Supply chain security requirements satisfied"

npm-shrinkwrap.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@
161161
"ini": "5.0.0",
162162
"js-yaml": "^4.1.0",
163163
"jwt-decode": "4.0.0",
164-
"lando": "github:automattic/lando-cli#1d3e8c0",
164+
"lando": "github:automattic/lando-cli#1d3e8c01f5f7e7f5b51b29aba145f3bddd2ca32e",
165165
"node-fetch": "^2.6.1",
166166
"node-stream-zip": "1.15.0",
167167
"open": "^10.0.0",

0 commit comments

Comments
 (0)