Issues (1844)

Security Analysis    not enabled

This project does not seem to handle request data directly as such no vulnerable execution paths were found.

  File Inclusion
File Inclusion enables an attacker to inject custom files into PHP's file loading mechanism, either explicitly passed to include, or for example via PHP's auto-loading mechanism.
  Regex Injection
Regex Injection enables an attacker to execute arbitrary code in your PHP process.
  SQL Injection
SQL Injection enables an attacker to execute arbitrary SQL code on your database server gaining access to user data, or manipulating user data.
  Response Splitting
Response Splitting can be used to send arbitrary responses.
  File Manipulation
File Manipulation enables an attacker to write custom data to files. This potentially leads to injection of arbitrary code on the server.
  Object Injection
Object Injection enables an attacker to inject an object into PHP code, and can lead to arbitrary code execution, file exposure, or file manipulation attacks.
  File Exposure
File Exposure allows an attacker to gain access to local files that he should not be able to access. These files can for example include database credentials, or other configuration files.
  XML Injection
XML Injection enables an attacker to read files on your local filesystem including configuration files, or can be abused to freeze your web-server process.
  Code Injection
Code Injection enables an attacker to execute arbitrary code on the server.
  Variable Injection
Variable Injection enables an attacker to overwrite program variables with custom data, and can lead to further vulnerabilities.
  XPath Injection
XPath Injection enables an attacker to modify the parts of XML document that are read. If that XML document is for example used for authentication, this can lead to further vulnerabilities similar to SQL Injection.
  Other Vulnerability
This category comprises other attack vectors such as manipulating the PHP runtime, loading custom extensions, freezing the runtime, or similar.
  Command Injection
Command Injection enables an attacker to inject a shell command that is execute with the privileges of the web-server. This can be used to expose sensitive data, or gain access of your server.
  LDAP Injection
LDAP Injection enables an attacker to inject LDAP statements potentially granting permission to run unauthorized queries, or modify content inside the LDAP tree.
  Cross-Site Scripting
Cross-Site Scripting enables an attacker to inject code into the response of a web-request that is viewed by other users. It can for example be used to bypass access controls, or even to take over other users' accounts.
  Header Injection
Unfortunately, the security analysis is currently not available for your project. If you are a non-commercial open-source project, please contact support to gain access.

class/Faq/Xoopsfaq.php (2 issues)

Labels
Severity
1
<?php declare(strict_types=1);
2
3
/*
4
 * You may not change or alter any portion of this comment or credits
5
 * of supporting developers from this source code or any supporting source code
6
 * which is considered copyrighted (c) material of the original comment or credit authors.
7
 *
8
 * This program is distributed in the hope that it will be useful,
9
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11
 */
12
13
/**
14
 * @copyright    {@link https://xoops.org/ XOOPS Project}
15
 * @license      {@link https://www.gnu.org/licenses/gpl-2.0.html GNU GPL 2 or later}
16
 * @author       Brian Wahoff <[email protected]>
17
 * @author       Eric Juden <[email protected]>
18
 * @author       XOOPS Development Team
19
 */
20
21
namespace XoopsModules\Xhelp\Faq;
22
23
use XoopsModules\Xhelp;
24
use XoopsModules\Xoopsfaq\Helper as AdapterHelper;
0 ignored issues
show
The type XoopsModules\Xoopsfaq\Helper was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
25
26
if (!\defined('XHELP_CLASS_PATH')) {
27
    exit();
28
}
29
30
\define('XHELP_XFAQ_PATH', XOOPS_ROOT_PATH . '/modules/xoopsfaq');
31
\define('XHELP_XFAQ_URL', XOOPS_URL . '/modules/xoopsfaq');
32
33
/**
34
 * class Xoopsfaq
35
 */
