Skip to content

clang 21#1430

Draft
mbrousset-ledger wants to merge 5 commits intoAPI_LEVEL_25from
mbr/clang-21
Draft

clang 21#1430
mbrousset-ledger wants to merge 5 commits intoAPI_LEVEL_25from
mbr/clang-21

Conversation

@mbrousset-ledger
Copy link
Contributor

…inated-string-initialization being addded to -Wextra in clang 21

Adding build flags for migration to clang-21

Description

Please provide a detailed description of what was done in this PR.
(And mention any links to an issue docs)

Changes include

  • Bugfix (non-breaking change that solves an issue)
  • New feature (non-breaking change that adds functionality)
  • Breaking change (change that is not backwards-compatible and/or changes current functionality)
  • Tests
  • Documentation
  • Other (for changes that might not fit in any category)

Breaking changes

Please complete this section if any breaking changes have been made, otherwise delete it.

Additional comments

Please post additional comments in this section if you have them, otherwise delete it.

Auto cherry-pick in API_LEVEL

If requested to port the commits from this PR on a dedicated API_LEVEL branch,
select the targeted one(s), or add new references if not listed:

[ ] TARGET_API_LEVEL: API_LEVEL_25

This will only create the PR with cherry-picks, ready to be reviewed and merged.

Remember:

  • The merge will ALWAYS be a manual operation.
  • It is possible the cherry-picks don't apply correctly, mainly if previous commits have been forgotten.
  • In case of failure, there is no other solution than redo the operation manually...

@codecov-commenter
Copy link

codecov-commenter commented Feb 17, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 82.52%. Comparing base (e591d2e) to head (4211d91).
⚠️ Report is 6 commits behind head on API_LEVEL_25.

Additional details and impacted files
@@              Coverage Diff              @@
##           API_LEVEL_25    #1430   +/-   ##
=============================================
  Coverage         82.52%   82.52%           
=============================================
  Files                46       46           
  Lines              5670     5670           
  Branches            774      774           
=============================================
  Hits               4679     4679           
  Misses              934      934           
  Partials             57       57           
Flag Coverage Δ
unittests 82.52% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@mbrousset-ledger mbrousset-ledger changed the base branch from API_LEVEL_25 to master February 17, 2026 13:51
@ledger-wiz-cspm-secret-detection
Copy link

ledger-wiz-cspm-secret-detection bot commented Feb 17, 2026

Wiz Scan Summary

Scanner Findings
Data Finding Sensitive Data -
Secret Finding Secrets -
IaC Misconfiguration IaC Misconfigurations -
SAST Finding SAST Findings -
Software Management Finding Software Management Findings -
Total -

View scan details in Wiz

To detect these findings earlier in the dev lifecycle, try using Wiz Code VS Code Extension.

Comment on lines +195 to +319
needs: [prepare-matrix]
strategy:
fail-fast: false
matrix:
apps: ${{ fromJSON(needs.prepare-matrix.outputs.c_apps) }}
runs-on: ubuntu-latest

steps:
- name: Clone App
uses: actions/checkout@v4
with:
repository: LedgerHQ/${{ matrix.apps.app-name }}
submodules: recursive
path: ${{ matrix.apps.app-name }}

- name: Pull official Docker image and start build container
run: |
docker pull ghcr.io/ledgerhq/ledger-app-builder/ledger-app-builder-lite:5.0.2
docker run -d --name builder-official -v $GITHUB_WORKSPACE:/workspace ghcr.io/ledgerhq/ledger-app-builder/ledger-app-builder-lite:5.0.2 sleep infinity
docker exec builder-official pip install --break-system-packages ledgered

- name: Create artifacts directory
run: mkdir -p $GITHUB_WORKSPACE/artifacts-official

