artifact object
An artifact
object represents a single artifact.
Tip
Generated with following command : php ./resources/serialize.php artifact docs/assets/sarif 192
docs/assets/sarif/artifact.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"
}
},
"artifacts": [
{
"location": {
"uri": "file:///C:/Code/app.zip"
},
"mimeType": "application/zip"
},
{
"location": {
"uri": "docs/intro.docx"
},
"parentIndex": 0,
"mimeType": "application/vnd.openxmlformats-officedocument.wordprocessingml.document"
},
{
"parentIndex": 1,
"offset": 17522,
"length": 4050,
"mimeType": "application/x-contoso-animation"
}
],
"results": []
}
]
}
examples/artifact.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\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);
$artifact1 = new Artifact();
$artifactLocation1 = new ArtifactLocation();
$artifactLocation1->setUri('file:///C:/Code/app.zip');
$artifact1->setLocation($artifactLocation1);
$artifact1->setMimeType('application/zip');
$artifact2 = new Artifact();
$artifactLocation2 = new ArtifactLocation();
$artifactLocation2->setUri('docs/intro.docx');
$artifact2->setLocation($artifactLocation2);
$artifact2->setMimeType('application/vnd.openxmlformats-officedocument.wordprocessingml.document');
$artifact2->setParentIndex(0);
$artifact3 = new Artifact();
$artifact3->setOffset(17522);
$artifact3->setLength(4050);
$artifact3->setMimeType('application/x-contoso-animation');
$artifact3->setParentIndex(1);
$run = new Run();
$run->setTool($tool);
$run->addArtifacts([$artifact1, $artifact2, $artifact3]);
$log = new SarifLog([$run]);
Note
This alternative API is available since release 1.5.0
examples/builder/artifact.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/artifact.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')
)
)
->addArtifact(
$factory->artifact()
->location(
$factory->artifactLocation()
->uri('file:///C:/Code/app.zip')
)
->mimeType('application/zip')
)
->addArtifact(
$factory->artifact()
->location(
$factory->artifactLocation()
->uri('docs/intro.docx')
)
->parentIndex(0)
->mimeType('application/vnd.openxmlformats-officedocument.wordprocessingml.document')
)
->addArtifact(
$factory->artifact()
->offset(17522)
->length(4050)
->parentIndex(1)
->mimeType('application/x-contoso-animation')
)
)
;