Repository navigation
169 lines (165 loc) · 7.49 KB
/
Copy pathapi-server-security.yml
File metadata and controls
169 lines (165 loc) · 7.49 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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
name: API server security
on:
pull_request:
paths:
- 'packages/api-server/**'
- 'packages/types/**'
- 'packages/sql-policy/**'
- 'apps/web/lib/explorer/**'
- 'apps/web/jest.security.config.cjs'
- 'apps/web/package.json'
- 'etl/**'
- '.dockerignore'
- 'ops/container-security/**'
- 'packages/pipeline/**'
- 'packages/prefetch/**'
- 'apps/web/lib/server/**'
- 'apps/web/app/**'
- 'apps/docs/lib/**'
- 'apps/docs/components/**'
- 'apps/docs/app/**'
- 'apps/docs/proxy.ts'
- 'apps/docs/next.config.mjs'
- 'apps/docs/scripts/**'
- 'apps/docs/package.json'
- 'apps/docs/content/blog/**'
- 'apps/docs/legacy-content/docs/**'
- 'configs/pipelines/**'
- 'apps/web/lib/request-policy.ts'
- 'apps/web/lib/cors.ts'
- 'apps/web/lib/content-security.ts'
- 'apps/web/next.config.mjs'
- 'apps/web/vercel.json'
- 'apps/web/proxy.ts'
- 'packages/site-shell/src/safe-json.ts'
- 'packages/sync-github-data/**'
- 'scripts/load-collection.mjs'
- 'scripts/lib/**'
- 'pnpm-lock.yaml'
- '.github/workflows/api-server-security.yml'
- '.github/workflows/sync-collection-configs.yml'
- '.github/workflows/verify-collection-configs.yml'
- '.github/workflows/daily-star-snapshots.yml'
- 'ops/collection-sync/**'
push:
branches: [main]
paths:
- 'packages/api-server/**'
- 'packages/types/**'
- 'packages/sql-policy/**'
- 'apps/web/lib/explorer/**'
- 'apps/web/jest.security.config.cjs'
- 'apps/web/package.json'
- 'etl/**'
- '.dockerignore'
- 'ops/container-security/**'
- 'packages/pipeline/**'
- 'packages/prefetch/**'
- 'apps/web/lib/server/**'
- 'apps/web/app/**'
- 'apps/docs/lib/**'
- 'apps/docs/components/**'
- 'apps/docs/app/**'
- 'apps/docs/proxy.ts'
- 'apps/docs/next.config.mjs'
- 'apps/docs/scripts/**'
- 'apps/docs/package.json'
- 'apps/docs/content/blog/**'
- 'apps/docs/legacy-content/docs/**'
- 'configs/pipelines/**'
- 'apps/web/lib/request-policy.ts'
- 'apps/web/lib/cors.ts'
- 'apps/web/lib/content-security.ts'
- 'apps/web/next.config.mjs'
- 'apps/web/vercel.json'
- 'apps/web/proxy.ts'
- 'packages/site-shell/src/safe-json.ts'
- 'packages/sync-github-data/**'
- 'scripts/load-collection.mjs'
- 'scripts/lib/**'
- 'pnpm-lock.yaml'
- '.github/workflows/api-server-security.yml'
- '.github/workflows/sync-collection-configs.yml'
- '.github/workflows/verify-collection-configs.yml'
- '.github/workflows/daily-star-snapshots.yml'
- 'ops/collection-sync/**'
permissions:
contents: read
jobs:
verify:
runs-on: ubuntu-latest
timeout-minutes: 20
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
persist-credentials: false
- uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
with:
node-version: '24'
- run: npm install --global pnpm@10.29.3
- run: pnpm install --filter @ossinsight/api-server... --filter @ossinsight/pipeline... --filter @ossinsight/prefetch... --filter @ossinsight/sync-github-data... --filter web... --filter docs... --frozen-lockfile --ignore-scripts --network-concurrency 12 --child-concurrency 12
- name: Build native SQLite for the runner
run: pnpm --filter @ossinsight/api-server rebuild sqlite3
env:
npm_config_build_from_source: 'true'
- name: Audit production dependencies
run: pnpm audit --prod --audit-level=high
- run: pnpm --filter @ossinsight/api-server... --filter @ossinsight/pipeline... --filter @ossinsight/prefetch... --filter @ossinsight/sync-github-data... --workspace-concurrency 12 -r build
- run: pnpm --filter @ossinsight/sync-github-data test:security
- run: pnpm --filter @ossinsight/api-server test:security
- run: pnpm --filter web test:security
- run: pnpm --filter docs test:security
- run: pnpm --filter @ossinsight/api-server test:runtime
- run: node --test scripts/lib/collection-store.test.mjs
- name: Verify isolated collection sync dependencies
run: |
npm ci --prefix ops/collection-sync --ignore-scripts --no-fund
npm audit --prefix ops/collection-sync --omit=dev --audit-level=high
cd ops/collection-sync
node -e "if (typeof require('@tidbcloud/serverless').connect !== 'function') process.exit(1)"
- name: Verify TiDB execution and database grants
env:
NODE_OPTIONS: --experimental-vm-modules
working-directory: packages/api-server
run: pnpm exec jest --maxWorkers=12 --runTestsByPath __tests__/core/executor/query-executor/TiDBPlaygroundQueryExecutor.ts __tests__/worker/queue-worker.ts __tests__/core/email-rekey.ts __tests__/core/app-startup.ts __tests__/core/public-abuse.ts __tests__/core/account-registration.ts
containers:
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
persist-credentials: false
- name: Install native Ruby build prerequisites
run: sudo apt-get update && sudo apt-get install -y --no-install-recommends default-libmysqlclient-dev pkg-config
- uses: ruby/setup-ruby@de492cf36cbab201753d720ce4f4e336cd688c94 # v1
with:
ruby-version: '3.4.12'
bundler: '4.0.23'
bundler-cache: true
working-directory: etl
- name: Audit locked Ruby dependencies
working-directory: etl
run: |
gem install bundler-audit -v 0.9.3 --no-document
bundler-audit check --update
- name: Verify Ruby security behavior and transport defaults
working-directory: etl
run: |
bundle exec ruby -e 'ARGV.each { |file| require_relative file }' ./test/sample_importer_test.rb ./test/seeds_test.rb ./test/archive_transport_test.rb ./test/worker_heartbeat_test.rb
ruby -rerb -ryaml -rjson -ropenssl -e 'config = YAML.safe_load(ERB.new(File.read("config/database.yml")).result, permitted_classes: [Symbol], aliases: true); abort "TLS not enforced" unless config["production"]["ssl_mode"] == :verify_identity'
- name: Build production images
run: |
docker build -f packages/api-server/Dockerfile -t ossinsight-api-security:test .
docker build -f etl/Dockerfile -t ossinsight-etl-security:test etl
- name: Verify read-only containers, native SQLite, verified TLS and real TiDB ingestion
run: python3 ops/container-security/check.py
- name: Scan runtime images for fixable high and critical vulnerabilities
env:
TRIVY_CACHE_DIR: ${{ runner.temp }}/trivy-cache
run: |
curl --fail --location --retry 3 https://github.com/aquasecurity/trivy/releases/download/v0.76.1/trivy_0.76.1_Linux-64bit.tar.gz --output "$RUNNER_TEMP/trivy.tar.gz"
echo "c7cbe3137fb8a48a17574bede3dd6beb16742d1e9772929940fc90082c39d9c0 $RUNNER_TEMP/trivy.tar.gz" | sha256sum --check --status
tar -xzf "$RUNNER_TEMP/trivy.tar.gz" -C "$RUNNER_TEMP" trivy
for image in ossinsight-api-security:test ossinsight-etl-security:test; do
"$RUNNER_TEMP/trivy" image --scanners vuln --severity HIGH,CRITICAL --ignore-unfixed --exit-code 1 --timeout 5m "$image"
done