GhostManager / Ghostwriter

The SpecterOps project management and reporting engine
https://ghostwriter.wiki
BSD 3-Clause "New" or "Revised" License
1.3k stars 178 forks source link

Select Caption Type for Evidence #478

Open wexew-ware opened 2 months ago

wexew-ware commented 2 months ago

Currently when attaching evidence the caption used is always the "Figure" caption even when the evidence used is a table and not an image. Would it be possible to have an option to choose a "Table" Caption and have it use the 'Label Used for Tables' that is set within the Global Report Configuration menu?

Screenshot from 2024-07-10 16-42-51

chrismaddalena commented 1 month ago

That's something we could do. We'd have to figure out how and where to make that an option.

Ghostwriter uses the figure options because it assumes evidence files are images or text. Are you uploading images of tables? You can insert tables with the WYSIWYG editor, but that doesn't add a caption or table label.

smcgu commented 1 month ago

We use both evidence images/charts and tables. For tables, we have a "Table Caption" style and it appears above the table. For evidence/images/charts, we use a "Figure Caption" style and the caption appears below the evidence. I have no idea how widespread this arrangement is in the technical writing world, but our technical editor enforces it and some technical writing guides recommend it.

So, we would have:

Some paragraph explaining the situation that provides data in {{.ref my-super-awesome-table}}
with a proof of concept in {{.ref super-awesome-screenshot}}.

{{.caption my-super-awesome-table}}My Table Header That Should Use a Table Caption Style
<some table>
{{super-awesome-screenshot}}

I was thinking that we could create two new Ghostwriter placeholders such as {{.figure}} and {{.table}}, with {{.caption}} being equivalent to {{.figure}} for backwards compatibility. They would be configurable to have their own:

Figures would use the current configuration options and tables would be the new config options; again, to maintain backwards compatibility.

So, from the above example, the change in the WYSIWYG would be minimal:

Some paragraph explaining the situation that provides data in {{.ref my-super-awesome-table}}
with a proof of concept in {{.ref super-awesome-screenshot}}.

{{.table my-super-awesome-table}}My Table Header That Should Use a Table Caption Style
<some table>
{{super-awesome-screenshot}}

And, if you wanted to manually create a figure caption with maybe some code block:

The proof of concept code execution is in {{.ref my-code-block}}.

`
code block
code block
code block
`
{{.figure my-code-block}}This is my POC code block

{{.caption}} could also work for this situation, too.

smcgu commented 1 month ago

Implementation wise, I was looking to:

  1. Implement the {{.figure}} placeholder that reuses the current {{.caption}} code that creates FIGURE sequence items.
  2. Implement the {{.table}} placeholder that creates TABLE sequence items.
  3. Create/adjust the Django admin panel and database for the distinct config items.
  4. Sanity check the template for the configured styles. I am a bit less clear on how this would work and the template validation code, but it would probably be good to check templates for the styles that are configured.