Issues (371)

Security Analysis    no vulnerabilities found

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/Jsonld.php (8 issues)

1
<?php declare(strict_types=1);
2
3
namespace XoopsModules\Publisher;
4
5
/**
6
 *
7
 */
8
class Jsonld
9
{
10
    public $website = [];
11
12
    public static function getAuthor(\XoopsUser $xoopsUser)
13
    {
14
        $author = [
15
            '@type'     => 'Person',
16
            'name'      => $xoopsUser->getVar('name') ?? $xoopsUser->getVar('uname'),
17
            'email'     => $xoopsUser->getVar('email') ?? '',
18
            'telephone' => $xoopsUser->getVar('phone') ?? '',
19
            'sameAs' => [
20
                $xoopsUser->getVar('facebook') ?? '',//"https://www.facebook.com/your-organization-url",
21
                $xoopsUser->getVar('instagram') ?? '',//"https://www.instagram.com/your-organization-url/",
22
            ],
23
        ];
24
        return $author;
25
    }
26
27
    public static function getAuthoritem($xoopsUser, array $xoopsConfig, string $xoops_url)
28
    {
29
        $ret    = '';
30
        $helper = Helper::getInstance();
31
        if ($helper->getConfig('generate_jsonld')) {
32
            $schema['@context'] = 'https://schema.org/';
0 ignored issues
show
Comprehensibility Best Practice introduced by
$schema was never initialized. Although not strictly required by PHP, it is generally a good practice to add $schema = array(); before regardless.
Loading history...
33
            $schema['@type']    = 'Article';
34
            if ($xoopsUser instanceof \XoopsUser) {
35
                $schema['author'] = self::getAuthor($xoopsUser);
36
            }
37
            $schema['publisher'] = self::getOrganization($xoopsConfig, $xoops_url);
38
39
            $ret = '<script type="application/ld+json">' . json_encode($schema, \JSON_PRETTY_PRINT | \JSON_UNESCAPED_UNICODE | \JSON_UNESCAPED_SLASHES) . '</script>';
40
        }
41
        return $ret;
42
    }
43
44
    public static function getCategory(Category $categoryObj)
45
    {
46
        $ret    = '';
47
        $helper = Helper::getInstance();
48
        if ($helper->getConfig('generate_jsonld')) {
49
            global $xoopsConfig, $xoopsUser, $xoops_url;
50
            $schema                   = [];
51
            $schema['@context']       = 'https://schema.org/';
52
            $schema['@type']          = 'Article';
53
            $schema['articleSection'] = $categoryObj->getVar('name');
54
            $schema['publisher']      = self::getOrganization($xoopsConfig, $xoops_url);
55
56
            $ret = '<script type="application/ld+json">' . json_encode($schema, \JSON_PRETTY_PRINT | \JSON_UNESCAPED_UNICODE | \JSON_UNESCAPED_SLASHES) . '</script>';
57
        }
58
        return $ret;
59
    }
60
61
    public static function getArticle(Item $itemObj, Category $categoryObj, \XoopsUser $xoopsUser, Helper $helper)
62
    {
63
        $itemImage = $itemObj->getVar('image');
64
        if (isset($itemImage)) {
65
            $imageHandler = \xoops_getHandler('image');
66
            $criteria     = new \Criteria('image_id', $itemObj->getVar('image'));
0 ignored issues
show
It seems like $itemObj->getVar('image') can also be of type array and array; however, parameter $value of Criteria::__construct() does only seem to accept string, 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

66
            $criteria     = new \Criteria('image_id', /** @scrutinizer ignore-type */ $itemObj->getVar('image'));
Loading history...
67
            $image        = $imageHandler->getObjects($criteria)[0] ?? null;
0 ignored issues
show
The method getObjects() does not exist on XoopsObjectHandler. It seems like you code against a sub-type of said class. However, the method does not exist in XoopsRankHandler or XoUserHandler or XoopsModules\Publisher\PermissionHandler. Are you sure you never get one of those? ( Ignorable by Annotation )

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

67
            $image        = $imageHandler->/** @scrutinizer ignore-call */ getObjects($criteria)[0] ?? null;
Loading history...
68
            $imageUrl     = '';
69
            if (null !== $image) {
70
                $imageUrl = XOOPS_URL . '/images/' . $image->getVar('image_name');
71
            }
72
        }
73
        if ($xoopsUser instanceof \XoopsUser) {
0 ignored issues
show
$xoopsUser is always a sub-type of XoopsUser.
Loading history...
74
            $authorName = $xoopsUser->getVar('name') ?? $xoopsUser->getVar('uname');
75
        }
76
        $item = [
77
            '@context'        => 'https://schema.org',
78
            '@type'           => 'Article',
79
            'articleSection'  => $categoryObj->getVar('name'),
80
            'url'             => $helper->url('item.php?itemid=') . $itemObj->getVar('itemid'),
81
            'headline'        => $itemObj->getVar('title'),
82
            'text'            => $itemObj->getVar('body'),
83
            'datePublished'   => $itemObj->getVar('datesub'),
84
            'dateModified'    => $itemObj->getVar('datesub'),
85
            'name'            => $authorName,
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable $authorName does not seem to be defined for all execution paths leading up to this point.
Loading history...
86
            'aggregateRating' => [
87
                '@type'       => 'AggregateRating',
88
                'ratingValue' => $itemObj->getVar('rating'),
89
                'ratingCount' => $itemObj->getVar('votes'),
90
            ],
91
            'commentCount'    => $itemObj->getVar('comments'),
92
            'image'           => [
93
                '@type'  => 'ImageObject',
94
                'url'    => $imageUrl,
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable $imageUrl does not seem to be defined for all execution paths leading up to this point.
Loading history...
95
                'width'  => '300',
96
                'height' => '60',
97
            ],
98
            'description'     => $itemObj->getVar('summary'),
99
        ];
100
        return $item;
101
    }
102
103
    public static function getOrganization(array $xoopsConfig, string $xoops_url)
104
    {
105
        $organization = [
106
            '@context' => 'https://schema.org',
107
            '@type'    => 'Organization',
108
            'name'     => $xoopsConfig['sitename'],
109
            'slogan'   => $xoopsConfig['slogan'],
110
            'url'      => $xoops_url,
111
            'logo'     => [
112
                '@type'  => 'ImageObject',
113
                'url'    => $xoops_url . '/images/logo.png',
114
                'width'  => '300',
115
                'height' => '60',
116
            ],
117
            //             "sameAs"   => [
118
            //                "https://www.facebook.com/your-organization-url",
119
            //                "https://www.instagram.com/your-organization-url/",
120
            //            ],
121
        ];
122
        return $organization;
123
    }
124
125
    public static function getWebsite($xoopsConfig, $xoops_url)
126
    {
127
        $website = [
128
            '@context' => 'https://schema.org',
129
            '@type'    => 'WebSite',
130
            'name'     => $xoopsConfig['sitename'],
131
            'slogan'   => $xoopsConfig['slogan'],
132
            'url'      => $xoops_url,
133
        ];
134
        return $website;
135
    }
136
137
    public static function getIndex($xoopsConfig, $xoopsUser, $xoops_url)
138
    {
139
        $ret    = '';
140
        $helper = Helper::getInstance();
141
142
        if ($helper->getConfig('generate_jsonld')) {
143
            $schema = [];
144
145
            //            $website = self::getWebsite($xoopsConfig, $xoops_url);
146
147
            $schema['@context'] = 'https://schema.org/';
148
            $schema['@type']    = 'Article';
149
            if ($xoopsUser instanceof \XoopsUser) {
150
                $schema['author'] = self::getAuthor($xoopsUser);
151
            }
152
            $schema['publisher'] = self::getOrganization($xoopsConfig, $xoops_url);
153
            $ret                 = '<script type="application/ld+json">' . json_encode($schema, \JSON_PRETTY_PRINT | \JSON_UNESCAPED_UNICODE | \JSON_UNESCAPED_SLASHES) . '</script>';
154
        }
155
156
        return $ret;
157
    }
158
159
    public static function getBreadcrumbs(?array $data, $settings = null)
0 ignored issues
show
The parameter $data is not used and could be removed. ( Ignorable by Annotation )

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

159
    public static function getBreadcrumbs(/** @scrutinizer ignore-unused */ ?array $data, $settings = null)

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
The parameter $settings is not used and could be removed. ( Ignorable by Annotation )

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

159
    public static function getBreadcrumbs(?array $data, /** @scrutinizer ignore-unused */ $settings = null)

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
160
    {
161
        //
162
        //            $breadcrumbs = [
163
        //                "@context"        => "https://schema.org",
164
        //                "@type"           => "BreadcrumbList",
165
        //                "itemListElement" => $listItems,
166
        //            ];
167
        //
168
        //        return $breadcrumbs;
169
    }
170
171
    public static function getItem(Item $itemObj, Category $categoryObj): string
172
    {
173
        $ret    = '';
174
        $helper = Helper::getInstance();
175
        if ($helper->getConfig('generate_jsonld')) {
176
            global $xoopsConfig, $xoopsUser, $xoops_url;
177
            $schema = [];
178
            //            $website      = self::getWebsite($xoopsConfig, $xoops_url);
179
            //            $category     = self::getCategory($categoryObj);
180
181
            if ($xoopsUser instanceof \XoopsUser) {
182
                $schema['article'] = self::getArticle($itemObj, $categoryObj, $xoopsUser, $helper);
183
                $schema['author']  = self::getAuthor($xoopsUser);
184
            }
185
            $schema['publisher'] = self::getOrganization($xoopsConfig, $xoops_url);
186
187
            $ret = '<script type="application/ld+json">' . json_encode($schema, \JSON_PRETTY_PRINT | \JSON_UNESCAPED_UNICODE | \JSON_UNESCAPED_SLASHES) . '</script>';
188
        }
189
190
        return $ret;
191
    }
192
}
193
194