PHP code example of xternalsoft / lararmis-vipr

1. Go to this page and download the library: Download xternalsoft/lararmis-vipr library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

xternalsoft / lararmis-vipr example snippets


return [
    'base_url' => env('ARMIS_VIPR_BASE_URL', 'https://silkapi.us1.app.silk.security'),
    'client_id' => env('ARMIS_VIPR_CLIENT_ID'),
    'client_secret' => env('ARMIS_VIPR_CLIENT_SECRET'),
    'token' => env('ARMIS_VIPR_TOKEN'),
];

use Xternalsoft\LararmisVipr\Facades\LararmisVipr;

$response = LararmisVipr::auth()->authenticate('your_client_id', 'your_client_secret');
$token = $response->dto()->token;

$info = LararmisVipr::auth()->tokenInfo();

use Xternalsoft\LararmisVipr\Facades\LararmisVipr;

$response = LararmisVipr::assets()->list(page: 1, pageSize: 20);
$dto = $response->dto(); // Returns AssetListResponseData

$response = LararmisVipr::assets()->listByCursor(cursor: 'MTcwMDY2NTQzMjE', pageSize: 15);
$dto = $response->dto(); // Returns AssetSearchResponseData

$response = LararmisVipr::assets()->get('ast_01HBF3P2Y8K3M4J5N6P7Q8R9S0');
$asset = $response->dto(); // Returns AssetData

$filters = [
    [
        'field' => 'region',
        'value' => [
            ['operator' => 'equals', 'value' => 'us-east-1'],
        ]
    ]
];

$response = LararmisVipr::assets()->search(filters: $filters, pageSize: 10);
$dto = $response->dto(); // Returns AssetSearchResponseData

$response = LararmisVipr::assets()->fields(fieldName: 'source', sortBy: 'count');

$response = LararmisVipr::users()->list(page: 1, pageSize: 10);
$dto = $response->dto(); // Returns UserListResponseData

$response = LararmisVipr::users()->create(
    emailAddress: '[email protected]',
    displayName: 'John Doe',
    permissions: 'admin'
);
$user = $response->dto(); // Returns UserData

$response = LararmisVipr::users()->get('[email protected]');
$user = $response->dto(); // Returns UserData

$response = LararmisVipr::users()->update(
    emailAddress: '[email protected]',
    displayName: 'Jonathan Doe'
);

$response = LararmisVipr::users()->delete('[email protected]');

$reports = LararmisVipr::reports()->listScheduledCustomReports()->dto(); // Returns CustomReportData[]

$runs = LararmisVipr::reports()->listCustomReportRuns('scheduled_report_id')->dto(); // Returns CustomReportRunData[]

$run = LararmisVipr::reports()->executeCustomReportRun('scheduled_report_id')->dto(); // Returns CustomReportRunData

$runStatus = LararmisVipr::reports()->getCustomReportRunStatus('report_id')->dto(); // Returns CustomReportRunData with downloadUrl

$latestRun = LararmisVipr::reports()->latestReadyRun('scheduled_report_id'); // Returns CustomReportRunData or null

$response = LararmisVipr::jobs()->status('job_id');
$job = $response->dto(); // Returns JobStatusData

use Xternalsoft\LararmisVipr\Support\ReportDownloader;

$latestRun = LararmisVipr::reports()->latestReadyRun('scheduled_report_id');

$localPath = storage_path('app/reports/findings.json.gz');
ReportDownloader::download($latestRun, $localPath);

use Xternalsoft\LararmisVipr\Support\ReportReader;

// Read NDJSON (.json.gz)
$records = ReportReader::streamNdjsonGz(storage_path('app/reports/findings.json.gz'));

// Read CSV (.csv.gz)
// $records = ReportReader::streamCsvGz(storage_path('app/reports/findings.csv.gz'));

// Process records sequentially using low memory
$records
    ->chunk(500)
    ->each(function ($chunk) {
        DB::table('findings')->insert($chunk->toArray());
    });
bash
php artisan vendor:publish --tag="lararmis-vipr-config"