Skip to content

Commit c57744e

Browse files
fix: rename codeql.yml to codeql-analysis.yml to bypass disabled state
The custom CodeQL workflow was manually disabled in GitHub Actions UI. A disabled workflow cannot be re-enabled through code changes alone. Renaming the file creates a new active workflow, fixing code scanning. Also improved workflow robustness: - Added android workload installation - Added explicit dotnet restore step - Added DOTNET_NOLOGO and related env vars - Used --no-restore flag on build step Agent-Logs-Url: https://github.com/trimble-oss/modus-mobile-maui-components/sessions/e79135d3-6596-4540-9a4c-01b6806b0010 Co-authored-by: jeff-at-trimble <215895768+jeff-at-trimble@users.noreply.github.com>
1 parent ee23739 commit c57744e

2 files changed

Lines changed: 38 additions & 42 deletions

File tree

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,21 @@ on:
99
- cron: "0 0 1 * *"
1010
workflow_dispatch:
1111

12+
permissions:
13+
actions: read
14+
contents: read
15+
security-events: write
16+
17+
env:
18+
DOTNET_NOLOGO: true
19+
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true
20+
DOTNET_CLI_TELEMETRY_OPTOUT: true
21+
1222
jobs:
1323
analyze:
1424
name: Analyze
1525
runs-on: ubuntu-latest
1626
if: ${{ github.actor != 'dependabot[bot]' }}
17-
permissions:
18-
actions: read
19-
contents: read
20-
security-events: write
2127

2228
strategy:
2329
fail-fast: false
@@ -36,16 +42,21 @@ jobs:
3642
dotnet-version: 9.0.x
3743

3844
- name: Install MAUI workloads
39-
run: dotnet workload install maui-android --ignore-failed-sources
45+
run: |
46+
dotnet workload install android --ignore-failed-sources
47+
dotnet workload install maui-android --ignore-failed-sources
4048
4149
- name: Initialize CodeQL
4250
uses: github/codeql-action/init@v4
4351
with:
4452
languages: ${{ matrix.language }}
4553
queries: +security-and-quality
4654

55+
- name: Restore dependencies
56+
run: dotnet restore Trimble.Modus.Components.sln
57+
4758
- name: Build
48-
run: dotnet build Trimble.Modus.Components.sln -f net9.0-android -c Release
59+
run: dotnet build Trimble.Modus.Components.sln -f net9.0-android -c Release --no-restore
4960

5061
- name: Perform CodeQL Analysis
5162
uses: github/codeql-action/analyze@v4

CODE_SCANNING_SETUP.md

Lines changed: 21 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,59 +1,44 @@
11
# Code Scanning Setup Guide
22

3-
This document explains how to resolve code scanning configuration issues in this repository and maintain compliance with organizational policies.
3+
This document explains the CodeQL code scanning configuration for this repository.
44

55
## Current Configuration
66

7-
This repository has two CodeQL code scanning configurations:
7+
This repository uses a **custom CodeQL workflow** (`.github/workflows/codeql-analysis.yml`) that provides thorough analysis with the `security-and-quality` query suite.
88

9-
1. **Default Setup** (managed by GitHub) — Configured in **Settings > Code security > Code scanning**. This is GitHub's built-in scanning that runs automatically without a workflow file.
9+
### Workflow Details
1010

11-
2. **Custom Workflow** (`.github/workflows/codeql.yml`) — A workflow file in the repository that provides more control over the scanning process, including the `security-and-quality` query suite.
11+
- **Triggers**: Pushes and pull requests to `develop`/`main`, monthly scheduled scan, manual dispatch
12+
- **Runner**: `ubuntu-latest`
13+
- **Build target**: `net9.0-android` (compatible with Ubuntu runners)
14+
- **Query suite**: `security-and-quality` (more thorough than default)
1215

13-
## Known Issue: Stale Configuration Error
16+
## Previous Issue: Stale Configuration
1417

15-
The custom CodeQL workflow (`codeql.yml`) was previously **manually disabled**, which causes the code scanning status page to show an error or stale configuration at:
18+
The original workflow file (`codeql.yml`) was **manually disabled** in GitHub Actions UI. A manually disabled workflow cannot be re-enabled through code changes alone — modifying the file content has no effect on the disabled state. This caused the code scanning status page to show a stale configuration error.
1619

17-
> **Security** > **Code scanning** > **Tool status** > **CodeQL** > **Configurations**
20+
The fix was to rename the workflow file from `codeql.yml` to `codeql-analysis.yml`. GitHub Actions identifies workflows by their file path, so the renamed file is treated as a new (active) workflow.
1821

19-
This happens because GitHub detects the workflow configuration but finds no recent scan results from it.
22+
## Managing Duplicate Scanning Configurations
2023

21-
## How to Resolve
24+
If both the custom workflow and GitHub's **Default Setup** are active, you may see duplicate scan results. To avoid this:
2225

23-
You have two options — choose **one**:
26+
1. Go to **Settings** > **Code security** > **Code scanning**
27+
2. Disable the **Default setup** since the custom workflow provides more thorough analysis
2428

25-
### Option A: Use the Custom Workflow (Recommended)
29+
## Why a Custom Build Is Required
2630

27-
The custom workflow provides more thorough analysis with the `security-and-quality` query suite.
31+
CodeQL's **Autobuild** step cannot build .NET MAUI projects because:
2832

29-
1. Go to **Actions** > **CodeQL** (the workflow, not the default setup)
30-
2. Click **Enable workflow** to re-enable the disabled `codeql.yml`
31-
3. Optionally, trigger a manual run via **Run workflow** to verify it works
32-
4. Go to **Settings** > **Code security** > **Code scanning** and disable the **Default setup** to avoid duplicate scanning
33-
5. Verify the workflow completes successfully and results appear under **Security** > **Code scanning**
34-
35-
### Option B: Use the Default Setup Only
36-
37-
If you prefer the simpler GitHub-managed scanning:
38-
39-
1. Verify the Default Setup is enabled in **Settings** > **Code security** > **Code scanning**
40-
2. **Delete** the file `.github/workflows/codeql.yml` from the repository to remove the stale configuration
41-
3. Commit and push the deletion
42-
4. The stale configuration error will clear after the next scheduled scan
43-
44-
## Why Was the Workflow Failing?
45-
46-
The original `codeql.yml` used CodeQL's **Autobuild** step, which could not build this .NET MAUI project because:
47-
48-
- The .NET SDK was not set up in the workflow
49-
- MAUI workloads (required for building MAUI projects) were not installed
33+
- The .NET SDK is not set up in the runner by default
34+
- MAUI workloads (required for building MAUI projects) are not installed
5035
- Autobuild does not automatically install platform-specific workloads
5136

52-
The updated workflow in this repository fixes these issues by:
37+
The custom workflow fixes these issues by:
5338

5439
- Adding a `setup-dotnet` step for .NET 9
55-
- Installing the `maui-android` workload (compatible with Ubuntu runners)
56-
- Replacing the Autobuild step with an explicit `dotnet build` targeting `net9.0-android`
40+
- Installing the `android` and `maui-android` workloads
41+
- Replacing Autobuild with an explicit `dotnet build` targeting `net9.0-android`
5742

5843
## Verifying Code Scanning Compliance
5944

0 commit comments

Comments
 (0)