Skip to content

Commit 06785cb

Browse files
Updates vulnerable dependencies in examples and adds "audit fix" script. (#8)
* Add audit fix script. * Update vulnerable dependencies with script. * Indentation.
1 parent 3521494 commit 06785cb

File tree

7 files changed

+1565
-1559
lines changed

7 files changed

+1565
-1559
lines changed

examples/laravel/package-lock.json

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

examples/nuxtjs/package-lock.json

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

examples/vite/package-lock.json

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

examples/vue/package-lock.json

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

examples/wasm-benchmark/package-lock.json

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

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@
2121
"prepare": "husky",
2222
"e2e-tests": "./scripts/e2e-tests.sh",
2323
"lint-staged": "lint-staged",
24-
"test": "playwright test"
24+
"test": "playwright test",
25+
"audit-fix": "./scripts/audit-dependencies.sh"
2526
},
2627
"lint-staged": {
2728
"*": ["biome check --write --no-errors-on-unmatched"]

scripts/audit-dependencies.sh

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
#!/bin/bash
2+
# Runs npm/pnpm audit fix on all examples and outputs the result
3+
4+
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
5+
6+
echo -e "\033[37;1mAuditing npm vulnerabilities in examples\033[0m\r"
7+
8+
for dir in examples/*; do
9+
if [ -d "$dir" ]; then
10+
11+
echo -e "\n\033[34;1m* $dir:\033[0m"
12+
13+
pushd "${SCRIPT_DIR}/../${dir}/" > /dev/null
14+
15+
result=0
16+
initialresult=0
17+
18+
if [ -f "pnpm-lock.yaml" ]; then
19+
# Check if the 'total' field exists and extract it if present
20+
initialresult=$(pnpm audit --json | jq -r '.metadata.vulnerabilities.total // 0')
21+
22+
pnpm audit fix > /dev/null
23+
24+
# Capture vulnerabilities metadata using pnpm
25+
result=$(pnpm audit --json | jq -r '.metadata.vulnerabilities.total // 0')
26+
elif [ -f "package-lock.json" ]; then
27+
# Capture vulnerabilities metadata using npm
28+
initialresult=$(npm audit --json | jq -r '.metadata.vulnerabilities.total // 0')
29+
30+
npm audit fix > /dev/null
31+
32+
# Capture vulnerabilities metadata using npm
33+
result=$(npm audit --json | jq -r '.metadata.vulnerabilities.total // 0')
34+
fi
35+
36+
# If vulnerabilities were found, output the result
37+
38+
if (( initialresult > 0 )); then
39+
((fixed = initialresult - result))
40+
echo -e " \033[93mFound: ${initialresult}\033[0m"
41+
echo -e " \033[92mFixed: $fixed\033[0m"
42+
43+
if (( result > 0 )); then
44+
echo -e " \033[31mRemaining: ${result}\033[0m"
45+
else
46+
echo -e " \033[92;1mAll fixed!\033[0m"
47+
fi
48+
else
49+
echo -e " \033[34mNo npm vulnerabilities found\033[0m"
50+
fi
51+
52+
popd > /dev/null
53+
fi
54+
done

0 commit comments

Comments
 (0)