Issues (432)

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/VisibilityHandler.php (1 issue)

Labels
Severity
1
<?php declare(strict_types=1);
2
3
namespace XoopsModules\Suico;
4
5
/**
6
 * Extended User Profile
7
 *
8
 * You may not change or alter any portion of this comment or credits
9
 * of supporting developers from this source code or any supporting source code
10
 * which is considered copyrighted (c) material of the original comment or credit authors.
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
14
 *
15
 * @copyright       (c) 2000-2016 XOOPS Project (www.xoops.org)
16
 * @license             GNU GPL 2 (https://www.gnu.org/licenses/gpl-2.0.html)
17
 * @since               2.3.0
18
 * @author              Jan Pedersen
19
 * @author              Taiwen Jiang <[email protected]>
20
 */
21
22
/**
23
 * Class ProfileVisibilityHandler
24
 */
25
class VisibilityHandler extends \XoopsPersistableObjectHandler
26
{
27
    /**
28
     * @param \XoopsDatabase $db
29
     */
30
    public function __construct(\XoopsDatabase $db)
31
    {
32
        parent::__construct($db, 'suico_profile_visibility', Visibility::class, 'field_id');
33
    }
34
35
    /**
36
     * Get fields visible to the $user_groups on a $profile_groups profile
37
     *
38
     * @param array      $profile_groups groups of the user to be accessed
39
     * @param array|null $user_groups    groups of the visitor, default as $GLOBALS['xoopsUser']
40
     *
41
     * @return array
42
     */
43
    public function getVisibleFields($profile_groups, $user_groups = null)
44
    {
45
        $user_groups[]    = 0;
46
        $profile_groups[] = 0;
47
        $sql              = "SELECT field_id FROM {$this->table} WHERE profile_group IN (" . \implode(',', $profile_groups) . ')';
48
        $sql              .= ' AND user_group IN (' . \implode(',', $user_groups) . ')';
0 ignored issues
show
It seems like $user_groups can also be of type null; however, parameter $pieces of implode() does only seem to accept array, maybe add an additional type check? ( Ignorable by Annotation )

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

48
        $sql              .= ' AND user_group IN (' . \implode(',', /** @scrutinizer ignore-type */ $user_groups) . ')';
Loading history...
49
        $field_ids        = [];
50
        if (false !== ($result = $this->db->query($sql))) {
51
            while (false !== ([$field_id] = $this->db->fetchRow($result))) {
52
                $field_ids[] = $field_id;
53
            }
54
        }
55
56
        return $field_ids;
57
    }
58
59
    /**
60
     * get all rows matching a condition
61
     *
62
     * @param \CriteriaElement|null $criteria {@link \CriteriaElement} to match
63
     *
64
     * @return array of row arrays, indexed by field_id
65
     */
66
    public function getAllByFieldId(\CriteriaElement $criteria = null)
67
    {
68
        $rawRows = parent::getAll($criteria, null, false, false);
69
        \usort($rawRows, [$this, 'visibilitySort']);
70
        $rows = [];
71
        foreach ($rawRows as $rawRow) {
72
            $rows[$rawRow['field_id']][] = $rawRow;
73
        }
74
75
        return $rows;
76
    }
77
78
    /**
79
     * compare two arrays, each a row from profile_visibility
80
     * The comparison is on three columns, 'field_id', 'user_group', 'profile_group' considered in that
81
     * order for comparison
82
     *
83
     * @param array $a associative array with 3 numeric entries 'field_id', 'user_group', 'profile_group'
84
     * @param array $b associative array with 3 numeric entries 'field_id', 'user_group', 'profile_group'
85
     *
86
     * @return int integer less that zero if $a is less than $b
87
     *              integer zero if $a and $b are equal
88
     *              integer greater than zero if $a is greater than $b
89
     */
90
    protected function visibilitySort($a, $b)
91
    {
92
        $fieldDiff = $a['field_id'] - $b['field_id'];
93
        $userDiff  = $a['user_group'] - $b['user_group'];
94
        $profDiff  = $a['profile_group'] - $b['profile_group'];
95
        if (0 != $fieldDiff) {
96
            return $fieldDiff;
97
        }
98
        if (0 !== $userDiff) {
99
            return $userDiff;
100
        }
101
102
        return $profDiff;
103
    }
104
}
105