blackstork-io / fabric

An open-source command-line tool for cybersecurity reporting automation and a configuration language for reusable templates. Reporting-as-Code
https://blackstork.io/fabric/
Apache License 2.0
27 stars 2 forks source link

Notion Publisher #221

Open brittonhayes opened 1 month ago

brittonhayes commented 1 month ago

Description

Hello! Love the project 😊 I'd like to see support for creating Notion pages with the report content rendered by Fabric. I'd be more than happy to take a pass at helping create this if it sounds interesting!

Use Case

The use case for this is the aggregation of vulnerability and security posture reporting into a flexible knowledge management tool. I'd like to be able to have a report get generated and uploaded to Notion, enabling back linking between Reports and other security knowledge such as case manager entries, tasks, projects, ATT&CK techniques etc.

Requirements

Additional Information

traut commented 1 month ago

@brittonhayes thank you for the issue and the kind words! I've been planning on making one for Notion delivery, so I'm glad to see some interest!

The ability to specify Notion as an output via a flag or config

In the latest release (v0.4.2, the docs came online just now!) we added a concept of publishers, configured through publish blocks. The idea is to support multiple delivery destination for the created documents. Publishers implement API integration and are responsible for API-specific formatting of the content.

We're still developing the idea. For now we have only one publisher implemented -- local_file (code), but we have GitHub gist planned already. I would love to have a publisher for Notion as well.

The ability to pass Notion API credentials securely either via Env Var or file path

Environment variables are already supported.

Conversion of Markdown document to Notion blocks (this could be out of scope and something I could create as an external pkg for your project to consume if helpful)

This can happen in the publisher. The easiest is to contribute a new notion plugin with notion_page (?) publisher inside to this repository -- we'll take care of the maintenance and the releases. Alternatively, you can create a separate repository for the plugin. It will be a bit of a learning experience for us, since we don't host plugins outside this repo just yet :)

brittonhayes commented 1 month ago

Love this idea!! Sounds like we're on the same page. I'll plan on taking a pass at building out a Notion publisher plugin in the fabric repository looking at the local file one as reference.

I don't feel the need to own the publisher plugin in my own repositories, happy to have it live in fabric so you can do whatever with it ☺️

Since a Notion publisher sounds like a welcome addition, I've gone ahead and built out the first piece of our puzzle here which is a Markdown AST -> Notion blocks converter. This will handle parsing the markdown, converting markdown components into their corresponding block types, chunking long documents into multiple blocks to support Notion's API limits (and allowing people to upload really big reports if they choose), etc etc.

Currently it supports headers, lists, paragraphs, and links. Once it's got support for things like codeblocks and text formatting I'll transition over to building out the publisher.

No idea how to do that at the moment but we can figure that out together πŸ˜‚ Not too worried about it.

traut commented 1 month ago

that's a great first iteration! With #159 we're planning on supporting a richer data structure (we're looking at the Goldmark AST types right now) in the future, so the publishers / formatters would need to be upgraded support it. But we're not there yet, so relying on Markdown is the way to go.