View Issue Details
| ID | Project | Category | View Status | Date Submitted | Last Update |
|---|---|---|---|---|---|
| 0020539 | mantisbt | security | public | 2016-01-22 21:07 | 2020-12-30 08:28 |
| Reporter | vboctor | Assigned To | vboctor | ||
| Priority | normal | Severity | minor | Reproducibility | have not tried |
| Status | closed | Resolution | fixed | ||
| Product Version | 1.2.19 | ||||
| Target Version | 1.3.0-rc.2 | Fixed in Version | 1.3.0-rc.2 | ||
| Summary | 0020539: Billing report exposes information about inaccessible projects when All Projects is selected | ||||
| Description | The billing information shows up in two places:
| ||||
| Tags | mantishub | ||||
| Attached Files | 0001-Add-access-check-filtering-for-billing-report.patch (1,178 bytes)
From e4ded41f9d31018da29e550d002fbe17bc24108b Mon Sep 17 00:00:00 2001
From: Victor Boctor <vboctor@gmail.com>
Date: Sat, 23 Jan 2016 02:08:28 +0000
Subject: [PATCH 1/3] Add access check / filtering for billing report
- In case of all projects, filter to user accessible ones.
- In case of a specific project, double check that user has access to it.
Fixes #20539
---
core/bugnote_api.php | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/core/bugnote_api.php b/core/bugnote_api.php
index a508b70..2266c0f 100644
--- a/core/bugnote_api.php
+++ b/core/bugnote_api.php
@@ -705,10 +705,13 @@ function bugnote_stats_get_project_array( $p_project_id, $p_from, $p_to, $p_cost
}
if( ALL_PROJECTS != $p_project_id ) {
+ access_ensure_project_level( config_get( 'view_bug_threshold' ), $p_project_id );
+
$t_project_where = ' AND b.project_id = ' . db_param() . ' AND bn.bug_id = b.id ';
$t_params[] = $p_project_id;
} else {
- $t_project_where = '';
+ $t_project_ids = current_user_get_accessible_projects();
+ $t_project_where = ' AND b.project_id in (' . implode( ', ', $t_project_ids ). ')';
}
if( !is_blank( $c_from ) ) {
--
1.9.1
0002-Add-access-check-filtering-for-billing-exports.patch (1,177 bytes)
From 03b20dd56c15088ed5119a5b82fc36ee897da411 Mon Sep 17 00:00:00 2001
From: Victor Boctor <vboctor@gmail.com>
Date: Sat, 23 Jan 2016 02:10:34 +0000
Subject: [PATCH 2/3] Add access check / filtering for billing exports
- In case of all projects, filter to user accessible ones.
- In case of a specific project, double check that user has access to it.
Fixes #20539
---
core/billing_api.php | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/core/billing_api.php b/core/billing_api.php
index c2ddc49..12be079 100644
--- a/core/billing_api.php
+++ b/core/billing_api.php
@@ -67,10 +67,13 @@ function billing_get_for_project( $p_project_id, $p_from, $p_to, $p_cost_per_hou
}
if( ALL_PROJECTS != $p_project_id ) {
+ access_ensure_project_level( config_get( 'view_bug_threshold' ), $p_project_id );
+
$t_project_where = ' AND b.project_id = ' . db_param() . ' AND bn.bug_id = b.id ';
$t_params[] = $p_project_id;
} else {
- $t_project_where = '';
+ $t_project_ids = current_user_get_accessible_projects();
+ $t_project_where = ' AND b.project_id in (' . implode( ', ', $t_project_ids ). ')';
}
if( !is_blank( $c_from ) ) {
--
1.9.1
0003-Use-billing-api-for-billing-page-access-check.patch (978 bytes)
From 171b72ca3381a8e1063224e275c88b662e8bdc09 Mon Sep 17 00:00:00 2001
From: Victor Boctor <vboctor@gmail.com>
Date: Sat, 23 Jan 2016 02:14:01 +0000
Subject: [PATCH 3/3] Use billing api for billing page access check
---
billing_page.php | 7 ++-----
1 file changed, 2 insertions(+), 5 deletions(-)
diff --git a/billing_page.php b/billing_page.php
index b62ebd4..ff6de97 100644
--- a/billing_page.php
+++ b/billing_page.php
@@ -32,16 +32,13 @@
require_once( 'core.php' );
require_api( 'access_api.php' );
+require_api( 'billing_api.php' );
require_api( 'config_api.php' );
require_api( 'constant_inc.php' );
require_api( 'html_api.php' );
require_api( 'lang_api.php' );
-if( !config_get( 'time_tracking_enabled' ) ) {
- trigger_error( ERROR_ACCESS_DENIED, ERROR );
-}
-
-access_ensure_project_level( config_get( 'time_tracking_reporting_threshold' ) );
+billing_ensure_reporting_access();
html_page_top( lang_get( 'time_tracking_billing_link' ) );
?>
--
1.9.1
| ||||
|
I've added a 3 commit patch. First commit, is likely to apply to both master and master-1.2.x The access is now needed in a couple of places because the logic done for reporting in CSV/Excel is different from the web page. Where the web page deals with aggregates and the Excel/CSV provide separate entries for separate notes. Let me know your feedback. |
|
|
Reminder sent to: atrol, cproensa, dregad, syncguru Please review the attached patch. |
|
|
I've published this to a github branch under my account with a fix to my change to handle sub-projects successfully. Let me know your feedback so that I can apply to master/master-1.2.x. https://github.com/vboctor/mantisbt/tree/time_tracking_access_check |
|
|
I have no time at the moment to have a deeper look or for any tests. |
|
|
@atrol Good catch. Fixing this for the export csv/excel is easy. Fixing it for the web report is harder because it currently aggregates time so I have to change how it works. Will update you once fixed |
|
I think we really need a way to share private branches in a non-public manner. I'll delay testing this until you have a patch as per your last note 0020539:0052400 |
|
|
|
|
I've pushed the code refactoring to add the access check and have one method that does the correct extraction of billing information from the database. All billing reporting APIs are now in core/billing_api.php. |
|
|
The numbers don't add up. After enabling time tracking and creating a couple bugs and bugnotes, running the reports with a reporter profile CSV export is correct Note: bugnotes 1a + 1c are public, 1b + 1d are private Online report is wrong - aggregation of administrator time does fails to consider bugnotes 1a + 1b |
|
|
Fixed, please try again. |
|
|
MantisBT: master 66f735c5 2016-02-04 07:34 Details Diff |
Check access for every time tracking note - Add access level check per bugnote. - Refactor code to have a single place where time tracking entries are calculated. Fixes 0020539 |
Affected Issues 0020539 |
|
| mod - billing_inc.php | Diff File | ||
| mod - billing_page.php | Diff File | ||
| mod - core/billing_api.php | Diff File | ||
| mod - core/bugnote_api.php | Diff File | ||
| mod - core/user_api.php | Diff File | ||