diff --git a/app/Commands/Composer.php b/app/Commands/Composer.php index 57e7769..ffd18c3 100644 --- a/app/Commands/Composer.php +++ b/app/Commands/Composer.php @@ -65,7 +65,9 @@ public function handle() : int $coordinates = $parser->getCoordinates($packages); - $ossindex = new OSSIndex(); + // Bit odd but a way of getting the package version and sending it to the class without + // it knowing too much about Laravel-Zero + $ossindex = new OSSIndex(null, config('app.version')); $response = $ossindex->getVulns($coordinates); diff --git a/app/OSSIndex/OSSIndex.php b/app/OSSIndex/OSSIndex.php index 131c786..062270e 100644 --- a/app/OSSIndex/OSSIndex.php +++ b/app/OSSIndex/OSSIndex.php @@ -17,12 +17,16 @@ class OSSIndex * @param Client|null $client */ public function __construct( - $client = null + $client = null, + $version = "not-set" ) { if ($client == null) { $this->client = new Client( ['base_uri' => 'https://ossindex.sonatype.org/api/', 'timeout' => 100.0, + 'headers' => [ + 'User-Agent' => "bach-client/{$version}" + ], ] ); } else {