-
Notifications
You must be signed in to change notification settings - Fork 0
77 lines (65 loc) · 2.2 KB
/
Copy pathvalidate.yml
File metadata and controls
77 lines (65 loc) · 2.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
name: Validate
on:
push:
pull_request:
permissions:
contents: read
jobs:
syntax:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-node@v4
with:
node-version: "20"
- name: Check JavaScript syntax
shell: bash
run: |
set -euo pipefail
while IFS= read -r -d '' file; do
node --check "$file"
done < <(find cloudfunctions miniprogram -type f -name '*.js' -print0)
- name: Validate JSON
shell: bash
run: |
node <<'NODE'
const fs = require("fs");
const path = require("path");
function walk(directory) {
for (const entry of fs.readdirSync(directory, { withFileTypes: true })) {
if ([".git", "node_modules", "miniprogram_npm"].includes(entry.name)) continue;
const target = path.join(directory, entry.name);
if (entry.isDirectory()) walk(target);
if (entry.isFile() && entry.name.endsWith(".json")) {
JSON.parse(fs.readFileSync(target, "utf8"));
}
}
}
walk(".");
NODE
- name: Check tracked sensitive configuration
shell: bash
run: |
set -euo pipefail
forbidden='^(project\.config\.json|project\.private\.config\.json|miniprogram/config\.js|cloudfunctions/(sendNoticeMessage|saveNoticeSubscriber)/config\.js)$'
if git ls-files | grep -E "$forbidden"; then
echo "Tracked sensitive configuration found."
exit 1
fi
- name: Scan Git history for high-confidence secrets
shell: bash
run: |
set -euo pipefail
patterns='wx[0-9a-fA-F]{16}|cloud://[A-Za-z0-9]|cloud[0-9]+-[a-z0-9-]{8,}|-----BEGIN ([A-Z ]+)?PRIVATE KEY-----'
found=0
while IFS= read -r commit; do
if git grep -I -n -E "$patterns" "$commit" --; then
found=1
fi
done < <(git rev-list --all)
if [ "$found" -ne 0 ]; then
echo "Potential secret found in Git history."
exit 1
fi