Issues (3)

Security Analysis    not enabled

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/Command/CompileCommand.php (2 issues)

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
 * Copyright (c) Nate Brunette.
4
 * Distributed under the MIT License (http://opensource.org/licenses/MIT)
5
 */
6
7
declare(strict_types=1);
8
9
namespace Tebru\Retrofit\Command;
10
11
use GuzzleHttp\Psr7\Response;
12
use Psr\Http\Message\RequestInterface;
13
use Psr\Http\Message\ResponseInterface;
14
use Symfony\Component\Console\Command\Command;
15
use Symfony\Component\Console\Exception\InvalidArgumentException;
16
use Symfony\Component\Console\Input\InputArgument;
17
use Symfony\Component\Console\Input\InputInterface;
18
use Symfony\Component\Console\Output\OutputInterface;
19
use Tebru\Retrofit\HttpClient;
20
use Tebru\Retrofit\Retrofit;
21
22
/**
23
 * Class CompileCommand
24
 *
25
 * @author Nate Brunette <[email protected]>
26
 * @codeCoverageIgnore
27
 */
28
class CompileCommand extends Command
29
{
30
    /**
31
     * Configure command
32
     *
33
     * @throws InvalidArgumentException
34
     */
35
    protected function configure(): void
36
    {
37
        $this->setName('compile');
38
        $this->setDescription('Compiles and caches all services found in the project');
39
        $this->addArgument('sourceDirectory', InputArgument::REQUIRED, 'Enter the source directory');
40
        $this->addArgument('cacheDirectory', InputArgument::REQUIRED, 'Enter the cache directory');
41
    }
42
43
    /**
44
     * Execute command
45
     *
46
     * @param InputInterface $input
47
     * @param OutputInterface $output
48
     * @return int|null|void
49
     */
50
    protected function execute(InputInterface $input, OutputInterface $output)
51
    {
52
        $srcDir = $input->getArgument('sourceDirectory');
53
        $cacheDir = $input->getArgument('cacheDirectory');
54
55
        $clientStub = new class implements HttpClient {
56
57
            /**
58
             * Send a request synchronously and return a PSR-7 [@see ResponseInterface]
59
             *
60
             * @param RequestInterface $request
61
             * @return ResponseInterface
62
             */
63
            public function send(RequestInterface $request): ResponseInterface
64
            {
65
                return new Response();
66
            }
67
68
            /**
69
             * Send a request asynchronously
70
             *
71
             * The response callback must be called if any response is returned from the request, and the failure
72
             * callback should only be executed if a request was not completed.
73
             *
74
             * The response callback should pass a PSR-7 [@see ResponseInterface] as the one and only argument. The
75
             * failure callback should pass a [@see Throwable] as the one and only argument.
76
             *
77
             * @param RequestInterface $request
78
             * @param callable $onResponse
79
             * @param callable $onFailure
80
             * @return void
81
             */
82
            public function sendAsync(RequestInterface $request, callable $onResponse, callable $onFailure): void
83
            {
84
            }
85
86
            /**
87
             * Calling this method should execute any enqueued requests asynchronously
88
             *
89
             * @return void
90
             */
91
            public function wait(): void
92
            {
93
            }
94
        };
95
96
        $retrofit = Retrofit::builder()
97
            ->setBaseUrl('')
98
            ->setHttpClient($clientStub)
99
            ->setCacheDir($cacheDir)
0 ignored issues
show
It seems like $cacheDir defined by $input->getArgument('cacheDirectory') on line 53 can also be of type array<integer,string> or null; however, Tebru\Retrofit\RetrofitBuilder::setCacheDir() does only seem to accept string, maybe add an additional type check?

If a method or function can return multiple different values and unless you are sure that you only can receive a single value in this context, we recommend to add an additional type check:

/**
 * @return array|string
 */
function returnsDifferentValues($x) {
    if ($x) {
        return 'foo';
    }

    return array();
}

$x = returnsDifferentValues($y);
if (is_array($x)) {
    // $x is an array.
}

If this a common case that PHP Analyzer should handle natively, please let us know by opening an issue.

Loading history...
100
            ->enableCache()
101
            ->build();
102
        $count = $retrofit->createAll($srcDir);
0 ignored issues
show
It seems like $srcDir defined by $input->getArgument('sourceDirectory') on line 52 can also be of type array<integer,string> or null; however, Tebru\Retrofit\Retrofit::createAll() does only seem to accept string, maybe add an additional type check?

If a method or function can return multiple different values and unless you are sure that you only can receive a single value in this context, we recommend to add an additional type check:

/**
 * @return array|string
 */
function returnsDifferentValues($x) {
    if ($x) {
        return 'foo';
    }

    return array();
}

$x = returnsDifferentValues($y);
if (is_array($x)) {
    // $x is an array.
}

If this a common case that PHP Analyzer should handle natively, please let us know by opening an issue.

Loading history...
103
104
        $output->writeln(sprintf('<info>Compiled %s %s successfully</info>', $count, ($count === 1) ? 'class' : 'classes'));
105
    }
106
}
107