New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Configure Enrichers #149

Closed
sts opened this Issue Oct 13, 2017 · 4 comments

Comments

Projects
None yet
2 participants
@sts

sts commented Oct 13, 2017

Currently the list of enrichers is hardcoded in class Enricher. We would like to disable IP and MAC Enrichers, so we don't leak information externally. What would be the best way to do so? Can we configure this somewhere?

@kiwiz kiwiz self-assigned this Oct 14, 2017

@kiwiz

This comment has been minimized.

Show comment
Hide comment
@kiwiz

kiwiz Oct 14, 2017

Collaborator

Hi! You can create a file called hook.php in the root of the project to override the list of Enrichers. Something like this: (Untested)

<?php

Hook::register('init.pre', function($args) {
    Enrichers::$TYPES = ['Stacktrace_Enricher', 'Link_Enricher', 'Null_Enricher'];
});

I'm not sure that this is necessary, as the enrichers should only be accessible when logged into 411. Can you provide more details on that?

Collaborator

kiwiz commented Oct 14, 2017

Hi! You can create a file called hook.php in the root of the project to override the list of Enrichers. Something like this: (Untested)

<?php

Hook::register('init.pre', function($args) {
    Enrichers::$TYPES = ['Stacktrace_Enricher', 'Link_Enricher', 'Null_Enricher'];
});

I'm not sure that this is necessary, as the enrichers should only be accessible when logged into 411. Can you provide more details on that?

@kiwiz kiwiz removed their assignment Oct 27, 2017

@sts

This comment has been minimized.

Show comment
Hide comment
@sts

sts Nov 9, 2017

Looks like there is a bug in Enricher.php:

    /**
     * Creates a new Enricher of the appropriate type.
     * @param string $type The type of the Enricher.
     * @return Enricher The new Enricher.
     */
    public static function getEnricher($type) {
        $types = self::getTypes();
        return Util::exists($types, $type) ? $types[$type] : 'null';
    }

Null is returned as string instead of null type.

This is how my hook.php looks like:


use FOO\Hook;
use FOO\Enricher;

Hook::register('init.pre', function($args) {
  Enricher::$TYPES = ['Link_Enricher'];
});

Exception:
PHP Fatal error: Uncaught Error: Class 'null' not found in /var/www/phplib/REST/Enrich.php:27

sts commented Nov 9, 2017

Looks like there is a bug in Enricher.php:

    /**
     * Creates a new Enricher of the appropriate type.
     * @param string $type The type of the Enricher.
     * @return Enricher The new Enricher.
     */
    public static function getEnricher($type) {
        $types = self::getTypes();
        return Util::exists($types, $type) ? $types[$type] : 'null';
    }

Null is returned as string instead of null type.

This is how my hook.php looks like:


use FOO\Hook;
use FOO\Enricher;

Hook::register('init.pre', function($args) {
  Enricher::$TYPES = ['Link_Enricher'];
});

Exception:
PHP Fatal error: Uncaught Error: Class 'null' not found in /var/www/phplib/REST/Enrich.php:27

@kiwiz

This comment has been minimized.

Show comment
Hide comment
@kiwiz

kiwiz Nov 9, 2017

Collaborator

That's actually referring to the fallback Null_Enricher type (in case we attempt to initialize an invalid type). If you add that to the list, it should work.

Collaborator

kiwiz commented Nov 9, 2017

That's actually referring to the fallback Null_Enricher type (in case we attempt to initialize an invalid type). If you add that to the list, it should work.

@kiwiz

This comment has been minimized.

Show comment
Hide comment
@kiwiz

kiwiz Nov 9, 2017

Collaborator

@sts My bad, you were right. Fixed on master.

Collaborator

kiwiz commented Nov 9, 2017

@sts My bad, you were right. Fixed on master.

@kiwiz kiwiz closed this Apr 2, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment