|
| 1 | +--- |
| 2 | +name: Upload a SARIF file |
| 3 | +example: octokit.codeScanning.uploadSarif({ owner, repo, commit_sha, ref, sarif, tool_name }) |
| 4 | +route: POST /repos/{owner}/{repo}/code-scanning/sarifs |
| 5 | +scope: codeScanning |
| 6 | +type: API method |
| 7 | +--- |
| 8 | + |
| 9 | +# Upload a SARIF file |
| 10 | + |
| 11 | +Upload a SARIF file containing the results of a code scanning analysis to make the results available in a repository. |
| 12 | +For private repos, you must use an access token with the `repo` scope. For public repos, you must use an access token with `public_repo` and `repo:security_events` scopes. GitHub Apps must have the `security_events` write permission to use this endpoint. |
| 13 | + |
| 14 | +```js |
| 15 | +octokit.codeScanning.uploadSarif({ |
| 16 | + owner, |
| 17 | + repo, |
| 18 | + commit_sha, |
| 19 | + ref, |
| 20 | + sarif, |
| 21 | + tool_name, |
| 22 | +}); |
| 23 | +``` |
| 24 | + |
| 25 | +## Parameters |
| 26 | + |
| 27 | +<table> |
| 28 | + <thead> |
| 29 | + <tr> |
| 30 | + <th>name</th> |
| 31 | + <th>required</th> |
| 32 | + <th>description</th> |
| 33 | + </tr> |
| 34 | + </thead> |
| 35 | + <tbody> |
| 36 | + <tr><td>owner</td><td>yes</td><td> |
| 37 | + |
| 38 | +</td></tr> |
| 39 | +<tr><td>repo</td><td>yes</td><td> |
| 40 | + |
| 41 | +</td></tr> |
| 42 | +<tr><td>commit_sha</td><td>yes</td><td> |
| 43 | + |
| 44 | +The commit SHA of the code scanning analysis file. |
| 45 | + |
| 46 | +</td></tr> |
| 47 | +<tr><td>ref</td><td>yes</td><td> |
| 48 | + |
| 49 | +The full Git reference of the code scanning analysis file, formatted as `refs/heads/<branch name>`. |
| 50 | + |
| 51 | +</td></tr> |
| 52 | +<tr><td>sarif</td><td>yes</td><td> |
| 53 | + |
| 54 | +A Base64 string representing the SARIF file to upload. You must first compress your SARIF file using [`gzip`](http://www.gnu.org/software/gzip/manual/gzip.html) and then translate the contents of the file into a Base64 encoding string. |
| 55 | + |
| 56 | +</td></tr> |
| 57 | +<tr><td>checkout_uri</td><td>no</td><td> |
| 58 | + |
| 59 | +The base directory used in the analysis, as it appears in the SARIF file. |
| 60 | +This property is used to convert file paths from absolute to relative, so that alerts can be mapped to their correct location in the repository. |
| 61 | + |
| 62 | +</td></tr> |
| 63 | +<tr><td>started_at</td><td>no</td><td> |
| 64 | + |
| 65 | +The time that the analysis run began. This is a timestamp in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format: `YYYY-MM-DDTHH:MM:SSZ`. |
| 66 | + |
| 67 | +</td></tr> |
| 68 | +<tr><td>tool_name</td><td>yes</td><td> |
| 69 | + |
| 70 | +The name of the tool used to generate the code scanning analysis alert. |
| 71 | + |
| 72 | +</td></tr> |
| 73 | + </tbody> |
| 74 | +</table> |
| 75 | + |
| 76 | +See also: [GitHub Developer Guide documentation](https://developer.github.com/v3/code-scanning/#upload-a-sarif-analysis). |
0 commit comments