Issues (108)

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.

Entity/Repository/SubscriptionRepository.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
/**
4
 * @author Rafał Muszyński <[email protected]>
5
 * @copyright 2015 Sourcefabric z.ú.
6
 * @license http://www.gnu.org/licenses/gpl-3.0.txt
7
 */
8
namespace Newscoop\PaywallBundle\Entity\Repository;
9
10
use Newscoop\ListResult;
11
12
/**
13
 * Subscription repository.
14
 */
15
class SubscriptionRepository extends TranslationRepository
16
{
17
    /**
18
     * Gets all available subscriptions by criteria.
19
     *
20
     * @param SubscriptionCriteria $criteria
21
     * @param bool                 $returnQuery
22
     *
23
     * @return ListResult|Doctrine\ORM\Query
24
     */
25
    public function getListByCriteria($criteria, $returnQuery = false)
26
    {
27
        $qb = $this->createQueryBuilder('s');
28
29
        $qb->select('s', 'r', 'd')
30
            ->andWhere('s.is_active = :is_active')
31
            ->leftJoin('s.ranges', 'r')
32
            ->leftJoin('r.discount', 'd')
33
            ->setParameter('is_active', true);
34
35
        if ($criteria->name) {
36
            $qb->andWhere('s.name = :name')
37
                ->setParameter('name', $criteria->name);
38
        }
39
40
        if ($criteria->currency) {
41
            $qb->andWhere('s.currency = :currency')
42
                ->setParameter('currency', $criteria->currency);
43
        }
44
45
        if ($criteria->type) {
46
            $qb->andWhere('s.type = :type')
47
                ->setParameter('type', $criteria->type);
48
        }
49
50 View Code Duplication
        foreach ($criteria->perametersOperators as $key => $operator) {
0 ignored issues
show
This code seems to be duplicated across 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...
51
            $qb->andWhere('s.'.$key.' = :'.$key)
52
                ->setParameter($key, $criteria->$key);
53
        }
54
55
        $metadata = $this->getClassMetadata();
56
        foreach ($criteria->orderBy as $key => $order) {
57
            if (array_key_exists($key, $metadata->columnNames)) {
58
                $key = 's.'.$key;
59
            }
60
61
            $qb->orderBy($key, $order);
62
        }
63
64
        $list = new ListResult();
65
        $countBuilder = clone $qb;
66
        $query = $this->setTranslatableHints($qb->getQuery(), $criteria->locale);
67
        if ($returnQuery) {
68
            return $query;
69
        }
70
71
        $list->count = (int) $countBuilder->select('COUNT(s)')->getQuery()->getSingleScalarResult();
72
        $list->items = $query;
73
74
        return $list;
75
    }
76
77
    /**
78
     * Gets active Subscriptions by the specification and type.
79
     *
80
     * @param string $locale Current language code (e.g. "en")
81
     * @param array  $specs  Subscription specification
82
     *                       (e.g. publication id, section number etc.)
83
     *
84
     * @return array
85
     */
86
    public function findActiveBy($locale = null, $specs = array())
87
    {
88
        $queryBuilder = $this
89
            ->createQueryBuilder('s')
90
            ->select('s', 'r')
91
            ->leftJoin('s.ranges', 'r')
92
            ->join('s.specification', 'sp')
93
            ->where('s.is_active = true');
94
95
        if (!empty($specs)) {
96
            foreach ($specs as $key => $value) {
97
                if (!$value) {
98
                    $queryBuilder
99
                        ->andWhere('sp.'.$key.' IS NULL');
100
                } else {
101
                    $queryBuilder
102
                        ->andWhere('sp.'.$key.' = :'.$key)
103
                        ->setParameter($key, $value);
104
                }
105
            }
106
        }
107
108
        $query = $queryBuilder->getQuery();
109
110
        return $this->setTranslatableHints($query, $locale)
111
            ->getArrayResult();
112
    }
113
114
    public function findActiveOneBy($id, $locale = null)
115
    {
116
        $query = $this
117
            ->createQueryBuilder('s')
118
            ->where('s.id = :id')
119
            ->andWhere('s.is_active = true')
120
            ->setParameter('id', $id)
121
            ->getQuery()
122
        ;
123
124
        return $this->setTranslatableHints($query, $locale)
125
            ->getOneOrNullResult()
126
        ;
127
    }
128
129
    public function findActive($locale = null)
130
    {
131
        $query = $this
132
            ->createQueryBuilder('s')
133
            ->andWhere('s.is_active = true')
134
            ->getQuery()
135
        ;
136
137
        return $this->setTranslatableHints($query, $locale);
138
    }
139
140
    public function getReference($id)
141
    {
142
        return $this->getEntityManager()->getReference($this->getEntityName(), $id);
143
    }
144
145
    public function findTemplates($type = null, $locale = null)
146
    {
147
        $queryBuilder = $this
148
            ->createQueryBuilder('s')
149
            ->where('s.isTemplate = true')
150
            ->andWhere('s.is_active = true')
151
        ;
152
153
        if ($type) {
154
            $queryBuilder
155
                ->andWhere('s.type = :type')
156
                ->setParameter('type', $type);
157
        }
158
159
        $query = $queryBuilder->getQuery();
160
161
        return $this->setTranslatableHints($query, $locale);
162
    }
163
}
164