-
Notifications
You must be signed in to change notification settings - Fork 0
107 lines (89 loc) · 3.22 KB
/
Copy pathsecurity.yml
File metadata and controls
107 lines (89 loc) · 3.22 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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
name: Security & Quality
on:
push:
branches: [master]
pull_request:
branches: [master]
env:
FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: true
# Auth for transitive @callmetechie/gatecontrol-config-hash via GitHub Packages (.npmrc).
NODE_AUTH_TOKEN: ${{ secrets.GC_PAT }}
permissions:
contents: read
security-events: write
jobs:
codeql:
name: CodeQL Analysis
runs-on: ubuntu-latest
if: github.actor != 'dependabot[bot]'
steps:
- uses: actions/checkout@v6
- name: Initialize CodeQL
uses: github/codeql-action/init@v4
with:
languages: javascript-typescript
queries: security-extended
- name: Autobuild
uses: github/codeql-action/autobuild@v4
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v4
audit:
name: Dependency Audit
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- uses: actions/setup-node@v6
with:
node-version: 22
- name: Clone core dependency
run: |
git clone https://github.com/CallMeTechie/gatecontrol-client-core.git .core
node -e "const p=require('./package.json'); p.dependencies['@gatecontrol/client-core']='file:.core'; require('fs').writeFileSync('package.json',JSON.stringify(p,null,2)+'\n')"
- name: Install dependencies
run: npm install --no-audit --no-fund
- name: Run npm audit
run: npm audit --audit-level=high || true
- name: Check for critical vulnerabilities
run: |
RESULT=$(npm audit --json 2>/dev/null | node -e "
const data=require('fs').readFileSync('/dev/stdin','utf8');
try {
const audit=JSON.parse(data);
const critical=(audit.metadata?.vulnerabilities?.critical||0);
console.log(critical);
} catch { console.log('0'); }
")
echo "High/Critical vulnerabilities: $RESULT"
if [ "$RESULT" -gt 0 ] 2>/dev/null; then
echo "::error::Found $RESULT high/critical vulnerabilities"
exit 1
fi
eslint-security:
name: ESLint Security
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- uses: actions/setup-node@v6
with:
node-version: 22
- name: Install ESLint with security plugin
run: npm install --no-save eslint@8 eslint-plugin-security@1.7.1
- name: Create security ESLint config
run: |
cat > .eslintrc.security.json << 'ESLINTEOF'
{
"plugins": ["security"],
"extends": ["plugin:security/recommended"],
"env": { "node": true, "es2022": true },
"parserOptions": { "ecmaVersion": 2022 },
"rules": {
"security/detect-eval-with-expression": "error",
"security/detect-non-literal-fs-filename": "warn",
"security/detect-non-literal-require": "warn",
"security/detect-possible-timing-attacks": "warn",
"security/detect-child-process": "warn"
}
}
ESLINTEOF
- name: Run ESLint security scan
run: npx eslint -c .eslintrc.security.json "src/**/*.js" --no-eslintrc --format stylish || true