GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

Issues (14)

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.

Controller/ApiKeyController.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 Ma27\ApiKeyAuthenticationBundle\Controller;
4
5
use Ma27\ApiKeyAuthenticationBundle\Event\OnAssembleResponseEvent;
6
use Ma27\ApiKeyAuthenticationBundle\Event\OnCredentialExceptionThrownEvent;
7
use Ma27\ApiKeyAuthenticationBundle\Exception\CredentialException;
8
use Ma27\ApiKeyAuthenticationBundle\Ma27ApiKeyAuthenticationEvents;
9
use Ma27\ApiKeyAuthenticationBundle\Service\Mapping\ClassMetadata;
10
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
11
use Symfony\Component\HttpFoundation\JsonResponse;
12
use Symfony\Component\HttpFoundation\Request;
13
use Symfony\Component\HttpFoundation\Response;
14
use Symfony\Component\HttpKernel\Exception\HttpException;
15
16
/**
17
 * Controller which is responsible for the authentication routes.
18
 */
19
class ApiKeyController extends Controller
20
{
21
    /**
22
     * Requests an api key.
23
     *
24
     * @param Request $request
25
     *
26
     * @throws HttpException If the login fails.
27
     *
28
     * @return JsonResponse
29
     */
30 12
    public function requestApiKeyAction(Request $request)
31
    {
32
        /** @var \Symfony\Component\EventDispatcher\EventDispatcherInterface $dispatcher */
33 12
        $dispatcher = $this->get('event_dispatcher');
34
35 12
        $credentials = [];
36 12
        if ($request->request->has('login')) {
37 12
            $credentials[$this->getPropertyName(ClassMetadata::LOGIN_PROPERTY)] = $request->request->get('login');
38
        }
39 12
        if ($request->request->has('password')) {
40 12
            $credentials[$this->getPropertyName(ClassMetadata::PASSWORD_PROPERTY)] = $request->request->get('password');
41
        }
42 12
        [$user, $exception] = $this->processAuthentication($credentials);
0 ignored issues
show
The variable $user does not exist. Did you forget to declare it?

This check marks access to variables or properties that have not been declared yet. While PHP has no explicit notion of declaring a variable, accessing it before a value is assigned to it is most likely a bug.

Loading history...
The variable $exception does not exist. Did you forget to declare it?

This check marks access to variables or properties that have not been declared yet. While PHP has no explicit notion of declaring a variable, accessing it before a value is assigned to it is most likely a bug.

Loading history...
43
44
        /** @var OnAssembleResponseEvent $result */
45 12
        $result = $dispatcher->dispatch(
46 12
            Ma27ApiKeyAuthenticationEvents::ASSEMBLE_RESPONSE,
47 12
            new OnAssembleResponseEvent($user, $exception)
48
        );
49
50 12
        if (!$response = $result->getResponse()) {
51
            throw new HttpException(
52
                Response::HTTP_INTERNAL_SERVER_ERROR,
53
                'Cannot assemble the response!',
54
                $exception
55
            );
56
        }
57
58 12
        return $response;
59
    }
60
61
    /**
62
     * Removes an api key.
63
     *
64
     * @param Request $request
65
     *
66
     * @return JsonResponse
67
     */
68 4
    public function removeSessionAction(Request $request)
69
    {
70
        /** @var \Doctrine\Common\Persistence\ObjectManager $om */
71 4
        $om = $this->get($this->container->getParameter('ma27_api_key_authentication.object_manager'));
72
73 4
        if (!$header = (string) $request->headers->get($this->container->getParameter('ma27_api_key_authentication.key_header'))) {
74 2
            return new JsonResponse(['message' => 'Missing api key header!'], 400);
75
        }
76
77
        $user = $om
78 2
            ->getRepository($this->container->getParameter('ma27_api_key_authentication.model_name'))
79 2
            ->findOneBy([
80 2
                $this->getPropertyName(ClassMetadata::API_KEY_PROPERTY) => $header,
81
            ]);
82
83 2
        $this->get('ma27_api_key_authentication.auth_handler')->removeSession($user);
84
85 2
        return new JsonResponse([], 204);
86
    }
87
88
    /**
89
     * Internal utility to handle the authentication process based on the credentials.
90
     *
91
     * @param array $credentials
92
     *
93
     * @return array
94
     */
95 12
    private function processAuthentication(array $credentials)
96
    {
97
        /** @var \Ma27\ApiKeyAuthenticationBundle\Service\Auth\AuthenticationHandlerInterface $authenticationHandler */
98 12
        $authenticationHandler = $this->get('ma27_api_key_authentication.auth_handler');
99
        /** @var \Symfony\Component\EventDispatcher\EventDispatcherInterface $dispatcher */
100 12
        $dispatcher = $this->get('event_dispatcher');
101
102
        try {
103 12
            $user = $authenticationHandler->authenticate($credentials);
104 4
        } catch (CredentialException $ex) {
105 4
            $userOrNull = $user ?? null;
106 4
            $dispatcher->dispatch(
107 4
                Ma27ApiKeyAuthenticationEvents::CREDENTIAL_EXCEPTION_THROWN,
108 4
                new OnCredentialExceptionThrownEvent($ex, $userOrNull)
109
            );
110
111 4
            return [$userOrNull, $ex];
112
        }
113
114 8
        return [$user, null];
115
    }
116
117
    /**
118
     * Returns the actual property name by the given metadata alias.
119
     *
120
     * @param string $internalMetadataAlias
121
     *
122
     * @return string
123
     */
124 12
    private function getPropertyName($internalMetadataAlias)
125
    {
126 12
        return $this->get('ma27_api_key_authentication.class_metadata')->getPropertyName($internalMetadataAlias);
127
    }
128
}
129