FOSSology  4.5.0-rc1
Open Source License Compliance by Open Source Software
Fossology\Spdx\SpdxAgent Class Reference

SPDX2 agent. More...

Inheritance diagram for Fossology\Spdx\SpdxAgent:
Inheritance graph
Collaboration diagram for Fossology\Spdx\SpdxAgent:
Collaboration graph

Public Member Functions

 processUploadId ($uploadId)
 Given an upload ID, process the items in it. More...
 
- Public Member Functions inherited from Fossology\Lib\Agent\Agent
 __construct ($agentName, $version, $revision)
 
 scheduler_connect ()
 Connect with scheduler and initialize options. More...
 
 heartbeat ($newProcessed)
 Send hear beat to the scheduler. More...
 
 bail ($exitvalue)
 Bail the agent, print the stack and disconnect from scheduler. More...
 
 scheduler_disconnect ($exitvalue)
 Closes connection from scheduler. More...
 
 scheduler_greet ()
 Greet the scheduler at the beginning of connection. More...
 
 initArsTable ()
 Initialize ARS table.
 
 run_scheduler_event_loop ()
 Runs a loop to read commands from scheduler and process them. More...
 

Public Attributes

const OUTPUT_FORMAT_KEY = "outputFormat"
 Argument key for output format.
 
const DEFAULT_OUTPUT_FORMAT = "spdx2"
 Default output format.
 
const AVAILABLE_OUTPUT_FORMATS = "spdx2,spdx2tv,dep5,spdx2csv,spdx3jsonld,spdx3json,spdx3rdf,spdx3tv"
 Output formats available.
 
const UPLOAD_ADDS = "uploadsAdd"
 Argument for additional uploads.
 
const DATA_LICENSE = "CC0-1.0"
 Data license for SPDX reports.
 

Protected Member Functions

 preWorkOnArgs ($args)
 Parse arguments. More...
 
 getTemplateFile ($partname)
 Get TWIG template file based on output format. More...
 
 getFileBasename ($packageName)
 Generate report basename based on upload name. More...
 
 getFileName ($packageName)
 Get absolute path for report. More...
 
 getUri ($packageName)
 Get the URI for the given package. More...
 
 renderPackage ($uploadId)
 Given an upload id, render the report string. More...
 
 getLicenseComment ($scannerIds)
 
 toLicensesWithFilesAdder (&$filesWithLicenses, $licenses, $copyrights, $file, $fullPath)
 Map licenses, copyrights, files and full path to filesWithLicenses array. More...
 
 toLicensesWithFiles (&$filesWithLicenses, $treeTableName)
 Map findings to the files. More...
 
 computeUri ($uploadId)
 For a given upload, compute the URI and filename for the report. More...
 
 writeReport (&$packageNodes, $packageIds, $uploadId)
 Write the report the file and update report table. More...
 
 updateReportTable ($uploadId, $jobId, $fileName)
 Update the reportgen table with new report path. More...
 
 renderString ($templateName, $vars)
 Render a twig template. More...
 
 generateFileNodes ($filesWithLicenses, $treeTableName, $uploadId)
 Generate report nodes for files. More...
 
 generateFileNodesByFiles ($filesWithLicenses, $treeTableName, $uploadId)
 For each file, generate the nodes by files. More...
 
 generateFileNodesByLicenses ($filesWithLicenses, $treeTableName)
 For each file, generate the nodes by licenses. More...
 
 getVerificationCode (Upload $upload)
 Get a unique identifier for a given upload. More...
 
 getSPDXReportConf ($uploadId, $key)
 Get spdx license comment state for a given upload. More...
 
 getSPDXDataLicense ()
 

Protected Attributes

 $dbManager
 
 $renderer
 
 $agentNames = AgentRef::AGENT_LIST
 
 $filebasename = null
 
 $uri
 
 $filename
 
 $outputFormat = self::DEFAULT_OUTPUT_FORMAT
 
 $concludedLicenseFileIds =[]
 
 $declaredLicenseFileIds =[]
 
- Protected Attributes inherited from Fossology\Lib\Agent\Agent
 $userId
 
 $groupId
 
 $jobId
 
 $agentSpecifOptions = ""
 
 $agentSpecifLongOptions = array()
 
 $args = array()
 
 $dbManager
 
 $agentDao
 
 $container
 
 $schedulerMode
 

Private Member Functions

 getObligations (int $uploadId, int $groupId)
 
 deduplicateLicenseList ()
 De-duplicate license list by comparing licenses with the same SPDX ID. More...
 

Private Attributes

 $uploadDao
 
 $clearingDao
 
 $licenseDao
 
 $licenseMap
 
 $licenseClearedGetter
 
 $licenseMainGetter
 
 $obligationsGetter
 
 $reportutils
 
 $licensesInDocument = []
 

Additional Inherited Members

- Static Public Member Functions inherited from Fossology\Lib\Agent\Agent
static heartbeat_handler ($signo)
 Function to handle hear beats from the agent and send them to the scheduler from STDOUT. More...
 

Detailed Description

SPDX2 agent.

Definition at line 75 of file spdx.php.

Member Function Documentation

◆ computeUri()

Fossology\Spdx\SpdxAgent::computeUri (   $uploadId)
protected

For a given upload, compute the URI and filename for the report.

Parameters
int$uploadId

Definition at line 579 of file spdx.php.

◆ deduplicateLicenseList()

Fossology\Spdx\SpdxAgent::deduplicateLicenseList ( )
private

De-duplicate license list by comparing licenses with the same SPDX ID.

First sort the license list by concatenating SPDX ID and shortname. Then compare each license with the next one. If they have the same SPDX ID, then the next one is a duplicate. Mark the duplicate by adding prefix of SPDX LicenseRef and suffix of MD5 hash of the license text to the shortname.

Returns
void

Definition at line 901 of file spdx.php.

◆ generateFileNodes()

Fossology\Spdx\SpdxAgent::generateFileNodes (   $filesWithLicenses,
  $treeTableName,
  $uploadId 
)
protected

Generate report nodes for files.

Parameters
FileNode[]$filesWithLicenses
string$treeTableName
int$uploadId
Returns
string Node content

Definition at line 672 of file spdx.php.

◆ generateFileNodesByFiles()

Fossology\Spdx\SpdxAgent::generateFileNodesByFiles (   $filesWithLicenses,
  $treeTableName,
  $uploadId 
)
protected

For each file, generate the nodes by files.

Parameters
FileNode[]$filesWithLicenses
string$treeTableName
int$uploadId
Returns
string Node string

Definition at line 689 of file spdx.php.

◆ generateFileNodesByLicenses()

Fossology\Spdx\SpdxAgent::generateFileNodesByLicenses (   $filesWithLicenses,
  $treeTableName 
)
protected

For each file, generate the nodes by licenses.

Parameters
FileNode[]$filesWithLicenses
string$treeTableName
Returns
string Node string

Definition at line 775 of file spdx.php.

◆ getFileBasename()

Fossology\Spdx\SpdxAgent::getFileBasename (   $packageName)
protected

Generate report basename based on upload name.

The base name is in format <OutputFormat>_<packagename>_<timestamp><.spdx.rdf|.spdx|.txt|.csv>

Parameters
string$packageNameName of the upload
Returns
string Report file's base name

Definition at line 287 of file spdx.php.

◆ getFileName()

Fossology\Spdx\SpdxAgent::getFileName (   $packageName)
protected

Get absolute path for report.

Parameters
string$packageNameName of the upload
Returns
string Absolute file path for report

Definition at line 327 of file spdx.php.

◆ getLicenseComment()

Fossology\Spdx\SpdxAgent::getLicenseComment (   $scannerIds)
protected
Parameters
string[]$scannerIds
Returns
string License Comment

Definition at line 484 of file spdx.php.

◆ getObligations()

Fossology\Spdx\SpdxAgent::getObligations ( int  $uploadId,
int  $groupId 
)
private

Get obligations for the upload.

Parameters
int$uploadIdCurrent upload id
int$groupIdCurrent group id
Returns
array List of all obligations

Definition at line 862 of file spdx.php.

◆ getSPDXDataLicense()

Fossology\Spdx\SpdxAgent::getSPDXDataLicense ( )
protected

Get SPDX Data License self::DATA_LICENSE

Returns
string Associated array with 'text', 'name', 'id', 'url'

Definition at line 884 of file spdx.php.

◆ getSPDXReportConf()

Fossology\Spdx\SpdxAgent::getSPDXReportConf (   $uploadId,
  $key 
)
protected

Get spdx license comment state for a given upload.

Parameters
int$uploadId
Returns
bool License comment state (TRUE : show license comment, FALSE : don't show it)

Definition at line 843 of file spdx.php.

◆ getTemplateFile()

Fossology\Spdx\SpdxAgent::getTemplateFile (   $partname)
protected

Get TWIG template file based on output format.

Parameters
string$partnamecopyright|document|file|package
Returns
string Template file path

Definition at line 253 of file spdx.php.

◆ getUri()

Fossology\Spdx\SpdxAgent::getUri (   $packageName)
protected

Get the URI for the given package.

Parameters
string$packageNameName of the upload
Returns
string URI for the upload

Definition at line 339 of file spdx.php.

◆ getVerificationCode()

Fossology\Spdx\SpdxAgent::getVerificationCode ( Upload  $upload)
protected

Get a unique identifier for a given upload.

This is done using concatenating SHA1 of every pfile in upload and calculating the SHA1 of the resulted string.

Parameters
Upload$upload
Returns
string The unique identifier

Definition at line 818 of file spdx.php.

◆ preWorkOnArgs()

Fossology\Spdx\SpdxAgent::preWorkOnArgs (   $args)
protected

Parse arguments.

Parameters
string[]$argsArray of arguments to be parsed
Returns
array $args Parsed arguments

Definition at line 197 of file spdx.php.

◆ processUploadId()

Fossology\Spdx\SpdxAgent::processUploadId (   $uploadId)

Given an upload ID, process the items in it.

This function is implemented by agent and should call heartbeat() at regular intervals.

Parameters
int$uploadIdUpload to be processed by the agent.
Returns
bool Process status
See also
Fossology::Lib::Agent::Agent::processUploadId()

Reimplemented from Fossology\Lib\Agent\Agent.

Definition at line 215 of file spdx.php.

◆ renderPackage()

Fossology\Spdx\SpdxAgent::renderPackage (   $uploadId)
protected

Given an upload id, render the report string.

Parameters
int$uploadId
Returns
string Rendered report string

Definition at line 355 of file spdx.php.

◆ renderString()

Fossology\Spdx\SpdxAgent::renderString (   $templateName,
  $vars 
)
protected

Render a twig template.

Parameters
string$templateNameName of the template to be rendered
array$varsVariables for the template
Returns
string The rendered output

Definition at line 660 of file spdx.php.

◆ toLicensesWithFiles()

Fossology\Spdx\SpdxAgent::toLicensesWithFiles ( $filesWithLicenses,
  $treeTableName 
)
protected

Map findings to the files.

Parameters
FileNode[]&$filesWithLicenses
string$treeTableName
Returns
string[][][] Array of files with associated findings

Definition at line 526 of file spdx.php.

◆ toLicensesWithFilesAdder()

Fossology\Spdx\SpdxAgent::toLicensesWithFilesAdder ( $filesWithLicenses,
  $licenses,
  $copyrights,
  $file,
  $fullPath 
)
protected

Map licenses, copyrights, files and full path to filesWithLicenses array.

Parameters
[in,out]string$filesWithLicenses
string$licenses
string[]$copyrights
string$file
string$fullPath

Definition at line 503 of file spdx.php.

◆ updateReportTable()

Fossology\Spdx\SpdxAgent::updateReportTable (   $uploadId,
  $jobId,
  $fileName 
)
protected

Update the reportgen table with new report path.

Parameters
int$uploadIdUpload id
int$jobIdJob id
string$fileNameFile name of the report

Definition at line 649 of file spdx.php.

◆ writeReport()

Fossology\Spdx\SpdxAgent::writeReport ( $packageNodes,
  $packageIds,
  $uploadId 
)
protected

Write the report the file and update report table.

Parameters
string$packageNodes
int[]$packageIds
int$uploadId

Definition at line 594 of file spdx.php.

Member Data Documentation

◆ $agentNames

array Fossology\Spdx\SpdxAgent::$agentNames = AgentRef::AGENT_LIST
protected

Agent names mapping

Definition at line 131 of file spdx.php.

◆ $clearingDao

ClearingDao Fossology\Spdx\SpdxAgent::$clearingDao
private

ClearingDao object

Definition at line 91 of file spdx.php.

◆ $concludedLicenseFileIds

array[] Fossology\Spdx\SpdxAgent::$concludedLicenseFileIds =[]
protected

List of Concluded License FileIds in the document

Definition at line 156 of file spdx.php.

◆ $dbManager

DbManager Fossology\Spdx\SpdxAgent::$dbManager
protected

DbManager object

Definition at line 99 of file spdx.php.

◆ $declaredLicenseFileIds

array[] Fossology\Spdx\SpdxAgent::$declaredLicenseFileIds =[]
protected

List of Declared License FileIds in the document

Definition at line 160 of file spdx.php.

◆ $filebasename

string Fossology\Spdx\SpdxAgent::$filebasename = null
protected

Basename of SPDX2 report

Definition at line 135 of file spdx.php.

◆ $filename

string Fossology\Spdx\SpdxAgent::$filename
protected

File name

Definition at line 143 of file spdx.php.

◆ $licenseClearedGetter

LicenseClearedGetter Fossology\Spdx\SpdxAgent::$licenseClearedGetter
private

License cleared getter to fetch licenses.

Definition at line 112 of file spdx.php.

◆ $licenseDao

LicenseDao Fossology\Spdx\SpdxAgent::$licenseDao
private

LicenseDao object

Definition at line 95 of file spdx.php.

◆ $licenseMainGetter

LicenseMainGetter Fossology\Spdx\SpdxAgent::$licenseMainGetter
private

Getter for main licenses.

Definition at line 117 of file spdx.php.

◆ $licenseMap

LicenseMap Fossology\Spdx\SpdxAgent::$licenseMap
private

LicenseMap object

Definition at line 107 of file spdx.php.

◆ $licensesInDocument

SpdxLicenseInfo[] Fossology\Spdx\SpdxAgent::$licensesInDocument = []
private

List of licenses found in the document.

Definition at line 148 of file spdx.php.

◆ $obligationsGetter

ObligationsGetter Fossology\Spdx\SpdxAgent::$obligationsGetter
private

Obligation getter.

Definition at line 122 of file spdx.php.

◆ $outputFormat

string Fossology\Spdx\SpdxAgent::$outputFormat = self::DEFAULT_OUTPUT_FORMAT
protected

Output format of the report

Definition at line 152 of file spdx.php.

◆ $renderer

Environment Fossology\Spdx\SpdxAgent::$renderer
protected

Twig_Environment object

Definition at line 103 of file spdx.php.

◆ $reportutils

ReportUtils Fossology\Spdx\SpdxAgent::$reportutils
private

Report utils.

Definition at line 127 of file spdx.php.

◆ $uploadDao

UploadDao Fossology\Spdx\SpdxAgent::$uploadDao
private

UploadDao object

Definition at line 87 of file spdx.php.

◆ $uri

string Fossology\Spdx\SpdxAgent::$uri
protected

URI of the file

Definition at line 139 of file spdx.php.


The documentation for this class was generated from the following file: