OSINT Advanced

OSINT Reporting: Findings, Confidence, Chain of Custody, and Reports Management Will Read

Turn OSINT findings into decisions: BLUF report structure, likelihood x impact ratings, confidence language, GDPR-aware redaction, and a Django app with append-only SHA-256 evidence, a finding workflow, audit log, HTML/PDF reports, CSV/JSON exports and tests.

KC Ramo DjangoZen Team Dec 05, 2026 18 min read 5 views

An OSINT assessment of your own organisation is only as useful as the decisions it produces. Raw findings (an exposed backup directory, a stale DNS record, credentials in a public repository) have to become a report that management can act on, with evidence that survives scrutiny and personal data that is handled lawfully. This tutorial covers the structure of a defender's report, risk and confidence ratings, data protection, chain of custody, and a Django app that stores findings and evidence, renders the report as HTML and PDF, exports CSV and JSON, and tracks remediation to closure.

Scope

The assessment is authorised, written down and limited to your own organisation's public exposure: domains, certificates, code, documents, archived pages and leaked organisational data. People are not targets. When a finding involves personal data, for example an employee's work address in a breach corpus, the finding is about the organisational exposure and the control that failed, never a profile of the person.

Versions used, all latest stable at the time of writing: Python 3.13, Django 5.2.20 (pinned Django>=5.2,<6.0 for the LTS line) and WeasyPrint 70.0 for PDF output.

From raw findings to decisions

A collection log is not a report. Between the two sits analysis: deduplicate, confirm each observation (is that backup directory really ours, is it still there?), group observations into findings that share a cause and a fix, and rate them. A useful test for each finding: can a named owner do something specific about it by a date? If not, it is context for the appendix, not a finding.

Management reads three things: what is wrong, how bad it is, and what it costs to fix. Everything else in the report exists to make those three answers trustworthy.

Structure of a defender's OSINT report

  1. Bottom line up front (BLUF). Three to five sentences: the number of findings, the ones that need a decision this month, and the single most important recommendation. A reader who stops here should still act correctly.
  2. Scope and method. What was in scope, who authorised it, the period, the source types used, and what was explicitly excluded. This protects the reader from over-reading "no findings" as "no exposure".
  3. Findings. One block per finding: title, description, risk rating, confidence, evidence references, recommendation.
  4. Risk overview. A matrix or a sorted table so the reader sees the distribution at a glance.
  5. Recommendations. Each with an owner (a team or role), a due date and a measurable done condition.
  6. Appendix. Evidence register with hashes, methodology details, glossary, distribution list.

Rating risk

Likelihood times impact

A 5 by 5 matrix is simple, explainable and good enough for most exposure findings. Define the scales in the report so the numbers mean something:

ScoreLikelihood (of exploitation in 12 months)Impact (if exploited)
1Rare: needs insider knowledge and effortNegligible: no data, no downtime
2Unlikely: obscure, not indexedMinor: internal information only
3Possible: findable with targeted searchingModerate: limited personal data or short outage
4Likely: indexed by search engines or scannersMajor: customer data, reportable breach
5Almost certain: already being accessed or tradedSevere: large-scale breach, regulatory action

The product gives bands: 1 to 5 Low, 6 to 11 Medium, 12 to 19 High, 20 to 25 Critical. Write the reasoning for both numbers in the finding; a score without a reason invites argument instead of action.

CVSS only where it fits

CVSS (version 4.0 is current) scores the technical severity of a vulnerability in a product. It fits when a finding is a known vulnerability, such as an exposed service running a version with a published CVE. It does not fit a leaked organisation chart, a typosquatted domain or an exposed backup directory. Forcing those into CVSS produces precise-looking numbers with no meaning. Store the CVSS vector alongside the matrix rating when it applies, and let the matrix drive prioritisation.

Confidence language

Every finding carries a confidence level that describes the evidence, not the severity: high (directly observed, reproduced, from our own systems or multiple independent sources), moderate (credible but single-source or partly inferred), low (fragmentary, unverified, or from a source of unknown reliability). When you state probabilities, use a fixed vocabulary such as the ICD 203 terms ("likely" means 55 to 80 percent) and print the scale in the appendix. Never let "possibly" and "probably" drift in meaning between sections.