36
class Xoopsfaq extends Xhelp\FaqAdapterAbstract
37
{
38
    /**
39
     * Does application support categories?
40
     * Possible Values:
41
     * XHELP_FAQ_CATEGORY_SING - entries can be in 1 category
42
     * XHELP_FAQ_CATEGORY_MULTI - entries can be in more than 1 category
43
     * XHELP_FAQ_CATEGORY_NONE - No category support
44
     */
45
    public $categoryType = \XHELP_FAQ_CATEGORY_SING;
46
    /**
47
     * Adapter Details
48
     * Required Values:
49
     * name - name of adapter
50
     * author - who wrote the plugin
51
     * author_email - contact email
52
     * version - version of this plugin
53
     * tested_versions - supported application versions
54
     * url - support url for plugin
55
     * module_dir - module directory name (not needed if class overloads the isActive() function from Xhelp\FaqAdapterAbstract)
56
     */
57
    public $meta = [
58
        'name'            => 'xoopsfaq',
59
        'author'          => 'Eric Juden',
60
        'author_email'    => '[email protected]',
61
        'description'     => 'Create xoopsfaq entries from xHelp helpdesk tickets',
62
        'version'         => '1.0',
63
        'tested_versions' => '1.1',
64
        'url'             => 'https://xoops.org',
65
        'module_dir'      => 'xoopsfaq',
66
    ];
67
68
    /**
69
     * Xhelp\Xoopsfaq constructor.
70
     */
71
    public function __construct()
72
    {
73
        if (\class_exists(AdapterHelper::class)) {
74
            $this->helper  = AdapterHelper::getInstance();
75
            $this->dirname = $this->helper->dirname();
76
        }
77
78
        $this->init();
79
    }
80
81
    /**
82
     * @return array
83
     */
84
    public function &getCategories(): array
85
    {
86
        global $xoopsDB;
87
88
        $ret = [];
89
90
        if (null === $this->helper) {
91
            return $ret;
92
        }
93
        $helper = Xhelp\Helper::getInstance();
94
        // Create an instance of the Xhelp\FaqCategoryHandler
95
        $faqCategoryHandler = $helper->getHandler('FaqCategory');
96
97
        $sql    = \sprintf('SELECT category_id, category_title FROM `%s` ORDER BY category_order', $xoopsDB->prefix('xoopsfaq_categories'));
98
        $result = $xoopsDB->query($sql);
99
100
        if (!$result) {
101
            return $ret;
102
        }
103
104
        //Convert the module specific category to the
105
        //Xhelp\FaqCategory object for standarization
106
        while (false !== ($myrow = $xoopsDB->fetchArray($result))) {
107
            $faqcat = $faqCategoryHandler->create();
108
            $faqcat->setVar('id', $myrow['category_id']);
109
            $faqcat->setVar('name', $myrow['category_title']);
110
            $faqcat->setVar('parent', 0);
111
            $ret[] = $faqcat;
112
        }
113
114
        return $ret;
115
    }
116
117
    /**
118
     * @param Xhelp\Faq|null $faq The faq to add
119
     * @return bool true (success)/false (failure)
120
     */
121
    public function storeFaq(Xhelp\Faq $faq = null): bool
122
    {
123
        global $xoopsDB, $xoopsUser;
124
125
        // Set values before storing to db
126
        //        $newid             = 0;
127
        $categories        = $faq->getVar('categories');
0 ignored issues
show
The method getVar() does not exist on null. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

127
        /** @scrutinizer ignore-call */ 
128
        $categories        = $faq->getVar('categories');

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
128
        $category_id       = $categories[0];
129
        $title             = $faq->getVar('problem');
130
        $contents          = $faq->getVar('solution');
131
        $contents_order    = 0;
132
        $contents_visible  = 1;
133
        $contents_nohtml   = 0;
134
        $contents_nosmiley = 0;
135
        $contents_noxcode  = 0;
136
137
        $sql = 'INSERT INTO ' . $xoopsDB->prefix('xoopsfaq_contents') . ' (category_id, contents_title, contents_contents, contents_time, contents_order, contents_visible, contents_nohtml, contents_nosmiley, contents_noxcode) VALUES ('
138
               //               . $newid
139
               //               . ', '
140
               . $category_id . ", '" . $title . "', '" . $contents . "', " . \time() . ', ' . $contents_order . ', ' . $contents_visible . ', ' . $contents_nohtml . ', ' . $contents_nosmiley . ', ' . $contents_noxcode . ')';
141
        $ret = $xoopsDB->query($sql);
142
143
        $newid = $xoopsDB->getInsertId();   // Get new faq id from db
144
        if ($ret) {
145
            $faq->setVar('id', $newid);
146
        }
147
148
        return $ret;
149
    }
150
151
    /**
152
     * @param \XoopsModules\Xhelp\Faq $faq
153
     * @return string
154
     */
155
    public function makeFaqUrl(\XoopsModules\Xhelp\Faq $faq): string
156
    {
157
        return \XHELP_XFAQ_URL . '/index.php?cat_id=' . $faq->getVar('categories') . '#q' . $faq->getVar('id');
158
    }
159
}
160