- name: Build App for Nano X
if: contains(matrix.apps.devices, 'nanox')
continue-on-error: true
run: |
docker exec builder-official bash -c "
cd /workspace/${{ matrix.apps.app-name }}/${{ matrix.apps.build-directory }} &&
echo 'Building for Nano X' &&
make clean &&
make TARGET=nanox BOLOS_SDK=/opt/nanox-secure-sdk
"
- name: Collect Nano X binary
if: contains(matrix.apps.devices, 'nanox')
run: |
cp ${{ matrix.apps.app-name }}/${{ matrix.apps.build-directory }}/build/nanox/bin/app.elf \
artifacts-official/${{ matrix.apps.app-name }}-nanox.elf || true
cp ${{ matrix.apps.app-name }}/${{ matrix.apps.build-directory }}/build/nanox/bin/app.map \
artifacts-official/${{ matrix.apps.app-name }}-nanox.map || true
- name: Build App for Nano S+
if: contains(matrix.apps.devices, 'nanos+')
continue-on-error: true
run: |
docker exec builder-official bash -c "
cd /workspace/${{ matrix.apps.app-name }}/${{ matrix.apps.build-directory }} &&
echo 'Building for Nano S+' &&
make clean &&
make TARGET=nanos2 BOLOS_SDK=/opt/nanosplus-secure-sdk
"
- name: Collect Nano S+ binary
if: contains(matrix.apps.devices, 'nanos+')
run: |
cp ${{ matrix.apps.app-name }}/${{ matrix.apps.build-directory }}/build/nanos2/bin/app.elf \
artifacts-official/${{ matrix.apps.app-name }}-nanosp.elf || true
cp ${{ matrix.apps.app-name }}/${{ matrix.apps.build-directory }}/build/nanos2/bin/app.map \
artifacts-official/${{ matrix.apps.app-name }}-nanosp.map || true
- name: Build App for Stax
if: contains(matrix.apps.devices, 'stax')
continue-on-error: true
run: |
docker exec builder-official bash -c "
cd /workspace/${{ matrix.apps.app-name }}/${{ matrix.apps.build-directory }} &&
echo 'Building for Stax' &&
make clean &&
make TARGET=stax BOLOS_SDK=/opt/stax-secure-sdk
"
- name: Collect Stax binary
if: contains(matrix.apps.devices, 'stax')
run: |
cp ${{ matrix.apps.app-name }}/${{ matrix.apps.build-directory }}/build/stax/bin/app.elf \
artifacts-official/${{ matrix.apps.app-name }}-stax.elf || true
cp ${{ matrix.apps.app-name }}/${{ matrix.apps.build-directory }}/build/stax/bin/app.map \
artifacts-official/${{ matrix.apps.app-name }}-stax.map || true
- name: Build App for Flex
if: contains(matrix.apps.devices, 'flex')
continue-on-error: true
run: |
docker exec builder-official bash -c "
cd /workspace/${{ matrix.apps.app-name }}/${{ matrix.apps.build-directory }} &&
echo 'Building for Flex' &&
make clean &&
make TARGET=flex BOLOS_SDK=/opt/flex-secure-sdk
"
- name: Collect Flex binary
if: contains(matrix.apps.devices, 'flex')
run: |
cp ${{ matrix.apps.app-name }}/${{ matrix.apps.build-directory }}/build/flex/bin/app.elf \
artifacts-official/${{ matrix.apps.app-name }}-flex.elf || true
cp ${{ matrix.apps.app-name }}/${{ matrix.apps.build-directory }}/build/flex/bin/app.map \
artifacts-official/${{ matrix.apps.app-name }}-flex.map || true
- name: Build App for Apex+
if: contains(matrix.apps.devices, 'apex_p')
continue-on-error: true
run: |
docker exec builder-official bash -c "
cd /workspace/${{ matrix.apps.app-name }}/${{ matrix.apps.build-directory }} &&
echo 'Building for Apex+' &&
make clean &&
make TARGET=apex_p BOLOS_SDK=/opt/apex-secure-sdk
"
- name: Collect Apex+ binary
if: contains(matrix.apps.devices, 'apex_p')
run: |
cp ${{ matrix.apps.app-name }}/${{ matrix.apps.build-directory }}/build/apex_p/bin/app.elf \
artifacts-official/${{ matrix.apps.app-name }}-apex_p.elf || true
cp ${{ matrix.apps.app-name }}/${{ matrix.apps.build-directory }}/build/apex_p/bin/app.map \
artifacts-official/${{ matrix.apps.app-name }}-apex_p.map || true

- name: Upload app binaries
if: always()
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.apps.app-name }}-binaries-official
path: artifacts-official/
if-no-files-found: ignore
retention-days: 1

- name: Cleanup
if: always()
run: docker rm -f builder-official || true

