Skip to content

address object

An address object describes a physical or virtual address, or a range of addresses, in an “addressable region” (memory or a binary file).

address object

Tip

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

docs/assets/sarif/address.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"
                }
            },
            "addresses": [
                {
                    "absoluteAddress": 1024,
                    "kind": "module",
                    "name": "Multitool.exe"
                },
                {
                    "absoluteAddress": 1400,
                    "relativeAddress": 376,
                    "kind": "header",
                    "name": "Sections",
                    "offsetFromParent": 376,
                    "parentIndex": 0
                },
                {
                    "absoluteAddress": 1536,
                    "relativeAddress": 512,
                    "kind": "section",
                    "name": ".text",
                    "offsetFromParent": 136,
                    "parentIndex": 1
                }
            ],
            "results": []
        }
    ]
}
examples/address.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\Address;
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);

$address1 = new Address();
$address1->setName('Multitool.exe');
$address1->setKind('module');
$address1->setAbsoluteAddress(1024);

$address2 = new Address();
$address2->setName('Sections');
$address2->setKind('header');
$address2->setParentIndex(0);
$address2->setOffsetFromParent(376);
$address2->setAbsoluteAddress(1400);
$address2->setRelativeAddress(376);

$address3 = new Address();
$address3->setName('.text');
$address3->setKind('section');
$address3->setParentIndex(1);
$address3->setOffsetFromParent(136);
$address3->setAbsoluteAddress(1536);
$address3->setRelativeAddress(512);

$run = new Run();
$run->setTool($tool);
$run->addAddresses([$address1, $address2, $address3]);

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

Note

This alternative API is available since release 1.5.0

examples/builder/address.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/address.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')
                    )
            )
            ->addAddress(
                $factory->address()
                    ->name('Multitool.exe')
                    ->kind('module')
                    ->absoluteAddress(1024)
            )
            ->addAddress(
                $factory->address()
                    ->name('Sections')
                    ->kind('header')
                    ->parentIndex(0)
                    ->offsetFromParent(376)
                    ->absoluteAddress(1400)
                    ->relativeAddress(376)
            )
            ->addAddress(
                $factory->address()
                    ->name('.text')
                    ->kind('section')
                    ->parentIndex(1)
                    ->offsetFromParent(136)
                    ->absoluteAddress(1536)
                    ->relativeAddress(512)
            )
    )
;