FOSSology  4.4.0
Open Source License Compliance by Open Source Software
agent-keyword.php
1 <?php
2 /*
3  SPDX-FileCopyrightText: © 2018 Siemens AG
4 
5  SPDX-License-Identifier: GPL-2.0-only
6 */
7 
9 
11 {
12  public function __construct()
13  {
14  $this->Name = "agent_keyword";
15  $this->Title = _("Keyword Analysis");
16  $this->AgentName = "keyword";
17 
18  parent::__construct();
19  }
20 
25  function AgentHasResults($uploadId=0)
26  {
27  return CheckARS($uploadId, $this->AgentName, "keyword scanner", "keyword_ars");
28  }
29 
30 
35  public function AgentAdd($jobId, $uploadId, &$errorMsg, $dependencies=array(), $arguments=null)
36  {
37  $unpackArgs = intval(@$_POST['scm']) == 1 ? '-I' : '';
38  if ($this->AgentHasResults($uploadId) == 1) {
39  return 0;
40  }
41 
42  $jobQueueId = \IsAlreadyScheduled($jobId, $this->AgentName, $uploadId);
43  if ($jobQueueId != 0) {
44  return $jobQueueId;
45  }
46 
47  $args = $unpackArgs;
48  if (!empty($unpackArgs)) {
49  return $this->doAgentAdd($jobId, $uploadId, $errorMsg, array("agent_mimetype"),$uploadId,$args);
50  } else {
51  return $this->doAgentAdd($jobId, $uploadId, $errorMsg, array("agent_adj2nest"), $uploadId);
52  }
53  }
54 
61  protected function isAgentIncluded($dependencies, $agentName)
62  {
63  foreach ($dependencies as $dependency) {
64  if ($dependency == $agentName) {
65  return true;
66  }
67  if (is_array($dependency) && $agentName == $dependency['name']) {
68  return true;
69  }
70  }
71  return false;
72  }
73 }
74 
75 register_plugin(new KeywordAgentPlugin());
doAgentAdd($jobId, $uploadId, &$errorMsg, $dependencies, $jqargs="", $jq_cmd_args=null)
AgentHasResults($uploadId=0)
isAgentIncluded($dependencies, $agentName)
AgentAdd($jobId, $uploadId, &$errorMsg, $dependencies=array(), $arguments=null)
CheckARS($upload_pk, $AgentName, $AgentDesc, $AgentARSTableName)
Check the ARS table to see if an agent has successfully scanned an upload.
IsAlreadyScheduled($job_pk, $AgentName, $upload_pk)
Check if an agent is already scheduled in a job.
Definition: common-job.php:378