Handling personal data in reports

OSINT reports attract personal data: e-mail addresses in breach dumps, names in leaked documents, phone numbers in exposed spreadsheets. Under the GDPR the report itself is processing, so apply the principles directly:

  • Minimisation. Report the exposure ("47 employee addresses at example.com appear in a 2026 breach corpus"), not the list. Keep the list in restricted evidence only if remediation needs it.
  • Redaction. Mask identifiers in the rendered report and exports by default. Keep the domain, which is the organisational fact, and drop the person-specific part.
  • Retention. Every evidence item gets a retain_until date at collection time, tied to the purpose (remediation plus an audit period).
  • Access control. The report and the evidence store are separately permissioned, evidence files are never served by the web server, and the distribution list is in the report.

Chain of custody

If a finding ends up in a dispute, an insurance claim or a regulator's inbox, someone will ask: how do you know this file is what you collected, and who has touched it since? Chain of custody answers with four elements: a cryptographic hash computed at collection (SHA-256), a UTC timestamp, the identity of the collector, and an append-only log of every later action. The hash proves integrity only from the moment it was computed, so hash at the point of capture, before any processing, and record the source URL and retrieval time next to it.

A Django app for findings and evidence

Create a project called myproject with an app called findings, and point MEDIA_ROOT at a directory the web server never exposes:

MEDIA_ROOT = BASE_DIR / "private_evidence"  # never served by the web server

Models: append-only evidence, workflow, audit log

import hashlib

from django.conf import settings
from django.core.exceptions import ValidationError
from django.db import models, transaction
from django.utils import timezone


class AppendOnlyError(Exception):
    pass


class AppendOnlyModel(models.Model):
    """Rows can be created, never changed or deleted through the ORM."""

    class Meta:
        abstract = True

    def save(self, *args, **kwargs):
        if self.pk is not None:
            raise AppendOnlyError(f"{type(self).__name__} is append-only")
        super().save(*args, **kwargs)

    def delete(self, *args, **kwargs):
        raise AppendOnlyError(f"{type(self).__name__} is append-only")


class Assessment(models.Model):
    reference = models.CharField(max_length=20, unique=True)  # OSINT-2026-03
    title = models.CharField(max_length=200)
    scope = models.TextField()
    authorised_by = models.CharField(max_length=100)  # role, not a private person
    period_start = models.DateField()
    period_end = models.DateField()

    def __str__(self):
        return self.reference


class AuditLog(AppendOnlyModel):
    at = models.DateTimeField(default=timezone.now)
    actor = models.ForeignKey(settings.AUTH_USER_MODEL, on_delete=models.PROTECT)
    action = models.CharField(max_length=40)
    object_type = models.CharField(max_length=40)
    object_id = models.PositiveIntegerField()
    detail = models.JSONField(default=dict)

    class Meta:
        ordering = ["at", "pk"]


class Evidence(AppendOnlyModel):
    assessment = models.ForeignKey(Assessment, on_delete=models.PROTECT)
    file = models.FileField(upload_to="evidence/%Y/%m/")
    sha256 = models.CharField(max_length=64, editable=False)
    description = models.CharField(max_length=300)
    source_url = models.URLField(blank=True)
    collected_at = models.DateTimeField(default=timezone.now)
    collected_by = models.ForeignKey(settings.AUTH_USER_MODEL, on_delete=models.PROTECT)
    contains_personal_data = models.BooleanField(default=False)
    retain_until = models.DateField()

    @staticmethod
    def digest(f) -> str:
        h = hashlib.sha256()
        f.seek(0)
        for chunk in iter(lambda: f.read(65536), b""):
            h.update(chunk)
        f.seek(0)
        return h.hexdigest()

    def save(self, *args, **kwargs):
        if self.pk is None:
            self.sha256 = self.digest(self.file)
        with transaction.atomic():
            super().save(*args, **kwargs)
            AuditLog.objects.create(
                actor=self.collected_by, action="evidence.added",
                object_type="evidence", object_id=self.pk,
                detail={"sha256": self.sha256, "name": self.file.name})

    def verify(self) -> bool:
        with self.file.open("rb") as f:
            return self.digest(f) == self.sha256


