PHP code example of marmelatze / cvss

1. Go to this page and download the library: Download marmelatze/cvss 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/ */

    

marmelatze / cvss example snippets


composer 

use YWH\Cvss;

$cvss = new Cvss3();
$cvss->setVector('CVSS:3.0/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:N');

Symfony\Component\OptionsResolver\Exception\UndefinedOptionsException

Symfony\Component\OptionsResolver\Exception\MissingOptionsException

Symfony\Component\OptionsResolver\Exception\InvalidOptionsException

use YWH\Cvss;

$cvss = new Cvss3();
$cvss->setVector('CVSS:3.0/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:N');

echo 'Base score: ' $cvss->getBaseScore();
// Base score: 0

use YWH\Cvss;

$cvss = new Cvss3();
$cvss->setVector('CVSS:3.0/AV:N/AC:L/PR:H/UI:N/S:U/C:N/I:L/A:N/E:U/RL:T/RC:C');

echo 'Base score: ' $cvss->getBaseScore();
// Base score: 2.7
echo 'Temporal score: ' $cvss->getTemporalScore();
// Temporal score: 2.4

use YWH\Cvss;

$cvss = new Cvss3();
$cvss->setVector('CVSS:3.0/AV:N/AC:L/PR:H/UI:N/S:C/C:H/I:H/A:H/E:U/RL:T/RC:U/CR:H/IR:M/AR:H/MAV:A/MAC:H/MPR:L/MUI:R/MS:U/MC:H/MI:N/MA:L');

echo 'Base score: ' $cvss->getBaseScore();
// Base score: 9.1
echo 'Temporal score: ' $cvss->getTemporalScore();
// Temporal score: 7.4
echo 'Environmental score: ' $cvss->getEnvironmentalScore();
// Environmental score: 7.4