Issues (1)

Security Analysis    no request data  

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.

src/Repositories/Canonicalizer.php (1 issue)

Labels
Severity
1
<?php
2
3
namespace Boomdraw\Canonicalizer\Repositories;
4
5
use Boomdraw\Canonicalizer\Contracts\Canonicalizer as CanonicalizerContract;
6
use Illuminate\Support\Str;
7
use Illuminate\Support\Traits\Macroable;
8
9
class Canonicalizer implements CanonicalizerContract
10
{
11
    use Macroable;
0 ignored issues
show
The trait Illuminate\Support\Traits\Macroable requires the property $name which is not provided by Boomdraw\Canonicalizer\Repositories\Canonicalizer.
Loading history...
12
13
    /**
14
     * Canonicalize string.
15
     *
16
     * @param string $string
17
     * @param bool $nullEmpty
18
     * @return string|null
19
     */
20 2
    public static function canonicalize(string $string, bool $nullEmpty = true): ?string
21
    {
22 2
        if ('' === $string) {
23 1
            return $nullEmpty ? null : '';
24
        }
25
26 2
        $encoding = mb_detect_encoding($string);
27
28 2
        $result = $encoding
29 2
            ? mb_convert_case($string, MB_CASE_LOWER, $encoding)
30 2
            : mb_convert_case($string, MB_CASE_LOWER);
31
32 2
        return $result;
33
    }
34
35
    /**
36
     * Canonicalize email.
37
     *
38
     * @param string $email
39
     * @return string|null
40
     */
41 1
    public static function email(string $email): ?string
42
    {
43 1
        if (false === strpos($email, '@')) {
44 1
            return null;
45
        }
46
47 1
        $email = self::canonicalize($email);
48 1
        $emailExploded = explode('@', $email);
49 1
        $email = str_replace('.', '', $emailExploded[0]);
50 1
        $email .= '@'.$emailExploded[1];
51
52 1
        return $email;
53
    }
54
55
    /**
56
     * Canonicalize slug.
57
     *
58
     * @param string $title
59
     * @param string $separator
60
     * @param string|null $language
61
     * @return string
62
     */
63 1
    public static function slug(string $title, string $separator = '-', ?string $language = 'en'): string
64
    {
65 1
        return Str::slug($title, $separator, $language);
66
    }
67
68
    /**
69
     * Canonicalize url.
70
     *
71
     * @param string $url
72
     * @param string $separator
73
     * @return string
74
     */
75 2
    public static function url(string $url, string $separator = '-'): string
76
    {
77 2
        $url = trim($url, " \t\n\r\0\x0B/\\");
78 2
        $url = explode('/', $url);
79
        array_walk($url, function (&$item) use ($separator) {
80 2
            $item = Str::slug($item, $separator);
81 2
        });
82
83 2
        return implode('/', $url);
84
    }
85
86
    /**
87
     * Canonicalize uri.
88
     *
89
     * @param string $uri
90
     * @param string $separator
91
     * @return string
92
     */
93 1
    public static function uri(string $uri, string $separator = '-'): string
94
    {
95 1
        return self::url($uri, $separator);
96
    }
97
}
98