CERT-Polska / mwdb-core

Malware repository component for samples & static configuration with REST API interface.
https://mwdb.readthedocs.io/
Other
320 stars 73 forks source link

Styling options in Rich attributes #887

Open yankovs opened 11 months ago

yankovs commented 11 months ago

Feature Category

Hey! :)

This isn't really a feature suggestion but the feature category seemed the most appropriate. This is more of a question.

Recently I used the rich attribute feature in MWDB, and in there I made a table, where one of the fields in it is sha256 hash and it is very long. This makes the table come out of the attribute boundaries and overall this is hard to work with for the end user as part of the table is under another UI element. What I would like to have as a user is either a way to specify I want the text to wrap, or maybe to show a short part of the hash (first 8 letters for example) and have it show the full value on hover and let you copy it somehow.

Generally mustache & markdown feels very restrictive, but maybe it is possible in some way. I was also thinking about maybe letting the user straight up write JS (so for example, a user can use substr to show part of a string), maybe by throwing their input into eval() but it seems not safe at all 😓.

Edit: Maybe what I'm thinking of is more in the line of filters in Jinja2. Would be pretty cool if it was possible to do {{hash|substr(0,8)}}

psrok1 commented 11 months ago

Hi!

I really like the idea with filters! I'm also not really sure about executing arbitrary JS from the template, but set of predefined filters extensible by plugins should work pretty OK.

Most of the rendering machinery is in these files: