You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: content/developers/overview/secret-scanning-partner-program.md
+41-19Lines changed: 41 additions & 19 deletions
Original file line number
Diff line number
Diff line change
@@ -59,26 +59,25 @@ Send this information to <a href="mailto:secret-scanning@github.com">secret-scan
59
59
60
60
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.
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.
75
+
The message body is a JSON array that contains one or more objects, with each object representing a single secret match. Your endpoint should be able to handle requests with a large number of matches without timing out. The keys for each secret match are:
77
76
78
77
***token**: The value of the secret match.
79
78
***type**: The unique name you provided to identify your regular expression.
80
79
***url**: The public URL where the match was found (may be empty)
81
-
***source**: Where the token was found on GitHub.
80
+
***source**: Where the token was found on {% data variables.product.prodname_dotcom %}.
82
81
83
82
The list of valid values for `source` are:
84
83
@@ -97,26 +96,32 @@ The list of valid values for `source` are:
97
96
98
97
### Implement signature verification in your secret alert service
99
98
100
-
We strongly recommend you implement signature validation in your secret alert service to ensure that the messages you receive are genuinely from {% data variables.product.prodname_dotcom %} and not malicious.
99
+
The HTTP request to your service will also contain headers that we strongly recommend using
100
+
to validate the messages you receive are genuinely from {% data variables.product.prodname_dotcom %}, and are not malicious.
101
+
102
+
The two HTTP headers to look for are:
103
+
104
+
*`GITHUB-PUBLIC-KEY-IDENTIFIER`: Which `key_identifier` to use from our API
105
+
*`GITHUB-PUBLIC-KEY-SIGNATURE`: Signature of the payload
101
106
102
-
You can retrieve the {% data variables.product.prodname_dotcom %} secret scanning public key from https://api.github.com/meta/public_keys/secret_scanning and validate the message using the `ECDSA-NIST-P256V1-SHA256` algorithm.
107
+
You can retrieve the {% data variables.product.prodname_dotcom %} secret scanning public key from https://api.github.com/meta/public_keys/secret_scanning and validate the message using the `ECDSA-NIST-P256V1-SHA256` algorithm. The endpoint
108
+
will provide several `key_identifier` and public keys. You can determine which public
109
+
key to use based on the value of `GITHUB-PUBLIC-KEY-IDENTIFIER`.
103
110
104
111
{% note %}
105
112
106
113
**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)."
107
114
108
115
{% endnote %}
109
116
110
-
Assuming you receive the following message, the code snippets below demonstrate how you could perform signature validation.
111
-
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.
112
-
113
117
{% note %}
114
118
115
119
**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.
The following code snippets demonstrate how you could perform signature validation.
152
+
The code examples assume you've set an environment variable called `GITHUB_PRODUCTION_TOKEN` with a generated [personal access token](https://github.com/settings/tokens) (PAT) to avoid hitting rate limits. The PAT does not need any scopes/permissions.
0 commit comments