Issues (29)

Security Analysis    no request data  

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.

src/SixtyNine/Cloud/Factory/FontsFactory.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
namespace SixtyNine\Cloud\Factory;
5
6
use Imagine\Gd\Imagine;
7
use Imagine\Image\Box;
8
use Imagine\Image\Color;
9
use Imagine\Image\Point;
10
use Imagine\Gd\Font as ImagineFont;
11
use SixtyNine\Cloud\Model\Font;
12
use Webmozart\Assert\Assert;
13
14
class FontsFactory
15
{
16
    /** @var array */
17
    protected $fonts = array();
18
19
    /**
20
     * Initialize the FontsFactory.
21
     *
22
     * If $isFontPath is true then the first parameter is considered as a path to
23
     * a directory containing the fonts. This directory is scanned for TTF and OTF
24
     * fonts.
25
     *
26
     * If $isFontPath is false, then the first parameter must contain a path to
27
     * a TTF/ODF font, or must be an array of those paths.
28
     *
29
     * @param string|array $fonts
30
     * @param bool $isFontPath
31
     */
32 14
    protected function __construct($fonts, $isFontPath = true)
33
    {
34 14
        if ($isFontPath) {
35 12
            $this->loadFonts($fonts);
0 ignored issues
show
It seems like $fonts defined by parameter $fonts on line 32 can also be of type array; however, SixtyNine\Cloud\Factory\FontsFactory::loadFonts() does only seem to accept string, maybe add an additional type check?

This check looks at variables that have been passed in as parameters and are passed out again to other methods.

If the outgoing method call has stricter type requirements than the method itself, an issue is raised.

An additional type check may prevent trouble.

Loading history...
36 12
            return;
37
        }
38
39 2
        $fonts = is_array($fonts) ? $fonts : [$fonts];
40 2
        foreach ($fonts as $font) {
41 2
            $this->addFont($font);
42
        }
43 2
    }
44
45
    /**
46
     * @param string $fonts
47
     * @param bool $isFontPath
48
     * @return FontsFactory
49
     */
50 14
    public static function create($fonts, $isFontPath = true)
51
    {
52 14
        return new self($fonts, $isFontPath);
53
    }
54
55
    /**
56
     * @param string $fontsPath
57
     */
58 12
    public function loadFonts($fontsPath)
59
    {
60 12
        Assert::fileExists($fontsPath, 'The fonts path must exist');
61 12
        foreach (glob($fontsPath . '/*.{ttf,otf}', GLOB_BRACE) as $filename) {
62 12
            $this->addFont($filename);
63
        }
64 12
    }
65
66
    /**
67
     * @param string $filename
68
     */
69 14
    protected function addFont($filename)
70
    {
71 14
        Assert::fileExists($filename, 'The font file must exist');
72 14
        $name = basename($filename);
73 14
        $this->fonts[$name] = realpath($filename);
74 14
    }
75
76
    /**
77
     * @param string $name
78
     * @return Font
79
     * @throws \InvalidArgumentException
80
     */
81 13
    public function getFont($name)
82
    {
83 13
        Assert::keyExists($this->fonts, $name, 'Font not found: ' . $name);
84 13
        return new Font($name, $this->fonts[$name]);
85
    }
86
87
    /**
88
     * @param string $name
89
     * @param int $size
90
     * @param string $color
91
     * @return ImagineFont
92
     */
93 13
    public function getImagineFont($name, $size, $color = '#000000')
94
    {
95 13
        $font = $this->getFont($name);
96 13
        return new ImagineFont($font->getFile(), $size, new Color($color));
97
    }
98
99
    /**
100
     * @return array
101
     */
102
    public function getFonts()
103
    {
104
        return array_keys($this->fonts);
105
    }
106
}
107