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/Seo.php (4 issues)

1
<?php declare(strict_types=1);
2
3
namespace XoopsModules\Publisher;
4
5
/*
6
 * $Id
7
 * Module: Publisher
8
 * Author: Sudhaker Raj <https://xoops.biz>
9
 * Licence: GNU
10
 */
11
12
// define PUBLISHER_SEO_ENABLED in mainfile.php, possible values
13
//   are "rewrite" & "path-info"
14
15
/**
16
 * Create a title for the shortUrl field of an article
17
 *
18
 * @credit psylove
19
 *
20
 * @return string sort_url for the article
21
 * @var    string $withExt do we add an html extension or not
22
 * @var    string $title   title of the article
23
 */
24
require_once \dirname(__DIR__) . '/include/common.php';
25
26
/**
27
 * Class Seo
28
 */
29
class Seo
30
{
31
    /**
32
     * @param string $title
33
     * @param bool   $withExt
34
     *
35
     * @return mixed|string
36
     */
37
    public static function getTitle($title = '', $withExt = true)
38
    {
39
        /**
40
         * if XOOPS ML is present, let's sanitize the title with the current language
41
         */
42
        $myts = \MyTextSanitizer::getInstance();
43
        if (\method_exists($myts, 'formatForML')) {
44
            $title = $myts->formatForML($title);
45
        }
46
47
        // Transformation de la chaine en minuscule
48
        // Codage de la chaine afin d'éviter les erreurs 500 en cas de caractères imprévus
49
        $title = \rawurlencode(\mb_strtolower($title));
50
51
        // Transformation des ponctuations
52
        $pattern    = [
53
            '/%09/', // Tab
54
            '/%20/', // Space
55
            '/%21/', // !
56
            '/%22/', // "
57
            '/%23/', // #
58
            '/%25/', // %
59
            '/%26/', // &
60
            '/%27/', // '
61
            '/%28/', // (
62
            '/%29/', // )
63
            '/%2C/', // ,
64
            '/%2F/', // /
65
            '/%3A/', // :
66
            '/%3B/', // ;
67
            '/%3C/', // <
68
            '/%3D/', // =
69
            '/%3E/', // >
70
            '/%3F/', // ?
71
            '/%40/', // @
72
            '/%5B/', // [
73
            '/%5C/', // \
74
            '/%5D/', // ]
75
            '/%5E/', // ^
76
            '/%7B/', // {
77
            '/%7C/', // |
78
            '/%7D/', // }
79
            '/%7E/', // ~
80
            '/\./', // .
81
        ];
82
        $repPattern = ['-', '-', '', '', '', '-100', '', '-', '', '', '', '-', '', '', '', '-', '', '', '-at-', '', '-', '', '-', '', '-', '', '-', ''];
83
        $title      = \preg_replace($pattern, $repPattern, $title);
84
85
        // Transformation des caractères accentués
86
        //                  è        é        ê        ë        ç        à        â        ä        î        ï        ù        ü        û        ô        ö
87
        $pattern    = ['/%B0/', '/%E8/', '/%E9/', '/%EA/', '/%EB/', '/%E7/', '/%E0/', '/%E2/', '/%E4/', '/%EE/', '/%EF/', '/%F9/', '/%FC/', '/%FB/', '/%F4/', '/%F6/'];
88
        $repPattern = ['-', 'e', 'e', 'e', 'e', 'c', 'a', 'a', 'a', 'i', 'i', 'u', 'u', 'u', 'o', 'o'];
89
        $title      = \preg_replace($pattern, $repPattern, $title);
90
91
        if (\count($title) > 0) {
0 ignored issues
show
$title of type string is incompatible with the type Countable|array expected by parameter $value of count(). ( Ignorable by Annotation )

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

91
        if (\count(/** @scrutinizer ignore-type */ $title) > 0) {
Loading history...
92
            if ($withExt) {
93
                $title .= '.html';
94
            }
95
96
            return $title;
97
        }
98
99
        return '';
100
    }
101
102
    /**
103
     * @param              $op
104
     * @param              $id
105
     * @param string|array $shortUrl
106
     *
107
     * @return string
108
     */
109
    public static function generateUrl($op, $id, $shortUrl = '')
110
    {
111
        $helper = Helper::getInstance();
112
        if ('none' !== $helper->getConfig('seo_url_rewrite')) {
113
            if (!empty($shortUrl)) {
114
                $shortUrl .= '.html';
115
            }
116
117
            if ('htaccess' === $helper->getConfig('seo_url_rewrite')) {
118
                // generate SEO url using htaccess
119
                return XOOPS_URL . '/' . $helper->getConfig('seo_module_name') . ".{$op}.{$id}/{$shortUrl}";
120
            }
121
122
            if ('path-info' === $helper->getConfig('seo_url_rewrite')) {
123
                // generate SEO url using path-info
124
                return PUBLISHER_URL . "/index.php/{$op}.{$id}/{$shortUrl}";
0 ignored issues
show
The constant XoopsModules\Publisher\PUBLISHER_URL was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
125
            }
126
            exit('Unknown SEO method.');
0 ignored issues
show
Using exit here is not recommended.

In general, usage of exit should be done with care and only when running in a scripting context like a CLI script.

Loading history...
127
        }
128
        // generate classic url
129
        switch ($op) {
130
            case 'category':
131
                return PUBLISHER_URL . "/{$op}.php?categoryid={$id}";
132
            case 'item':
133
            case 'print':
134
                return PUBLISHER_URL . "/$op.php?itemid={$id}";
135
            default:
136
                exit('Unknown SEO operation.');
0 ignored issues
show
Using exit here is not recommended.

In general, usage of exit should be done with care and only when running in a scripting context like a CLI script.

Loading history...
137
        }
138
    }
139
}
140