Received payload
{
"webhook_patrolserver": 1,
"identifier": "webhook.test",
"event_id": 18,
"webhook_id": 219
}
The data needed to fetch the event will be delivered in JSON format. We guarantee that events will be accessible for fetching for a maximum of 30 days.
Definition
GET http://api.patrolserver.com/webhooks/:webhook_id:/events/:event_id:
Request
$ curl http://api.patrolserver.com/webhooks/21/events/52?key=KEY&secret=SECRET
The following response is an example of the webhook.new_server_issues
event, which gets triggered when your server becomes vulnerable or when new issues are found.
Response
{
"server_id": 1,
"new_issues": [
{
"title": "Upgrade your PHP to a supported version.",
"description": "Your current PHP version (5.2.27) is no longer supported, it is advised to upgrade to a supported version.",
"software": {
"version": "5.2.17",
"software": {
"name": "PHP",
"canonical_name": "php"
}
}
}
]
}
We'll wrap this in an example, imagine you've hosted a PHP file on your website with the the following URL: http://example.com/webhook.php
. This particular URL is added on your dashboard and we will send a webhook event whenever one occurs. The code below are the contents of the file.
// Use the Singleton or create a separate PatrolSdk\Patrol object
use PatrolSdk\Singleton as Patrol;
Patrol::setApiKey('<% user.key %>');
Patrol::setApiSecret('<% user.secret %>');
Patrol::webhook('webhook.scan_finished', function ($event) {
// Get the Server object from the server_id
$server = Patrol::server($event['server_id']);
// Get the installed software
$software = $server->allSoftware();
// The variable $software contains all the software that we've found on your server
});
Patrol::webhook('webhook.new_server_issues', function ($event) {
$server = Patrol::server($event['server_id']);
$issues = $event['new_issues'];
foreach ($issues as $issue) {
$installed = $issue['software'];
$software = $installed['software'];
$version = "unknown";
if (isset($installed['version']))
$version = $installed['version'];
if (isset($installed['versions']))
$version = implode(', ',$installed['versions']);
$str = $software['name'] . ' ' . $version . ' is no longer safe.';
// $str is a textual representation of the software with current version no longer being safe.
}
});