ywh/cvss-bundle

CVSS integration in Symfony2

1.0 2018-01-14 00:01 UTC

README

Latest Stable Version Total Downloads Latest Unstable Version License

This bundle provides integration for CVSS in your Symfony2 Project.

License: MIT

Installation

Step 1: Download the Bundle

Open a command console, enter your project directory and execute the following command to download the latest stable version of this bundle:

    $ composer require ywh/cvss-bundle

This command requires you to have Composer installed globally, as explained in the installation chapter of the Composer documentation.

2: Enable the Bundle

When using Flex, this step is handled automatically.

Then, enable the bundle by adding the following line in the app/AppKernel.php file of your project:


    // app/AppKernel.php

    class AppKernel extends Kernel
    {
        public function registerBundles()
        {
            $bundles = array(
                // ...

                new YWH\CvssBundle\YWHCvssBundle(),
            );

            // ...
        }

        // ...
    }

3: Configure the bundle

# app/config/config.yml
ywh_cvss:
    translation_domain: 'cvss'

Cvss form type

Basic exemple

use YWH\CvssBundle\Form\Type\Cvss3Type;
//...
$builder->add('cvss', Cvss3Type::class);

Advanced exemple

use YWH\CvssBundle\Form\Type\Cvss3Type;
//...
$builder->add('cvss', Cvss3Type::class, array(
    'options' => array(),
    'base_options' => array(
        'required' => true,
    ),
    'temporal' => true,
    'temporal_options' => array(
        'required' => false,
    ),
    'environmental' => true,
    'environmental_options' => array(
        'required' => false,
    ),
));

Cvss3 validator

use YWH\CvssBundle\Validator\Constraints as CvssAssert;

class MyEntity 
{
    //...
    
    /**
     * ...
     * @CvssAssert\Cvss3
     */
    private $cvss;
    
    //...
}