threadFlow object
A threadFlow
object is a sequence of code locations that specify a possible path through a single thread of execution
such as an operating system thread or a fiber.
Tip
Generated with following command : php ./resources/serialize.php codeFlow docs/assets/sarif 192
docs/assets/sarif/codeFlow.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": [
{
"message": {
"text": "A result object"
},
"codeFlows": [
{
"threadFlows": [
{
"locations": [
{
"location": {
"physicalLocation": {
"artifactLocation": {
"uri": "ui/window.c",
"uriBaseId": "SRCROOT"
},
"region": {
"startLine": 42
}
}
},
"state": {
"x": {
"text": "42"
},
"y": {
"text": "54"
},
"x+y": {
"text": "96"
}
},
"nestingLevel": 0,
"executionOrder": 2
}
],
"id": "thread-123",
"message": {
"text": "A threadFlow object"
}
}
],
"message": {
"text": "A codeFlow object"
}
}
]
}
]
}
]
}
examples/codeFlow.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\ArtifactLocation;
use Bartlett\Sarif\Definition\CodeFlow;
use Bartlett\Sarif\Definition\Location;
use Bartlett\Sarif\Definition\Message;
use Bartlett\Sarif\Definition\MultiformatMessageString;
use Bartlett\Sarif\Definition\PhysicalLocation;
use Bartlett\Sarif\Definition\Region;
use Bartlett\Sarif\Definition\Result;
use Bartlett\Sarif\Definition\Run;
use Bartlett\Sarif\Definition\ThreadFlow;
use Bartlett\Sarif\Definition\ThreadFlowLocation;
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);
$threadFlowLocation = new ThreadFlowLocation();
$location = new Location();
$artifactLocation = new ArtifactLocation();
$artifactLocation->setUri('ui/window.c');
$artifactLocation->setUriBaseId('SRCROOT');
$physicalLocation = new PhysicalLocation();
$physicalLocation->setArtifactLocation($artifactLocation);
$region = new Region();
$region->setStartLine(42);
$physicalLocation->setRegion($region);
$location->setPhysicalLocation($physicalLocation);
$threadFlowLocation->setLocation($location);
$x = new MultiformatMessageString();
$x->setText('42');
$y = new MultiformatMessageString();
$y->setText('54');
$xy = new MultiformatMessageString();
$xy->setText('96');
$threadFlowLocation->addAdditionalProperties([
'x' => $x,
'y' => $y,
'x+y' => $xy,
]);
$threadFlowLocation->setNestingLevel(0);
$threadFlowLocation->setExecutionOrder(2);
$message = new Message();
$message->setText('A threadFlow object');
$threadFlow = new ThreadFlow();
$threadFlow->setId('thread-123');
$threadFlow->setMessage($message);
$threadFlow->addLocations([$threadFlowLocation]);
$message = new Message();
$message->setText('A codeFlow object');
$codeFlow = new CodeFlow();
$codeFlow->setMessage($message);
$codeFlow->addThreadFlows([$threadFlow]);
$message = new Message();
$message->setText('A result object');
$result = new Result();
$result->setMessage($message);
$result->addCodeFlows([$codeFlow]);
$run = new Run();
$run->setTool($tool);
$run->addResults([$result]);
$log = new SarifLog([$run]);
Note
This alternative API is available since release 1.5.0
examples/builder/codeFlow.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/codeFlow.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')
)
)
->addResult(
$factory->result()
->message(
$factory->message()
->text('A result object')
)
->addCodeFlow(
$factory->codeFlow()
->threadFlow(
$factory->threadFlow()
->addLocation(
$factory->threadFlowLocation()
->location(
$factory->location()
->physicalLocation(
$factory->physicalLocation()
->artifactLocation(
$factory->artifactLocation()
->uri('ui/window.c')
->uriBaseId('SRCROOT')
)
->region(
$factory->region()
->startLine(42)
)
)
)
->nestingLevel(0)
->executionOrder(2)
->addAdditionalProperty('x', '42')
->addAdditionalProperty('y', '54')
->addAdditionalProperty('x+y', '96')
)
->id('thread-123')
->message('A threadFlow object')
)
->message('A codeFlow object')
)
)
)
;