Add/dashboard report tickets by group and status - #25146
Conversation
|
Semgrep found 1 Untrusted input could be used to tamper with a web page rendering, which can lead to a Cross-site scripting (XSS) vulnerability. XSS vulnerabilities occur when untrusted input executes malicious JavaScript code, leading to issues such as account compromise and sensitive information leakage. To prevent this vulnerability, validate the user input, perform contextual output encoding or sanitize the input. In PHP you can encode or sanitize user input with View Dataflow Graphflowchart LR
classDef invis fill:white, stroke: none
classDef default fill:#e7f5ff, color:#1c7fd6, stroke: none
subgraph File0["<b>src/Glpi/Security/SessionTracker.php</b>"]
direction LR
%% Source
subgraph Source
direction LR
v0["<a href=https://github.com/glpi-project/glpi/blob/7f742b2c8429cd964a1654529334ab1fbf0efe88/src/Glpi/Security/SessionTracker.php#L697 target=_blank style='text-decoration:none; color:#1c7fd6'>[Line: 697] $_GET</a>"]
end
%% Intermediate
subgraph Traces0[Traces]
direction TB
v2["<a href=https://github.com/glpi-project/glpi/blob/7f742b2c8429cd964a1654529334ab1fbf0efe88/src/Glpi/Security/SessionTracker.php#L697 target=_blank style='text-decoration:none; color:#1c7fd6'>[Line: 697] $start</a>"]
v3["<a href=https://github.com/glpi-project/glpi/blob/7f742b2c8429cd964a1654529334ab1fbf0efe88/src/Glpi/Security/SessionTracker.php#L707 target=_blank style='text-decoration:none; color:#1c7fd6'>[Line: 707] $this->getSessions</a>"]
v4["<a href=https://github.com/glpi-project/glpi/blob/7f742b2c8429cd964a1654529334ab1fbf0efe88/src/Glpi/Security/SessionTracker.php#L533 target=_blank style='text-decoration:none; color:#1c7fd6'>[Line: 533] $start</a>"]
v5["<a href=https://github.com/glpi-project/glpi/blob/7f742b2c8429cd964a1654529334ab1fbf0efe88/src/Glpi/Security/SessionTracker.php#L543 target=_blank style='text-decoration:none; color:#1c7fd6'>[Line: 543] $it</a>"]
v6["<a href=https://github.com/glpi-project/glpi/blob/7f742b2c8429cd964a1654529334ab1fbf0efe88/src/Glpi/Security/SessionTracker.php#L571 target=_blank style='text-decoration:none; color:#1c7fd6'>[Line: 571] as</a>"]
v7["<a href=https://github.com/glpi-project/glpi/blob/7f742b2c8429cd964a1654529334ab1fbf0efe88/src/Glpi/Security/SessionTracker.php#L571 target=_blank style='text-decoration:none; color:#1c7fd6'>[Line: 571] $data</a>"]
end
v2 --> v3
v3 --> v4
v4 --> v5
v5 --> v6
v6 --> v7
%% Sink
subgraph Sink
direction LR
v1["<a href=https://github.com/glpi-project/glpi/blob/7f742b2c8429cd964a1654529334ab1fbf0efe88/src/Glpi/Security/SessionTracker.php#L645 target=_blank style='text-decoration:none; color:#1c7fd6'>[Line: 645] htmlescape(sprintf(__('Expires at %s'), $data['date_expiration']))</a>"]
end
end
%% Class Assignment
Source:::invis
Sink:::invis
Traces0:::invis
File0:::invis
%% Connections
Source --> Traces0
Traces0 --> Sink
|
ecd3772 to
229df2d
Compare
| 'widgettype' => ['hBars', 'stackedHBars'], | ||
| 'itemtype' => "\\Ticket", | ||
| 'group' => __('Assistance'), | ||
| 'label' => __("Number of opened and closed tickets by group"), |
There was a problem hiding this comment.
| 'label' => __("Number of opened and closed tickets by group"), | |
| 'label' => __("Number of opened and solved tickets by group"), |
From the code, the "closed tickets" part is actually solved + closed tickets: $closed_statuses = implode(',', [Ticket::SOLVED, Ticket::CLOSED]);.
With that in mind, I think "solved" would be a more precise label here.
| new QueryExpression("COUNT(CASE WHEN $ticket_table.status IN ($opened_statuses) THEN $ticket_table.id END) AS opened"), | ||
| new QueryExpression("COUNT(CASE WHEN $ticket_table.status IN ($closed_statuses) THEN $ticket_table.id END) AS closed"), |
There was a problem hiding this comment.
| new QueryExpression("COUNT(CASE WHEN $ticket_table.status IN ($opened_statuses) THEN $ticket_table.id END) AS opened"), | |
| new QueryExpression("COUNT(CASE WHEN $ticket_table.status IN ($closed_statuses) THEN $ticket_table.id END) AS closed"), | |
| new QueryExpression("COUNT(DISTINCT CASE WHEN $ticket_table.status IN ($opened_statuses) THEN $ticket_table.id END) AS opened"), | |
| new QueryExpression("COUNT(DISTINCT CASE WHEN $ticket_table.status IN ($closed_statuses) THEN $ticket_table.id END) AS closed"), |
I have some duplicated results when testing, adding UNIQUE seems to fix them.
For example, in a database with only one ticket attached to two groups and using these groups as a filter I would get 2 results:

| ], | ||
| ], | ||
| ], | ||
| 'WHERE' => [ |
| ['name' => __('Opened'), 'data' => []], | ||
| ['name' => __('Closed'), 'data' => []], |
| $group_ticket_table = Group_Ticket::getTable(); | ||
| $group_table = Group::getTable(); | ||
|
|
||
| $opened_statuses = implode(',', [Ticket::INCOMING, Ticket::ASSIGNED, Ticket::PLANNED, Ticket::WAITING]); |
There was a problem hiding this comment.
| $opened_statuses = implode(',', [Ticket::INCOMING, Ticket::ASSIGNED, Ticket::PLANNED, Ticket::WAITING]); | |
| $opened_statuses = implode(',', [Ticket::getNotSolvedStatusArray()]); |
I think you forget Ticket::APPROVAL (unless it is missing on purpose?), if that is the case you can use getNotSolvedStatusArray() so you are sure to not miss anything ;)
| "$ticket_table.is_deleted" => 0, | ||
| ] + getEntitiesRestrictCriteria($ticket_table), | ||
| 'GROUPBY' => "$group_table.id", | ||
| 'ORDERBY' => "$group_table.name", |
9513189 to
2fffe40
Compare




Checklist before requesting a review
Please delete options that are not relevant.
Description
plugins/mreporting/inc/helpdesk.class.php
reportHgbarTicketNumberByService l.475
Screenshots (if appropriate):