Issues (24)

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.

src/Actions/ManagesContacts.php (6 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 TestMonitor\ActiveCampaign\Actions;
4
5
use TestMonitor\ActiveCampaign\Resources\Tag;
6
use TestMonitor\ActiveCampaign\Resources\Contact;
7
use TestMonitor\ActiveCampaign\Resources\Automation;
8
use TestMonitor\ActiveCampaign\Resources\ContactTag;
9
use TestMonitor\ActiveCampaign\Resources\ContactAutomation;
10
11
trait ManagesContacts
12
{
13
    use ImplementsActions;
14
15
    /**
16
     * Get all contacts.
17
     *
18
     * @return array
19
     */
20
    public function contacts()
21
    {
22
        return $this->transformCollection(
23
            $this->get('contacts'),
24
            Contact::class,
25
            'contacts'
26
        );
27
    }
28
29
    /**
30
     * Find contact by email.
31
     *
32
     * @param string $email
33
     *
34
     * @return Contact|null
35
     */
36
    public function findContact($email)
37
    {
38
        $contacts = $this->transformCollection(
39
            $this->get('contacts', ['query' => ['email' => $email]]),
40
            Contact::class,
41
            'contacts'
42
        );
43
44
        return array_shift($contacts);
45
    }
46
47
    /**
48
     * Create new contact.
49
     *
50
     * @param string $email
51
     * @param string $firstName
52
     * @param string $lastName
53
     * @param int|null $phone
54
     *
55
     * @return Contact|null
56
     */
57 View Code Duplication
    public function createContact($email, $firstName, $lastName, $phone = null)
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...
58
    {
59
        $contacts = $this->transformCollection(
60
            $this->post('contacts', ['json' => ['contact' => compact('email', 'firstName', 'lastName', 'phone')]]),
61
            Contact::class
62
        );
63
64
        return array_shift($contacts);
65
    }
66
67
    /**
68
     * Find or create a contact.
69
     *
70
     * @param string $email
71
     * @param string $firstName
72
     * @param string $lastName
73
     * @param string $phone
74
     *
75
     * @return Contact
76
     */
77
    public function findOrCreateContact($email, $firstName, $lastName, $phone)
78
    {
79
        $contact = $this->findContact($email);
80
81
        if ($contact instanceof Contact) {
82
            return $contact;
83
        }
84
85
        return $this->createContact($email, $firstName, $lastName, $phone);
86
    }
87
88
    /**
89
     * Update or create an account.
90
     *
91
     * @param string $name
0 ignored issues
show
There is no parameter named $name. Was it maybe removed?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.

Consider the following example. The parameter $italy is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $island
 * @param array $italy
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was removed, but the annotation was not.

Loading history...
92
     * @param array $data
0 ignored issues
show
There is no parameter named $data. Was it maybe removed?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.

Consider the following example. The parameter $italy is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $island
 * @param array $italy
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was removed, but the annotation was not.

Loading history...
93
     *
94
     * @return Contact
95
     */
96 View Code Duplication
    public function updateOrCreateContact($email, $firstName, $lastName, $phone)
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...
97
    {
98
        $contacts = $this->transformCollection(
99
            $this->post('contact/sync', ['json' => ['contact' => compact('email', 'firstName', 'lastName', 'phone')]]),
100
            Contact::class
101
        );
102
103
        return array_shift($contacts);
104
    }
105
106
    /**
107
     * Get all automations of a contact.
108
     *
109
     * @param \TestMonitor\ActiveCampaign\Resources\Contact $contact
110
     *
111
     * @return array
112
     */
113
    public function contactAutomations(Contact $contact)
114
    {
115
        return $this->transformCollection(
116
            $this->get("contacts/{$contact->id}/contactAutomations"),
117
            ContactAutomation::class,
118
            'contactAutomations'
119
        );
120
    }
121
122
    /**
123
     * Get all tags of a contact.
124
     *
125
     * @param \TestMonitor\ActiveCampaign\Resources\Contact $contact
126
     *
127
     * @return array
128
     */
129
    public function contactTags(Contact $contact)
130
    {
131
        return $this->transformCollection(
132
            $this->get("contacts/{$contact->id}/contactTags"),
133
            ContactTag::class,
134
            'contactTags'
135
        );
136
    }
137
138
    /**
139
     * Removing a automation from a contact.
140
     *
141
     * @param \TestMonitor\ActiveCampaign\Resources\Contact $contact
142
     * @param \TestMonitor\ActiveCampaign\Resources\Automation $automation
143
     */
144 View Code Duplication
    public function removeAutomationFromContact(Contact $contact, Automation $automation)
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...
145
    {
146
        $contactAutomations = $this->contactAutomations($contact);
147
148
        $contactAutomation = current(array_filter($contactAutomations, function ($contactAutomation) use ($automation) {
149
            return $contactAutomation->automation == $automation->id;
150
        }));
151
152
        if (empty($contactAutomation)) {
153
            return;
154
        }
155
156
        $this->delete("contactAutomations/{$contactAutomation->id}");
157
    }
158
159
    /**
160
     * Removing all automations from a contact.
161
     *
162
     * @param \TestMonitor\ActiveCampaign\Resources\Contact $contact
163
     */
164
    public function removeAllAutomationsFromContact(Contact $contact)
165
    {
166
        $contactAutomations = $this->contactAutomations($contact);
167
168
        foreach ($contactAutomations as $contactAutomation) {
169
            $this->delete("contactAutomations/{$contactAutomation->id}");
170
        }
171
    }
172
173
    /**
174
     * Removing a tag from a contact.
175
     *
176
     * @param \TestMonitor\ActiveCampaign\Resources\Contact $contact
177
     * @param \TestMonitor\ActiveCampaign\Resources\Tag $tag
178
     */
179 View Code Duplication
    public function removeTagFromContact(Contact $contact, Tag $tag)
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...
180
    {
181
        $contactTags = $this->contactTags($contact);
182
183
        $contactTag = current(array_filter($contactTags, function ($contactTag) use ($tag) {
184
            return $contactTag->tag == $tag->id;
185
        }));
186
187
        if (empty($contactTag)) {
188
            return;
189
        }
190
191
        $this->delete("contactTags/{$contactTag->id}");
192
    }
193
}
194