class FindingQuerySet(models.QuerySet):
    def open(self):
        return self.exclude(status__in=Finding.CLOSED)

    def overdue(self, today=None):
        today = today or timezone.localdate()
        return self.open().filter(due_date__lt=today)


class Finding(models.Model):
    class Status(models.TextChoices):
        NEW = "new", "New"
        TRIAGED = "triaged", "Triaged"
        IN_REMEDIATION = "in_remediation", "In remediation"
        RESOLVED = "resolved", "Resolved, awaiting retest"
        VERIFIED = "verified", "Verified closed"
        RISK_ACCEPTED = "risk_accepted", "Risk accepted"
        FALSE_POSITIVE = "false_positive", "False positive"

    class Confidence(models.TextChoices):
        HIGH = "high", "High"
        MODERATE = "moderate", "Moderate"
        LOW = "low", "Low"

    S = Status
    TRANSITIONS = {
        S.NEW: {S.TRIAGED, S.FALSE_POSITIVE},
        S.TRIAGED: {S.IN_REMEDIATION, S.RISK_ACCEPTED, S.FALSE_POSITIVE},
        S.IN_REMEDIATION: {S.RESOLVED, S.RISK_ACCEPTED},
        S.RESOLVED: {S.VERIFIED, S.IN_REMEDIATION},  # retest failed: back
        S.RISK_ACCEPTED: {S.TRIAGED},                # acceptance expired
    }
    CLOSED = {S.VERIFIED, S.RISK_ACCEPTED, S.FALSE_POSITIVE}

    assessment = models.ForeignKey(Assessment, on_delete=models.PROTECT,
                                   related_name="findings")
    title = models.CharField(max_length=200)
    description = models.TextField()
    likelihood = models.PositiveSmallIntegerField()  # 1-5
    impact = models.PositiveSmallIntegerField()      # 1-5
    cvss_vector = models.CharField(max_length=120, blank=True)  # only for vulns
    confidence = models.CharField(max_length=10, choices=Confidence.choices)
    recommendation = models.TextField()
    owner = models.CharField(max_length=100, blank=True)  # team or role
    due_date = models.DateField(null=True, blank=True)
    status = models.CharField(max_length=20, choices=Status.choices,
                              default=Status.NEW)
    evidence = models.ManyToManyField(Evidence, blank=True)

    objects = FindingQuerySet.as_manager()

    class Meta:
        constraints = [
            models.CheckConstraint(
                condition=models.Q(likelihood__range=(1, 5), impact__range=(1, 5)),
                name="risk_scale_1_5"),
        ]

    @property
    def risk_score(self) -> int:
        return self.likelihood * self.impact

    @property
    def risk_level(self) -> str:
        score = self.risk_score
        if score >= 20:
            return "Critical"
        if score >= 12:
            return "High"
        if score >= 6:
            return "Medium"
        return "Low"

    def transition(self, to, actor, note="", retest_evidence=None):
        if to not in self.TRANSITIONS.get(self.status, set()):
            raise ValidationError(f"{self.status} -> {to} is not allowed")
        if to in (self.S.IN_REMEDIATION, self.S.RISK_ACCEPTED) and not (
                self.owner and self.due_date):
            raise ValidationError("owner and due date are required")
        if to == self.S.VERIFIED and retest_evidence is None:
            raise ValidationError("closing requires retest evidence")
        old = self.status
        with transaction.atomic():
            self.status = to
            self.save(update_fields=["status"])
            if retest_evidence is not None:
                self.evidence.add(retest_evidence)
            AuditLog.objects.create(
                actor=actor, action="finding.status", object_type="finding",
                object_id=self.pk, detail={"from": old, "to": to, "note": note})

