xternalsoft/laravel-patrowl

A clean, fluent, and developer-friendly PHP wrapper for the Patrowl API

Maintainers

Package info

github.com/XternalSoft/laravel-patrowl

Homepage

pkg:composer/xternalsoft/laravel-patrowl

Transparency log

Fund package maintenance!

xternalsoft

Statistics

Installs: 21

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

v1.3.2 2026-07-03 13:36 UTC

README

Latest Version on Packagist GitHub Tests Action Status GitHub Code Style Action Status Total Downloads

A clean, fluent, and developer-friendly PHP wrapper for the Patrowl API. This package allows you to easily interact with assets, asset groups, and tags within the Patrowl ecosystem from your Laravel application.

Support us

We invest a lot of resources into creating best in class open source packages. You can support us by buying one of our paid products.

We highly appreciate you sending us a postcard from your hometown, mentioning which of our package(s) you are using. You'll find our address on our contact page. We publish all received postcards on our virtual postcard wall.

Installation

You can install the package via composer:

composer require xternalsoft/laravel-patrowl

You can publish and run the migrations with:

php artisan vendor:publish --tag="laravel-patrowl-migrations"
php artisan migrate

You can publish the config file with:

php artisan vendor:publish --tag="laravel-patrowl-config"

This is the contents of the published config file:

return [
    'api_token' => env('PATROWL_API_TOKEN'),
    'base_url' => env('PATROWL_API_BASE_URL', 'https://dashboard.cloud.patrowl.io/api/auth'),
    'timeout' => 30,
    'default_organization_id' => env('PATROWL_DEFAULT_ORGANIZATION_ID'),
    'limit' => env('PATROWL_PAGINATION_LIMIT', 100),
];

Optionally, you can publish the views using

php artisan vendor:publish --tag="laravel-patrowl-views"

Usage

Configuration

Add your Patrowl API token and base URL to your .env file:

PATROWL_API_TOKEN=your-api-token
PATROWL_API_BASE_URL=https://dashboard.cloud.patrowl.io/api/auth
PATROWL_DEFAULT_ORGANIZATION_ID=1

Basic Usage

You can use the LaravelPatrowl facade to interact with the API:

use Xternalsoft\LaravelPatrowl\Facades\LaravelPatrowl;

// Get all assets
$assets = LaravelPatrowl::assets()->all();

foreach ($assets->items() as $asset) {
    echo $asset->value;
}

Managing Assets

Create an Asset

use Xternalsoft\LaravelPatrowl\Data\CreateAssetData;

$data = new CreateAssetData(
    value: 'example.com',
    description: 'My new asset',
    organization: 1
);

$asset = LaravelPatrowl::assets()->create($data);

Add a Tag to an Asset

use Xternalsoft\LaravelPatrowl\Data\AddTagToAssetData;

$data = new AddTagToAssetData(
    value: 'production',
    organization: 1
);

$response = LaravelPatrowl::assets()->addTag($assetId, $data);

if ($response->successful()) {
    // Tag added successfully
}

Remove a Tag from an Asset

$response = LaravelPatrowl::assets()->removeTag($assetId, $tagId);

Risks

List and Get Risks

// List all risks
$risks = LaravelPatrowl::risks()->all();

foreach ($risks->items() as $risk) {
    echo $risk->title . ' (' . $risk->severity->name . ')';
}

// Get a specific risk
$risk = LaravelPatrowl::risks()->get($riskId);

Export Risks to CSV

// Export all risks to CSV format
$csvContent = LaravelPatrowl::risks()->exportCsv();

file_put_contents('risks_export.csv', $csvContent);

List Risk Topics and Subtopics

// List all risk topics
$topics = LaravelPatrowl::risks()->topics();

foreach ($topics->items() as $topic) {
    echo $topic->title . ' (' . $topic->slug . ')';
}

// List all risk subtopics
$subtopics = LaravelPatrowl::risks()->subtopics();

foreach ($subtopics->items() as $subtopic) {
    echo $subtopic->title . ' (' . $subtopic->slug . ')';
}

Asset Groups

Create an Asset Group

use Xternalsoft\LaravelPatrowl\Data\CreateAssetGroupData;

$data = new CreateAssetGroupData(
    title: 'My Production Assets',
    description: 'Assets in production environment',
    organization: 1,
    assets: [123, 456] // List of asset IDs to add after creation
);

$group = LaravelPatrowl::assetGroups()->create($data);

List and Get Asset Groups

// List all asset groups
$groups = LaravelPatrowl::assetGroups()->all();

// Get a specific group
$group = LaravelPatrowl::assetGroups()->get($groupId);

Add a Tag to an Asset Group

use Xternalsoft\LaravelPatrowl\Data\AddTagToAssetData;

$data = new AddTagToAssetData(
    value: 'critical-infrastructure',
    organization: 1
);

$response = LaravelPatrowl::assetGroups()->addTag($groupId, $data);

Asset Tags

List Tags

To retrieve a paginated, filterable list of all tags, use the tags method. Passing 'related' => true returns complete related asset and asset group data:

// List all available tags with complete related data
$tags = LaravelPatrowl::assetTags()->tags([
    'related' => true,
]);

foreach ($tags as $tag) {
    echo $tag->value;
    echo $tag->description;
    
    // View linked assets
    foreach ($tag->assets as $asset) {
        echo $asset['value'];
    }
}

Bulk Associate Tags with Assets

To bulk associate multiple tags with multiple assets across an organization:

use Xternalsoft\LaravelPatrowl\Data\BulkAssociateTagsData;

$bulkData = new BulkAssociateTagsData(
    assetIds: [2635579],
    tagIds: [4241],
    organizationId: 1815
);

$response = LaravelPatrowl::assetTags()->associate($bulkData);

if ($response->successful()) {
    echo $response->json('message'); // "Associated 1 tags with 1 assets."
}

Bulk Dissociate Tags from Assets

To bulk dissociate multiple tags from multiple assets (DELETE /assets/tags/):

$response = LaravelPatrowl::assetTags()->dissociate(
    assetIds: [2635579],
    tagIds: [4241]
);

if ($response->successful()) {
    echo $response->json('message'); // "Dissociated 1 tags from 1 assets."
}

List Raw Asset Tags

Alternatively, to query the raw tag indices, use:

$assetTags = LaravelPatrowl::assetTags()->all();

Controls

// List all controls with auto-pagination
$controls = LaravelPatrowl::controls()->all();

foreach ($controls as $control) {
    echo $control->title;
}

// Get a specific control in detail (including impacted assets and vulnerabilities)
$control = LaravelPatrowl::controls()->get($controlId);

foreach ($control->assetsImpacted as $asset) {
    echo $asset->value;
}

Filtering Controls

You can filter controls and utilize the built-in integer-backed enums:

use Xternalsoft\LaravelPatrowl\Enums\ControlStatusEnum;
use Xternalsoft\LaravelPatrowl\Enums\ControlResultEnum;

// Filter controls by severity and status
$controls = LaravelPatrowl::controls()->all([
    'severity' => 'critical',
    'status' => ControlStatusEnum::Finished->value,
]);

foreach ($controls as $control) {
    if ($control->result === ControlResultEnum::Impacted) {
        // Handle impacted asset controls
    }
}

Testing

composer test

Changelog

Please see CHANGELOG for more information on what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security Vulnerabilities

Please review our security policy on how to report security vulnerabilities.

Credits

License

The MIT License (MIT). Please see License File for more information.