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.

  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/Options.php (1 issue)

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
namespace EddTurtle\DirectUpload;
4
5
use EddTurtle\DirectUpload\Exceptions\InvalidOptionException;
6
7
/**
8
 * Class Options
9
 *
10
 * @todo
11
 *
12
 * @package EddTurtle\DirectUpload
13
 */
14
class Options
15
{
16
17
    /**
18
     * Default options, these can be overwritten within the constructor.
19
     *
20
     * @var array
21
     */
22
    protected $options = [
23
24
        // If the upload is a success, this is the http code we get back from S3.
25
        // By default this will be a 201 Created.
26
        'success_status' => 201,
27
28
        // If the file should be private/public-read/public-write.
29
        // This is file specific, not bucket. More info: http://amzn.to/1SSOgwO
30
        'acl' => 'private',
31
32
        // The file's name on s3, can be set with JS by changing the input[name="key"].
33
        // ${filename} will just mean the original filename of the file being uploaded.
34
        'default_filename' => '${filename}',
35
36
        // The maximum file size of an upload in MB. Will refuse with a EntityTooLarge
37
        // and 400 Bad Request if you exceed this limit.
38
        'max_file_size' => 500,
39
40
        // Request expiration time, specified in relative time format or in seconds.
41
        // minimum of 1 (+1 second), maximum of 604800 (+7 days)
42
        'expires' => '+6 hours',
43
44
        // Server will check that the filename starts with this prefix and fail
45
        // with a AccessDenied 403 if not.
46
        'valid_prefix' => '',
47
48
        // Strictly only allow a single content type, blank will allow all. Will fail
49
        // with a AccessDenied 403 is this condition is not met.
50
        'content_type' => '',
51
52
        // Sets whether AWS server side encryption should be applied to the uploaded files,
53
        // so that files will be encrypted with AES256 when at rest.
54
        'encryption' => false,
55
56
        // Allow S3 compatible solutions by specifying the domain it should POST to. Must be
57
        // a valid url (inc. http/https) otherwise will throw InvalidOptionException.
58
        'custom_url' => null,
59
60
        // Set Amazon S3 Transfer Acceleration
61
        'accelerate' => false,
62
63
        // Any additional inputs to add to the form. This is an array of name => value
64
        // pairs e.g. ['Content-Disposition' => 'attachment']
65
        'additional_inputs' => []
66
67
    ];
68
69
    public function __construct(array $options = [])
70
    {
71
        $this->setOptions($options);
72
    }
73
74
    /**
75
     * Get all options.
76
     *
77
     * @return array
78
     */
79
    public function getOptions(): array
80
    {
81
        return $this->options;
82
    }
83
84
    public function get(string $name)
0 ignored issues
show
The return type could not be reliably inferred; please add a @return annotation.

Our type inference engine in quite powerful, but sometimes the code does not provide enough clues to go by. In these cases we request you to add a @return annotation as described here.

Loading history...
85
    {
86
        if (!array_key_exists($name, $this->options)) {
87
            throw new InvalidOptionException("Invalid option given to get()");
88
        }
89
        return $this->options[$name];
90
    }
91
92
    /**
93
     * Set/overwrite any default options.
94
     *
95
     * @param array $options any options to override.
96
     */
97
    public function setOptions(array $options): void
98
    {
99
        // Overwrite default options
100
        $this->options = $options + $this->options;
101
102
        $this->options['acl'] = new Acl($this->options['acl']);
103
104
        // Return HTTP code must be a string
105
        $this->options['success_status'] = (string)$this->options['success_status'];
106
107
        // Encryption option is just a helper to set this header, but we need to set it early on so it
108
        // affects both the policy and the inputs generated.
109
        if ($this->options['encryption']) {
110
            $this->options['additional_inputs']['X-amz-server-side-encryption'] = 'AES256';
111
        }
112
    }
113
114
    public function set(string $name, $value): void
115
    {
116
        if (!array_key_exists($name, $this->options)) {
117
            throw new InvalidOptionException("Invalid option given to set()");
118
        }
119
        $this->options[$name] = $value;
120
    }
121
}
122