-
Notifications
You must be signed in to change notification settings - Fork 104
Add Radar webook docs #1164
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
jonathanfrappier
wants to merge
5
commits into
main
Choose a base branch
from
RADAR-882/add-radar-webhook-docs
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+173
−0
Open
Add Radar webook docs #1164
Changes from 1 commit
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
077d1de
Add Radar webook docs
jonathanfrappier c6b40af
Update content/hcp-docs/content/docs/vault-radar/get-started/set-up-a…
jonathanfrappier 6ab6daf
Update content/hcp-docs/content/docs/vault-radar/get-started/set-up-a…
jonathanfrappier 91f3f24
Update content/hcp-docs/content/docs/vault-radar/get-started/set-up-a…
jonathanfrappier 1d856c1
Merge branch 'main' into RADAR-882/add-radar-webhook-docs
jonathanfrappier File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
118 changes: 118 additions & 0 deletions
118
...docs/content/docs/vault-radar/get-started/set-up-alerting/webhooks/payloads.mdx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,118 @@ | ||
| --- | ||
| page_title: Webhook - payloads | ||
| description: >- | ||
| Interpreting the contents of webhook payloads | ||
| --- | ||
|
|
||
| # Webhook Payloads | ||
|
|
||
| Webhooks provide a mechanism to receive near-real-time events from software | ||
| applications to a specified endpoint. Webhooks may be used as a substitute for | ||
| polling an external API for updates. | ||
|
|
||
| Once a webhook connection and a subscription have been configured, Vault Radar | ||
| will send events that match the filter set on the webhook subscription to the | ||
| HTTPS endpoint configured on the webhook connection. Events are sent to the | ||
| HTTPS endpoint as an HTTP POST request. | ||
|
|
||
| ## Delivery Headers | ||
jonathanfrappier marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| Headers included on every delivery: | ||
|
|
||
| - `Content-type: application/json; charset=utf-8` — the request content type. | ||
| - `X-HCP-Radar-Subscription-Name` — the human readable name of the subscription whose filter matched the event. | ||
| - `X-HCP-Radar-Subscription-ID` — the unique identifier for the subscription whose filter matched the event. | ||
| - `X-HCP-Radar-Message-ID` — the unique identifier for this message. | ||
| - `X-HCP-Radar-Signature` — HMAC signature of the request body using SHA-512 in the format `sha512=<hex digest>`. | ||
| - `X-HCP-Radar-Timestamp` — UNIX timestamp (seconds since epoch) added when the message is signed with an HMAC signature. | ||
|
|
||
| ## Payload Schema | ||
jonathanfrappier marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| Vault Radar sends a single-event JSON payload for each webhook delivery. | ||
|
|
||
| |Field |Type |Description | | ||
| |--------------------|----------|----------------------------------------------------------------------------------| | ||
| |`version` | `string` | Webhook payload version | | ||
| |`event_id` | `string` | Unique identifier for the event | | ||
| |`event_type` | `string` | High level type for the event | | ||
| |`event_subtype` | `string` | Optional subtype for the event | | ||
| |`description` | `string` | Full description of the finding | | ||
| |`summary` | `string` | Short summary text for display | | ||
| |`severity` | `string` | Severity label for the finding | | ||
| |`risk_category` | `string` | Risk category assigned by Radar | | ||
| |`data_source` | `object` | Information about the data source that produced the finding | | ||
| |`event_details` | `object` | Additional fields vary by `data_source.type` | | ||
| |`managed_locations` | `list` | List of managed locations in Vault. See [Copy leaked secrets into HashiCorp Vault](/hcp/docs/vault-radar/remediate-secrets/copy-secrets) for more information | | ||
| |`links` | `object` | Deep links to Vault Radar and data source | | ||
|
|
||
| **Example payload:** | ||
|
|
||
| <CodeBlockConfig hideClipboard> | ||
|
|
||
| ```json | ||
| { | ||
| "version": "1.0", | ||
| "event_id": "f1f50398-8452-410a-b906-c20c8905c800", | ||
| "event_type": "REPO_SCAN_MATCH", | ||
| "event_subtype": "password_assignment", | ||
| "description": "Password assignment", | ||
| "summary": "Discovered some form of secret assignment in the resource. Best practice is to store the secret in a secret manager and revoke this found secret.", | ||
| "severity": "high", | ||
| "risk_category": "secrets", | ||
| "data_source": { | ||
| "type": "GitHub Cloud", | ||
| "name": "hashidemo", | ||
| "resource": "repo-with-secret" | ||
| }, | ||
| "event_details": { | ||
| "author": "[email protected]", | ||
| "author_time": "2025-04-11 15:14:06+00:00", | ||
| "commit_hash": "07a88a2b410fc53f804165c280fd38f4109b3a98", | ||
| "repo_file_path": "file.json" | ||
| }, | ||
| "managed_locations": { | ||
| "hashicorp_vault": [ | ||
| { | ||
| "location": "vault://vault.hashicorp.cloud:8200/admin/kv?key=mysecret&version=1", | ||
| "is_latest": true, | ||
| "is_created_by_radar": true | ||
| } | ||
| ] | ||
| }, | ||
| "links": { | ||
| "vault_radar_link": "<deep link to radar portal>", | ||
| "data_source_provider_link": "<deep link to data source>" | ||
| } | ||
| ``` | ||
|
|
||
| </CodeBlockConfig> | ||
|
|
||
| ## Validate HMAC signature | ||
|
|
||
| Vault Radar signs payloads using HMAC-SHA512 to generate a hex-encoded digest of | ||
| the raw request body (UTF-8) hashed with the configured shared secret. The HMAC | ||
| signature is placed in the `X-HCP-Radar-Signature` header with the `sha512=` | ||
| prefix. Vault Radar will include the `X-HCP-Radar-Signature` and | ||
| `X-HCP-Radar-Timestamp` headers when a secret is configured. | ||
|
|
||
| To validate the HMAC signature: | ||
|
|
||
| 1. Compute HMAC-SHA512 of the raw request body using the webhook secret shared with Vault Radar during webhook connection setup. | ||
|
|
||
| 1. Convert the result to lowercase hexadecimal. | ||
|
|
||
| 1. Compare the computed value with the value in the `X-HCP-Radar-Signature` header. | ||
|
|
||
| The following example validates the HMAC signature in Python 3.12 using the built-in `hmac` library: | ||
|
|
||
| ```python | ||
| import hmac | ||
| import hashlib | ||
|
|
||
| secret = b"my-secret-key" | ||
| message = b"message to verify" | ||
| signature = "sha512=expected_signature_hex" | ||
|
|
||
| computed = hmac.new(secret, message, hashlib.sha512).hexdigest() | ||
| is_valid = hmac.compare_digest(signature.split('=')[1], computed) | ||
| ``` | ||
42 changes: 42 additions & 0 deletions
42
...cp-docs/content/docs/vault-radar/get-started/set-up-alerting/webhooks/setup.mdx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,42 @@ | ||
| --- | ||
| page_title: Setup alerting - webhook | ||
| description: >- | ||
| Set up alerts using webhooks for Vault Radar. | ||
| --- | ||
|
|
||
| # Set up alerting - webhook | ||
|
|
||
| @include 'beta-feature.mdx' | ||
|
|
||
| You can receive alerts from HCP Vault Radar to a custom HTTPS endpoint using a webhook. | ||
|
|
||
| ## Prerequisites | ||
|
|
||
| - An HTTPS endpoint configured to receive HTTP POST requests | ||
|
|
||
| ## Create a webhook connection | ||
|
|
||
| 1. Click **Settings** from the side navigation. | ||
|
|
||
| 1. Under the **Integration** menu, click **Webhook**. | ||
|
|
||
| 1. Click **+ Add connection**. | ||
|
|
||
| 1. Enter a unique name for the connection and a valid HTTPS endpoint configured to receive HTTP POST requests. | ||
|
|
||
| 1. Enter a token used to generate HMAC tokens for Vault Radar events for authorization. | ||
|
|
||
| Vault Radar will send a test message to your specified HTTPS endpoint validate the connection details. | ||
|
|
||
| ## Create a webhook subscription | ||
|
|
||
| 1. Click the **Connection Name**. | ||
|
|
||
| 1. Click **+ Subscription**. | ||
|
|
||
| 1. Enter a name for the subscription and the saved filter(s) you would like the subscription to use. | ||
|
|
||
| 1. Click **Test & Save**. | ||
|
|
||
| Vault Radar events matching your filters will send events via webhooks to the | ||
| specified HTTPS endpoint. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.