Skip to content

externalProperties object

The top-level element of an external property file SHALL be an object which we refer to as an externalProperties object.

externalProperties object

Tip

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

docs/assets/sarif/externalProperties.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"
                }
            },
            "results": []
        }
    ],
    "inlineExternalProperties": [
        {
            "schema": "https://json.schemastore.org/sarif-2.1.0.json",
            "version": "2.1.0",
            "guid": "00001111-2222-1111-8888-555566667777",
            "runGuid": "88889999-AAAA-1111-8888-DDDDEEEEFFFF",
            "externalizedProperties": {
                "team": "Security Assurance Team"
            },
            "artifacts": [
                {
                    "location": {
                        "uri": "apple.png"
                    },
                    "mimeType": "image/png"
                },
                {
                    "location": {
                        "uri": "banana.png"
                    },
                    "mimeType": "image/png"
                }
            ]
        }
    ]
}
examples/externalProperties.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\Artifact;
use Bartlett\Sarif\Definition\ArtifactLocation;
use Bartlett\Sarif\Definition\ExternalProperties;
use Bartlett\Sarif\Definition\PropertyBag;
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');

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

$apple = new Artifact();
$location = new ArtifactLocation();
$location->setUri('apple.png');
$apple->setLocation($location);
$apple->setMimeType('image/png');

$banana = new Artifact();
$location = new ArtifactLocation();
$location->setUri('banana.png');
$banana->setLocation($location);
$banana->setMimeType('image/png');

$propertyBag = new PropertyBag();
$propertyBag->addProperty('team', 'Security Assurance Team');

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

$log = new SarifLog([$run]);
$externalProperties = new ExternalProperties();
$externalProperties->setGuid('00001111-2222-1111-8888-555566667777');
$externalProperties->setRunGuid('88889999-AAAA-1111-8888-DDDDEEEEFFFF');
$externalProperties->addArtifacts([$apple, $banana]);
$externalProperties->setExternalizedProperties($propertyBag);
$log->addInlineExternalProperties([$externalProperties]);

Note

This alternative API is available since release 1.5.0

examples/builder/externalProperties.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/result.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')
                    )
            )
    )
    ->addInlineExternalProperties(
        $factory->externalProperties()
            ->guid('00001111-2222-1111-8888-555566667777')
            ->runGuid('88889999-AAAA-1111-8888-DDDDEEEEFFFF')
            ->addArtifact(
                $factory->artifact()
                    ->location(
                        $factory->artifactLocation()
                            ->uri('apple.png')
                    )
                    ->mimeType('image/png')
            )
            ->addArtifact(
                $factory->artifact()
                    ->location(
                        $factory->artifactLocation()
                            ->uri('banana.png')
                    )
                    ->mimeType('image/png')
            )
            ->externalizedProperties(
                $factory->propertyBag()
                    ->addProperty('team', 'Security Assurance Team')
            )
    )
;