FOSSology  4.4.0
Open Source License Compliance by Open Source Software
agent-ecc.php
1 <?php
2 /*
3  SPDX-FileCopyrightText: © 2014-2015 Siemens AG
4 
5  SPDX-License-Identifier: GPL-2.0-only
6 */
7 
9 
15 {
17  private $ECCDesc = "Performs file scanning to find text fragments that could be relevant for export control. Note: More keywords related to export control can be included using the configuration file.";
18 
19  public function __construct()
20  {
21  $this->Name = "agent_ecc";
22  $this->Title = _("ECC Analysis <img src=\"images/info_16.png\" data-toggle=\"tooltip\" title=\"".$this->ECCDesc."\" class=\"info-bullet\"/>");
23  $this->AgentName = "ecc";
24 
25  parent::__construct();
26  }
27 
32  function AgentHasResults($uploadId=0)
33  {
34  return CheckARS($uploadId, $this->AgentName, "ecc scanner", "ecc_ars");
35  }
36 
41  public function AgentAdd($jobId, $uploadId, &$errorMsg, $dependencies=[],
42  $arguments=null, $request=null, $unpackArgs=null)
43  {
44  if ($request != null && !is_array($request)) {
45  $unpackArgs = intval($request->get('scm', 0)) == 1 ? '-I' : '';
46  } else {
47  $unpackArgs = intval(@$_POST['scm']) == 1 ? '-I' : '';
48  }
49  if ($this->AgentHasResults($uploadId) == 1) {
50  return 0;
51  }
52 
53  $jobQueueId = \IsAlreadyScheduled($jobId, $this->AgentName, $uploadId);
54  if ($jobQueueId != 0) {
55  return $jobQueueId;
56  }
57 
58  $args = $unpackArgs;
59  if (!empty($unpackArgs)) {
60  return $this->doAgentAdd($jobId, $uploadId, $errorMsg, array("agent_mimetype"),$uploadId,$args,$request);
61  } else {
62  return $this->doAgentAdd($jobId, $uploadId, $errorMsg, array("agent_adj2nest"), $uploadId, null, $request);
63  }
64  }
65 
72  protected function isAgentIncluded($dependencies, $agentName)
73  {
74  foreach ($dependencies as $dependency) {
75  if ($dependency == $agentName) {
76  return true;
77  }
78  if (is_array($dependency) && $agentName == $dependency['name']) {
79  return true;
80  }
81  }
82  return false;
83  }
84 }
85 
86 register_plugin(new EccAgentPlugin());
Create UI plugin for ECC agent.
Definition: agent-ecc.php:15
isAgentIncluded($dependencies, $agentName)
Definition: agent-ecc.php:72
AgentAdd($jobId, $uploadId, &$errorMsg, $dependencies=[], $arguments=null, $request=null, $unpackArgs=null)
Definition: agent-ecc.php:41
AgentHasResults($uploadId=0)
Definition: agent-ecc.php:32
doAgentAdd($jobId, $uploadId, &$errorMsg, $dependencies, $jqargs="", $jq_cmd_args=null, $request=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