Design notes:

  • AppendOnlyModel blocks save() on existing rows and delete() on instances. Queryset update() and delete() bypass both, so in production add database-level protection as well: a separate database role without UPDATE and DELETE on the evidence and audit tables, or a PostgreSQL trigger that rejects them.
  • The hash is computed in chunks from the uploaded file before the row is written, and the evidence row and its audit entry are committed in one transaction.
  • Owners are teams or roles, which keeps personal data out of the findings table and survives staff changes.
  • The workflow encodes management's rules: no remediation or risk acceptance without an owner and a due date, and no closure without retest evidence. A failed retest goes back to remediation; an expired risk acceptance goes back to triage.

Redaction filter

import re

from django import template

register = template.Library()

EMAIL = re.compile(r"\b([A-Za-z0-9._%+-])[A-Za-z0-9._%+-]*@([A-Za-z0-9.-]+\.[A-Za-z]{2,})\b")
PHONE = re.compile(r"\+?\d[\d ()-]{7,}\d")


@register.filter
def redact(text: str) -> str:
    """Keep the domain (useful for exposure), drop the person-specific part."""
    text = EMAIL.sub(r"\1***@\2", text)
    return PHONE.sub("[phone redacted]", text)

Regular expressions catch the common cases, not all of them. Treat the filter as a safety net behind a review step, not as the control itself.

Generating the report

HTML from a Django template

The template lives in findings/templates/findings/report.html. It is a complete document because WeasyPrint needs one; the site's normal layout is deliberately not used.

{% load redact %}<!DOCTYPE html>
<html lang="en"><head><meta charset="utf-8">
<title>{{ a.reference }}: {{ a.title }}</title></head>
<body>
<h1>{{ a.title }}</h1>
<p>{{ a.reference }} | Generated {{ generated|date:"Y-m-d H:i" }} UTC | Restricted</p>

<h2>Bottom line</h2>
<p>{{ findings|length }} findings, {{ open_high|length }} open at High or Critical.</p>
<ul>{% for f in open_high %}
  <li>{{ f.title }}: {{ f.risk_level }}. Owner {{ f.owner|default:"UNASSIGNED" }},
      due {{ f.due_date|date:"Y-m-d"|default:"not set" }}.</li>
{% endfor %}</ul>

<h2>Scope and method</h2>
<p>{{ a.scope }}</p>
<p>Period {{ a.period_start|date:"Y-m-d" }} to {{ a.period_end|date:"Y-m-d" }}. Authorised by {{ a.authorised_by }}.</p>

<h2>Findings</h2>
{% for f in findings %}
<h3>F{{ forloop.counter }}. {{ f.title }}</h3>
<p>Risk {{ f.risk_level }} (L{{ f.likelihood }} x I{{ f.impact }} = {{ f.risk_score }})
   | Confidence {{ f.get_confidence_display }} | Status {{ f.get_status_display }}</p>
<p>{{ f.description|redact }}</p>
<p><strong>Recommendation:</strong> {{ f.recommendation }}</p>
<p>Evidence: {% for e in f.evidence.all %}E{{ e.pk }} (sha256 {{ e.sha256|slice:":12" }}){% if not forloop.last %}, {% endif %}{% empty %}none{% endfor %}</p>
{% endfor %}

<h2>Appendix: evidence register</h2>
<table>
<tr><th>ID</th><th>Collected (UTC)</th><th>Description</th><th>SHA-256</th></tr>
{% for f in findings %}{% for e in f.evidence.all %}
<tr><td>E{{ e.pk }}</td><td>{{ e.collected_at|date:"Y-m-d H:i" }}</td>
    <td>{{ e.description|redact }}</td><td>{{ e.sha256 }}</td></tr>
{% endfor %}{% endfor %}
</table>
</body></html>

Views and PDF output

from django.contrib.auth.decorators import permission_required
from django.http import HttpResponse
from django.shortcuts import get_object_or_404
from django.template.loader import render_to_string
from django.utils import timezone

from .models import Assessment


def build_context(reference):
    assessment = get_object_or_404(Assessment, reference=reference)
    findings = sorted(assessment.findings.prefetch_related("evidence"),
                      key=lambda f: (-f.risk_score, f.pk))
    return {"a": assessment, "findings": findings,
            "generated": timezone.now(),
            "open_high": [f for f in findings
                          if f.risk_score >= 12 and f.status not in f.CLOSED]}


@permission_required("findings.view_finding", raise_exception=True)
def report_html(request, reference):
    html = render_to_string("findings/report.html", build_context(reference), request)
    return HttpResponse(html)


@permission_required("findings.view_finding", raise_exception=True)
def report_pdf(request, reference):
    try:
        from weasyprint import HTML  # needs Pango/GLib system libraries
    except OSError:
        return HttpResponse("PDF rendering unavailable on this host", status=501)
    html = render_to_string("findings/report.html", build_context(reference), request)
    pdf = HTML(string=html, base_url=request.build_absolute_uri("/")).write_pdf()
    resp = HttpResponse(pdf, content_type="application/pdf")
    resp["Content-Disposition"] = f'attachment; filename="{reference}.pdf"'
    return resp
from django.urls import path

from . import views

app_name = "findings"
urlpatterns = [
    path("reports/<str:reference>/", views.report_html, name="report"),
    path("reports/<str:reference>/pdf/", views.report_pdf, name="report_pdf"),
]

Rendered with two seeded findings, the top of the report reads:

<h2>Bottom line</h2>
<p>2 findings, 1 open at High or Critical.</p>
<ul>
  <li>Public backup directory on files.example.com: Critical. Owner Platform team,
      due 2026-12-12.</li>
</ul>
...
<h3>F1. Public backup directory on files.example.com</h3>
<p>Risk Critical (L4 x I5 = 20)
   | Confidence High | Status New</p>
<p>Listing exposes a database dump; notify j***@example.com</p>
...
<p>Evidence: E1 (sha256 724f3c910214)</p>

On the Windows test machine WeasyPrint 70.0 installed from pip but failed at import with OSError: cannot load library 'libgobject-2.0-0': it needs the Pango and GLib system libraries, which pip does not provide. On Windows install them through MSYS2 as described in the WeasyPrint documentation; on Debian or Ubuntu servers install packages such as libpango-1.0-0 and libpangoft2-1.0-0 (the installation page lists the full set). The view catches the OSError and returns HTTP 501, so the HTML report keeps working and the missing dependency is visible rather than silent. Browsers can also print the HTML report to PDF as a fallback.

Exporting findings to CSV and JSON

Ticketing systems, GRC tools and spreadsheets want structured data, not prose. A management command exports one assessment, redacted, with evidence hashes so the export can be tied back to the evidence register.

import csv
import json
import sys

from django.core.management.base import BaseCommand

from findings.models import Finding
from findings.templatetags.redact import redact

FIELDS = ["id", "title", "risk_level", "risk_score", "confidence",
          "status", "owner", "due_date", "evidence_sha256"]


class Command(BaseCommand):
    help = "Export findings of one assessment as CSV or JSON (redacted)."

    def add_arguments(self, parser):
        parser.add_argument("reference")
        parser.add_argument("--format", choices=["csv", "json"], default="csv")

    def handle(self, reference, format, **opts):
        rows = []
        qs = Finding.objects.filter(assessment__reference=reference)
        for f in qs.prefetch_related("evidence").order_by("pk"):
            rows.append({
                "id": f.pk, "title": redact(f.title),
                "risk_level": f.risk_level, "risk_score": f.risk_score,
                "confidence": f.confidence, "status": f.status,
                "owner": f.owner,
                "due_date": f.due_date.isoformat() if f.due_date else "",
                "evidence_sha256": ";".join(e.sha256 for e in f.evidence.all()),
            })
        if format == "json":
            self.stdout.write(json.dumps(rows, indent=2))
        else:
            writer = csv.DictWriter(self.stdout, fieldnames=FIELDS)
            writer.writeheader()
            writer.writerows(rows)
python manage.py export_findings OSINT-2026-03
id,title,risk_level,risk_score,confidence,status,owner,due_date,evidence_sha256

