-
Notifications
You must be signed in to change notification settings - Fork 26
316 lines (278 loc) · 13.3 KB
/
devguard-scanner.yaml
File metadata and controls
316 lines (278 loc) · 13.3 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
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
# DevSecOps Workflow Definition
# This workflow is triggered on every push to the repository
name: DevGuard-Workflow
on:
workflow_dispatch:
push:
jobs:
golangci:
name: lint
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5 - https://github.com/actions/checkout/releases/tag/v5.0.0
with:
submodules: recursive
persist-credentials: false
- uses: cachix/install-nix-action@v31
with:
install_url: https://releases.nixos.org/nix/nix-2.34.4/install
extra_nix_config: |
experimental-features = nix-command flakes
substituters = https://cache.nixos.org https://nix.garage.l3montree.cloud
trusted-public-keys = cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY= nix.garage.l3montree.cloud:MGlzfPQKA91/zxw91CN+GP7NpjAAwmKvWXlDYgeeI8k=
- name: golangci-lint
run: nix develop . --command golangci-lint run --timeout=30m
tests:
name: tests
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- name: Check out code
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5 - https://github.com/actions/checkout/releases/tag/v5.0.0
with:
submodules: recursive
persist-credentials: false
- uses: cachix/install-nix-action@v31
with:
install_url: https://releases.nixos.org/nix/nix-2.34.4/install
extra_nix_config: |
experimental-features = nix-command flakes
substituters = https://cache.nixos.org https://nix.garage.l3montree.cloud
trusted-public-keys = cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY= nix.garage.l3montree.cloud:MGlzfPQKA91/zxw91CN+GP7NpjAAwmKvWXlDYgeeI8k=
- name: Run unittests
run: nix develop . --command bash -c "go test \$(go list ./... | grep -v '/mocks') -coverprofile=coverage.out && go tool cover -func=coverage.out"
- name: Archive code coverage results
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2 - https://github.com/actions/upload-artifact/releases/tag/v4.6.2
with:
name: code-coverage
path: coverage.out
code-scanning:
uses: l3montree-dev/devguard-action/.github/workflows/code-scanning.yml@nix
permissions:
contents: read
security-events: write
with:
asset-name: l3montree-cybersecurity/projects/devguard/assets/devguard
api-url: https://api.main.devguard.org
fail-on-risk: high
fail-on-cvss: high
web-ui: https://main.devguard.org
continue-on-open-code-risk: true
secrets:
devguard-token: ${{ secrets.DEVGUARD_TOKEN }}
api-pipeline:
if: github.event_name == 'workflow_dispatch' || startsWith(github.ref, 'refs/tags/') || github.ref == 'refs/heads/main'
uses: l3montree-dev/devguard-action/.github/workflows/full-nix.yml@nix
permissions:
contents: read
packages: write
security-events: write
with:
nix-target-amd64: devguard-amd64
nix-target-arm64: devguard-arm64
nix-version: '2.34.4'
image-name: ghcr.io/${{ github.repository }}
asset-name: l3montree-cybersecurity/projects/devguard/assets/devguard
api-url: https://api.main.devguard.org
web-ui: https://main.devguard.org
fail-on-cvss: high
fail-on-risk: high
nix-cache-substituter: https://nix.garage.l3montree.cloud
nix-cache-public-key: nix.garage.l3montree.cloud:MGlzfPQKA91/zxw91CN+GP7NpjAAwmKvWXlDYgeeI8k=
nix-cache-s3-bucket: nix
nix-cache-region: garage
secrets:
devguard-token: ${{ secrets.DEVGUARD_TOKEN }}
scanner-pipeline:
if: github.event_name == 'workflow_dispatch' || startsWith(github.ref, 'refs/tags/') || github.ref == 'refs/heads/main'
needs: [tests]
uses: l3montree-dev/devguard-action/.github/workflows/full-nix.yml@nix
permissions:
contents: read
packages: write
security-events: write
with:
nix-target-amd64: devguard-scanner-amd64
nix-target-arm64: devguard-scanner-arm64
nix-version: '2.34.4'
image-name: ghcr.io/${{ github.repository }}/scanner
artifact-name-suffix: scanner
asset-name: l3montree-cybersecurity/projects/devguard/assets/devguard
api-url: https://api.main.devguard.org
web-ui: https://main.devguard.org
fail-on-cvss: high
fail-on-risk: high
nix-cache-substituter: https://nix.garage.l3montree.cloud
nix-cache-public-key: nix.garage.l3montree.cloud:MGlzfPQKA91/zxw91CN+GP7NpjAAwmKvWXlDYgeeI8k=
nix-cache-s3-bucket: nix
nix-cache-region: garage
secrets:
devguard-token: ${{ secrets.DEVGUARD_TOKEN }}
postgresql-pipeline:
if: github.event_name == 'workflow_dispatch' || startsWith(github.ref, 'refs/tags/') || github.ref == 'refs/heads/main'
uses: l3montree-dev/devguard-action/.github/workflows/full-nix.yml@nix
permissions:
contents: read
packages: write
security-events: write
with:
nix-target-amd64: postgresql-amd64
nix-target-arm64: postgresql-arm64
nix-version: '2.34.4'
image-name: ghcr.io/${{ github.repository }}/postgresql
artifact-name-suffix: postgresql
asset-name: l3montree-cybersecurity/projects/devguard/assets/devguard-postgresql
api-url: https://api.main.devguard.org
web-ui: https://main.devguard.org
fail-on-cvss: high
fail-on-risk: high
nix-cache-substituter: https://nix.garage.l3montree.cloud
nix-cache-public-key: nix.garage.l3montree.cloud:MGlzfPQKA91/zxw91CN+GP7NpjAAwmKvWXlDYgeeI8k=
nix-cache-s3-bucket: nix
nix-cache-region: garage
secrets:
devguard-token: ${{ secrets.DEVGUARD_TOKEN }}
release:
name: Build and Release Binaries
runs-on: ubuntu-latest
permissions:
contents: write
# needs: [golangci, tests, sign-scanner, devguard]
if: startsWith(github.ref, 'refs/tags/') || github.ref == 'refs/heads/test-release'
outputs:
tag: ${{ steps.tag.outputs.tag }}
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
persist-credentials: false
- uses: cachix/install-nix-action@v31
with:
install_url: https://releases.nixos.org/nix/nix-2.34.4/install
extra_nix_config: |
experimental-features = nix-command flakes
substituters = https://cache.nixos.org https://nix.garage.l3montree.cloud
trusted-public-keys = cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY= nix.garage.l3montree.cloud:MGlzfPQKA91/zxw91CN+GP7NpjAAwmKvWXlDYgeeI8k=
- name: Get tag
id: tag
run: |
if [[ "${GITHUB_REF}" == refs/tags/* ]]; then
echo "tag=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT
echo "TAG_NO_V=${GITHUB_REF_NAME#v}" >> $GITHUB_ENV
else
echo "tag=test-$(date +%Y%m%d-%H%M%S)" >> $GITHUB_OUTPUT
fi
- name: Build cross-platform binaries
run: |
nix develop . --command bash -c "
mkdir -p dist
BUILD_FLAGS=\"-s -w -buildid= -X main.version=${STEPS_TAG_OUTPUTS_TAG} -X main.commit=${{ github.sha }} -X main.date=\$(date -u +%Y-%m-%dT%H:%M:%SZ) -X main.builtBy=github-actions\"
GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build -ldflags=\"\$BUILD_FLAGS\" -o dist/devguard-scanner-linux-amd64 ./cmd/devguard-scanner
GOOS=linux GOARCH=arm64 CGO_ENABLED=0 go build -ldflags=\"\$BUILD_FLAGS\" -o dist/devguard-scanner-linux-arm64 ./cmd/devguard-scanner
GOOS=windows GOARCH=amd64 CGO_ENABLED=0 go build -ldflags=\"\$BUILD_FLAGS\" -o dist/devguard-scanner-windows-amd64.exe ./cmd/devguard-scanner
GOOS=windows GOARCH=arm64 CGO_ENABLED=0 go build -ldflags=\"\$BUILD_FLAGS\" -o dist/devguard-scanner-windows-arm64.exe ./cmd/devguard-scanner
GOOS=darwin GOARCH=amd64 CGO_ENABLED=0 go build -ldflags=\"\$BUILD_FLAGS\" -o dist/devguard-scanner-darwin-amd64 ./cmd/devguard-scanner
GOOS=darwin GOARCH=arm64 CGO_ENABLED=0 go build -ldflags=\"\$BUILD_FLAGS\" -o dist/devguard-scanner-darwin-arm64 ./cmd/devguard-scanner
"
env:
STEPS_TAG_OUTPUTS_TAG: ${{ steps.tag.outputs.tag }}
- name: Create archives
run: |
cd dist
# Create tar.gz archives for Unix-like systems
tar -czf devguard-scanner-linux-amd64.tar.gz devguard-scanner-linux-amd64
tar -czf devguard-scanner-linux-arm64.tar.gz devguard-scanner-linux-arm64
tar -czf devguard-scanner-darwin-amd64.tar.gz devguard-scanner-darwin-amd64
tar -czf devguard-scanner-darwin-arm64.tar.gz devguard-scanner-darwin-arm64
# Create zip archives for Windows
zip devguard-scanner-windows-amd64.zip devguard-scanner-windows-amd64.exe
zip devguard-scanner-windows-arm64.zip devguard-scanner-windows-arm64.exe
# Remove individual binaries, keep archives
rm -f devguard-scanner-linux-amd64 devguard-scanner-linux-arm64 devguard-scanner-darwin-amd64 devguard-scanner-darwin-arm64
rm -f devguard-scanner-windows-amd64.exe devguard-scanner-windows-arm64.exe
- name: Generate checksums
run: |
cd dist
sha256sum *.tar.gz *.zip > checksums.txt
echo "Generated checksums for all release artifacts"
- name: Sign release artifacts with devguard-scanner
uses: docker://ghcr.io/l3montree-dev/devguard/scanner:main
with:
entrypoint: /bin/sh
args: |
-c "
cd dist
for file in *.tar.gz *.zip checksums.txt; do
if [ -f \"\$file\" ]; then
echo \"Signing \$file with devguard-scanner...\"
devguard-scanner sign --token ${{ secrets.DEVGUARD_TOKEN }} \"\$file\" > ${file}.sig
fi
done
"
- name: Create GitHub Release
uses: softprops/action-gh-release@de2c0eb89ae2a093876385947365aca7b0e5f844 # v1
with:
tag_name: ${{ steps.tag.outputs.tag }}
name: "DevGuard Scanner ${{ steps.tag.outputs.tag }}"
draft: false
prerelease: ${{ contains(steps.tag.outputs.tag, 'test-') }}
body: |
## 🚀 DevGuard Release ${{ steps.tag.outputs.tag }}
**Secure software supply chain scanning and security analysis toolkit**
### Release Assets
#### **📱 Binaries**
- `devguard-scanner-linux-amd64.tar.gz` - Linux x64 binary
- `devguard-scanner-linux-arm64.tar.gz` - Linux ARM64 binary
- `devguard-scanner-darwin-amd64.tar.gz` - macOS x64 binary
- `devguard-scanner-darwin-arm64.tar.gz` - macOS ARM64 (Apple Silicon) binary
- `devguard-scanner-windows-amd64.zip` - Windows x64 binary
- `devguard-scanner-windows-arm64.zip` - Windows ARM64 binary
#### **🐳 Container Images**
- **Registry**:
- `ghcr.io/l3montree-dev/devguard:${{ steps.tag.outputs.tag }}` (Main platform)
- `ghcr.io/l3montree-dev/devguard-web:${{ steps.tag.outputs.tag }}` (Frontend of the platform)
- `ghcr.io/l3montree-dev/devguard/scanner:${{ steps.tag.outputs.tag }}` (Scanner tool)
#### Helm Charts
`oci://ghcr.io/l3montree-dev/devguard-helm-chart/devguard` (Main platform Helm chart)
```bash
helm install my-devguard oci://ghcr.io/l3montree-dev/devguard-helm-chart/devguard --version ${{ env.TAG_NO_V }}
```
### Quick Start
#### **Download and Install**
```bash
# Linux/macOS - Download and extract
curl -L https://github.com/l3montree-dev/devguard/releases/download/${{ steps.tag.outputs.tag }}/devguard-scanner-linux-amd64.tar.gz | tar -xz
chmod +x devguard-scanner-linux-amd64
sudo mv devguard-scanner-linux-amd64 /usr/local/bin/devguard-scanner
# Verify installation
devguard-scanner --version
```
#### **Docker Usage**
```bash
# Pull DevGuard Scanner from registry
docker pull ghcr.io/l3montree-dev/devguard/scanner:${{ steps.tag.outputs.tag }}
# Pull DevGuard Platform from registry
docker pull ghcr.io/l3montree-dev/devguard:${{ steps.tag.outputs.tag }}
```
#### **Go Install**
```bash
go install github.com/l3montree-dev/devguard/cmd/devguard-scanner@${{ steps.tag.outputs.tag }}
```
---
📖 **Documentation**: [DevGuard Documentation](https://github.com/l3montree-dev/devguard)
🐛 **Report Issues**: [GitHub Issues](https://github.com/l3montree-dev/devguard/issues)
💬 **Community**: [Discussions](https://github.com/l3montree-dev/devguard/discussions)
files: |
dist/*.tar.gz
dist/*.zip
dist/checksums.txt
dist/*.sig
dist/*.link
dist/*.provenance.json
dist/*.sbom.json
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}