r107906 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r107905‎ | r107906 | r107907 >
Date:17:29, 3 January 2012
Author:mah
Status:ok (Comments)
Tags:miscextensions 
Comment:
Bug 33380 - Details of actions caught by a private filter should be private
Author: Nikola Kovacs

Hide private information from logs
Modified paths:
  • /trunk/extensions/AbuseFilter/AbuseFilter.class.php (modified) (history)
  • /trunk/extensions/AbuseFilter/AbuseFilter.i18n.php (modified) (history)
  • /trunk/extensions/AbuseFilter/Views/AbuseFilterView.php (modified) (history)
  • /trunk/extensions/AbuseFilter/Views/AbuseFilterViewExamine.php (modified) (history)
  • /trunk/extensions/AbuseFilter/Views/AbuseFilterViewList.php (modified) (history)
  • /trunk/extensions/AbuseFilter/special/SpecialAbuseLog.php (modified) (history)

Diff [purge]

Index: trunk/extensions/AbuseFilter/special/SpecialAbuseLog.php
@@ -199,7 +199,10 @@
200200 }
201201
202202 if ( $this->mSearchFilter ) {
203 - $conds['afl_filter'] = $this->mSearchFilter;
 203+ // if the filter is hidden, users who can't view private filters should not be able to find log entries generated by it
 204+ if ( !AbuseFilter::filterHidden( $this->mSearchFilter ) || AbuseFilterView::canViewPrivate() ) {
 205+ $conds['afl_filter'] = $this->mSearchFilter;
 206+ }
204207 }
205208
206209 $searchTitle = Title::newFromText( $this->mSearchTitle );
@@ -222,10 +225,6 @@
223226
224227 function showDetails( $id ) {
225228 $out = $this->getOutput();
226 - if ( !self::canSeeDetails() ) {
227 - $out->addWikiMsg( 'abusefilter-log-cannot-see-details' );
228 - return;
229 - }
230229
231230 $dbr = wfGetDB( DB_SLAVE );
232231
@@ -242,6 +241,17 @@
243242 return;
244243 }
245244
 245+ if ( AbuseFilter::decodeGlobalName( $row->afl_filter ) ) {
 246+ $filter_hidden = null;
 247+ } else {
 248+ $filter_hidden = $row->af_hidden;
 249+ }
 250+
 251+ if ( !self::canSeeDetails( $row->afl_filter, $filter_hidden ) ) {
 252+ $out->addWikiMsg( 'abusefilter-log-cannot-see-details' );
 253+ return;
 254+ }
 255+
