Issues (36)

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.

Models/Adapters/CardQuery.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
 * Created by Carl Owens ([email protected])
4
 * Company: PartFire Ltd (www.partfire.co.uk)
5
 * Copyright © 2017 PartFire Ltd. All rights reserved.
6
 *
7
 * User:    Carl Owens
8
 * Date:    18/01/2017
9
 * Time:    23:53
10
 * File:    CardQuery.php
11
 **/
12
13
namespace PartFire\MangoPayBundle\Models\Adapters;
14
15
use MangoPay\Card as mangoCard;
16
use PartFire\MangoPayBundle\Models\CardQueryInterface;
17
use PartFire\MangoPayBundle\Models\DTOs\Card;
18
use MangoPay\MangoPayApi;
19
use PartFire\MangoPayBundle\Models\DTOs\Translators\CardTranslator;
20
use Symfony\Bridge\Monolog\Logger;
21
use PartFire\MangoPayBundle\Models\Exception as PartFireException;
22
use MangoPay\Libraries\Exception;
23
use MangoPay\Libraries\ResponseException;
24
25
class CardQuery extends AbstractQuery implements CardQueryInterface
26
{
27
    /**
28
     * @var CardTranslator
29
     */
30
    private $cardTranslator;
31
32
    /**
33
     * CardQuery constructor.
34
     * @param $clientId
35
     * @param $clientPassword
36
     * @param $baseUrl
37
     * @param MangoPayApi $mangoPayApi
38
     * @param Logger $logger
39
     * @param CardTranslator $cardTranslator
40
     */
41
    public function __construct(
42
        $clientId,
43
        $clientPassword,
44
        $baseUrl,
45
        MangoPayApi $mangoPayApi,
46
        Logger $logger,
47
        CardTranslator $cardTranslator
48
    ) {
49
        parent::__construct($clientId, $clientPassword, $baseUrl, $mangoPayApi, $logger);
50
        $this->cardTranslator = $cardTranslator;
51
    }
52
53
    /**
54
     * @param string $cardId
55
     * @return null|Card
56
     * @throws PartFireException
57
     */
58 View Code Duplication
    public function get(string $cardId): Card
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...
59
    {
60
        try {
61
            $card = $this->mangoPayApi->Cards->Get($cardId);
62
            if ($card instanceof mangoCard) {
63
                return $this->cardTranslator->translateMangoCardToDto($card);
64
            }
65
            $this->logger->addCritical("Card ID: $cardId not found when querying API.");
66
            throw new PartFireException("Card ID: $cardId not found when querying API.");
67
        } catch (ResponseException $e) {
68
            $this->logger->addCritical($e->getMessage(), ['code' => $e->getCode(), 'details' => $e->GetErrorDetails()]);
69
            throw new PartFireException($e->getMessage(), $e->getCode(), $e);
70
        } catch (Exception $e) {
71
            $this->logger->addError($e->getMessage());
72
            throw new PartFireException($e->getMessage(), $e->getCode(), $e);
73
        }
74
    }
75
76
    public function deactivate(string $cardId): Card
77
    {
78
        try {
79
            $card = $this->mangoPayApi->Cards->Get($cardId);
80
            if ($card instanceof mangoCard) {
81
                $card->Active = false;
82
                $card = $this->mangoPayApi->Cards->Update($card);
83
                return $this->cardTranslator->translateMangoCardToDto($card);
84
            }
85
            $this->logger->addCritical("Card ID: $cardId not found when querying API.");
86
            throw new PartFireException("Card ID: $cardId not found when querying API.");
87
        } catch (ResponseException $e) {
88
            $this->logger->addCritical($e->getMessage(), ['code' => $e->getCode(), 'details' => $e->GetErrorDetails()]);
89
            throw new PartFireException($e->getMessage(), $e->getCode(), $e);
90
        } catch (Exception $e) {
91
            $this->logger->addError($e->getMessage());
92
            throw new PartFireException($e->getMessage(), $e->getCode(), $e);
93
        }
94
    }
95
}
96