Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

Finding Fields

A finding in CoPyRIT has a title, a severity and a set of fields. Each deployment chooses those fields. The finding dialog, the finding cards and the exports all follow them.

Default Fields

Without any configuration, findings use these fields:

Defining Your Own Fields

To use other fields, subclass FindingsInitializer and return a FindingFields from get_finding_fields. Every deployment has a severity slot. It’s always a required choice field, but its options are your own: the example below uses Sev 1–3 instead of the defaults. The fields in fields follow it in the dialog.

from pyrit.models import FindingField, FindingFields, FindingFieldType, FindingSeverityColor
from pyrit.setup.initializers import FindingsInitializer


class ContosoFindingsInitializer(FindingsInitializer):
    """Finding fields for the Contoso red team."""

    def get_finding_fields(self) -> FindingFields:
        return FindingFields(
            severity=FindingField(
                key="severity",
                label="Severity",
                type=FindingFieldType.CHOICE,
                options=[("sev1", "Sev 1"), ("sev2", "Sev 2"), ("sev3", "Sev 3")],
                default="sev2",
                colors={"sev1": FindingSeverityColor.RED, "sev2": FindingSeverityColor.ORANGE},
            ),
            fields=[
                FindingField(
                    key="harm_category",
                    label="Harm category",
                    type=FindingFieldType.CHOICE,
                    required=True,
                    options={
                        ("content", "Content safety"): [("hate", "Hate"), ("violence", "Violence")],
                        ("security", "Security"): [("prompt_injection", "Prompt injection")],
                    },
                    levels=[("subcategory", "Subcategory")],
                ),
                FindingField(key="repro_steps", label="Repro steps", type=FindingFieldType.MULTILINE),
                FindingField(key="cvss_score", label="CVSS score", type=FindingFieldType.NUMBER),
                FindingField(key="contoso_ticket", label="Contoso ticket", type=FindingFieldType.TEXT),
            ],
        )

A few things to note in this example:

FindingField also takes hint, section and allow_other. section puts a heading, such as “Reproduction”, above a field whose section differs from the field before it. The FindingField docstring describes each setting.

Save the script as contoso_findings.py in your custom initializers source. The file name is the initializer’s name. Then turn it on in .pyrit_conf:

allow_custom_initializers: true
custom_initializers_source: /srv/contoso/pyrit_initializers
initializers:
  - name: target
  - name: technique
  - name: contoso_findings

With allow_custom_initializers: true, the backend runs every script in that source. Only trusted administrators should be able to write to it. See the configuration file guide for details.

Rules

Changing the Fields

A deployment has one set of finding fields, and every operation uses it, including operations from before a change. Changing the initializer changes how findings show in all of them:

Upgrading

One database migration moves findings saved before finding fields existed. It stores Other severity text as the severity itself, and moves the harm type and description into field values. Finding IDs and evidence don’t change. Downgrading that migration moves those values back: a severity or harm type that PyRIT 1.2 doesn’t list becomes Other with its text. It refuses, without changing anything, while any finding has a value under another key, and names those keys so you can remove the values first.

Code written for PyRIT 1.2

PyRIT 1.2 had fixed finding fields. Code that uses them still works, with a deprecation warning, until PyRIT 1.5.0:

PyRIT 1.2Use instead
FindingSeverityThe option keys of FindingFields.severity, such as "critical"
descriptionfield_values.get("description", "")
harm_type and harm_type_otherfield_values.get("harm_type"), which holds the category or its Other text
severity_otherseverity, which holds Other text itself
finding.severity.valuefinding.severity
GET /api/operations/finding-optionsGET /api/operations/{operation_id}/finding-fields

An optional field that isn’t set has no key in field_values, so read it with get.

Creating or updating a finding with the old fields moves their values the way the migration does, so they fill the default fields’ keys. A deployment whose fields don’t use those keys rejects them. API responses still include the old fields, marked deprecated in the API schema.

Three things can’t keep working. A severity with Other text is that text, so it no longer equals FindingSeverity.OTHER. A severity is now a string, so it isn’t an instance of FindingSeverity. Finding.model_dump() and model_dump_json() no longer include the old fields; read severity and field_values instead.