Problem/Motivation

Sometimes we want to be able to log messages which contain encrypted data. We can't use watchdog for this and also we want to keep it seperated from all the other messages which watchdog generates so we can give access to supereditors to this logs.

Proposed resolution

We already have dvg_logger, which currently is only used for:

* log failed login attempts
* log the change of the test BSN number

If we expand this functionality a bit and create an UI, we will be able to enhance dvg_logger for our purposes.

Remaining tasks

* Add encrypted field to dvg_logger table
* add $encrypted parameter to _dvg_logger_register_log()
* create UI
* create permissions
* create update hook

User interface changes

New user interface for admins and supereditors at:
/admin/reports/dvg-logger

API changes

New parameter $encrypted:

_dvg_logger_register_log($type, $name, $encrypted = FALSE);

Data model changes

New field "encrypted" (boolean) in table dvg_logger.

Comments

askibinski created an issue. See original summary.

askibinski’s picture

Status: Active » Needs review
StatusFileSize
new9.62 KB
Danny.Wouters’s picture

Status: Needs review » Reviewed & tested by the community

The patch works. Log messages with encrypted data are now logged in the dvg_logger table

askibinski’s picture

Status: Reviewed & tested by the community » Needs work

We need to add a configurable option which types should be mailed. Now, all types are mailed in _dvg_logger_send_email() which would result in our encrypted entries also being mailed.

askibinski’s picture

Status: Needs work » Needs review
StatusFileSize
new11.91 KB
new2.86 KB
askibinski’s picture

Status: Needs review » Needs work

Needs work:

1. expand options to purge logs. Currently only 1 month, 2 months. Should be 1 to 7 days, 2 weeks, 1 month, etc.
2. our overview query currently fails if the messages are very large because of memory limits:

  $query->fields('dl', [
    'lid',
    'type',
    'message',
    'hostname',
    'timestamp',
    'encrypted',
  ])
    ->extend('TableSort')
    ->extend('PagerDefault')
    ->orderByHeader($header)
    ->limit(25);

We aren't showing message any more in the table overview so this should be removed from the query.

Danny.Wouters’s picture

Status: Needs work » Needs review
StatusFileSize
new1.12 KB
new12.19 KB

I created a new patch which adds additional time slot options to purge the logs. I also removed the 'message' field from the query

Danny.Wouters’s picture

StatusFileSize
new11.69 KB
new520 bytes

I removed the changes to the .info file from the previous patch

heine’s picture

+ $query->condition('dl.type', check_plain($form_state['input']['filter_type']), '=');

Why the check_plain?

+    if ($row->encrypted) {
+      $message = decrypt($row->message);
+    }

Message is no longer used here.

+              _dvg_logger_register_log('dvg_logger_mail', t('E-mailed @period log of type @type', array('@period' => $period, '@type' => $type)));

I wonder why this is t() and not format_string(). If translations are desired, the watchdog approach would be more appropriate.

Is it possible to show only a part of the message (if non-encrypted) in the overview table? That would make the overview more useful. If dvg_logger is also required for debugging using large data dumps, wouldn't it be better to separate messages, message variables & dump? Or in other words; what is the purpose of this module?

Danny.Wouters’s picture

StatusFileSize
new11.7 KB
new536 bytes

The function _dvg_logger_register_log didn't use the parameter $encrypted to encrypt the message.
I made a new patch to encrypt the message depending on the value of $encrypted

heine’s picture

In addition to #9; dvg_logger_update_7002 uses schema. See https://www.drupal.org/node/150220 for why this will work now, but is not correct.

askibinski’s picture

Status: Needs review » Needs work

@heine the idea is to extend dvg_logger into a more generic solution for dvg specific logging and this patch is a first step but we need to separate into more types to make the overview and dvg_logger more useful.

The check_plain isn't needed indeed and $message was leftover code from an earlier version.

Danny.Wouters’s picture

StatusFileSize
new1.71 KB
new11.59 KB

@Heine thanks for the review. I added your suggestions to a new pach

paulvandenburg’s picture

Status: Needs work » Needs review
StatusFileSize
new11.63 KB
new558 bytes

Fixed @heine's feedback from #11.

I however took a different approach than the linked documentation.
This should mitigate the problem as well, without having to add redundant the schema definitions.

joshahubbers’s picture

Status: Needs review » Reviewed & tested by the community

  • paulvandenburg committed d36fc10 on 7.x-1.x
    Issue #2930491 by Danny.Wouters, askibinski, paulvandenburg, Heine,...
paulvandenburg’s picture

Status: Reviewed & tested by the community » Fixed
paulvandenburg’s picture

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

paulvandenburg’s picture

StatusFileSize
new635 bytes

This issue accidentally added the short array syntax. Until we've formally dropped php 5.6 support (soon?), we shouldn't do that.
I've already committed this, but here is the patch separately anyway.