246256 if ( $row->afl_deleted && !self::canSeeHidden() ) {
247257 $out->addWikiMsg( 'abusefilter-log-details-hidden' );
248258 return;
@@ -325,8 +335,18 @@
326336 /**
327337 * @return bool
328338 */
329 - static function canSeeDetails() {
 339+ static function canSeeDetails( $filter_id = null, $filter_hidden = null ) {
330340 global $wgUser;
 341+
 342+ if ( $filter_id !== null ) {
 343+ if ( $filter_hidden === null ) {
 344+ $filter_hidden = AbuseFilter::filterHidden( $filter_id );
 345+ }
 346+ if ( $filter_hidden ) {
 347+ return $wgUser->isAllowed( 'abusefilter-log-detail' ) && AbuseFilterView::canViewPrivate();
 348+ }
 349+ }
 350+
331351 return $wgUser->isAllowed( 'abusefilter-log-detail' );
332352 }
333353
@@ -392,11 +412,13 @@
393413 // Pull global filter description
394414 $parsed_comments =
395415 $wgOut->parseInline( AbuseFilter::getGlobalFilterDescription( $globalIndex ) );
 416+ $filter_hidden = null;
396417 } else {
397418 $parsed_comments = $wgOut->parseInline( $row->af_public_comments );
 419+ $filter_hidden = $row->af_hidden;
398420 }
399421
400 - if ( self::canSeeDetails() ) {
 422+ if ( self::canSeeDetails( $row->afl_filter, $filter_hidden ) ) {
401423 $examineTitle = SpecialPage::getTitleFor( 'AbuseFilter', 'examine/log/' . $row->afl_id );
402424 $detailsLink = $sk->makeKnownLinkObj(
403425 $this->getTitle($row->afl_id),
Index: trunk/extensions/AbuseFilter/Views/AbuseFilterViewList.php
@@ -225,11 +225,15 @@
226226 $lang->formatNum( $value )
227227 );
228228 // @todo FIXME: makeKnownLinkObj() is deprecated.
229 - $link = Linker::makeKnownLinkObj(
230 - SpecialPage::getTitleFor( 'AbuseLog' ),
231 - $count_display,
232 - 'wpSearchFilter=' . $row->af_id
233 - );
 229+ if ( SpecialAbuseLog::canSeeDetails( $row->af_id, $row->af_hidden ) ) {
 230+ $link = Linker::makeKnownLinkObj(
 231+ SpecialPage::getTitleFor( 'AbuseLog' ),
 232+ $count_display,
 233+ 'wpSearchFilter=' . $row->af_id
 234+ );
 235+ } else {
 236+ $link = "";
 237+ }
234238 return $link;
235239 case 'af_timestamp':
236240 $userLink =
Index: trunk/extensions/AbuseFilter/Views/AbuseFilterView.php
@@ -22,9 +22,10 @@
2323 abstract function show();
2424
2525 /**
 26+ * @static
2627 * @return bool
2728 */
28 - function canEdit() {
 29+ static function canEdit() {
2930 global $wgUser;
3031 static $canEdit = null;
3132
@@ -36,14 +37,15 @@
3738 }
3839
3940 /**
 41+ * @static
4042 * @return bool
4143 */
42 - function canViewPrivate() {
 44+ static function canViewPrivate() {
4345 global $wgUser;
4446 static $canView = null;
4547
4648 if ( is_null( $canView ) ) {
47 - $canView = $this->canEdit() || $wgUser->isAllowed( 'abusefilter-view-private' );
 49+ $canView = self::canEdit() || $wgUser->isAllowed( 'abusefilter-view-private' );
4850 }
4951
5052 return $canView;
Index: trunk/extensions/AbuseFilter/Views/AbuseFilterViewExamine.php
@@ -106,7 +106,7 @@
107107 self::$examineType = 'log';
108108 self::$examineId = $logid;
109109
110 - if ( !SpecialAbuseLog::canSeeDetails() ) {
 110+ if ( !SpecialAbuseLog::canSeeDetails( $row->afl_filter ) ) {
111111 $this->getOutput()->addWikiMsg( 'abusefilter-log-cannot-see-details' );
112112 return;
113113 }
Index: trunk/extensions/AbuseFilter/AbuseFilter.class.php
@@ -206,7 +206,17 @@
207207 }
208208
209209 public static function filterHidden( $filter ) {
210 - $dbr = wfGetDB( DB_SLAVE );
 210+ $globalIndex = self::decodeGlobalName( $filter );
 211+ if ( $globalIndex ) {
 212+ global $wgAbuseFilterCentralDB;
 213+ if ( !$wgAbuseFilterCentralDB ) {
 214+ return false;
 215+ }
 216+ $dbr = wfGetDB( DB_SLAVE, array(), $wgAbuseFilterCentralDB );
 217+ $filter = $globalIndex;
 218+ } else {
 219+ $dbr = wfGetDB( DB_SLAVE );
 220+ }
211221 $hidden = $dbr->selectField(
212222 'abuse_filter',
213223 'af_hidden',
Index: trunk/extensions/AbuseFilter/AbuseFilter.i18n.php
@@ -104,7 +104,7 @@
105105 'abusefilter-log-linkoncontribs-text' => 'Abuse log for this user',
106106 'abusefilter-log-hidden' => '(entry hidden)',
107107 'abusefilter-log-hide' => 'hide or unhide', // @todo FIXME: Message unused?
108 - 'abusefilter-log-cannot-see-details' => 'You do not have permission to see details of any entries.',
 108+ 'abusefilter-log-cannot-see-details' => 'You do not have permission to see details of this entry.',
109109 'abusefilter-log-details-hidden' => 'You cannot view the details for this entry because it is hidden from public view.',
110110
111111 // Hiding log entries
@@ -581,7 +581,7 @@
582582 'abusefilter-log-linkoncontribs-text' => 'Title for link added on [[Special:Contributions]] and other relevant special pages.',
583583 'abusefilter-log-hidden' => 'Text for a hidden log entry.',
584584 'abusefilter-log-hide' => 'This message may be unused.',
585 - 'abusefilter-log-cannot-see-details' => 'Message show instead of the log row for users without permissions to see any details.',
 585+ 'abusefilter-log-cannot-see-details' => 'Message show instead of log row details for users without permissions to see them.',
586586 'abusefilter-log-details-hidden' => 'Message shown instead of log row details when those are hidden.',
587587 'abusefilter-log-hide-legend' => 'Legend for form to hide a log entry.',
588588 'abusefilter-log-hide-id' => 'Field label in form to hide a log entry.',

Sign-offs

UserFlagDate
Nikerabbitinspected20:51, 3 January 2012

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r107454Fix Bug 33380 - Details of actions caught by a private filter should be private...mah00:26, 28 December 2011

Comments

#Comment by Nikerabbit (talk | contribs)   20:52, 3 January 2012

A bit ugly to depend on $wgUser like that but I guess it's fine.

#Comment by Krinkle (talk | contribs)   00:07, 16 January 2012

User Thehelpfulone would like this to be backported to 1.18 for wmf wikis. I don't know this extension very well, but if it doesn't depend on anything new in 1.19 we can do that.

#Comment by MarkAHershberger (talk | contribs)   19:07, 29 February 2012

Tagged this for 1.19, then realized it was in 1.19.

Status & tagging log