Skip to content

Commit 32268b4

Browse files
chore: add script to check git history if package-version has ever been used
use script to verify vulnerable npm packages are not part of any of our releases
1 parent 4428c0d commit 32268b4

File tree

2 files changed

+508
-0
lines changed

2 files changed

+508
-0
lines changed
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#!/bin/bash
2+
# This script checks the git history for changes to yarn.lock that include
3+
# any of the packages listed in "effected-packages.txt"
4+
5+
# example format "effected-packages.txt":
6+
7+
8+
9+
10+
11+
12+
13+
# Usage from the root of your monorepo, run:
14+
# ./scripts/manual-vulnerability-check/check-git-history.sh
15+
packages=()
16+
while IFS= read -r line; do
17+
packages+=("$line")
18+
done < ./scripts/manual-vulnerability-check/effected-packages.txt
19+
i=0
20+
for package in "${packages[@]}"; do
21+
# modify package string from
22+
# @scope/package@version to @scope/package@npm:version
23+
# package@version to package@npm:version
24+
package=$(echo "$package" | sed -E 's/@([0-9]+\.[0-9]+\.[0-9]+)/@npm:\1/')
25+
# show progress
26+
echo "Line $((i+1)): $package"
27+
# search through git log for changes to yarn.lock
28+
# that include "package@npm:version"
29+
git log -p --all -- yarn.lock | grep -A 2 -B 2 -E "$package"
30+
((i++))
31+
done

0 commit comments

Comments
 (0)