Create a draft GitHub Security Advisory
curl --request POST \
--url https://www.hckrt.com/api/v1/admin/reports/{id}/github/advisories \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"repoId": 123456789,
"summary": "Access control issue in example-project",
"description": "Version 2.0.0 corrects an access control issue in example-project.",
"ecosystem": "npm",
"packageName": "example-project",
"affectedVersions": "< 2.0.0",
"patchedVersions": "2.0.0"
}
'import requests
url = "https://www.hckrt.com/api/v1/admin/reports/{id}/github/advisories"
payload = {
"repoId": 123456789,
"summary": "Access control issue in example-project",
"description": "Version 2.0.0 corrects an access control issue in example-project.",
"ecosystem": "npm",
"packageName": "example-project",
"affectedVersions": "< 2.0.0",
"patchedVersions": "2.0.0"
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
repoId: 123456789,
summary: 'Access control issue in example-project',
description: 'Version 2.0.0 corrects an access control issue in example-project.',
ecosystem: 'npm',
packageName: 'example-project',
affectedVersions: '< 2.0.0',
patchedVersions: '2.0.0'
})
};
fetch('https://www.hckrt.com/api/v1/admin/reports/{id}/github/advisories', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://www.hckrt.com/api/v1/admin/reports/{id}/github/advisories",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'repoId' => 123456789,
'summary' => 'Access control issue in example-project',
'description' => 'Version 2.0.0 corrects an access control issue in example-project.',
'ecosystem' => 'npm',
'packageName' => 'example-project',
'affectedVersions' => '< 2.0.0',
'patchedVersions' => '2.0.0'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://www.hckrt.com/api/v1/admin/reports/{id}/github/advisories"
payload := strings.NewReader("{\n \"repoId\": 123456789,\n \"summary\": \"Access control issue in example-project\",\n \"description\": \"Version 2.0.0 corrects an access control issue in example-project.\",\n \"ecosystem\": \"npm\",\n \"packageName\": \"example-project\",\n \"affectedVersions\": \"< 2.0.0\",\n \"patchedVersions\": \"2.0.0\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://www.hckrt.com/api/v1/admin/reports/{id}/github/advisories")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"repoId\": 123456789,\n \"summary\": \"Access control issue in example-project\",\n \"description\": \"Version 2.0.0 corrects an access control issue in example-project.\",\n \"ecosystem\": \"npm\",\n \"packageName\": \"example-project\",\n \"affectedVersions\": \"< 2.0.0\",\n \"patchedVersions\": \"2.0.0\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://www.hckrt.com/api/v1/admin/reports/{id}/github/advisories")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"repoId\": 123456789,\n \"summary\": \"Access control issue in example-project\",\n \"description\": \"Version 2.0.0 corrects an access control issue in example-project.\",\n \"ecosystem\": \"npm\",\n \"packageName\": \"example-project\",\n \"affectedVersions\": \"< 2.0.0\",\n \"patchedVersions\": \"2.0.0\"\n}"
response = http.request(request)
puts response.read_body{
"ghsaId": "GHSA-2345-6789-CFGH",
"url": "https://github.com/example/project/security/advisories/GHSA-2345-6789-CFGH",
"state": "draft",
"timelineCommentRecorded": true
}{
"type": "<string>",
"title": "<string>",
"status": 123,
"detail": "<string>"
}{
"type": "<string>",
"title": "<string>",
"status": 123,
"detail": "<string>"
}{
"type": "<string>",
"title": "<string>",
"status": 123,
"detail": "<string>"
}{
"type": "<string>",
"title": "<string>",
"status": 123,
"detail": "<string>"
}{
"type": "<string>",
"title": "<string>",
"status": 123,
"detail": "<string>"
}{
"type": "<string>",
"title": "<string>",
"status": 123,
"detail": "<string>"
}API Reference
Create a draft GitHub Security Advisory
Requires reports:triage and a SuperAdmin or StandardAdmin role for the report. The report must be accepted or closed and the chosen repository must be enabled for its organization. The GitHub App installation requires Repository security advisories write permission. Hackrate derives severity and CWE from the report and adds an internal timeline comment after creation. Each POST can create a draft. Check the GitHub repository for the draft before retrying a request with an uncertain outcome.
POST
/
reports
/
{id}
/
github
/
advisories
Create a draft GitHub Security Advisory
curl --request POST \
--url https://www.hckrt.com/api/v1/admin/reports/{id}/github/advisories \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"repoId": 123456789,
"summary": "Access control issue in example-project",
"description": "Version 2.0.0 corrects an access control issue in example-project.",
"ecosystem": "npm",
"packageName": "example-project",
"affectedVersions": "< 2.0.0",
"patchedVersions": "2.0.0"
}
'import requests
url = "https://www.hckrt.com/api/v1/admin/reports/{id}/github/advisories"
payload = {
"repoId": 123456789,
"summary": "Access control issue in example-project",
"description": "Version 2.0.0 corrects an access control issue in example-project.",
"ecosystem": "npm",
"packageName": "example-project",
"affectedVersions": "< 2.0.0",
"patchedVersions": "2.0.0"
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
repoId: 123456789,
summary: 'Access control issue in example-project',
description: 'Version 2.0.0 corrects an access control issue in example-project.',
ecosystem: 'npm',
packageName: 'example-project',
affectedVersions: '< 2.0.0',
patchedVersions: '2.0.0'
})
};
fetch('https://www.hckrt.com/api/v1/admin/reports/{id}/github/advisories', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://www.hckrt.com/api/v1/admin/reports/{id}/github/advisories",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'repoId' => 123456789,
'summary' => 'Access control issue in example-project',
'description' => 'Version 2.0.0 corrects an access control issue in example-project.',
'ecosystem' => 'npm',
'packageName' => 'example-project',
'affectedVersions' => '< 2.0.0',
'patchedVersions' => '2.0.0'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://www.hckrt.com/api/v1/admin/reports/{id}/github/advisories"
payload := strings.NewReader("{\n \"repoId\": 123456789,\n \"summary\": \"Access control issue in example-project\",\n \"description\": \"Version 2.0.0 corrects an access control issue in example-project.\",\n \"ecosystem\": \"npm\",\n \"packageName\": \"example-project\",\n \"affectedVersions\": \"< 2.0.0\",\n \"patchedVersions\": \"2.0.0\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://www.hckrt.com/api/v1/admin/reports/{id}/github/advisories")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"repoId\": 123456789,\n \"summary\": \"Access control issue in example-project\",\n \"description\": \"Version 2.0.0 corrects an access control issue in example-project.\",\n \"ecosystem\": \"npm\",\n \"packageName\": \"example-project\",\n \"affectedVersions\": \"< 2.0.0\",\n \"patchedVersions\": \"2.0.0\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://www.hckrt.com/api/v1/admin/reports/{id}/github/advisories")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"repoId\": 123456789,\n \"summary\": \"Access control issue in example-project\",\n \"description\": \"Version 2.0.0 corrects an access control issue in example-project.\",\n \"ecosystem\": \"npm\",\n \"packageName\": \"example-project\",\n \"affectedVersions\": \"< 2.0.0\",\n \"patchedVersions\": \"2.0.0\"\n}"
response = http.request(request)
puts response.read_body{
"ghsaId": "GHSA-2345-6789-CFGH",
"url": "https://github.com/example/project/security/advisories/GHSA-2345-6789-CFGH",
"state": "draft",
"timelineCommentRecorded": true
}{
"type": "<string>",
"title": "<string>",
"status": 123,
"detail": "<string>"
}{
"type": "<string>",
"title": "<string>",
"status": 123,
"detail": "<string>"
}{
"type": "<string>",
"title": "<string>",
"status": 123,
"detail": "<string>"
}{
"type": "<string>",
"title": "<string>",
"status": 123,
"detail": "<string>"
}{
"type": "<string>",
"title": "<string>",
"status": 123,
"detail": "<string>"
}{
"type": "<string>",
"title": "<string>",
"status": 123,
"detail": "<string>"
}Authorizations
Body
application/json
Response
Draft advisory created in GitHub
Was this page helpful?