Set up webhooks
Perform these steps in Semgrep AppSec Platform to set up webhooks:1
Create a webhook integration:i. On the navigation menu, click Settings > Integrations > Add.ii. Click Webhook.iii. In the Name field, enter a name for the integration.iv. In the Webhook URL field, enter the target webhook URL for the integration.v. Optional: Provide a Signature Secret. The secret must be at least 15 characters long. If you provide a secret, Semgrep sends an
X-Semgrep-Signature-256 signature header with the payload.vi. Optional: If you use the Semgrep Network Broker, and your webhook URL is only accessible from your private network, enable the Use Network Broker toggle.vii. Click Subscribe.2
Turn notifications on:i. When creating or editing the desired policy, click Add action > Call a webhook, then select the webhook integration you created.
Test webhooks
To verify that Semgrep can post to your URL:1
Navigate to Settings > Integrations
2
Click the Test button of the webhook integration you want to test.
3
The following sample code in Python shows how to verify the signature in the
X-Semgrep-Signature-256 header:Notification and alert de-duplication
Notifications are sent only the first time a given finding is detected. When running a diff-aware scan, Semgrep doesn’t notify you when a pull request has a finding that existed on the base branch already, even if that line is moved or re-indented. Semgrep also tracks notifications that have already been sent, so subsequent scans of the same changes in a pull request won’t result in duplicate notifications.NOTESee Findings in CI for more information about how Semgrep tracks a finding through its lifetime.
Semgrep findings object
The following is an example of asemgrep_finding object sent by Semgrep:
numeric_id field represents the finding’s ID in Semgrep AppSec Platform.
Semgrep scan object
The following is an example of asemgrep_scan object sent by Semgrep:
Semgrep supply chain incident object
The following example shows asemgrep_supply_chain_incident object sent by Semgrep:
SCHEMA COMPATABILITYSemgrep may add new fields to the payload at any time without changing the
schema_version. Configure your webhook endpoint to ignore unrecognized fields. Semgrep increments the schema_version only for breaking changes, such as removing or renaming fields, or changing the type or meaning of an existing field.incident_packages field details which dependencies are affected by an incident and matching_projects lists the projects that used those packages as of their last full scan. For large incidents or deployments with many projects, Semgrep truncates items and sets truncated while reporting the full number under total_count. Visit advisories_url for the most up-to-date information.
Each incident_id uniquely identifies an incident.
The description and blog_url fields are optional and can be null.