Skip to content

Commit 3b84ac1

Browse files
committed
ci: run virus scan during build process
1 parent 68a2a76 commit 3b84ac1

File tree

3 files changed

+33
-14
lines changed

3 files changed

+33
-14
lines changed

.github/workflows/build.yml

Lines changed: 27 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,17 +14,38 @@ jobs:
1414
runs-on: ubuntu-latest
1515
steps:
1616
- uses: actions/checkout@v4
17+
with:
18+
fetch-depth: 0
19+
fetch-tags: true
1720

1821
- name: Set up Go
1922
uses: actions/setup-go@v4
2023
with:
2124
go-version: '1.23'
2225

23-
- name: Install keepassxc-cli
24-
run: sudo apt-get update && sudo apt-get install -y keepassxc
25-
26-
- name: Build
27-
run: go build
26+
- name: Install system dependencies (keepassxc + clamav)
27+
run: |
28+
sudo apt-get update
29+
sudo apt-get install -y --no-install-recommends keepassxc clamav
2830
29-
- name: Test
31+
- name: Run unit tests
3032
run: go test ./...
33+
34+
- name: Run build
35+
run: scripts/build_binaries
36+
37+
- name: Virus scan
38+
run: |
39+
scannerVersion=$(clamscan --version)
40+
echo "Using scanner version: $scannerVersion"
41+
42+
echo "Scanning built binary with ClamAV..."
43+
clamscan --recursive --infected --verbose dist/ || SCAN_STATUS=$?
44+
if [ "${SCAN_STATUS:-0}" -eq 1 ]; then
45+
echo "❌ Virus detected in built binary. Build failed." >&2
46+
exit 1
47+
elif [ "${SCAN_STATUS:-0}" -gt 1 ]; then
48+
echo "❌ ClamAV scan error (exit code $SCAN_STATUS). Build failed." >&2
49+
exit $SCAN_STATUS
50+
fi
51+
echo "✅ No viruses found in built binary."

.github/workflows/release.yml

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,6 @@ jobs:
2929
run: |
3030
sudo apt-get update
3131
sudo apt-get install -y --no-install-recommends keepassxc clamav
32-
# Update ClamAV signatures using GitHub token to avoid rate limits
33-
echo "Updating ClamAV signatures..."
34-
sudo freshclam --user-agent="ClamAV-GitHub/${{ github.repository }} (${{ secrets.GITHUB_TOKEN }})" || echo "freshclam failed; using existing signatures"
35-
clamscan --version
3632
3733
- name: Run unit tests
3834
run: go test ./...
@@ -44,15 +40,17 @@ jobs:
4440
version: '~> v2'
4541
install-only: true
4642

47-
- name: GoReleaser release (build only, skip publish & announce)
43+
- name: GoReleaser build
4844
env:
4945
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
5046
run: goreleaser release --clean --skip=publish --skip=announce
5147

52-
- name: Virus scan dist artifacts
48+
- name: Virus scan
5349
run: |
54-
echo "Scanning dist/ with ClamAV..."
50+
scannerVersion=$(clamscan --version)
51+
echo "Using scanner version: $scannerVersion"
5552
53+
echo "Scanning built binary with ClamAV..."
5654
clamscan --recursive --infected --verbose dist/ || SCAN_STATUS=$?
5755
if [ "${SCAN_STATUS:-0}" -eq 1 ]; then
5856
echo "❌ Virus detected in build artifacts. Aborting publish." >&2

scripts/build_binaries

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ PROJECT_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)"
88
cd "$PROJECT_ROOT"
99

1010
# Define the output directory for the binaries
11-
OUTPUT_DIR="$PROJECT_ROOT/bin/ctRestClient"
11+
OUTPUT_DIR="$PROJECT_ROOT/dist"
1212

1313
# Clean the output directory
1414
echo "Cleaning the output directory..."

0 commit comments

Comments
 (0)