Description
Hi,
I'm facing an issue uploading a SARIF file using upload-sarif@v1 on a self-hosted runner.
Here is my code (in a composite action) :
- name: Scan image
id: scan
uses: sysdiglabs/scan-action@v3
with:
[...]
- uses: github/codeql-action/upload-sarif@v1
with:
sarif_file: ${{ steps.scan.outputs.sarifReport }}
This works great when I push / PR to a branch called develop
but an issue is happening when I apply the same composite action to master
branch. It looks like for some reason the upload-sarif@v1 action doesn't call the API correctly ?
Here are the logs on develop (omitting env variables) :
Run github/codeql-action/upload-sarif@v1
with:
sarif_file: ./sarif.json
checkout_path: /home/azureuser/actions-runner-2/runner/_work/my-app/my-app
token: ***
matrix: {
"node-version": "16.3.0",
"env": {
"name": "development"
}
}
env:
[...]
Uploading results
Processing sarif files: ["./sarif.json"]
Uploading results
Successfully uploaded results
I can see the uploaded results on the security tab of the github repo.
Here are the logs on master:
Processing sarif files: ["./sarif.json"]
Uploading results
Error: Invalid request.
master does not match /^refs\/(heads|pull|tags)\/.*$/.
RequestError [HttpError]: Invalid request.
master does not match /^refs\/(heads|pull|tags)\/.*$/.
at /home/azureuser/actions-runner-2/runner/_work/_actions/github/codeql-action/v1/node_modules/@octokit/request/dist-node/index.js:66:23
at processTicksAndRejections (internal/process/task_queues.js:93:5)
at async Job.doExecute (/home/azureuser/actions-runner-2/runner/_work/_actions/github/codeql-action/v1/node_modules/bottleneck/light.js:405:18) {
name: 'HttpError',
status: 422,
headers: {
'access-control-allow-origin': '*',
'access-control-expose-headers': 'ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Used, X-RateLimit-Resource, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type, Deprecation, Sunset',
connection: 'close',
'content-length': '141',
'content-security-policy': "default-src 'none'",
'content-type': 'application/json; charset=utf-8',
date: 'Thu, 28 Oct 2021 06:12:21 GMT',
'referrer-policy': 'origin-when-cross-origin, strict-origin-when-cross-origin',
server: 'GitHub.com',
'strict-transport-security': 'max-age=31536000; includeSubdomains; preload',
vary: 'Accept-Encoding, Accept, X-Requested-With',
'x-content-type-options': 'nosniff',
'x-frame-options': 'deny',
'x-github-media-type': 'github.v3; format=json',
'x-github-request-id': '0805:5EAA:1CCB18D:34AE888:617A3F44',
'x-ratelimit-limit': '500',
'x-ratelimit-remaining': '490',
'x-ratelimit-reset': '1635404509',
'x-ratelimit-resource': 'code_scanning_upload',
'x-ratelimit-used': '10',
'x-xss-protection': '0'
},
request: {
method: 'PUT',
url: 'https://api.github.com/repos/MYORG/my-app/code-scanning/analysis',
headers: {
accept: 'application/vnd.github.v3+json',
'user-agent': 'CodeQL-Action/1.0.20 octokit-core.js/3.1.2 Node.js/12.13.1 (linux; x64)',
authorization: 'token [REDACTED]',
'content-type': 'application/json; charset=utf-8'
},
...
The API doc mention that ref is Required. The full Git reference, formatted as refs/heads/<branch name>,refs/pull/<number>/merge, or refs/pull/<number>/head.
: https://docs.github.com/en/rest/reference/code-scanning#upload-an-analysis-as-sarif-data
Using this action we have no control other what the action sends to the API so it is not possible in our end to enforce the full git reference.
Is this a known issue ? Any reason why I am facing here in a master
branch but not on other branches ?