Skip to content

fix(CI): broken cppcheck - #60

Merged
BLumia merged 1 commit into
masterfrom
tmp-patch-1
Oct 9, 2026
Merged

BLumia merged 1 commit into
masterfrom
tmp-patch-1

Conversation

@BLumia

@BLumia BLumia commented Oct 9, 2026 •

Copy link
Copy Markdown
Member

See also: https://github.com/linuxdeepin/.github/blob/master/workflow-templates/cppcheck.yml and linuxdeepin/deepin-camera#501

Log:

Summary by Sourcery

Restore reliable Cppcheck validation for pull requests.

Bug Fixes:

  • Fix the Cppcheck GitHub Actions workflow so pull request analysis can run successfully.

CI:

  • Update the checkout action and enable safe handling of pull request head revisions for Cppcheck checks.

@deepin-ci-robot

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: BLumia

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@sourcery-ai

sourcery-ai Bot commented Oct 9, 2026

Copy link
Copy Markdown
Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

The CI workflow updates actions/checkout and opts into unsafe pull request checkout so the Cppcheck job can successfully analyze pull request head revisions.

File-Level Changes

Change Details Files
Update the Cppcheck workflow checkout configuration to support pull request head commits under the newer checkout action.
  • Upgrade the checkout action from v4 to v7.
  • Enable unsafe pull request checkout explicitly while retaining the PR head SHA and disabled credential persistence.
.github/workflows/cppcheck.yml

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@BLumia
BLumia merged commit bb51999 into master Oct 9, 2026
6 of 9 checks passed
@BLumia
BLumia deleted the tmp-patch-1 branch October 9, 2026 07:10

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - I've found 1 issue

Prompt for AI Agents
Please address the comments from this code review:

## Individual Comments

### Comment 1
<location path=".github/workflows/cppcheck.yml" line_range="21" />
<code_context>
         with:
           ref: ${{ github.event.pull_request.head.sha }}
           persist-credentials: false
+          allow-unsafe-pr-checkout: true
       - uses: linuxdeepin/action-cppcheck@main
         with:
</code_context>
<issue_to_address>
**Pull requests can expose workflow token**

When an untrusted PR supplies files that trigger code execution or an exploitable path while the Cppcheck action processes its checkout, a malicious PR can make the privileged `pull_request_target` job check out and process attacker-controlled files with `linuxdeepin/action-cppcheck@main`; if that processing executes attacker-controlled code or is exploited, the action's `${{ secrets.GITHUB_TOKEN }}` is exposed. The token can then be used with the permissions granted to this workflow.

Run analysis of untrusted PR contents without a privileged token, and perform any token-bearing reporting in a separate trusted job that does not check out or execute the PR head.
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨

with:
ref: ${{ github.event.pull_request.head.sha }}
persist-credentials: false
allow-unsafe-pr-checkout: true

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟠 High · Pull requests can expose workflow token

When an untrusted PR supplies files that trigger code execution or an exploitable path while the Cppcheck action processes its checkout, a malicious PR can make the privileged pull_request_target job check out and process attacker-controlled files with linuxdeepin/action-cppcheck@main; if that processing executes attacker-controlled code or is exploited, the action's ${{ secrets.GITHUB_TOKEN }} is exposed. The token can then be used with the permissions granted to this workflow.

Run analysis of untrusted PR contents without a privileged token, and perform any token-bearing reporting in a separate trusted job that does not check out or execute the PR head.

Prompt for AI agents
In `.github/workflows/cppcheck.yml` at line 21:

**Pull requests can expose workflow token**

When an untrusted PR supplies files that trigger code execution or an exploitable path while the Cppcheck action processes its checkout, a malicious PR can make the privileged `pull_request_target` job check out and process attacker-controlled files with `linuxdeepin/action-cppcheck@main`; if that processing executes attacker-controlled code or is exploited, the action's `${{ secrets.GITHUB_TOKEN }}` is exposed. The token can then be used with the permissions granted to this workflow.

Run analysis of untrusted PR contents without a privileged token, and perform any token-bearing reporting in a separate trusted job that does not check out or execute the PR head.

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