Interview Prep/DevSecOps/SAST, SCA and secrets scanning in CI

`upload-sarif` fails with `Resource not accessible by integration`

BeginnerTroubleshootingSAST, SCA and secrets scanning in CI
Answer

Likely causes → The GITHUB_TOKEN lacks security-events: write, often because the org default is read-only, or the run is from a fork.

Diagnose → Check the workflow's permissions: block and the run's "Set up job" log, which lists granted permissions.

Fix →

permissions:
  contents: read
  security-events: write

For fork PRs, upload from a workflow_run workflow instead of granting write to untrusted code.

Prevent → Declare least-privilege permissions: per job in every workflow.

All DevSecOps questions Roadmap: Security in the pipeline

More on SAST, SCA and secrets scanning in CI