compare-builds:
name: Compare builds

Check warning

Code scanning / CodeQL

Workflow does not contain permissions Medium

Actions job or workflow does not limit the permissions of the GITHUB_TOKEN. Consider setting an explicit permissions block, using the following as a minimal starting point: {contents: read}

Copilot Autofix

AI 11 days ago

In general, the fix is to explicitly declare a minimal permissions block rather than relying on repository defaults. Since multiple jobs in this workflow use actions/checkout and artifact upload/download, but none modify repository state (no pushes or PR/issue writes), a conservative and correct choice is to set contents: read at the workflow root. This documents intent and prevents unexpected elevation if org defaults change.

The single best way to fix this without changing functionality is:

  • Add a top-level permissions: block near the top of .github/workflows/build_all_c_apps.yml (e.g., after name:), setting contents: read. This applies to all jobs (build-docker, build-docker-full, prepare-matrix, test-build-official, etc.) that don’t override permissions, including the one flagged by CodeQL.
  • No per-job overrides are needed based on the shown snippet: jobs only read repository contents and use artifacts and Docker, all of which work with contents: read and the default implicit scopes for artifacts.

Concretely, edit .github/workflows/build_all_c_apps.yml:

  • Insert:
permissions:
  contents: read

right after the name: Build all C apps on latest C SDK line (line 1). No imports or other definitions are required.

Suggested changeset 1
.github/workflows/build_all_c_apps.yml

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/.github/workflows/build_all_c_apps.yml b/.github/workflows/build_all_c_apps.yml
--- a/.github/workflows/build_all_c_apps.yml
+++ b/.github/workflows/build_all_c_apps.yml
@@ -1,5 +1,8 @@
 name: Build all C apps on latest C SDK
 
+permissions:
+  contents: read
+
 on:
   workflow_dispatch:
     inputs:
EOF
@@ -1,5 +1,8 @@
name: Build all C apps on latest C SDK

permissions:
contents: read

on:
workflow_dispatch:
inputs:
Copilot is powered by AI and may make mistakes. Always verify output.
@mbrousset-ledger mbrousset-ledger changed the base branch from master to API_LEVEL_25 February 18, 2026 17:55
@mbrousset-ledger mbrousset-ledger changed the title Adding missing end of string null byte to metadata following -Wunterm… clang 21 Feb 18, 2026

Check warning

Code scanning / CodeQL

Workflow does not contain permissions Medium

Actions job or workflow does not limit the permissions of the GITHUB_TOKEN. Consider setting an explicit permissions block, using the following as a minimal starting point: {}

Copilot Autofix

AI 11 days ago

To fix the problem, add an explicit permissions block that limits the GITHUB_TOKEN to the minimal required scope. This workflow only needs to read repository contents (for actions/checkout in other jobs, if present) and to allow built-in actions to function; it does not need to write to the repo, issues, or pull requests. The safest and clearest fix is to define a root-level permissions block (applies to all jobs) with contents: read. If in the broader file some jobs needed more, they could override it, but we are constrained to the shown snippet and should not widen permissions unnecessarily.

Concretely, in .github/workflows/build_all_c_apps.yml, add:

permissions:
  contents: read

near the top of the workflow, after the on: block (line 10–11) and before jobs: (line 15). This documents and enforces least-privilege for all jobs, including compare, without changing any existing functionality, because all current steps rely only on artifact and local operations, which work with read-only contents permissions.

Suggested changeset 1
.github/workflows/build_all_c_apps.yml

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/.github/workflows/build_all_c_apps.yml b/.github/workflows/build_all_c_apps.yml
--- a/.github/workflows/build_all_c_apps.yml
+++ b/.github/workflows/build_all_c_apps.yml
@@ -9,6 +9,9 @@
         default: ''
   pull_request:
 
+permissions:
+  contents: read
+
 # NOTE : changes made to this file in the context of  this PR will be reverted
 #        these are just for the sake of testing the PR
 
EOF
@@ -9,6 +9,9 @@
default: ''
pull_request:

permissions:
contents: read

# NOTE : changes made to this file in the context of this PR will be reverted
# these are just for the sake of testing the PR

Copilot is powered by AI and may make mistakes. Always verify output.
Comment on lines +17 to +29
name: Build ledger-app-builder-lite
uses: LedgerHQ/ledger-app-workflows/.github/workflows/reusable_docker_deployment.yml@v1
with:
app_repository: LedgerHQ/ledger-app-builder
app_ref: mbr/clang-21
image_name: ledger-app-builder-lite
dockerfile_path: lite/Dockerfile
dry_run: true
outputs: "type=docker,dest=/tmp/ledger-app-builder-lite.tar"
secrets:
token: ${{ secrets.GITHUB_TOKEN }}

build-docker-full:

Check warning

Code scanning / CodeQL

Workflow does not contain permissions Medium

Actions job or workflow does not limit the permissions of the GITHUB_TOKEN. Consider setting an explicit permissions block, using the following as a minimal starting point: {}

Copilot Autofix

AI 11 days ago

In general, the fix is to add an explicit permissions block to the workflow (at the top level under name: / on:) or to each job, granting only the minimal GITHUB_TOKEN scopes required. Since the jobs here only read the repository (via actions/checkout) and use artifacts, and do not push commits, manage PRs, or alter releases, they can operate with contents: read. The reusable workflow that receives secrets.GITHUB_TOKEN also typically needs at most read access to the repo unless it’s designed to push or manage PRs.

The single best, minimally invasive change is to add a root-level permissions section that applies to all jobs, right after the on: block. This documents and enforces least privilege without changing the workflow’s functional behavior. A safe baseline is:

permissions:
  contents: read

This aligns with GitHub’s recommended read-only default for most build/test workflows and is sufficient for actions/checkout and the artifact actions being used. No additional imports or dependencies are needed; this is purely a YAML configuration change in .github/workflows/build_all_c_apps.yml.

Specifically:

  • Edit .github/workflows/build_all_c_apps.yml.
  • Insert a permissions: block after the on: section (after line 10, before the # NOTE comment).
  • Set contents: read as the minimal required permission.
Suggested changeset 1
.github/workflows/build_all_c_apps.yml

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/.github/workflows/build_all_c_apps.yml b/.github/workflows/build_all_c_apps.yml
--- a/.github/workflows/build_all_c_apps.yml
+++ b/.github/workflows/build_all_c_apps.yml
@@ -9,6 +9,9 @@
         default: ''
   pull_request:
 
+permissions:
+  contents: read
+
 # NOTE : changes made to this file in the context of  this PR will be reverted
 #        these are just for the sake of testing the PR
 
EOF
@@ -9,6 +9,9 @@
default: ''
pull_request:

permissions:
contents: read

# NOTE : changes made to this file in the context of this PR will be reverted
# these are just for the sake of testing the PR

Copilot is powered by AI and may make mistakes. Always verify output.
Comment on lines +30 to +73
name: Build ledger-app-builder
needs: [build-docker]
runs-on: ubuntu-latest
steps:
- name: Checkout ledger-app-builder
uses: actions/checkout@v4
with:
repository: LedgerHQ/ledger-app-builder
ref: mbr/clang-21
token: ${{ secrets.GITHUB_TOKEN }}

- name: Download ledger-app-builder-lite image artifact
uses: actions/download-artifact@v4
with:
name: ledger-app-builder-lite
path: /tmp

- name: Load ledger-app-builder-lite image
run: docker load -i /tmp/ledger-app-builder-lite.tar

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
with:
driver: docker

- name: Build ledger-app-builder image
uses: docker/build-push-action@v6
with:
context: .
file: full/Dockerfile
push: false
tags: ledger-app-builder:latest

- name: Export ledger-app-builder image to tar
run: docker save ledger-app-builder:latest -o /tmp/ledger-app-builder.tar

- name: Upload ledger-app-builder image artifact
uses: actions/upload-artifact@v4
with:
name: ledger-app-builder
path: /tmp/ledger-app-builder.tar
retention-days: 1

check-clang-version-custom:

Check warning

Code scanning / CodeQL

Workflow does not contain permissions Medium

Actions job or workflow does not limit the permissions of the GITHUB_TOKEN. Consider setting an explicit permissions block, using the following as a minimal starting point: {contents: read}

Copilot Autofix

AI 11 days ago

To fix this, define explicit, least-privilege permissions for the workflow so that all jobs (including the highlighted build-docker-full job) do not rely on repo/org defaults. This is best done at the workflow root so that all jobs inherit the same minimal permissions, and only expanded if some job later needs more.

In this workflow, the token is only needed for standard operations like actions/checkout and accessing the repository; no job writes to repository contents or issues. Therefore, contents: read is sufficient and aligns with the minimal starting point suggested by CodeQL. We can add:

permissions:
  contents: read

near the top of .github/workflows/build_all_c_apps.yml, at the same indentation level as on: and jobs:. No other code changes, imports, or dependencies are required, and existing functionality (checking out code, using artifacts, building Docker images) remains unchanged because read access to contents is all that is needed.


Suggested changeset 1
.github/workflows/build_all_c_apps.yml

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/.github/workflows/build_all_c_apps.yml b/.github/workflows/build_all_c_apps.yml
--- a/.github/workflows/build_all_c_apps.yml
+++ b/.github/workflows/build_all_c_apps.yml
@@ -9,6 +9,9 @@
         default: ''
   pull_request:
 
+permissions:
+  contents: read
+
 # NOTE : changes made to this file in the context of  this PR will be reverted
 #        these are just for the sake of testing the PR
 
EOF
@@ -9,6 +9,9 @@
default: ''
pull_request:

permissions:
contents: read

# NOTE : changes made to this file in the context of this PR will be reverted
# these are just for the sake of testing the PR

Copilot is powered by AI and may make mistakes. Always verify output.
Comment on lines +74 to +94
name: Check clang version (custom image)
needs: [build-docker-full]
runs-on: ubuntu-latest
steps:
- name: Download ledger-app-builder image artifact
uses: actions/download-artifact@v4
with:
name: ledger-app-builder
path: /tmp

- name: Check clang version
run: |
LOADED_IMAGE=$(docker load -i /tmp/ledger-app-builder.tar | grep "Loaded image" | head -1 | awk '{print $NF}')
CLANG_VERSION=$(docker run --rm "$LOADED_IMAGE" clang --version)
echo "$CLANG_VERSION"
echo "## clang version (custom image)" >> $GITHUB_STEP_SUMMARY
echo '```' >> $GITHUB_STEP_SUMMARY
echo "$CLANG_VERSION" >> $GITHUB_STEP_SUMMARY
echo '```' >> $GITHUB_STEP_SUMMARY

check-clang-version-official:

Check warning

Code scanning / CodeQL

Workflow does not contain permissions Medium

Actions job or workflow does not limit the permissions of the GITHUB_TOKEN. Consider setting an explicit permissions block, using the following as a minimal starting point: {}

Copilot Autofix

AI 11 days ago

In general, the fix is to explicitly declare a permissions block that grants only the minimal scopes required for this workflow. Since none of the jobs push commits, manage issues, or otherwise modify repository state, they can safely run with contents: read (and no additional write permissions). This both documents intent and ensures the workflow does not accidentally gain more privileges if repo/org defaults change.

The best minimal fix without altering behavior is to add a top-level permissions block near the top of .github/workflows/build_all_c_apps.yml, applying to all jobs, e.g.:

permissions:
  contents: read

This satisfies CodeQL’s requirement and provides least-privilege defaults. None of the shown jobs require more than read access: they build Docker images, download/upload artifacts, run Docker containers, check out code, and call a Python script; these all work with contents: read. No job appears to need write access to PRs, issues, or repository contents. Concretely, insert the permissions block after the on: trigger section (after line 11), before the jobs: key. No imports or additional definitions are required.

Suggested changeset 1
.github/workflows/build_all_c_apps.yml

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/.github/workflows/build_all_c_apps.yml b/.github/workflows/build_all_c_apps.yml
--- a/.github/workflows/build_all_c_apps.yml
+++ b/.github/workflows/build_all_c_apps.yml
@@ -9,6 +9,9 @@
         default: ''
   pull_request:
 
+permissions:
+  contents: read
+
 # NOTE : changes made to this file in the context of  this PR will be reverted
 #        these are just for the sake of testing the PR
 
EOF
@@ -9,6 +9,9 @@
default: ''
pull_request:

permissions:
contents: read

# NOTE : changes made to this file in the context of this PR will be reverted
# these are just for the sake of testing the PR

Copilot is powered by AI and may make mistakes. Always verify output.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants