Jump to content

Connect SuperML | Leeroopedia MCP: Equip your AI agents with best practices, code verification, and debugging knowledge. Powered by Leeroo — building Organizational Superintelligence. Contact us at founders@leeroo.com.

Implementation:Trailofbits Fickling AnalysisResults To Dict

From Leeroopedia
Knowledge Sources
Domains Security, Reporting, Data_Serialization
Last Updated 2026-02-14 14:00 GMT

Overview

Concrete tool for serializing pickle analysis results to dict and string formats provided by the Fickling library.

Description

AnalysisResults.to_dict() returns a dictionary with keys severity (enum name string), analysis (formatted message text), and detailed_results (per-analysis trigger dict). AnalysisResults.to_string() returns newline-joined messages for results above the verbosity threshold.

Usage

Use to_dict() for JSON output to files or APIs. Use to_string() for terminal or log output. Both accept a verbosity parameter to filter by minimum severity.

Code Reference

Source Location

  • Repository: fickling
  • File: fickling/analysis.py
  • Lines: L428-446

Signature

class AnalysisResults:
    def to_string(
        self,
        verbosity: Severity = Severity.POSSIBLY_UNSAFE
    ) -> str:
        """Return newline-joined messages for results at or above verbosity."""

    def to_dict(
        self,
        verbosity: Severity = Severity.POSSIBLY_UNSAFE
    ) -> dict:
        """Return structured dict with severity, analysis, and detailed_results.

        Returns:
            {"severity": str, "analysis": str, "detailed_results": dict}
        """

Import

from fickling.analysis import AnalysisResults, Severity

I/O Contract

Inputs

Name Type Required Description
verbosity Severity No Minimum severity threshold for included results (default: POSSIBLY_UNSAFE)

Outputs

Name Type Description
to_dict() dict {"severity": str, "analysis": str, "detailed_results": dict}
to_string() str Newline-joined messages for results above verbosity threshold

Usage Examples

JSON Output for CI Pipeline

import json
from fickling.fickle import Pickled
from fickling.analysis import check_safety

with open("model.pkl", "rb") as f:
    pickled = Pickled.load(f)

results = check_safety(pickled)

# Machine-readable output
report = results.to_dict()
print(json.dumps(report, indent=2))
# {"severity": "LIKELY_SAFE", "analysis": "...", "detailed_results": {...}}

# Human-readable output
print(results.to_string())

Related Pages

Implements Principle

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment