cybersecurity · intermediate · ~15 min · safe pentest lab

Build a finding block

Format a Markdown finding for a report.

Challenge

Format one finding as a Markdown block so a report stays skimmable and tool-parseable.

Task

Implement int build_finding(char *out, int outsz, const char *title, const char *sev) that writes the finding into out and returns its length.

Input

  • out: caller buffer of size outsz.
  • title: the finding title.
  • sev: the severity label.

Output

Writes exactly ## <title>\n**Severity:** <sev>\n into out (using snprintf) and returns the length snprintf reports.

Example

build_finding(b, 128, "SQL Injection", "High")
  ->  b = "## SQL Injection\n**Severity:** High\n"

Edge cases

  • The layout is exact, including the heading ##, the bold **Severity:**, and the trailing newline.

Input format

An output buffer out, its size outsz, a title, and a severity sev.

Output format

The length written by snprintf; out holds ## <title>\n**Severity:** <sev>\n.

Constraints

Use snprintf; match the exact heading/bold/newline layout.

Starter code

#include <stdio.h>

int build_finding(char *out, int outsz, const char *title, const char *sev) {
    /* TODO */
    return 0;
}

Solve this exercise in the browser editor — compile and run against the test harness, no setup required.