Skip to content

Migrate to reusable workflows#36

Closed
mbrousset-ledger wants to merge 1 commit into
developfrom
mbr/chore-migrate-to-reusable-wf
Closed

Migrate to reusable workflows#36
mbrousset-ledger wants to merge 1 commit into
developfrom
mbr/chore-migrate-to-reusable-wf

Conversation

@mbrousset-ledger

Copy link
Copy Markdown

This PR migrates workflows to use centralized reusable workflows from LedgerHQ/ledger-app-workflows.

@ledger-wiz-cspm-secret-detection

Copy link
Copy Markdown

Wiz Scan Summary

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

View scan details in Wiz

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

Comment on lines +14 to +16
name: Call Ledger CodeQL analysis
uses: LedgerHQ/ledger-app-workflows/.github/workflows/reusable_codeql_checks.yml@v1
secrets: inherit

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 4 months ago

In general, the problem is fixed by adding an explicit permissions: block that limits GITHUB_TOKEN to the least privileges necessary. This can be set at the workflow root (applies to all jobs) or at the job level. Since our snippet shows only a single job and we are invoking a reusable workflow, the safest, non-breaking approach is to add a job-level permissions: block under jobs.analyse, so the reusable workflow runs with constrained permissions. For a CodeQL analysis that only needs to read the repository contents, contents: read is a reasonable minimal baseline.

Concretely, in .github/workflows/codeql.yml, under the existing analyse job (line 13 onwards), we will insert a permissions: section at the same indentation level as name, uses, and secrets. We will set:

permissions:
  contents: read

This does not alter any existing logic or behavior of the workflow other than constraining token rights. No imports or additional methods are needed, as this is purely a YAML configuration change.

Suggested changeset 1
.github/workflows/codeql.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/codeql.yml b/.github/workflows/codeql.yml
--- a/.github/workflows/codeql.yml
+++ b/.github/workflows/codeql.yml
@@ -12,5 +12,7 @@
 jobs:
   analyse:
     name: Call Ledger CodeQL analysis
+    permissions:
+      contents: read
     uses: LedgerHQ/ledger-app-workflows/.github/workflows/reusable_codeql_checks.yml@v1
     secrets: inherit
EOF
@@ -12,5 +12,7 @@
jobs:
analyse:
name: Call Ledger CodeQL analysis
permissions:
contents: read
uses: LedgerHQ/ledger-app-workflows/.github/workflows/reusable_codeql_checks.yml@v1
secrets: inherit
Copilot is powered by AI and may make mistakes. Always verify output.
Comment on lines +14 to +16
name: Unit Tests
uses: LedgerHQ/ledger-app-workflows/.github/workflows/reusable_unit_tests.yml@v1
secrets: inherit

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 4 months ago

To fix this, explicitly define least-privilege permissions for the workflow so the GITHUB_TOKEN does not inherit potentially broad defaults. Since this workflow only dispatches a reusable unit-test workflow and does not itself perform any repository modifications, a safe minimal set is read-only access to repository contents.

The best way to do this without changing existing functionality is to add a top-level permissions: block (at the same indentation level as on: and jobs:) with contents: read. This will apply to all jobs in the workflow, including the unit_tests job that calls the reusable workflow, unless that reusable workflow overrides permissions internally. No other changes to the job definition are necessary.

Concretely, in .github/workflows/unit-tests.yml, insert:

permissions:
  contents: read

between the on: block and the jobs: block (e.g., after line 10 or 11 in the provided snippet). This requires no imports or additional methods, as it’s purely a YAML configuration change for GitHub Actions.

Suggested changeset 1
.github/workflows/unit-tests.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/unit-tests.yml b/.github/workflows/unit-tests.yml
--- a/.github/workflows/unit-tests.yml
+++ b/.github/workflows/unit-tests.yml
@@ -9,6 +9,9 @@
       - develop
   pull_request:
 
+permissions:
+  contents: read
+
 jobs:
   unit_tests:
     name: Unit Tests
EOF
@@ -9,6 +9,9 @@
- develop
pull_request:

permissions:
contents: read

jobs:
unit_tests:
name: Unit Tests
Copilot is powered by AI and may make mistakes. Always verify output.
@mbrousset-ledger

Copy link
Copy Markdown
Author

Closing this PR for now.

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