Skip to content

Commit 2f96a4a

Browse files
committed
Prevent unprivileged users from viewing private Issues
If a Private Issue is attached to an existing Changeset, then any user can view the Issue's Summary field. The information is visible on view.php, as well as on list.php (via pop-up on Affected Issues id hyperlink). Filtering accessible issues before display fixes the problem. Thanks to d3vpoo1 (https://gitlab.com/jrckmcsb) for reporting this. Fixes #344 # Conflicts: # Source/Source.ViewAPI.php # Source/pages/view.php
1 parent c888810 commit 2f96a4a

File tree

2 files changed

+33
-11
lines changed

2 files changed

+33
-11
lines changed

Source/Source.ViewAPI.php

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ function Source_View_Changesets( $p_changesets, $p_repos=null, $p_show_repos=tru
2929
$t_changeset->load_bugs();
3030
$t_changeset->load_files();
3131

32+
bug_cache_array_rows( $t_changeset->bugs );
33+
3234
$t_author = Source_View_Author( $t_changeset, false );
3335
$t_committer = Source_View_Committer( $t_changeset, false );
3436
?>
@@ -65,7 +67,22 @@ function Source_View_Changesets( $p_changesets, $p_repos=null, $p_show_repos=tru
6567
<?php }
6668
?>
6769
</td>
68-
<td colspan="2"><?php
70+
71+
<?php
72+
# Build list of related issues the user has access to, with link
73+
$t_view_bug_threshold = config_get('view_bug_threshold');
74+
$t_bugs = array_map(
75+
'string_get_bug_view_link',
76+
array_filter(
77+
$t_changeset->bugs,
78+
function( $p_bug_id ) use ( $t_view_bug_threshold ) {
79+
return bug_exists( $p_bug_id )
80+
&& access_has_bug_level( $t_view_bug_threshold, $p_bug_id );
81+
}
82+
)
83+
);
84+
?>
85+
<td colspan=2><?php
6986
# The commit message is manually transformed (adding href, bug and bugnote
7087
# links + nl2br) instead of calling string_display_links(), which avoids
7188
# unwanted html tags processing by the MantisCoreFormatting plugin.
@@ -81,9 +98,6 @@ function Source_View_Changesets( $p_changesets, $p_repos=null, $p_show_repos=tru
8198
</td>
8299
<td>
83100
<?php
84-
# Build list of related issues with link
85-
$t_bugs = array_map( 'string_get_bug_view_link', $t_changeset->bugs );
86-
87101
if( $t_bugs ) {
88102
echo '<span class="bold">',
89103
plugin_lang_get( 'affected_issues', 'Source' ),

Source/pages/view.php

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,23 @@
1414
$t_changeset = SourceChangeset::load( $f_changeset_id );
1515
$t_changeset->load_files();
1616
$t_changeset->load_bugs();
17-
bug_cache_array_rows( $t_changeset->bugs );
1817

18+
# Get the list of related bugs the user has access to
19+
$t_view_bug_threshold = config_get('view_bug_threshold');
20+
$t_visible_bugs = array_filter(
21+
$t_changeset->bugs,
22+
function( $p_bug_id ) use ( $t_view_bug_threshold ) {
23+
return bug_exists( $p_bug_id)
24+
&& access_has_bug_level( $t_view_bug_threshold, $p_bug_id );
25+
}
26+
);
27+
bug_cache_array_rows( $t_visible_bugs );
1928
$t_bug_rows = array();
20-
foreach( $t_changeset->bugs as $t_bug_id ) {
21-
$t_bug_row = bug_cache_row( $t_bug_id, false );
22-
if ( false === $t_bug_row ) { continue; }
23-
24-
$t_bug_rows[$t_bug_id] = $t_bug_row;
29+
foreach( $t_visible_bugs as $t_bug_id ) {
30+
$t_bug_rows[$t_bug_id] = bug_get_row( $t_bug_id );
2531
}
26-
$t_affected_rowspan = count( $t_bug_rows ) + ( $t_can_update ? 1 : 0 );
32+
33+
$t_affected_rowspan = count( $t_visible_bugs ) + ( $t_can_update ? 1 : 0 );
2734

2835
$t_repos = SourceRepo::load_by_changesets( $t_changeset );
2936
if ( count( $t_repos ) < 1 ) {
@@ -149,6 +156,7 @@
149156
<?php
150157
$t_first = true;
151158
$t_user_id = auth_get_current_user_id();
159+
152160
foreach ( $t_bug_rows as $t_bug_id => $t_bug_row ) {
153161
$t_color_class = html_get_status_css_class(
154162
$t_bug_row['status'],

0 commit comments

Comments
 (0)