scorecard-action icon indicating copy to clipboard operation
scorecard-action copied to clipboard

"The 'repo_token' variable is empty." on PR Runs of Scorecard Action

Open nibanks opened this issue 3 years ago • 12 comments

I believe https://github.com/ossf/scorecard-action/pull/71 regressed PR runs of scorecard, where we don't actually need the repo_token because we aren't pushing the results, just checking them:

https://github.com/microsoft/msquic/runs/5259593124?check_suite_focus=true

nibanks avatar Feb 19 '22 16:02 nibanks

Thanks for the report. Fyi, we have not advertised support for pull request yet (it's not in the workflow example we provide). This should have been clearer from us. The token is used for two reason:

  1. to access GitHubAPIs - in this case you're right it's not needed. I think the checkout should not need the token. But I wonder if GitHub may still require one sometimes?
  2. Uploading the results as SARIF is still performed, and that's how the GitHub UI manages to show fixed and/or additional results introduced by the given PR.

We will try to add PR support in the next release.

laurentsimon avatar Feb 22 '22 16:02 laurentsimon

@laurentsimon any idea on when you might add PR support? I will be blocking dependabot updates (i.e. this PR) for this action until I can safely merge the latest without breaking our existing behavior.

nibanks avatar Mar 05 '22 15:03 nibanks

We are waiting to hear back from GitHub team for better support for the default secrets.GITHUB_TOKEN, because we don't want to ask users to expose the secrets to PRs in general. So no specific timeline yet. Sorry about the inconvenience.

cc @josepalafox

laurentsimon avatar Mar 07 '22 16:03 laurentsimon

Why is that necessary? As you mentioned in your (1) above no token should be necessary since you'd just be querying state, not publishing anything for PRs.

nibanks avatar Mar 07 '22 16:03 nibanks

token is not necessary for scorecard to run, but the workflow (example today) still exposes it to the code running in the PR. It's low risk (scorecard does not run external code unless someone finds a bug), but we're trying to follow best practices.

laurentsimon avatar Mar 07 '22 16:03 laurentsimon

ebpf-for-windows project is now also blocked updating beyond 1.0.3 due to this issue.

dthaler avatar Mar 28 '22 20:03 dthaler

@dthaler have you tested with v1.0.4?

laurentsimon avatar Mar 28 '22 20:03 laurentsimon

@dthaler have you tested with v1.0.4?

Yes, we see intermittant failures, such as in https://github.com/microsoft/ebpf-for-windows/runs/5726574449?check_suite_focus=true (whereas https://github.com/microsoft/ebpf-for-windows/runs/5725496349?check_suite_focus=true passed referencing the same commit)

dthaler avatar Mar 28 '22 20:03 dthaler

Great finding, intermittent problems, that's really interesting. Could you use this PR's branch (my personal repo) to add logs to the action? I think we may be able to point out the problems with this additional log - just this file needs to be updated https://github.com/ossf/scorecard-action/pull/155/files#diff-6f9d41d046756f0ddc2fcee0626bdb50100d12b88f293734eff742818e03efa2

laurentsimon avatar Mar 28 '22 21:03 laurentsimon

FYI, in the ebpf-for-windows project, I used dependabot ignore this minor version to block upgrading the scorecard-action from 1.0.3 until this issue is fixed or 1.1 comes out, since the PR to upgrade to 1.0.3 was accidentally merged and everything started failing and had to be reverted.

dthaler avatar Apr 04 '22 15:04 dthaler

@laurentsimon @naveensrinivasan fyi good testcase to add to our e2e tests - workflows which have pull_request (or other non-supported events enabled).

azeemshaikh38 avatar Apr 04 '22 17:04 azeemshaikh38

I'l spend some time to reproduce the problem soon.

laurentsimon avatar Apr 04 '22 22:04 laurentsimon

@laurentsimon

We will try to add PR support in the next release.

Now that v2.0 is out, is there any progress on fixing this PR?

dthaler avatar Sep 13 '22 16:09 dthaler

Not officially supported yet, but it should work if you use

publish_results: ${{ github.event_name != 'pull_request' }}

I will create a PR to have the equivalent of ${{ github.event_name != 'pull_request' }} in the code.

laurentsimon avatar Sep 13 '22 17:09 laurentsimon