1,Public backup directory on files.example.com,Critical,20,high,new,Platform team,2026-12-12,724f3c910214faed24380edd7bfc97a2fd85295bfd6a371d511077188a86ca7d

2,Stale DNS record points to released cloud IP,Medium,9,moderate,new,,,

The same command with --format json produces a list of objects with the same keys. Exports are copies of restricted data: label them, store them in the same access-controlled location as the report, and include them in your retention schedule.

Verifying evidence integrity

Hashes are only useful if somebody checks them. Run this command before the report is issued and on a schedule afterwards:

from django.core.management.base import BaseCommand, CommandError

from findings.models import AuditLog, Evidence


class Command(BaseCommand):
    help = "Re-hash every evidence file and compare with the stored SHA-256."

    def handle(self, **opts):
        bad = 0
        for ev in Evidence.objects.order_by("pk"):
            ok = ev.verify()
            bad += not ok
            self.stdout.write(f"E{ev.pk} {ev.sha256[:16]} {'OK' if ok else 'MISMATCH'}")
            if not ok:
                AuditLog.objects.create(
                    actor=ev.collected_by, action="evidence.mismatch",
                    object_type="evidence", object_id=ev.pk, detail={})
        if bad:
            raise CommandError(f"{bad} evidence file(s) failed verification")
> python manage.py verify_evidence
E1 724f3c910214faed OK
> (append a line to the stored evidence file)
> python manage.py verify_evidence
CommandError: 1 evidence file(s) failed verification
E1 724f3c910214faed MISMATCH

The audit log now holds both the original evidence.added entry with its hash and an evidence.mismatch entry, which is exactly the history an investigator needs.

Tracking remediation to closure

A report is a snapshot; remediation is a process. Use the workflow and the overdue() queryset to drive a short weekly review: new findings without an owner, findings past their due date, risk acceptances nearing expiry and resolved findings waiting for retest. Close a finding only with retest evidence collected the same way as the original, for example a fresh capture showing HTTP 403 where the directory listing used to be. Report closure rates to management alongside new findings, because a falling backlog is the clearest proof that the assessment was worth doing.

Tests

import hashlib
import json
import shutil
import tempfile
from datetime import date
from io import StringIO

from django.contrib.auth.models import Permission, User
from django.core.exceptions import ValidationError
from django.core.files.base import ContentFile
from django.core.management import call_command
from django.test import TestCase, override_settings

from .models import AppendOnlyError, Assessment, AuditLog, Evidence, Finding
from .templatetags.redact import redact

MEDIA = tempfile.mkdtemp()


