FOSSology  4.4.0
Open Source License Compliance by Open Source Software
agent-scanoss.php
Go to the documentation of this file.
1 <?php
2 /***********************************************************
3  *
4  * The SCANOSS Agent for Fossology tool
5  *
6  * Copyright (C) 2018-2022 SCANOSS.COM
7  *
8  * This program is free software: you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation, either version 2 of the License, or
11  * (at your option) any later version.
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  * You should have received a copy of the GNU General Public License
17  * along with this program. If not, see <https://www.gnu.org/licenses/>.
18  ********************************************************************/
19 # SPDX-FileCopyrightText: © 2023 SCANOSS.COM
20 
21 # SPDX-License-Identifier: GPL-2.0-only
23 
33 {
35  private $scanOssDesc = "Enables detection of both declared and undeclared open source components. SCANOSS Toolkit tracks new software versions and components in real time.";
36 
37  public function __construct() {
38  $this->Name = "agent_scanoss";
39  $this->Title = _("SCANOSS Toolkit <img src=\"images/info_16.png\" data-toggle=\"tooltip\" title=\"".$this->scanOssDesc."\" class=\"info-bullet\"/>");
40  $this->AgentName = "scanoss";
41 
42  parent::__construct();
43  }
44 
50  public function renderContent(&$vars)
51  {
52  $renderer = $GLOBALS['container']->get('twig.environment');
53  return $renderer->load('scanoss.html.twig')->render($vars);
54  }
55 
60  function AgentHasResults($uploadId=0)
61  {
62  return CheckARS($uploadId, $this->AgentName, "SCANOSS Snippet and License scan", "scanoss_ars");
63  }
64 
69  function preInstall()
70  {
71  $dbManager = $GLOBALS['container']->get('db.manager');
72  $latestPkgAgent = $dbManager->getSingleRow("SELECT agent_enabled FROM agent WHERE agent_name=$1 ORDER BY agent_ts LIMIT 1",array('scanoss'));
73  if (isset($latestPkgAgent) && !$dbManager->booleanFromDb($latestPkgAgent['agent_enabled']))
74  {
75  return 0;
76  }
77  menu_insert("Agents::" . $this->Title, 0, $this->Name);
78  }
79 
80 }
81 
82 register_plugin(new ScanossAgentPlugin());
UI plugin of scanoss Agent.
AgentHasResults($uploadId=0)
renderContent(&$vars)
Render HTML from template.
CheckARS($upload_pk, $AgentName, $AgentDesc, $AgentARSTableName)
Check the ARS table to see if an agent has successfully scanned an upload.
menu_insert($Path, $LastOrder=0, $URI=NULL, $Title=NULL, $Target=NULL, $HTML=NULL)
Given a Path, order level for the last item, and optional plugin name, insert the menu item.