Issues (20)

Security Analysis    not enabled

This project does not seem to handle request data directly as such no vulnerable execution paths were found.

  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.
  Regex Injection
Regex Injection enables an attacker to execute arbitrary code in your PHP process.
  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.
  Response Splitting
Response Splitting can be used to send arbitrary responses.
  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.
  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.
  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.
  Code Injection
Code Injection enables an attacker to execute arbitrary code on the server.
  Variable Injection
Variable Injection enables an attacker to overwrite program variables with custom data, and can lead to further vulnerabilities.
  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.
  Other Vulnerability
This category comprises other attack vectors such as manipulating the PHP runtime, loading custom extensions, freezing the runtime, or similar.
  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.
  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.
  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.
  Header Injection
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.

SlashCommandHandlers/Jobs/SearchTDTicketJob.php (5 issues)

1
<?php
2
3
namespace Slackbot001\SlashCommandHandlers\Jobs;
4
5
use Illuminate\Support\Facades\Log;
6
use Slackbot001\SessionManager;
7
use Spatie\SlashCommand\Attachment;
8
use Spatie\SlashCommand\AttachmentAction;
9
use Spatie\SlashCommand\AttachmentField;
10
use Spatie\SlashCommand\Jobs\SlashCommandResponseJob;
11
12
class SearchTDTicketJob extends SlashCommandResponseJob
13
{
14
    // notice here that Laravel will automatically inject dependencies here
15
    public function handle()
16
    {
17
        $build = \Tremby\LaravelGitVersion\GitVersionHelper::getVersion();
18
19
        $userSession = new SessionManager();
20
        $TDinstance = $userSession->setupSession($this->request->userId, $this->request->token);
21
22 View Code Duplication
        if ($TDinstance->checkToken()) {
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...
23
            Log::info('CP_SearchTDTicketJob: There is a token.');
24
            $auth = true;
25
            $tickets = $TDinstance->searchTicketsName($this->request->text);
26
            $userSession()->increment('td_searches');
27
        } else {
28
            Log::info('CP_SearchTDTicketJob: No token.');
29
            $auth = false;
30
            $tickets = null;
31
        }
32
33
        $opencount = 0;
34
        if (!count($tickets) && $auth) {
35
            return $this->respondToSlack('🕵️ I could not find any tickets with that requestor name.')->send();
0 ignored issues
show
Are you sure the usage of ...questor name.')->send() targeting Spatie\SlashCommand\Response::send() seems to always return null.

This check looks for function or method calls that always return null and whose return value is used.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
if ($a->getObject()) {

The method getObject() can return nothing but null, so it makes no sense to use the return value.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
36
        } elseif (!$auth) {
37
            return $this->respondToSlack("🕵️ I wasn't authorized to access TeamDynamix.")->send();
0 ignored issues
show
Are you sure the usage of ... TeamDynamix.')->send() targeting Spatie\SlashCommand\Response::send() seems to always return null.

This check looks for function or method calls that always return null and whose return value is used.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
if ($a->getObject()) {

The method getObject() can return nothing but null, so it makes no sense to use the return value.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
38
        }
39
40
        foreach ($tickets as $ticket) {
41
            if ($ticket['StatusName'] != 'Closed' && $ticket['StatusName'] != 'Cancelled') {
42
                $opencount++;
43
                $date = date('F jS, Y', strtotime($ticket['CreatedDate']));
44
                //$ticketURL = (string) $TDinstance->rootAppsUrl().'Tickets/TicketDet?TicketID='.$ticket['ID'];
45
                $ticketDescription = $TDinstance->ticket($ticket['ID']); //Need to do this because in the TD API, searched ticket's desctiption is empty.
46
47
                $attachmentFields[] = AttachmentField::create('Opened On', $date);
48
                $attachmentFields[] = AttachmentField::create('Requested By', $ticket['RequestorName'])->displaySideBySide();
49
                $attachmentFields[] = AttachmentField::create('Assigned To', $ticket['ResponsibleFullName'])->displaySideBySide();
50
51
                $attachmentAction = AttachmentAction::create('action', '📋 Show Ticket', 'button')
52
                ->setValue($ticket['ID'])
53
                ->setStyle('good');
54
55
                $action = $attachmentAction->toArray();
56
                $ticketattachments[] = Attachment::create()
57
                ->setFallback('Ticket '.$ticket['ID'])
58
                ->setTitle('🏷 '.$ticket['ID'])
59
                ->setText($ticketDescription['Description'])
60
                ->setFields($attachmentFields)
61
                ->setCallbackId($ticket['ID'])
62
                ->addAction($action)
63
                ->setColor('good')
64
                ->setFooter('CP_TD/S API bot microservice v'.$TDinstance->getVersion().' | Build: '.$build);
65
            }
66
            unset($attachmentFields);
67
        }
68
69
        if ($opencount > 0) {
70
            $this
71
             ->respondToSlack('🕵️ I found '.$opencount.' open tickets.')
72
             ->withAttachments($ticketattachments)
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable $ticketattachments does not seem to be defined for all execution paths leading up to this point.
Loading history...
73
             ->displayResponseToEveryoneOnChannel()
74
             ->send();
75
        } elseif ($opencount > 100) {
76
            $this
77
            ->respondToSlack('🕵️ I found '.$opencount.' open tickets, but Slack only supports 100 attachments. Sorry!')
78
            ->displayResponseToEveryoneOnChannel()
79
            ->send();
80
        } else {
81
            return $this
0 ignored issues
show
Are you sure the usage of ...yoneOnChannel()->send() targeting Spatie\SlashCommand\Response::send() seems to always return null.

This check looks for function or method calls that always return null and whose return value is used.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
if ($a->getObject()) {

The method getObject() can return nothing but null, so it makes no sense to use the return value.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
82
             ->respondToSlack('🕵️ I found '.$opencount.' open tickets.')
83
             ->withAttachment(Attachment::create()
84
                 ->setFallback('🕵️ I found no open tickets.')
85
                 ->setColor('warning')
86
                 ->setFooter('CP_TD/S API bot microservice v'.$TDinstance->getVersion().' | Build: '.$build)
87
             )
88
             ->displayResponseToEveryoneOnChannel()
89
             ->send();
90
        }
91
    }
92
}
93