@override_settings(MEDIA_ROOT=MEDIA)
class FindingsTests(TestCase):
    @classmethod
    def tearDownClass(cls):
        super().tearDownClass()
        shutil.rmtree(MEDIA, ignore_errors=True)

    def setUp(self):
        self.user = User.objects.create_user("analyst")
        self.a = Assessment.objects.create(
            reference="OSINT-2026-03", title="External exposure review",
            scope="Domains example.com and example.org", authorised_by="CISO",
            period_start=date(2026, 11, 2), period_end=date(2026, 11, 27))
        self.body = b"HTTP/1.1 200 OK\r\n\r\nIndex of /backup"
        self.ev = Evidence.objects.create(
            assessment=self.a, file=ContentFile(self.body, name="listing.txt"),
            description="Directory listing on files.example.com",
            collected_by=self.user, retain_until=date(2027, 11, 27))
        self.f = Finding.objects.create(
            assessment=self.a, title="Public backup directory",
            description="Listing exposes db.sql; contact j.doe@example.com",
            likelihood=4, impact=5, confidence="high",
            recommendation="Disable listing, move backups off the web root")
        self.f.evidence.add(self.ev)

    def test_evidence_hash_and_append_only(self):
        self.assertEqual(self.ev.sha256, hashlib.sha256(self.body).hexdigest())
        self.assertTrue(self.ev.verify())
        self.ev.description = "changed"
        with self.assertRaises(AppendOnlyError):
            self.ev.save()
        with self.assertRaises(AppendOnlyError):
            self.ev.delete()

    def test_risk_matrix(self):
        self.assertEqual((self.f.risk_score, self.f.risk_level), (20, "Critical"))

    def test_workflow_requires_owner_and_retest(self):
        self.f.transition(Finding.Status.TRIAGED, self.user)
        with self.assertRaises(ValidationError):
            self.f.transition(Finding.Status.IN_REMEDIATION, self.user)
        self.f.owner, self.f.due_date = "Platform team", date(2026, 12, 12)
        self.f.save()
        self.f.transition(Finding.Status.IN_REMEDIATION, self.user)
        self.f.transition(Finding.Status.RESOLVED, self.user, "listing off")
        with self.assertRaises(ValidationError):
            self.f.transition(Finding.Status.VERIFIED, self.user)
        retest = Evidence.objects.create(
            assessment=self.a, file=ContentFile(b"HTTP/1.1 403", name="retest.txt"),
            description="Retest: 403", collected_by=self.user,
            retain_until=date(2027, 11, 27))
        self.f.transition(Finding.Status.VERIFIED, self.user, retest_evidence=retest)
        steps = [e.detail["to"] for e in AuditLog.objects.filter(action="finding.status")]
        self.assertEqual(steps, ["triaged", "in_remediation", "resolved", "verified"])

    def test_illegal_transition(self):
        with self.assertRaises(ValidationError):
            self.f.transition(Finding.Status.VERIFIED, self.user)

    def test_overdue(self):
        self.f.due_date = date(2026, 12, 1)
        self.f.save()
        self.assertEqual(list(Finding.objects.overdue(date(2026, 12, 5))), [self.f])

    def test_redaction(self):
        self.assertEqual(redact("mail j.doe@example.com or +31 20 123 4567"),
                         "mail j***@example.com or [phone redacted]")

    def test_report_requires_permission_and_redacts(self):
        self.client.force_login(self.user)
        url = "/osint/reports/OSINT-2026-03/"
        self.assertEqual(self.client.get(url).status_code, 403)
        self.user.user_permissions.add(Permission.objects.get(codename="view_finding"))
        html = self.client.get(url).content.decode()
        self.assertIn("Bottom line", html)
        self.assertIn("j***@example.com", html)
        self.assertNotIn("j.doe@", html)
        self.assertIn(self.ev.sha256, html)
        pdf = self.client.get(url + "pdf/")
        self.assertIn(pdf.status_code, {200, 501})

    def test_exports(self):
        out = StringIO()
        call_command("export_findings", "OSINT-2026-03", "--format", "json", stdout=out)
        row = json.loads(out.getvalue())[0]
        self.assertEqual(row["evidence_sha256"], self.ev.sha256)
        out = StringIO()
        call_command("export_findings", "OSINT-2026-03", stdout=out)
        self.assertTrue(out.getvalue().startswith("id,title,risk_level"))
python manage.py test findings
Found 8 test(s).
...
Ran 8 tests in 0.241s

OK

On a host without the Pango libraries, WeasyPrint prints an installation warning to stderr during the PDF test; the test accepts both 200 and 501 so it passes on both kinds of host.

Checklist

  1. Written authorisation and scope are recorded on the assessment before collection starts.
  2. Every evidence item is hashed with SHA-256 at capture, with UTC time, collector and source URL.
  3. Evidence and audit tables are append-only in the application and protected at database level.
  4. Every finding has a likelihood and impact with written reasoning, plus a confidence level; CVSS is used only for real vulnerabilities.
  5. The report opens with a BLUF that names decisions, owners and dates.
  6. Personal data is minimised, redacted in the report and exports, and given a retention date.
  7. Reports, exports and evidence are access-controlled and evidence files are never web-served.
  8. verify_evidence runs before issue and on a schedule; mismatches are investigated.
  9. Findings close only through retest evidence; overdue items are reviewed weekly.
  10. The test suite covers hashing, append-only behaviour, the workflow, redaction, permissions and exports.

Found a mistake in this tutorial? Let us know and we will fix it.