Skip to content

reportingConfiguration object

A reportingConfiguration object contains the information in a reportingDescriptor that a SARIF producer can modify at runtime, before executing its scan.

reportingConfiguration object

Tip

Generated with following command : php ./resources/serialize.php reportingConfiguration docs/assets/sarif 192

docs/assets/sarif/reportingConfiguration.json
{
    "$schema": "https://json.schemastore.org/sarif-2.1.0.json",
    "version": "2.1.0",
    "runs": [
        {
            "tool": {
                "driver": {
                    "name": "CodeScanner",
                    "semanticVersion": "1.1.2-beta.12",
                    "informationUri": "https://codeScanner.dev",
                    "rules": [
                        {
                            "id": "SA2707",
                            "name": "LimitSourceLineLength",
                            "shortDescription": {
                                "text": "Limit source line length for readability."
                            },
                            "defaultConfiguration": {
                                "enabled": true,
                                "level": "warning",
                                "rank": -1,
                                "parameters": {
                                    "maxLength": 120
                                }
                            }
                        }
                    ]
                }
            },
            "results": []
        }
    ]
}
examples/reportingConfiguration.php
<?php declare(strict_types=1);
/**
 * This file is part of the Sarif-PHP-SDK package.
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 *
 * @author Laurent Laville
 */

use Bartlett\Sarif\Definition\MultiformatMessageString;
use Bartlett\Sarif\Definition\PropertyBag;
use Bartlett\Sarif\Definition\ReportingConfiguration;
use Bartlett\Sarif\Definition\ReportingDescriptor;
use Bartlett\Sarif\Definition\Run;
use Bartlett\Sarif\Definition\Tool;
use Bartlett\Sarif\Definition\ToolComponent;
use Bartlett\Sarif\SarifLog;

require_once dirname(__DIR__) . '/vendor/autoload.php';

$driver = new ToolComponent();
$driver->setName('CodeScanner');
$driver->setInformationUri('https://codeScanner.dev');
$driver->setSemanticVersion('1.1.2-beta.12');

$rule = new ReportingDescriptor();
$rule->setId('SA2707');
$rule->setName('LimitSourceLineLength');
$desc = new MultiformatMessageString();
$desc->setText('Limit source line length for readability.');
$rule->setShortDescription($desc);
$reportingConf = new ReportingConfiguration();
$propertyBag = new PropertyBag();
$propertyBag->addProperty('maxLength', 120);
$reportingConf->setParameters($propertyBag);
$rule->setDefaultConfiguration($reportingConf);
$driver->addRules([$rule]);

$tool = new Tool();
$tool->setDriver($driver);

$run = new Run();
$run->setTool($tool);

$log = new SarifLog([$run]);

Note

This alternative API is available since release 1.5.0

examples/builder/reportingConfiguration.php
<?php declare(strict_types=1);
/**
 * This file is part of the Sarif-PHP-SDK package.
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 *
 * @author Laurent Laville
 */

require_once dirname(__DIR__, 2) . '/vendor/autoload.php';

use Bartlett\Sarif\Factory\BuilderFactory;

$factory = new BuilderFactory();

// @link https://github.com/llaville/sarif-php-sdk/blob/1.1/docs/reference/reportingConfiguration.md
$spec = $factory->specification('2.1.0')
    ->addRun(
        $factory->run()
            ->tool(
                $factory->tool()
                    ->driver(
                        $factory->driver()
                            ->name('CodeScanner')
                            ->semanticVersion('1.1.2-beta.12')
                            ->informationUri('https://codeScanner.dev')
                            ->addRule(
                                $factory->rule()
                                    ->id('SA2707')
                                    ->name('LimitSourceLineLength')
                                    ->shortDescription('Limit source line length for readability.')
                                    ->defaultConfiguration(
                                        $factory->configuration()
                                            ->enabled(true)
                                            ->level('warning')
                                            ->rank(-1)
                                            ->parameters([
                                                'maxLength' => 120,
                                            ])
                                    )
                            )
                    )
            )
    )
;