Skip to content

Commit cf71049

Browse files
roshan-kudmkarthi
andauthored
Add Coverity and Trivy scan workflow (#3)
* Add Coverity scan workflow * Restructure CI: move coverity and trivy into reusable actions under analysis * Trigger CI and daily build on PRs targeting main * Fix coverity download: prefer wget with --no-proxy over curl * Fix coverity: use --gcc template to capture all compiler variants * Fix coverity: configure cc compiler and clean build for proper capture * Fix coverity: use executable name 'cc' not full path with --template * Fix coverity: trust SSL cert for commit-defects, simplify compiler config * Fix coverity: remove --ssl flag (incompatible with https URL), keep --on-new-cert trust * Add SSL cert import step to coverity action * Remove coverity download/install and cert import steps (pre-installed on runner) * Remove cov-commit-defects and unused secrets/inputs * ci: serialize scans, consolidate reports under single artifact - Add shellcheck as dedicated sub-action (analysis/shellcheck/) - Remove analysis wrapper action.yml (no longer needed) - Save coverity console output to reports/coverity_scan.txt - Save trivy console output to reports/trivy_scan.txt - Move all coverity/trivy reports to \/reports/ - Remove binary size/symbol check from build action - Serialize build, smoke, unit-tests, shellcheck, coverity, trivy in a single job across ci, daily_build, pull_request workflows - Upload all reports under one artifact link per workflow run * ci: remove pull_request trigger from daily_build workflow daily_build was firing on PRs to main alongside ci, causing duplicate runs. Restrict to schedule and push to main only. --------- Co-authored-by: D M, Karthik <karthik.d.m@intel.com>
1 parent 3d5dd2d commit cf71049

10 files changed

Lines changed: 176 additions & 173 deletions

File tree

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
#
2+
# BSD 3-Clause License
3+
# Copyright (C) 2026 Intel Corporation
4+
# SPDX-License-Identifier: BSD-3-Clause
5+
#
6+
name: 'Coverity Scan'
7+
description: 'Run Coverity static analysis (assumes Coverity pre-installed on runner)'
8+
9+
runs:
10+
using: composite
11+
steps:
12+
- name: Set up MTL environment
13+
shell: bash
14+
run: |
15+
if pkg-config --exists mtl 2>/dev/null; then
16+
echo "MTL already discoverable via pkg-config"
17+
exit 0
18+
fi
19+
MTL_PC=$(find /usr /home /opt -name "mtl.pc" 2>/dev/null | head -1)
20+
if [ -z "$MTL_PC" ]; then
21+
echo "ERROR: MTL pkg-config file not found under /usr, /home, or /opt."
22+
echo "Please ensure Media Transport Library is built and installed on the runner."
23+
exit 1
24+
fi
25+
MTL_PC_DIR=$(dirname "$MTL_PC")
26+
echo "Found MTL pkgconfig at: $MTL_PC_DIR"
27+
echo "PKG_CONFIG_PATH=${MTL_PC_DIR}:${PKG_CONFIG_PATH}" >> "$GITHUB_ENV"
28+
29+
- name: Coverity Scan
30+
shell: bash
31+
run: |
32+
cd "$GITHUB_WORKSPACE"
33+
REPORT_DIR="$GITHUB_WORKSPACE/reports"
34+
mkdir -p "$REPORT_DIR"
35+
36+
{
37+
# Configure Coverity for cc (meson uses cc which is gcc)
38+
$HOME/coverity/bin/cov-configure --compiler cc --comptype gcc --template
39+
40+
# Clean and setup meson build directory
41+
rm -rf build coverity_output
42+
meson setup build
43+
44+
# Run cov-build wrapping the ninja compilation
45+
$HOME/coverity/bin/cov-build --dir coverity_output/ ninja -C build
46+
47+
# Analyze captured build
48+
$HOME/coverity/bin/cov-analyze --dir coverity_output/ \
49+
--webapp-security \
50+
--enable-audit-checkers \
51+
--enable-default
52+
53+
# Generate JSON report
54+
$HOME/coverity/bin/cov-format-errors --dir coverity_output/ \
55+
--json-output-v8 "$REPORT_DIR/coverity-report.json"
56+
} 2>&1 | tee "$REPORT_DIR/coverity_scan.txt"
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#
2+
# BSD 3-Clause License
3+
# Copyright (C) 2026 Intel Corporation
4+
# SPDX-License-Identifier: BSD-3-Clause
5+
#
6+
name: 'ShellCheck'
7+
description: 'Run shellcheck on shell scripts. Report written to $GITHUB_WORKSPACE/reports/'
8+
9+
runs:
10+
using: composite
11+
steps:
12+
- name: shellcheck scripts
13+
shell: bash
14+
run: |
15+
REPORT_DIR="$GITHUB_WORKSPACE/reports"
16+
mkdir -p "$REPORT_DIR"
17+
echo "===== shellcheck Script Analysis ====="
18+
shellcheck scripts/build.sh scripts/test.sh 2>&1 | tee "$REPORT_DIR/shellcheck-report.txt" || true
19+
echo "shellcheck scan complete. Report: $REPORT_DIR/shellcheck-report.txt"
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
#
2+
# BSD 3-Clause License
3+
# Copyright (C) 2026 Intel Corporation
4+
# SPDX-License-Identifier: BSD-3-Clause
5+
#
6+
name: 'Trivy Scan'
7+
description: 'Run Trivy filesystem, config, and secret scans'
8+
9+
runs:
10+
using: composite
11+
steps:
12+
- name: Verify Trivy installation
13+
shell: bash
14+
run: |
15+
if ! command -v trivy > /dev/null 2>&1; then
16+
echo "ERROR: Trivy is not installed or not available in PATH for the runner user."
17+
echo "Install Trivy on the self-hosted runner and ensure PATH includes the binary location."
18+
echo "If installed via snap, verify /snap/bin is available to the runner service."
19+
exit 1
20+
fi
21+
trivy --version
22+
23+
- name: Trivy filesystem scan
24+
shell: bash
25+
run: |
26+
REPORT_DIR="$GITHUB_WORKSPACE/reports"
27+
mkdir -p "$REPORT_DIR"
28+
{
29+
echo "===== Trivy Filesystem Scan ====="
30+
trivy fs --list-all-pkgs --format json \
31+
--output "$REPORT_DIR/trivy-fs-full-report.json" . || true
32+
trivy fs --ignore-unfixed . | tee "$REPORT_DIR/trivy-fs-report.txt"
33+
} 2>&1 | tee -a "$REPORT_DIR/trivy_scan.txt"
34+
35+
- name: Trivy config scan
36+
shell: bash
37+
run: |
38+
REPORT_DIR="$GITHUB_WORKSPACE/reports"
39+
mkdir -p "$REPORT_DIR"
40+
{
41+
echo "===== Trivy Config Scan ====="
42+
trivy config . | tee "$REPORT_DIR/trivy-config-report.txt"
43+
} 2>&1 | tee -a "$REPORT_DIR/trivy_scan.txt" || true
44+
45+
- name: Trivy secret scan
46+
shell: bash
47+
run: |
48+
REPORT_DIR="$GITHUB_WORKSPACE/reports"
49+
mkdir -p "$REPORT_DIR"
50+
{
51+
echo "===== Trivy Secret Scan ====="
52+
trivy fs --scanners secret . | tee "$REPORT_DIR/trivy-secret-report.txt"
53+
} 2>&1 | tee -a "$REPORT_DIR/trivy_scan.txt" || true

.github/actions/build-dvledtx/action.yml

Lines changed: 1 addition & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
# SPDX-License-Identifier: BSD-3-Clause
55
#
66
name: 'Build dvledtx'
7-
description: 'Build dvledtx with FFMPEG and MTL TX APIs, keep both binaries, run binary size/symbol check for each'
7+
description: 'Build dvledtx with FFMPEG and MTL TX APIs, keep both binaries'
88

99
runs:
1010
using: composite
@@ -34,26 +34,3 @@ runs:
3434
mkdir -p ./bins
3535
cp ./build/dvledtx ./bins/dvledtx-mtl
3636
echo "MTL build saved: $(file ./bins/dvledtx-mtl)"
37-
38-
- name: Binary size and symbol check
39-
shell: bash
40-
run: |
41-
REPORT_DIR="$GITHUB_WORKSPACE/reports"
42-
mkdir -p "$REPORT_DIR"
43-
44-
for BINARY in ./bins/dvledtx-ffmpeg ./bins/dvledtx-mtl; do
45-
NAME=$(basename "$BINARY")
46-
echo "" | tee -a "$REPORT_DIR/binary-report.txt"
47-
echo "===== $NAME: Binary Size =====" | tee -a "$REPORT_DIR/binary-report.txt"
48-
size "$BINARY" | tee -a "$REPORT_DIR/binary-report.txt"
49-
50-
echo "" | tee -a "$REPORT_DIR/binary-report.txt"
51-
echo "===== $NAME: Shared Library Dependencies =====" | tee -a "$REPORT_DIR/binary-report.txt"
52-
readelf -d "$BINARY" | grep NEEDED | tee -a "$REPORT_DIR/binary-report.txt"
53-
54-
echo "" | tee -a "$REPORT_DIR/binary-report.txt"
55-
echo "===== $NAME: Undefined External Symbols =====" | tee -a "$REPORT_DIR/binary-report.txt"
56-
nm -u "$BINARY" | tee -a "$REPORT_DIR/binary-report.txt"
57-
done
58-
59-
echo "Binary report saved to $REPORT_DIR/binary-report.txt"

.github/actions/environment-check/action.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,12 +49,12 @@ runs:
4949
fi
5050
echo "All required pip packages present."
5151
52-
- name: Check static analysis tools
52+
- name: Check analysis tools
5353
shell: bash
5454
run: |
55-
echo "===== Static Analysis Tools Check ====="
55+
echo "===== Analysis Tools Check ====="
5656
MISSING=""
57-
for TOOL in cppcheck flawfinder shellcheck codespell; do
57+
for TOOL in shellcheck; do
5858
if command -v "$TOOL" &>/dev/null; then
5959
echo " [OK] $TOOL ($(command -v "$TOOL"))"
6060
else
@@ -63,10 +63,10 @@ runs:
6363
fi
6464
done
6565
if [ -n "$MISSING" ]; then
66-
echo "ERROR: Missing static analysis tools:$MISSING"
66+
echo "ERROR: Missing analysis tools:$MISSING"
6767
exit 1
6868
fi
69-
echo "All required static analysis tools present."
69+
echo "All required analysis tools present."
7070
7171
- name: Check system libraries
7272
shell: bash

.github/actions/static-analysis/action.yml

Lines changed: 0 additions & 53 deletions
This file was deleted.

.github/workflows/ci.yml

Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,21 +3,26 @@
33
# Copyright (C) 2026 Intel Corporation
44
# SPDX-License-Identifier: BSD-3-Clause
55
#
6-
name: DVLED App CI
6+
name: Continuous Integration
77

88
on:
99
push:
1010
branches:
1111
- main
12+
pull_request:
13+
branches:
14+
- main
15+
workflow_dispatch:
1216

1317
jobs:
14-
static-analysis:
18+
ci:
1519
name: Continuous Integration
1620
runs-on: self-hosted
1721
steps:
1822
- name: Clean up previous run
1923
run: |
2024
find "${{ github.workspace }}" -mindepth 1 -maxdepth 1 -exec rm -rf {} +
25+
rm -rf /tmp/trivy-*
2126
2227
- name: Checkout repository
2328
uses: actions/checkout@v4
@@ -28,13 +33,28 @@ jobs:
2833
- name: Environment check
2934
uses: ./.github/actions/environment-check
3035

31-
- name: Static analysis
32-
uses: ./.github/actions/static-analysis
36+
- name: Build dvledtx
37+
uses: ./.github/actions/build-dvledtx
38+
39+
- name: Smoke test
40+
uses: ./.github/actions/smoke-tests
41+
42+
- name: Run unit tests
43+
uses: ./.github/actions/unit-tests
44+
45+
- name: ShellCheck
46+
uses: ./.github/actions/analysis/shellcheck
47+
48+
- name: Coverity Scan
49+
uses: ./.github/actions/analysis/coverity
50+
51+
- name: Trivy Scan
52+
uses: ./.github/actions/analysis/trivy
3353

34-
- name: Upload static analysis reports
54+
- name: Upload all reports
3555
uses: actions/upload-artifact@v4
3656
if: always()
3757
with:
38-
name: static-analysis-reports-${{ github.run_id }}
58+
name: all-scan-reports-${{ github.run_id }}
3959
path: ${{ github.workspace }}/reports/
4060
retention-days: 30

.github/workflows/daily_build.yml

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ on:
1313
push:
1414
branches:
1515
- main
16-
1716
workflow_dispatch:
1817

1918
jobs:
@@ -46,8 +45,14 @@ jobs:
4645
- name: Run unit tests
4746
uses: ./.github/actions/unit-tests
4847

49-
- name: Static analysis
50-
uses: ./.github/actions/static-analysis
48+
- name: ShellCheck
49+
uses: ./.github/actions/analysis/shellcheck
50+
51+
- name: Coverity Scan
52+
uses: ./.github/actions/analysis/coverity
53+
54+
- name: Trivy Scan
55+
uses: ./.github/actions/analysis/trivy
5156

5257
- name: Upload daily build reports
5358
uses: actions/upload-artifact@v4

.github/workflows/pull_request.yml

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,14 @@ jobs:
4545
- name: Run unit tests
4646
uses: ./.github/actions/unit-tests
4747

48-
- name: Static analysis
49-
uses: ./.github/actions/static-analysis
48+
- name: ShellCheck
49+
uses: ./.github/actions/analysis/shellcheck
50+
51+
- name: Coverity Scan
52+
uses: ./.github/actions/analysis/coverity
53+
54+
- name: Trivy Scan
55+
uses: ./.github/actions/analysis/trivy
5056

5157
- name: Upload PR reports
5258
uses: actions/upload-artifact@v4

0 commit comments

Comments
 (0)