Skip to content
This repository has been archived by the owner on Mar 18, 2024. It is now read-only.

Commit

Permalink
imrove OS detection
Browse files Browse the repository at this point in the history
  • Loading branch information
mms-gianni committed Aug 3, 2021
1 parent 95f79d4 commit ba37a55
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 0 deletions.
1 change: 1 addition & 0 deletions app/Http/Controllers/ReportController.php
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ public function apiCreateVuln($report_uid, $image_uid, Request $request)
$i->image_uid = $image_uid;
$i->target = $target['Target'];
$i->target_type = $target['Type'];
$i->is_os = filter_var($target['isOS'], FILTER_VALIDATE_BOOLEAN);
$i->save();
if (isset($target['Vulnerabilities'])) {
foreach ($target['Vulnerabilities'] as $vuln) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ public function up()
target_type character varying COLLATE pg_catalog."default",
report_uid character varying COLLATE pg_catalog."default",
image_uid character varying COLLATE pg_catalog."default",
is_os boolean,
CONSTRAINT k_target_trivy_pkey PRIMARY KEY (uid),
CONSTRAINT k_target_trivy_report_uid_fkey FOREIGN KEY (report_uid)
REFERENCES public.k_reports (uid) MATCH SIMPLE
Expand Down
39 changes: 39 additions & 0 deletions database/migrations/2021_08_03_100000_add_target_os.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class AddTargetOs extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
$create_sql[] = <<<SQL
ALTER TABLE public.k_target_trivy ADD COLUMN IF NOT EXISTS isOS boolean
SQL;
foreach ($create_sql as $sql ) {
DB::statement($sql);
}
}

/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
$create_sql[] = <<<SQL
ALTER TABLE public.k_target_trivy DROP COLUMN isOS;
SQL;

foreach ($create_sql as $sql ) {
DB::statement($sql);
}
}
}

0 comments on commit ba37a55

Please sign in to comment.