Issues (12)

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/Message/Attachment.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
namespace Slack\Message;
3
4
use Slack\DataObject;
5
6
/**
7
 * A message attachment containing rich text data.
8
 *
9
 * @see https://api.slack.com/docs/attachments
10
 */
11
class Attachment extends DataObject
12
{
13
    /**
14
     * Creates a new message attachment.
15
     *
16
     * @param string $title    The attachment title.
17
     * @param string $text     The attachment body text.
18
     * @param string $fallback A plain-text summary of the attachment.
19
     */
20 4
    public function __construct($title, $text, $fallback = null, $color = null, $pretext = null, array $fields = [])
21
    {
22 4
        $this->data['title'] = $title;
23 4
        $this->data['text'] = $text;
24 4
        $this->data['fallback'] = $fallback ?: $text;
25 4
        $this->data['color'] = $color;
26 4
        $this->data['pretext'] = $pretext;
27 4
        $this->data['fields'] = $fields;
28 4
    }
29
30
    /**
31
     * Gets a plain-text summary of the attachment.
32
     *
33
     * @return string A plain-text summary of the attachment.
34
     */
35 1
    public function getFallbackText()
36
    {
37 1
        return $this->data['fallback'];
38
    }
39
40
    /**
41
     * Gets the attachment border color.
42
     *
43
     * @return string The attachment border color. Can be "good", "warning", "danger", or a hex color code.
44
     */
45 1
    public function getColor()
46
    {
47 1
        return isset($this->data['color']) ? $this->data['color'] : null;
48
    }
49
50
    /**
51
     * Gets the attachment pretext.
52
     *
53
     * @return string Optional text that appears above the message attachment block.
54
     */
55 1
    public function getPretext()
56
    {
57 1
        return isset($this->data['pretext']) ? $this->data['pretext'] : '';
58
    }
59
60
    /**
61
     * Gets the author name.
62
     *
63
     * @return string The attachment author's name.
64
     */
65 1
    public function getAuthorName()
66
    {
67 1
        return isset($this->data['author_name']) ? $this->data['author_name'] : null;
68
    }
69
70
    /**
71
     * Gets the author link.
72
     *
73
     * @return string A link URL for the author.
74
     */
75 1
    public function getAuthorLink()
76
    {
77 1
        return isset($this->data['author_link']) ? $this->data['author_link'] : null;
78
    }
79
80
    /**
81
     * Gets the author icon.
82
     *
83
     * @return string An icon URL to show next to the author name.
84
     */
85 1
    public function getAuthorIcon()
86
    {
87 1
        return isset($this->data['author_icon']) ? $this->data['author_icon'] : null;
88
    }
89
90
    /**
91
     * Gets the title.
92
     *
93
     * @return string The attachment title.
94
     */
95 1
    public function getTitle()
96
    {
97 1
        return $this->data['title'];
98
    }
99
100
    /**
101
     * Gets the title link.
102
     *
103
     * @return string A link URL the title should link to.
104
     */
105 1
    public function getTitleLink()
106
    {
107 1
        return isset($this->data['title_link']) ? $this->data['title_link'] : null;
108
    }
109
110
    /**
111
     * Gets the attachment body text.
112
     *
113
     * @return string The attachment body text.
114
     */
115 2
    public function getText()
116
    {
117 2
        return $this->data['text'];
118
    }
119
120
    /**
121
     * Gets the image URL.
122
     *
123
     * @return string A URL to an image to display in the attachment body.
124
     */
125 1
    public function getImageUrl()
126
    {
127 1
        return isset($this->data['image_url']) ? $this->data['image_url'] : null;
128
    }
129
130
    /**
131
     * Gets the thumbnail URL.
132
     *
133
     * @return string A URL to an image to display as a thumbnail.
134
     */
135 1
    public function getThumbUrl()
136
    {
137 1
        return isset($this->data['thumb_url']) ? $this->data['thumb_url'] : null;
138
    }
139
140
    /**
141
     * Gets the footer text.
142
     *
143
     * @return string The footer text.
144
     */
145
    public function getFooterText()
146
    {
147
        return isset($this->data['footer']) ? $this->data['footer'] : null;
148
    }
149
150
    /**
151
     * Gets a URL to an image to show to the left of the footer text.
152
     *
153
     * @return string The footer icon URL.
154
     */
155
    public function getFooterIcon()
156
    {
157
        return isset($this->data['footer_icon']) ? $this->data['footer_icon'] : null;
158
    }
159
160
    /**
161
     * Gets an extra timestamp value in the footer.
162
     *
163
     * @return \DateTime The time of the timestamp.
164
     */
165 1
    public function getTimestamp()
166
    {
167 1
        if (!isset($this->data['ts'])) {
168
            return null;
169
        }
170
171 1
        $time = new \DateTime();
172 1
        $time->setTimestamp($this->data['ts']);
173 1
        return $time;
174
    }
175
176
    /**
177
     * Checks if the attachment has fields.
178
     *
179
     * @return bool
180
     */
181 1
    public function hasFields()
182
    {
183 1
        return isset($this->data['fields']) && count($this->data['fields']) > 0;
184
    }
185
186
    /**
187
     * Gets all the attachment's fields.
188
     *
189
     * @return AttachmentField[]
190
     */
191 1
    public function getFields()
192
    {
193 1
        return isset($this->data['fields']) ? $this->data['fields'] : [];
194
    }
195
196
    /**
197
     * {@inheritDoc}
198
     */
199 15 View Code Duplication
    public function jsonUnserialize(array $data)
200
    {
201 15
        if (!isset($this->data['fields'])) {
202 14
            return;
203
        }
204
205 1
        for ($i = 0; $i < count($this->data['fields']); $i++) {
0 ignored issues
show
Performance Best Practice introduced by
It seems like you are calling the size function count() as part of the test condition. You might want to compute the size beforehand, and not on each iteration.

If the size of the collection does not change during the iteration, it is generally a good practice to compute it beforehand, and not on each iteration:

for ($i=0; $i<count($array); $i++) { // calls count() on each iteration
}

// Better
for ($i=0, $c=count($array); $i<$c; $i++) { // calls count() just once
}
Loading history...
206 1
            $this->data['fields'][$i] = AttachmentField::fromData($this->data['fields'][$i]);
207 1
        }
208 1
    }
209
}
210