Repository navigation
58 lines (55 loc) · 2 KB
/
Copy pathsocket-security.yml
File metadata and controls
58 lines (55 loc) · 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
name: Socket Security Analysis
on:
pull_request:
paths:
- 'package.json'
- 'package-lock.json'
- 'pnpm-lock.yaml'
- '**/package.json'
permissions:
contents: read
pull-requests: write
jobs:
socket-security:
runs-on: ubuntu-latest
steps:
- uses: step-security/harden-runner@5c7944e73c4c2a096b17a9cb74d65b6c2bbafbde # v2.9.1
with:
egress-policy: audit
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
with:
fetch-depth: 2
- name: Check Socket credentials
id: socket-auth
env:
SOCKET_SECURITY_API_KEY: ${{ secrets.SOCKET_SECURITY_API_KEY }}
run: |
if [ -z "${SOCKET_SECURITY_API_KEY:-}" ]; then
echo "enabled=false" >> "$GITHUB_OUTPUT"
echo "::warning title=Socket scan skipped::SOCKET_SECURITY_API_KEY is not configured; skipping Socket dependency scan."
{
echo "### Socket scan skipped"
echo ""
echo "Set the repository or organization secret \`SOCKET_SECURITY_API_KEY\` to enable Socket dependency scanning."
} >> "$GITHUB_STEP_SUMMARY"
exit 0
fi
echo "enabled=true" >> "$GITHUB_OUTPUT"
- uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5
if: steps.socket-auth.outputs.enabled == 'true'
with:
python-version: '3.12'
- name: Install Socket CLI
if: steps.socket-auth.outputs.enabled == 'true'
run: pip install socketsecurity --upgrade
- name: Run Socket Security Scan
if: steps.socket-auth.outputs.enabled == 'true'
env:
SOCKET_SECURITY_API_KEY: ${{ secrets.SOCKET_SECURITY_API_KEY }}
GH_API_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PR_NUMBER: ${{ github.event.pull_request.number }}
run: |
socketcli \
--target-path "$GITHUB_WORKSPACE" \
--scm github \
--pr-number "$PR_NUMBER"