Issues (7)

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.

Resolvable/Resolver/AwsS3PresignedUrlResolver.php (2 issues)

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 Gaufrette\Extras\Resolvable\Resolver;
4
5
use Aws\S3\S3Client;
6
use Gaufrette\Extras\Resolvable\ResolverInterface;
7
8
/**
9
 * Resolves object paths into time-limited URLs, namely presigned URLs.
10
 *
11
 * @author Albin Kerouanton <[email protected]>
12
 *
13
 * @see http://docs.aws.amazon.com/AmazonS3/latest/dev/ShareObjectPreSignedURL.html
14
 */
15
class AwsS3PresignedUrlResolver implements ResolverInterface
16
{
17
    /** @var S3Client */
18
    private $service;
19
20
    /** @var string */
21
    private $bucket;
22
23
    /** @var string */
24
    private $baseDir;
25
26
    /** @var \DateTimeInterface */
27
    private $expiresAt;
28
29
    /**
30
     * @param S3Client           $service   Could be the same as the one given to the adapter or any other S3 client.
31
     * @param string             $bucket    Same as the one given to adapter.
32
     * @param string             $baseDir   Same as the one given to adapter.
33
     * @param \DateTimeInterface $expiresAt Presigned links are valid for a certain amount time of time only.
34
     */
35
    public function __construct(S3Client $service, $bucket, $baseDir, \DateTimeInterface $expiresAt)
36
    {
37
        $this->service   = $service;
38
        $this->bucket    = $bucket;
39
        $this->baseDir   = trim($baseDir, '/');
40
        $this->expiresAt = $expiresAt;
41
    }
42
43
    /**
44
     * Resolves given object path into presigned request URI.
45
     *
46
     * @param string $path
47
     *
48
     * @return string
49
     */
50
    public function resolve($path)
51
    {
52
        // For AWS SDK v2
53
        if ($this->service instanceof \Aws\Common\Client\AbstractClient) {
0 ignored issues
show
The class Aws\Common\Client\AbstractClient does not exist. Did you forget a USE statement, or did you not list all dependencies?

This error could be the result of:

1. Missing dependencies

PHP Analyzer uses your composer.json file (if available) to determine the dependencies of your project and to determine all the available classes and functions. It expects the composer.json to be in the root folder of your repository.

Are you sure this class is defined by one of your dependencies, or did you maybe not list a dependency in either the require or require-dev section?

2. Missing use statement

PHP does not complain about undefined classes in ìnstanceof checks. For example, the following PHP code will work perfectly fine:

if ($x instanceof DoesNotExist) {
    // Do something.
}

If you have not tested against this specific condition, such errors might go unnoticed.

Loading history...
54
            return $this->service->getObjectUrl(
55
                $this->bucket,
56
                $this->computePath($path),
57
                $this->expiresAt
58
            );
59
        }
60
61
        // For AWS SDK v3
62
        $command = $this->service->getCommand('GetObject', [
63
            'Bucket' => $this->bucket,
64
            'Key'    => $this->computePath($path),
65
        ]);
66
67
        return (string) $this->service->createPresignedRequest($command, $this->expiresAt)->getUri();
0 ignored issues
show
$this->expiresAt is of type object<DateTimeInterface>, but the function expects a integer|string|object<DateTime>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
68
    }
69
70
    /**
71
     * Appends baseDir to $key.
72
     *
73
     * @param string $key
74
     *
75
     * @return string
76
     */
77
    private function computePath($key)
78
    {
79
        return ltrim($this->baseDir . '/' . ltrim($key, '/'), '/');
80
    }
81
}
82