Problem/Motivation
The current doxygen is "Logger channel interface" when the interface is called "LoggerChannelInterface". That's not too helpful. Also, $context['link'] is printed as-is and that little fact is not documented. Anywhere. In the last decade.
Proposed resolution
Write some helpful notes on the two sides of logging: implementing a logger and using the logger. Add a security notice about link existing and being printed as-is.
Remaining tasks
Backport the security notice. This doesn't need to be handled privately because it is extremely likely that whoever used this (can't be a lot given how poorly it is documented and rarely used in core) used l() as core does. Also
On the other hand, an XSS issue related to other names (e.g. languages) that are unlikely to be entered/imported from an untrusted source can be handled in public.
| Comment | File | Size | Author |
|---|---|---|---|
| #18 | 2535192_18.patch | 1.6 KB | chx |
Comments
Comment #1
chx commentedComment #2
dawehnerIf this is the central place for loggers I think we should document how to use loggers. a) Inject one of the loggers from the core.services.yml file and b) not typehint against LoggerChannelInterface but rather LoggerInterface. Especially the later one seems not obvious reading the first sentence.
Comment #3
chx commentedWrote more docs. Also, in D7 we had
function watchdog($type, $message, $variables = array(), $severity = WATCHDOG_NOTICE, $link = NULL) {in D8 it is possible to set $context['link'] instead but there's nowhere to document this because the LoggerInterface is in vendor.Comment #4
dawehnerDouble "\\" :)
Well, let's assume people read that interface you are patching. Then nothing blocks you from providing the same interface method again in our subinterface.
In general try to not be so pessimistic, this time we can actually make sense out of the documentation. The docs in D7 has been also just wrong.
You did not passed in a link, but rather a path / URL.
Comment #5
chx commented> The docs in D7 has been also just wrong. You did not passed in a link, but rather a path / URL.
No, you passed in whatever you wanted and was and still printed as-is. I am not kidding. Check dblog_event in D7 (or any Drupal version you want back to 3.0 or somesuch -- yes, I checked a lot of git history) and DblogController::eventDetails for more (DbLog::log just records it). It is currently broken in syslog as the tags are stripped (and has been stripped since syslog got added to core) and #76588-62: Syslog module's serialization of log components possibly broken tried to fix in 2009 (as I said: I dug up all history relating to this) but the issue simply lies there CNW since.
After some digging I found a usage in D7 modules/book/book.admin.inc:
which still exists in D8 core/modules/book/src/Form/BookAdminEditForm.php
and following this, you can search for
logger.*linkand find a couple dozen usages.So
Purdy! I am raising this to major. The security notice needs a backport, too. Back to whatever versions we still commit patches to :) This is merely a weakness, one that is unlikely to be exploitable since people pass the output of l() to this in D7 and below anyways.
Comment #6
chx commentedComment #7
chx commentedComment #8
chx commentedComment #9
chx commentedOpsie, i accidentally patched vendor.
Comment #10
chx commentedWhile discussing how
l()is gone from D8 I foundLinkGeneratorTrait::l()so I added that to the list.Comment #11
chx commentedscor points out Url using security note so i renamed here as well.
Comment #12
dawehnerI'm confused because many of the callers in core specify a path there.
Comment #13
dawehnerOh you are absolutely right and I was blind from reading d6 code.
Comment #14
jhodgdonUm....
So I agree the interface docs need some love, but... After reading through these docs I was left with a lot of confusion. Can they get a bit more work please?
Why should this be done? I have no idea... why would we define this interface and then say not to use it?
When I read this paragraph, I was confused in the 3rd line by "this interface"... is it referring to LoggerInterface or LoggerChannelInterface? The "this" is ambiguous because there are two interfaces (the one being documented and the one talked about in the paragraph). And I still don't know why we have our own interface here if we're just supposed to implement the PSR interface? Makes no sense to me.
Actually I have no idea what this paragraph means. I'm sure it makes sense if you already know the information, but I don't and it doesn't... ???
What context array? Maybe this is related to one of the methods? If so it should say that and/or be documented on that method?
Comment #15
dawehnerThat interface is about injecting some things into the logger. This is something the caller of a logger should not care about at all.
On top of that its also better to write code in the smallest interface as possible, as your code gets more compatible with PSR-3
Comment #16
jhodgdonOK, how about making that comment say something like:
This interface defines the full behavior of the central Drupal logger facility. However, when writing code that does logging, use the generic \Psr\Log\LoggerInterface for typehinting instead (you shouldn't need the methods here).
Comment #17
chx commentedComment #18
chx commentedComment #19
chx commentedComment #20
jhodgdonLooks good to me now, thanks!
Comment #21
alexpottLoggerChannelInterface's love has been received. Committed 3838074 and pushed to 8.0.x. Thanks!
I think that D7 should have a new issue since this interface does not exist there.
Comment #23
jhodgdonFair enough. D7 follow-up:
#2540830: Sanitize watchdog() link in dblog_event()