Skip to content

Commit 19b38a6

Browse files
authored
Update secret-scanning partner onboarding to add more 'gotcha' information for signature validation (#5637)
1 parent bcb7053 commit 19b38a6

1 file changed

Lines changed: 21 additions & 21 deletions

File tree

content/developers/overview/secret-scanning.md

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@ topics:
1515

1616
When a match of your secret format is found in a public repository, a payload is sent to an HTTP endpoint of your choice.
1717

18-
When a match of your secret format is found in a private repository configured for {% data variables.product.prodname_secret_scanning %}, then repository admins are alerted and can view and manage the {% data variables.product.prodname_secret_scanning %} results on {% data variables.product.prodname_dotcom %}. For more information, see "[Managing alerts from {% data variables.product.prodname_secret_scanning %}](/github/administering-a-repository/managing-alerts-from-secret-scanning)."
18+
When a match of your secret format is found in a private repository configured for {% data variables.product.prodname_secret_scanning %}, then repository admins and the committer are alerted and can view and manage the {% data variables.product.prodname_secret_scanning %} result on {% data variables.product.prodname_dotcom %}. For more information, see "[Managing alerts from {% data variables.product.prodname_secret_scanning %}](/github/administering-a-repository/managing-alerts-from-secret-scanning)."
1919

20-
This article describes how you can partner with {% data variables.product.prodname_dotcom %} as a service provider and join the {% data variables.product.prodname_secret_scanning %} program.
20+
This article describes how you can partner with {% data variables.product.prodname_dotcom %} as a service provider and join the {% data variables.product.prodname_secret_scanning %} partner program.
2121

2222
### The {% data variables.product.prodname_secret_scanning %} process
2323

@@ -54,7 +54,7 @@ Send this information to <a href="mailto:secret-scanning@github.com">secret-scan
5454

5555
#### Create a secret alert service
5656

57-
Create a public, internet accessible HTTP endpoint at the URL you provided to us. When a match of your regular expression is found in a public repository, {% data variables.product.prodname_dotcom %} will send a HTTP `POST` message to your endpoint.
57+
Create a public, internet accessible HTTP endpoint at the URL you provided to us. When a match of your regular expression is found in a public repository, {% data variables.product.prodname_dotcom %} will send an HTTP `POST` message to your endpoint.
5858

5959
##### Example POST sent to your endpoint
6060

@@ -64,16 +64,10 @@ Host: HOST
6464
Accept: */*
6565
Content-Type: application/json
6666
GITHUB-PUBLIC-KEY-IDENTIFIER: 90a421169f0a406205f1563a953312f0be898d3c7b6c06b681aa86a874555f4a
67-
GITHUB-PUBLIC-KEY-SIGNATURE: MEUCICop4nvIgmcY4+mBG6Ek=
67+
GITHUB-PUBLIC-KEY-SIGNATURE: MEQCIA6C6L8ZYvZnqgV0zwrrmRab10QmIFV396gsba/WYm9oAiAI6Q+/jNaWqkgG5YhaWshTXbRwIgqIK6Ru7LxVYDbV5Q==
6868
Content-Length: 0123
6969
70-
[
71-
{
72-
"token": "X-Header-Bearer: as09dalkjasdlfkjasdf09a",
73-
"type": "ACompany_API_token",
74-
"url": "https://github.com/octocat/Hello-World/commit/123456718ee16e59dabbacb1b4049abc11abc123"
75-
}
76-
]
70+
[{"token":"NMIfyYncKcRALEXAMPLE","type":"mycompany_api_token","url":"https://github.com/octocat/Hello-World/commit/123456718ee16e59dabbacb1b4049abc11abc123"}]
7771
```
7872

7973
The message body is a JSON array that contains one or more objects with the following contents. When multiple matches are found, {% data variables.product.prodname_dotcom %} may send a single message with more than one secret match. Your endpoint should be able to handle requests with a large number of matches without timing out.
@@ -90,12 +84,18 @@ You can retrieve the {% data variables.product.prodname_dotcom %} secret scannin
9084

9185
{% note %}
9286

93-
**Note**: When you send a request to the public key endpoint above, you may hit rate limits. To avoid hitting rate limits, you can use a personal access token as suggested below, or use a conditional request. For more information, see "[Getting started with the REST API](/rest/guides/getting-started-with-the-rest-api#conditional-requests)."
87+
**Note**: When you send a request to the public key endpoint above, you may hit rate limits. To avoid hitting rate limits, you can use a personal access token (no scopes required) as suggested in the samples below, or use a conditional request. For more information, see "[Getting started with the REST API](/rest/guides/getting-started-with-the-rest-api#conditional-requests)."
9488

9589
{% endnote %}
9690

9791
Assuming you receive the following message, the code snippets below demonstrate how you could perform signature validation.
98-
The code also assumes you've set an environment variable called `GITHUB_PRODUCTION_TOKEN` with a generated PAT (https://github.com/settings/tokens). The token does not need any permissions set.
92+
The code snippets assume you've set an environment variable called `GITHUB_PRODUCTION_TOKEN` with a generated PAT (https://github.com/settings/tokens) to avoid hitting rate limits. The PAT does not need any scopes/permissions.
93+
94+
{% note %}
95+
96+
**Note**: The signature was generated using the raw message body. So it's important you also use the raw message body for signature validation, instead of parsing and stringifying the JSON, to avoid rearranging the message or changing spacing.
97+
98+
{% endnote %}
9999

100100
**Sample message sent to verify endpoint**
101101
```http
@@ -104,10 +104,10 @@ Host: HOST
104104
Accept: */*
105105
content-type: application/json
106106
GITHUB-PUBLIC-KEY-IDENTIFIER: 90a421169f0a406205f1563a953312f0be898d3c7b6c06b681aa86a874555f4a
107-
GITHUB-PUBLIC-KEY-SIGNATURE: MEUCICxTWEpKo7BorLKutFZDS6ie+YFg6ecU7kEA6rUUSJqsAiEA9bK0Iy6vk2QpZOOg2IpBhZ3JRVdwXx1zmgmNAR7Izpc=
107+
GITHUB-PUBLIC-KEY-SIGNATURE: MEUCIQDKZokqnCjrRtw0tni+2Ltvl/uiMJ1EGumEsp1BsNr32AIgQY1YXD2nlj+XNfGK4rBfkMJ1JDOQcYXxa2sY8FNkrKc=
108108
Content-Length: 0000
109109
110-
[{"token": "some_token", "type": "some_type", "url": "some_url"}]
110+
[{"token":"some_token","type":"some_type","url":"some_url"}]
111111
```
112112

113113
**Validation sample in Go**
@@ -130,14 +130,14 @@ import (
130130
)
131131

132132
func main() {
133-
payload := `[{"token": "some_token", "type": "some_type", "url": "some_url"}]`
133+
payload := `[{"token":"some_token","type":"some_type","url":"some_url"}]`
134134

135135
kID := "90a421169f0a406205f1563a953312f0be898d3c7b6c06b681aa86a874555f4a"
136136

137-
kSig := "MEUCICxTWEpKo7BorLKutFZDS6ie+YFg6ecU7kEA6rUUSJqsAiEA9bK0Iy6vk2QpZOOg2IpBhZ3JRVdwXx1zmgmNAR7Izpc="
137+
kSig := "MEUCIQDKZokqnCjrRtw0tni+2Ltvl/uiMJ1EGumEsp1BsNr32AIgQY1YXD2nlj+XNfGK4rBfkMJ1JDOQcYXxa2sY8FNkrKc="
138138

139139
// Fetch the list of GitHub Public Keys
140-
req, err := http.NewRequest("GET", "https://api.github.com/meta/public_keys/token_scanning", nil)
140+
req, err := http.NewRequest("GET", "https://api.github.com/meta/public_keys/secret_scanning", nil)
141141
if err != nil {
142142
fmt.Printf("Error preparing request: %s\n", err)
143143
os.Exit(1)
@@ -249,16 +249,16 @@ require 'json'
249249
require 'base64'
250250

251251
payload = <<-EOL
252-
[{"token": "some_token", "type": "some_type", "url": "some_url"}]
252+
[{"token":"some_token","type":"some_type","url":"some_url"}]
253253
EOL
254254

255255
payload = payload
256256

257-
signature = "MEUCICxTWEpKo7BorLKutFZDS6ie+YFg6ecU7kEA6rUUSJqsAiEA9bK0Iy6vk2QpZOOg2IpBhZ3JRVdwXx1zmgmNAR7Izpc="
257+
signature = "MEUCIQDKZokqnCjrRtw0tni+2Ltvl/uiMJ1EGumEsp1BsNr32AIgQY1YXD2nlj+XNfGK4rBfkMJ1JDOQcYXxa2sY8FNkrKc="
258258

259259
key_id = "90a421169f0a406205f1563a953312f0be898d3c7b6c06b681aa86a874555f4a"
260260

261-
url = URI.parse('https://api.github.com/meta/public_keys/token_scanning')
261+
url = URI.parse('https://api.github.com/meta/public_keys/secret_scanning')
262262

263263
raise "Need to define GITHUB_PRODUCTION_TOKEN environment variable" unless ENV['GITHUB_PRODUCTION_TOKEN']
264264
request = Net::HTTP::Get.new(url.path)

0 commit comments

Comments
 (0)