Issues (9)

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/Device/DistillerParameters/FontTrait.php (1 issue)

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
 * This file is part of the Ghostscript package
4
 *
5
 * @author Daniel Schröder <[email protected]>
6
 */
7
8
namespace GravityMedia\Ghostscript\Device\DistillerParameters;
9
10
use GravityMedia\Ghostscript\Enum\CannotEmbedFontPolicy;
11
use GravityMedia\Ghostscript\Enum\PdfSettings;
12
13
/**
14
 * The font distiller parameters trait.
15
 *
16
 * @package GravityMedia\Ghostscript\Device\DistillerParameters
17
 *
18
 * @link    http://ghostscript.com/doc/current/Ps2pdf.htm
19
 */
20
trait FontTrait
21
{
22
    /**
23
     * Get argument value
24
     *
25
     * @param string $name
26
     *
27
     * @return null|string
28
     */
29
    abstract protected function getArgumentValue($name);
30
31
    /**
32
     * Set argument
33
     *
34
     * @param string $argument
35
     *
36
     * @return $this
37
     */
38
    abstract protected function setArgument($argument);
39
40
    /**
41
     * Get PDF settings
42
     *
43
     * @return string
44
     */
45
    abstract public function getPdfSettings();
46
47
    /**
48
     * Get cannot embed font policy
49
     *
50
     * @return string
51
     */
52 10 View Code Duplication
    public function getCannotEmbedFontPolicy()
0 ignored issues
show
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
53
    {
54 10
        $value = $this->getArgumentValue('-dCannotEmbedFontPolicy');
55 10
        if (null === $value) {
56 10
            switch ($this->getPdfSettings()) {
57 10
                case PdfSettings::PREPRESS:
58 2
                    return CannotEmbedFontPolicy::ERROR;
59 4
                default:
60 8
                    return CannotEmbedFontPolicy::WARNING;
61 4
            }
62
        }
63
64 10
        return ltrim($value, '/');
65
    }
66
67
    /**
68
     * Set cannot embed font policy
69
     *
70
     * @param string $cannotEmbedFontPolicy
71
     *
72
     * @param \InvalidArgumentException
73
     *
74
     * @return $this
75
     */
76 12
    public function setCannotEmbedFontPolicy($cannotEmbedFontPolicy)
77
    {
78 12
        $cannotEmbedFontPolicy = ltrim($cannotEmbedFontPolicy, '/');
79 12
        if (!in_array($cannotEmbedFontPolicy, CannotEmbedFontPolicy::values())) {
80 2
            throw new \InvalidArgumentException('Invalid cannot embed font policy argument');
81
        }
82
83 10
        $this->setArgument(sprintf('-dCannotEmbedFontPolicy=/%s', $cannotEmbedFontPolicy));
84
85 10
        return $this;
86
    }
87
88
    /**
89
     * Whether to embed all fonts
90
     *
91
     * @return bool
92
     */
93 10
    public function isEmbedAllFonts()
94
    {
95 10
        $value = $this->getArgumentValue('-dEmbedAllFonts');
96 10
        if (null === $value) {
97 10
            switch ($this->getPdfSettings()) {
98 10
                case PdfSettings::SCREEN:
99 2
                    return false;
100 4
                default:
101 8
                    return true;
102 4
            }
103
        }
104
105 10
        return filter_var($value, FILTER_VALIDATE_BOOLEAN);
106
    }
107
108
    /**
109
     * Set embed all fonts flag
110
     *
111
     * @param string $embedAllFonts
112
     *
113
     * @return $this
114
     */
115 10
    public function setEmbedAllFonts($embedAllFonts)
116
    {
117 10
        $this->setArgument(sprintf('-dEmbedAllFonts=%s', $embedAllFonts ? 'true' : 'false'));
118
119 10
        return $this;
120
    }
121
122
    /**
123
     * Get max subset pct
124
     *
125
     * @return int
126
     */
127 2
    public function getMaxSubsetPct()
128
    {
129 2
        $value = $this->getArgumentValue('-dMaxSubsetPct');
130 2
        if (null === $value) {
131 2
            return 100;
132
        }
133
134 2
        return intval($value);
135
    }
136
137
    /**
138
     * Set max subset pct
139
     *
140
     * @param int $maxSubsetPct
141
     *
142
     * @return $this
143
     */
144 2
    public function setMaxSubsetPct($maxSubsetPct)
145
    {
146 2
        $this->setArgument(sprintf('-dMaxSubsetPct=%s', $maxSubsetPct));
147
148 2
        return $this;
149
    }
150
151
    /**
152
     * Whether to subset fonts
153
     *
154
     * @return bool
155
     */
156 2
    public function isSubsetFonts()
157
    {
158 2
        $value = $this->getArgumentValue('-dSubsetFonts');
159 2
        if (null === $value) {
160 2
            return true;
161
        }
162
163 2
        return filter_var($value, FILTER_VALIDATE_BOOLEAN);
164
    }
165
166
    /**
167
     * Set subset fonts flag
168
     *
169
     * @param bool $subsetFonts
170
     *
171
     * @return $this
172
     */
173 2
    public function setSubsetFonts($subsetFonts)
174
    {
175 2
        $this->setArgument(sprintf('-dSubsetFonts=%s', $subsetFonts ? 'true' : 'false'));
176
177 2
        return $this;
178
    }
179
}
180