secret-detection fails for forked pipelines

Summary

Our Category:Secret Detection job currently fails for forked pipelines, see https://gitlab.com/gitlab-org/gitlab/-/jobs/1517575115.

Looks like we have the origin remote hardcoded into our job definition but this won't resolve properly for a forked pipeline given the origin will reference the target project not the source.

Steps to reproduce

  1. Create MR from fork
  2. Run forked pipeline for target project

Example Project

https://gitlab.com/gitlab-org/gitlab/-/jobs/1517575115

What is the current bug behavior?

secret-detection fails

What is the expected correct behavior?

secret-detection runs correctly

Relevant logs and/or screenshots

https://gitlab.com/gitlab-org/gitlab/-/jobs/1517575115

Output of checks

This bug happens on GitLab.com

Possible fixes

I'm unsure if we have any ENV we can rely on in this context conditionally but we should sub origin for the correct remote to fetch commits from.