Issues (55)

Security Analysis    not enabled

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

  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.
  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.
  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.
  Code Injection
Code Injection enables an attacker to execute arbitrary code on the server.
  Response Splitting
Response Splitting can be used to send arbitrary responses.
  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.
  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.
  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.
  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.
  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.
  Header Injection
  Other Vulnerability
This category comprises other attack vectors such as manipulating the PHP runtime, loading custom extensions, freezing the runtime, or similar.
  Regex Injection
Regex Injection enables an attacker to execute arbitrary code in your PHP process.
  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.
  Variable Injection
Variable Injection enables an attacker to overwrite program variables with custom data, and can lead to further vulnerabilities.
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.

SetOrganizationUserElementTableAttributeHtml.php (1 issue)

Labels
Severity

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
2
3
/**
4
 * @copyright  Copyright (c) Flipbox Digital Limited
5
 * @license    https://flipboxfactory.com/software/patron/license
6
 * @link       https://www.flipboxfactory.com/software/patron/
7
 */
8
9
namespace flipbox\organizations\events\handlers;
10
11
use Craft;
12
use craft\elements\User;
13
use craft\events\SetElementTableAttributeHtmlEvent;
14
use craft\helpers\Html;
15
use flipbox\organizations\behaviors\OrganizationsAssociatedToUserBehavior;
16
use flipbox\organizations\Organizations;
17
use flipbox\organizations\records\UserAssociation;
18
use flipbox\organizations\records\UserType;
19
20
/**
21
 * @author Flipbox Factory <[email protected]>
22
 * @since 1.0.0
23
 */
24
class SetOrganizationUserElementTableAttributeHtml
25
{
26
    /**
27
     * @param SetElementTableAttributeHtmlEvent $event
28
     * @throws \Twig\Error\LoaderError
29
     * @throws \Twig\Error\RuntimeError
30
     * @throws \Twig\Error\SyntaxError
31
     */
32
    public static function handle(SetElementTableAttributeHtmlEvent $event)
33
    {
34
        if (!in_array($event->attribute, ['state', 'types', 'edit'], true)) {
35
            return;
36
        }
37
38
        if ($event->attribute === 'edit') {
39
            $event->html = '<span class="edit-association icon settings"></span>';
40
            return;
41
        }
42
43
        /** @var User|OrganizationsAssociatedToUserBehavior $element */
44
        $element = $event->sender;
45
46
        /** @var UserAssociation $association */
47
        $association = $element->getOrganizations()->findOne(
0 ignored issues
show
The method getOrganizations does only exist in flipbox\organizations\be...ssociatedToUserBehavior, but not in craft\elements\User.

It seems like the method you are trying to call exists only in some of the possible types.

Let’s take a look at an example:

class A
{
    public function foo() { }
}

class B extends A
{
    public function bar() { }
}

/**
 * @param A|B $x
 */
function someFunction($x)
{
    $x->foo(); // This call is fine as the method exists in A and B.
    $x->bar(); // This method only exists in B and might cause an error.
}

Available Fixes

  1. Add an additional type-check:

    /**
     * @param A|B $x
     */
    function someFunction($x)
    {
        $x->foo();
    
        if ($x instanceof B) {
            $x->bar();
        }
    }
    
  2. Only allow a single type to be passed if the variable comes from a parameter:

    function someFunction(B $x) { /** ... */ }
    
Loading history...
48
            Craft::$app->getRequest()->getParam('organization')
49
        );
50
51
        switch ($event->attribute) {
52
            case 'state':
53
                $params = [
54
                    'indicator' => '',
55
                    'label' => 'N/A'
56
                ];
57
58
                $state = Organizations::getInstance()->getSettings()->getUserStates();
59
60
                if ($association) {
61
                    $params = [
62
                        'indicator' => $association->state,
63
                        'label' => $state[$association->state] ?? 'N/A'
64
                    ];
65
                }
66
67
                $event->html = Html::encodeParams(
68
                    '<span class="user-state status {indicator}"></span>{label}',
69
                    $params
70
                );
71
                break;
72
73
            case 'types':
74
                $types = $association ? $association->getTypes() : [];
75
76
                $html = $label = [];
77
                foreach ($types->getCollection() as $type) {
78
                    $label[] = $type->name;
79
                    $html[] = self::icon($type);
80
                }
81
82
                $event->html = Html::encodeParams(
83
                    '<span class="user-types-icons" data-label="' . implode(', ', $label) . '">' . implode(
84
                        '',
85
                        $html
86
                    ) . '</span>',
87
                    []
88
                );
89
90
                break;
91
        }
92
    }
93
94
    /**
95
     * @param UserType $type
96
     * @return string
97
     * @throws \Twig\Error\LoaderError
98
     * @throws \Twig\Error\RuntimeError
99
     * @throws \Twig\Error\SyntaxError
100
     */
101
    private static function icon(UserType $type)
102
    {
103
        return '<span class="foo" data-label="' . $type->name . '">' . Craft::$app->getView()->renderTemplate(
104
            "organizations/_includes/icon.svg",
105
            [
106
                'label' => $type->name
107
            ]
108
        ) . '</span>';
109
    }
110
}
111