Commit graph

20 commits

Author SHA1 Message Date
Umherirrender
a30fe542ae build: Enable SecurityCheck-DoubleEscaped and suppress issues
This issue type was globally suppressed in
I849ac4f120fd15b483e8939d4db45c98dc351259 to make reviewer easier.

This adds inline suppressions or @suppress directives on function
docs for false positives, mostly restoring those removed in
I849ac4f120fd15b483e8939d4db45c98dc351259

Bug: T231311
Change-Id: I1b1d814bd907e9d49fcc39f777982936574fc7c6
2020-12-30 23:34:20 +00:00
Umherirrender
e9e784a09e build: Enable phan-taint-check-plugin and suppress issues
Taint check checks for possible security issues by tracking html
escaping and more by using phan.
This slows done the phan-job a bit and requires more ram

Keep the DoubleEscaped issues out to make reviewer easier

Adds suppression for false positives
Adds taint-annotation to help taint-check
Removes suppression for code phan now understand better by the tracking
of keys in taint-check
Fix some small issues by adding int cast or htmlspecialchars calls

Bug: T216348
Bug: T268920
Change-Id: I849ac4f120fd15b483e8939d4db45c98dc351259
2020-12-30 19:02:22 +01:00
Umherirrender
ad4570b9e1 taint-check: Set raw taints on Message::rawParam
Also add taint for LogFormatter::makePageLink similiar to
LogFormatter::makeUserLink to avoid false positives as the return of
this function is mostly wrapped in Message::rawParam

Change-Id: Iab770702fd3a1d20f25f54057770dc03e28f1b0e
2020-12-13 00:32:26 +01:00
Umherirrender
4c51a42ba7 Add taint hints for message creation method
Some function using union type string|Message where string is a message
key and not html. This can be marked as tainted to avoid double escape
issues from taint-check

Bug: T216348
Change-Id: I40a305b5e49d67b3f6d7737c0846b93a80b78fa9
2020-12-10 23:18:18 +01:00
James D. Forrester
8e2124a159 Drop Message->getFormat(), hard deprecated since 1.29
Change-Id: I02955f93b773868e067c577e9d497dd0bb428d5c
2020-09-20 14:56:41 +01:00
daniel
272db6afde Replace "@stable for calling" by "@stable to call"
For compliance with the new version of the table interface policy
(T255803).

This patch was created by an automated search & replace operation
on the includes/ directory.

Bug: T257789
Change-Id: If560596f5e1e0a3da91afc36e656e7c27f040968
2020-07-13 08:55:28 +00:00
daniel
bd5c3d06a2 Annotate newable classes
This annotates classes that can safely be instantiated by
extensions, per the Stable Interface Policy.

Bug: T247862
Change-Id: Ia280f559874fc0750265ddeb7f831e65fd7d7d6a
2020-07-07 15:38:57 +02:00
Umherirrender
8919239236 Remove is_scalar check on array
is_array is called before is_scalar and arrays are not scalar

Change-Id: I73e65ac8bce95e31a2c5da7a48a212ce35fb4f40
2020-06-19 19:23:17 +02:00
Reedy
d53e91d272 Fix more PSR12.Properties.ConstantVisibility.NotFound
Change-Id: I94520b10d78a17ea8e965633dd475ea711f25c99
2020-05-15 00:33:32 +01:00
Kosta Harlan
9f0fad8c5e Remove reference to wfMsgHtml()
It was removed in MediaWiki 1.27

Change-Id: I9d84d16371ee466064813b24ea855da82ff1e267
2020-05-11 17:24:40 +02:00
Umherirrender
3161311c5a Use MediaWikiServices::getMessageCache
Change-Id: I07fcc9529991adc634c10e5ed8498ac138a1c2b7
2020-03-14 14:25:03 +01:00
Timo Tijhof
92db3a1ff8 language: Avoid title parsing cost for serialised Message objects
There is currently notable overhead from having to call
Title::getPrefixedText/TitleFormatter upon serialisation,
and Title::newFromText/TitleParser upon unserialisation.

An unscientific benchmark:

> $start = microtime(true); $a = new RawMessage('some content');
> $a->title( Title::makeTitle( NS_SPECIAL, 'Badtitle/MessageCache' ) );
> $s = serialize($a); $b = unserialize($s);
> $duration = microtime(true) - $start;
> echo 'time: ' . round($duration * 1000, 1) . ' ms';

Run on mediawiki-docker-dev on PHP 7.2.28, via eval.php:

* Before: 129.7 ms, 118.6 ms
* After: 6.6 ms, 4.7 ms

Bug: T247035
Change-Id: I999db53e2f6189fb4319fefc2fbd8e5e5a228df0
2020-03-06 20:56:35 +00:00
Timo Tijhof
f5895c2c82 language: Clean up file headers and class-level docs
This follows-up d83fcce5cb, which did something similar for
includes/profiler/.

* Ensure presence of license header.

* Merge any file-level descriptions with the class block,
  where it gets seen in generated docs about that class.

* Add any missing `@ingroup` tags to class blocks.

* Remove remaining `@ingroup` from file blocks.
  These clutter the Doxygen pages with duplicate entries.

* Fix some misspelled words from 61e0908fa2 and f136c2953c.

Change-Id: I5d21ec159766b799ba519da951d4f0716bae5f9f
2020-02-12 02:15:44 +00:00
Gergő Tisza
dd01c6dd64
Allow injecting a message localizer into Status
The coupling of Status with the global request context for
Message object creation is a common pain point in unit tests and
in no-session code. As a short term solution (until Status is
properly deprecated) allow injecting a different localizer.

Also refactor the code a bit to get rid if the explicit need for
the context language (which is already implicit in the localizer).

Change-Id: I82a2e4a83743546a934fb938b94e877a2471a3d2
2019-10-30 17:10:22 -07:00
Aryeh Gregor
0de9c47b50 Remove Language::factory and getParentLanguage use
Change-Id: I11f8801ef47ec1a1f63d840116e69667e6f3ae3c
2019-10-27 12:34:28 +02:00
Daimona Eaytoy
2612175ef3 Use real variargs for variadic methods
These were all checked via codesearch to ensure that nothing is overriding
these methods.

Change-Id: Ie2d8c1fd01478f46f3d0d1259417182b0d955a12
2019-10-06 14:47:54 +00:00
Daimona Eaytoy
5eac6d131c Unsuppress more phan issues (part 3)
Bug: T231636
Depends-On: I78354bf5f0c831108c8f606e50c87cf6bc00d8bd
Change-Id: I58e67c2b38389df874438deada4239510d21654f
2019-08-31 16:38:55 +00:00
Daimona Eaytoy
fb3428eb8f Unsuppress other phan issues with low count
And also update approximated counts, which for the most part are lower
than reported (hooray!)

Bug: T231636
Depends-On: Ica50297ec7c71a81ba2204f9763499da925067bd
Change-Id: I78354bf5f0c831108c8f606e50c87cf6bc00d8bd
2019-08-30 09:42:15 +00:00
Aaron Schulz
c21fec141b Import the PSR logger classes in Message
Change-Id: If05db9b55275246174b6f1fd0ca8437f271f5eea
2019-07-04 12:51:09 -07:00
Timo Tijhof
f557b2be4f language: Move some language-related classes to includes/language/
Bug: T225756
Change-Id: Ica351483d83a3a912d58ebb194b30828541fbcf3
2019-06-18 21:38:44 +00:00
Renamed from includes/Message.php (Browse further)