Issues (3948)

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.

app/Models/TaskRecurrenceModel.php (5 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
/*
4
 * This file is part of Jitamin.
5
 *
6
 * Copyright (C) Jitamin Team
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Jitamin\Model;
13
14
use DateInterval;
15
use DateTime;
16
17
/**
18
 * Task Recurrence.
19
 */
20
class TaskRecurrenceModel extends TaskDuplicationModel
21
{
22
    /**
23
     * Return the list user selectable recurrence status.
24
     *
25
     * @return array
26
     */
27
    public function getRecurrenceStatusList()
28
    {
29
        return [
30
            TaskModel::RECURRING_STATUS_NONE    => t('No'),
31
            TaskModel::RECURRING_STATUS_PENDING => t('Yes'),
32
        ];
33
    }
34
35
    /**
36
     * Return the list recurrence triggers.
37
     *
38
     * @return array
39
     */
40 View Code Duplication
    public function getRecurrenceTriggerList()
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...
41
    {
42
        return [
43
            TaskModel::RECURRING_TRIGGER_FIRST_COLUMN => t('When task is moved from first column'),
44
            TaskModel::RECURRING_TRIGGER_LAST_COLUMN  => t('When task is moved to last column'),
45
            TaskModel::RECURRING_TRIGGER_CLOSE        => t('When task is closed'),
46
        ];
47
    }
48
49
    /**
50
     * Return the list options to calculate recurrence due date.
51
     *
52
     * @return array
53
     */
54
    public function getRecurrenceBasedateList()
55
    {
56
        return [
57
            TaskModel::RECURRING_BASEDATE_DUEDATE     => t('Existing due date'),
58
            TaskModel::RECURRING_BASEDATE_TRIGGERDATE => t('Action date'),
59
        ];
60
    }
61
62
    /**
63
     * Return the list recurrence timeframes.
64
     *
65
     * @return array
66
     */
67 View Code Duplication
    public function getRecurrenceTimeframeList()
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...
68
    {
69
        return [
70
            TaskModel::RECURRING_TIMEFRAME_DAYS   => t('Day(s)'),
71
            TaskModel::RECURRING_TIMEFRAME_MONTHS => t('Month(s)'),
72
            TaskModel::RECURRING_TIMEFRAME_YEARS  => t('Year(s)'),
73
        ];
74
    }
75
76
    /**
77
     * Duplicate recurring task.
78
     *
79
     * @param int $task_id Task id
80
     *
81
     * @return bool|int Recurrence task id
82
     */
83
    public function duplicateRecurringTask($task_id)
84
    {
85
        $values = $this->copyFields($task_id);
86
87
        if ($values['recurrence_status'] == TaskModel::RECURRING_STATUS_PENDING) {
88
            $values['recurrence_parent'] = $task_id;
89
            $values['column_id'] = $this->columnModel->getFirstColumnId($values['project_id']);
0 ignored issues
show
The property columnModel does not exist on object<Jitamin\Model\TaskRecurrenceModel>. Since you implemented __get, maybe consider adding a @property annotation.

Since your code implements the magic getter _get, this function will be called for any read access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

If the property has read access only, you can use the @property-read annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
90
            $this->calculateRecurringTaskDueDate($values);
91
92
            $recurring_task_id = $this->save($task_id, $values);
93
94
            if ($recurring_task_id !== false) {
95
                $this->tagDuplicationModel->duplicateTaskTags($task_id, $recurring_task_id);
0 ignored issues
show
The property tagDuplicationModel does not exist on object<Jitamin\Model\TaskRecurrenceModel>. Since you implemented __get, maybe consider adding a @property annotation.

Since your code implements the magic getter _get, this function will be called for any read access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

If the property has read access only, you can use the @property-read annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
96
97
                $parent_update = $this->db
0 ignored issues
show
The property db does not exist on object<Jitamin\Model\TaskRecurrenceModel>. Since you implemented __get, maybe consider adding a @property annotation.

Since your code implements the magic getter _get, this function will be called for any read access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

If the property has read access only, you can use the @property-read annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
98
                    ->table(TaskModel::TABLE)
99
                    ->eq('id', $task_id)
100
                    ->update([
101
                        'recurrence_status' => TaskModel::RECURRING_STATUS_PROCESSED,
102
                        'recurrence_child'  => $recurring_task_id,
103
                    ]);
104
105
                if ($parent_update) {
106
                    return $recurring_task_id;
107
                }
108
            }
109
        }
110
111
        return false;
112
    }
113
114
    /**
115
     * Calculate new due date for new recurrence task.
116
     *
117
     * @param array $values Task fields
118
     */
119
    public function calculateRecurringTaskDueDate(array &$values)
120
    {
121
        if (!empty($values['date_due']) && $values['recurrence_factor'] != 0) {
122
            if ($values['recurrence_basedate'] == TaskModel::RECURRING_BASEDATE_TRIGGERDATE) {
123
                $values['date_due'] = time();
124
            }
125
126
            $factor = abs($values['recurrence_factor']);
127
            $subtract = $values['recurrence_factor'] < 0;
128
129
            switch ($values['recurrence_timeframe']) {
130
                case TaskModel::RECURRING_TIMEFRAME_MONTHS:
131
                    $interval = 'P'.$factor.'M';
132
                    break;
133
                case TaskModel::RECURRING_TIMEFRAME_YEARS:
134
                    $interval = 'P'.$factor.'Y';
135
                    break;
136
                default:
137
                    $interval = 'P'.$factor.'D';
138
            }
139
140
            $date_due = new DateTime();
141
            $date_due->setTimestamp($values['date_due']);
142
143
            $subtract ? $date_due->sub(new DateInterval($interval)) : $date_due->add(new DateInterval($interval));
144
145
            $values['date_due'] = $date_due->getTimestamp();
146
        }
147
    }
148
}
149