Skip to content
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

Implementing an Image_Handler and Header-Styles #1

Merged
merged 6 commits into from
Aug 15, 2022

Conversation

LukyLuke
Copy link
Contributor

@LukyLuke LukyLuke commented Jul 29, 2022

To be able to use images in docx reports and also headers from markdown, I decided to made these few simple changes.
To be able to use it also from DFIR-IRIS, I will also create a pullrequest there.

HTML-Tags in Links

Some people use HTML-Tags in link descriptions for example to add an Icon or emphasize something. This produces then a corrupt document.xml:

<w:r><w:t xml:space="preserve"><i class="icon icon_one" />Some text with a Link: </w:t></w:r>
<w:hyperlink r:id="rId13" w:tgtFrame="_blank"><w:r>
<w:t xml:space="preserve">[DS] siesta.jpg</w:t></w:r></w:hyperlink>

Maybe this is elsewhere the case too 🤔

Header Styles

We use a lot of markdown in our reports and therefore also headers, which where just stripped of till now.
I extended the styles with header1 to header5 and the DocxRenderer to use it as all other tags.

Image-Handler

Since DFIR-IRIS can handle Datastore-Images we also need them in our Reports. Therefore I have implemented an image_handler based on the PictureGlobal which can now handle local and http(s) images.
It downloads all the images and stores them in a subfolder of the generating report and adds them via the already implemented logic.

There is a inconvenience in docx.image.tiff class which also parses EXIF information from JPEG files. In case there is an unreadable or unknown resolution tag, the image cannot be added. I have not spotted this errors with PNGs. Because this costed me quite some time to figure out, i added a little better log and error message.
Open issue: python-openxml/python-docx#1124

Thanks for your work!
Lukas

@whikernel whikernel self-requested a review July 30, 2022 07:15
@whikernel whikernel added the enhancement New feature or request label Jul 30, 2022
@whikernel whikernel self-assigned this Jul 30, 2022
@whikernel whikernel changed the base branch from master to develop August 15, 2022 06:25
@whikernel whikernel merged commit cf58401 into dfir-iris:develop Aug 15, 2022
@LukyLuke LukyLuke deleted the different_fixes branch August 15, 2022 14:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

2 participants