FOSSology  4.4.0
Open Source License Compliance by Open Source Software
common-agents.php File Reference

These are common functions used by analysis agents. More...

Go to the source code of this file.

Functions

 AgentCheckBoxMake ($upload_pk, $SkipAgents=array(), $specified_username="")
 Generate a checkbox list of available agents. More...
 
 AgentCheckBoxDo ($job_pk, $upload_pk)
 Assume someone called AgentCheckBoxMake() and submitted the HTML form. Run AgentAdd() for each of the checked agents. More...
 
 AgentSchedule ($jobId, $uploadId, $agents)
 Schedule all given agents. More...
 
 FindDependent ($UploadPk, $list=NULL)
 Find the jobs in the job and jobqueue table to be dependent on. More...
 
 GetAgentKey ($agentName, $agentDesc)
 Get the latest enabled agent_pk for a given agent. More...
 
 LatestAgentpk ($upload_pk, $arsTableName, $arsSuccess=false)
 Given an upload_pk, find the latest enabled agent_pk with results. More...
 
 AgentSelect ($TableName, $upload_pk, $SLName, &$agent_pk, $extra="")
 
 userAgents ($agents=null)
 Read the UI form and format the user selected agents into a comma separated list. More...
 
 checkedAgents ($agents=null)
 read the UI form and return array of user selected agents Because input comes from the user, validate that everything is legitimate. More...
 
 listAgents ()
 Search in available plugins and return all agents. More...
 
 CheckARS ($upload_pk, $AgentName, $AgentDesc, $AgentARSTableName)
 Check the ARS table to see if an agent has successfully scanned an upload. More...
 

Detailed Description

These are common functions used by analysis agents.

Analysis Agents should register themselves in the menu structure under the top-level "Agents" menu.

Every analysis agent should have a function called "AgentAdd()" that takes an Upload_pk and an optional array of dependent agents ids.

This function should return:
0 = not scheduled
1 = scheduled
2 = completed

Definition in file common-agents.php.

Function Documentation

◆ AgentCheckBoxDo()

AgentCheckBoxDo (   $job_pk,
  $upload_pk 
)

Assume someone called AgentCheckBoxMake() and submitted the HTML form. Run AgentAdd() for each of the checked agents.

Parameters
int$job_pkJob ID
int$upload_pkUpload ID

Definition at line 121 of file common-agents.php.

◆ AgentCheckBoxMake()

AgentCheckBoxMake (   $upload_pk,
  $SkipAgents = array(),
  $specified_username = "" 
)

Generate a checkbox list of available agents.

Only agents that are not already scheduled are added. If $upload_pk == -1, then list all. User agent preferences will be checked as long as the agent is not already scheduled.

Parameters
int$upload_pkUpload id
array$SkipAgentsArray of agent names to omit from the checkboxes
string$specified_usernameIf not empty, use the specified username instead of username stored in session.
Returns
string containing formatted checkbox list HTML

Definition at line 40 of file common-agents.php.

◆ AgentSchedule()

AgentSchedule (   $jobId,
  $uploadId,
  $agents 
)

Schedule all given agents.

Parameters
int$jobId
int$uploadId
array$agentsArray of agent plugin, mapped by name as in listAgents()
Returns
null|string null on success or error message [sic]

Definition at line 137 of file common-agents.php.

◆ AgentSelect()

AgentSelect (   $TableName,
  $upload_pk,
  $SLName,
$agent_pk,
  $extra = "" 
)

The purpose of this function is to return a pulldown select list for users to be able to select the dataset results they want to see.

This is for _ars tables only, for example, nomos_ars and bucket_ars. The _ars tables have a standard format with optional agent_fk's named agent_fk2, agent_fk3, ...

Parameters
string$TableNameName of the ars table (e.g. nomos_ars)
int$upload_pk
string$SLNameSelect list element name
string&$agent_pkReturn which agent is selected
string$extraExtra info for the select element, e.g. "onclick=..."
Returns
Agent select list, when only one data, return null

Definition at line 320 of file common-agents.php.

◆ CheckARS()

CheckARS (   $upload_pk,
  $AgentName,
  $AgentDesc,
  $AgentARSTableName 
)

Check the ARS table to see if an agent has successfully scanned an upload.

Parameters
int$upload_pkThe upload will be checked
string$AgentNameAgent name, eg "nomos"
string$AgentDescAgent description, eg "license scanner"
string$AgentARSTableNameAgent ars table name, eg "nomos_ars"
Returns
  • 0 = no
  • 1 = yes, from latest agent version
  • 2 = yes, from older agent version (does not apply to adj2nest)

Definition at line 432 of file common-agents.php.

◆ checkedAgents()

checkedAgents (   $agents = null)

read the UI form and return array of user selected agents Because input comes from the user, validate that everything is legitimate.

Returns
Plugin[] list of checked agent plugins, mapped by name

Definition at line 372 of file common-agents.php.

◆ FindDependent()

FindDependent (   $UploadPk,
  $list = NULL 
)

Find the jobs in the job and jobqueue table to be dependent on.

Parameters
int$UploadPkThe upload PK
array$listAn optional array of jobs to use instead of all jobs associated with the upload
Returns
Array of dependencies

Definition at line 157 of file common-agents.php.

◆ GetAgentKey()

GetAgentKey (   $agentName,
  $agentDesc 
)

Get the latest enabled agent_pk for a given agent.

This needs to match the C version of same function in libfossagent This will create an agent record if one doesn't already exist.

Parameters
string$agentNameThe name of the agent e.g. nomos
string$agentDescThe agent_desc colunm
Todo:
When creating an agent record, set the agent_rev.
Returns
-1 or agent_pk

Definition at line 223 of file common-agents.php.

◆ LatestAgentpk()

LatestAgentpk (   $upload_pk,
  $arsTableName,
  $arsSuccess = false 
)

Given an upload_pk, find the latest enabled agent_pk with results.

Parameters
int$upload_pkUpload id
string$arsTableNameName of ars table to check for the requested agent
bool$arsSuccessNeed only success results?
Returns
Nomos agent_pk or 0 if none

Definition at line 291 of file common-agents.php.

◆ listAgents()

listAgents ( )

Search in available plugins and return all agents.

Returns
Plugin[] list of checked agent plugins, mapped by name

Definition at line 397 of file common-agents.php.

◆ userAgents()

userAgents (   $agents = null)

Read the UI form and format the user selected agents into a comma separated list.

Returns
String $agentsChecked list of checked agents

Definition at line 361 of file common-agents.php.