Hi Haonan, Chris, and all,

Thanks Haonan for researching options for fork PR SonarCloud checks.

While using workflow_run with artifacts is a common workaround for PRs from
forks, it introduces several notable security and technical risks that we
should consider carefully:

   1. Security & Token Exposure (Artifact Poisoning):

   Because workflow_run executes in the context of the main repository with
   elevated privileges and access to sensitive secrets (such as the SonarCloud
   token), untrusted code from a fork build could produce malicious build
   artifacts. If the scanning step consumes or processes those artifacts
   without strict sanitization, it creates an attack vector where compromised
   inputs or code could compromise repository secrets or leak sensitive
   credentials.
   2. Asynchronous Matching & Traceability Issues:

   The workflow_run approach operates asynchronously after the initial PR
   build completes. Correlating build outputs, coverage artifacts, and PR
   numbers across detached workflow runs can lead to reporting mismatches or
   delayed feedback on PRs, making it harder for contributors to trace
   failures back to specific commits.
   3. Build & Environment Inconsistencies:

   Splitting execution across two distinct workflows (one running in the
   fork context and one in the upstream workflow_run context) can introduce
   discrepancies in JDK/Maven setup, dependency resolution, or cached states.
   This risks inconsistent test or Sonar results between fork builds and
   upstream runs.

Given these security and maintenance concerns, Chris, do you have any
alternative recommendations or better suggestions for handling SonarCloud
analysis on fork PRs safely?

Best regards,
----------------------
Yuan Tian

Reply via email to