Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Scorecards.yml: do not upload the result in the security dashboard if it is a pull request #1820

Closed
joycebrum opened this issue Nov 14, 2022 · 17 comments
Assignees

Comments

@joycebrum
Copy link

joycebrum commented Nov 14, 2022

When the action is configured to run in pull request, although it do not try to publish results (since 2.0.4), it tries to upload the results to Github's code scanning dashboard and returns an error (https://github.com/systemd/systemd/actions/runs/3276042271/jobs/5391618343).

I've manually disable it using the following configuration:

 # Upload the results to GitHub's code scanning dashboard.
      - name: "Upload to code-scanning"
        if: ${{ github.event_name != 'pull_request' }}
        uses: github/codeql-action/upload-sarif@5f532563584d71fdef14ee64d17bafb34f751ce5 # tag=v1.0.26
        with:
          sarif_file: results.sarif

I think the best solution is to avoid uploading the results to the security dashboard if it is a pull request, what do you think? I can suggest the PR with the changes if so.

@joycebrum joycebrum changed the title Bug: do not upload the result in the security dashboard if it is a pull request Scorecards.yml: do not upload the result in the security dashboard if it is a pull request Nov 14, 2022
@Phantsure
Copy link
Contributor

This feels more of an issue with codeql action
I found two issues which are related to this in codeql action:
github/codeql-action#390
github/codeql-action#1061 (comment)

@Phantsure
Copy link
Contributor

Does this problem also occurs with v2? That template has older version

@joycebrum
Copy link
Author

I've tested using codeql-action 2.1.31 and I've got the same error https://github.com/joycebrum/SQLGame/actions/runs/3489036386/jobs/5838617362

Seems to be really related to the issues but it does not seemed solved.

@Phantsure
Copy link
Contributor

Yeah not solved yet. I feel adding an optional tigger on condition and having an optional condition to run when triggered in pull request does seem correct. And this would be failing for all the code-scanning template.

@Phantsure
Copy link
Contributor

Does "results.sarif" not exist for that case?

@joycebrum
Copy link
Author

Actually we don't have a published sarif in scorecard action (see https://github.com/ossf/scorecard-action/pull/935/files) when running on pull request, because pull_request do not have the necessary token-id: write permissions.

@Phantsure
Copy link
Contributor

I guess pull_request_target should get through

@joycebrum
Copy link
Author

I've testes using pull_request_target instead of pull_request and, for some reason, the scorecard does not run. I think that's because pull_request_target runs in the context of the base of the pull request, rather than in the context of the merge commit, as the pull_request event does.

@Phantsure
Copy link
Contributor

Yes, for pull_request_target to work it should be already present in base branch while raising pull request. I guessed it would work as sometimes token permission differs with ref when specifying no explicit permissions.

@laurentsimon
Copy link
Contributor

pull_request_target should not be used, because it would expose PAT tokens, if users have configured one.

@Phantsure
Copy link
Contributor

Actually we don't have a published sarif in scorecard action (see https://github.com/ossf/scorecard-action/pull/935/files) when running on pull request, because pull_request do not have the necessary token-id: write permissions.

I feel it is by design of scorecard action. Right @laurentsimon?
I don't see an action item on us here if this is a design choice on scorecard.

@joycebrum
Copy link
Author

@Phantsure I think the only action item we could do here is the one I suggested in the PR (#1821) to avoid the upload if it is a PR, which seemed to be enough to fix the run on the test cases I've tested (like systemd)

@laurentsimon
Copy link
Contributor

laurentsimon commented Dec 8, 2022

@joycebrum Can you file an issue on scorecard-action? It seems like in your run, the sarif file only contains:

   "$schema": "https://raw.githubusercontent.com/oasis-tcs/sarif-spec/master/Schemata/sarif-schema-2.1.0.json",
   "version": "2.1.0",
   "runs": []
}

In a test PR I sent https://github.com/ossf/scorecard/actions/runs/3561057797/jobs/5981621304, you can see the SARIF contained information.

Maybe that is where the problem comes from, given that empty SARIF files seem to trigger github/codeql-action#390

Enabling SARIF on pull requests lets users see which lines are changing the scorecard results, so it'd be nice to keep it.

@joycebrum
Copy link
Author

Sure, I'll do it.

@Phantsure
Copy link
Contributor

@Phantsure I think the only action item we could do here is the one I suggested in the PR (#1821) to avoid the upload if it is a PR, which seemed to be enough to fix the run on the test cases I've tested (like systemd)

@laurentsimon Do you also want this change in starter workflow or want to keep track in new issue here created by @joycebrum ?

@laurentsimon
Copy link
Contributor

Let's close this issue and find out what's going on in scorecard. This may be a bug there. We'll re-open here if needed. @joycebrum ok with this?

@joycebrum
Copy link
Author

Sure, it makes sense. Thanks for the support @Phantsure and @laurentsimon

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 a pull request may close this issue.

4 participants