Implementation:Trailofbits Fickling Check For Corruption
Appearance
| Knowledge Sources | |
|---|---|
| Domains | Security, File_Format, Integrity |
| Last Updated | 2026-02-14 14:00 GMT |
Overview
Concrete tool for detecting structural corruption in PyTorch files provided by the Fickling library.
Description
check_for_corruption takes the properties dictionary from find_file_properties and applies structural integrity rules. Currently checks for TorchScript files with model.json but missing both attributes.pkl and constants.pkl. Returns a tuple of (corrupted: bool, reason: str).
Usage
Use after find_file_properties to verify file structural integrity before format identification or analysis.
Code Reference
Source Location
- Repository: fickling
- File: fickling/polyglot.py
- Lines: L259-273
Signature
def check_for_corruption(properties: dict) -> tuple[bool, str]:
"""Check for structural corruption in PyTorch files.
Args:
properties: Properties dict from find_file_properties().
Returns:
Tuple of (corrupted: bool, reason: str).
Returns (False, "") if no corruption detected.
"""
Import
from fickling.polyglot import check_for_corruption
I/O Contract
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
| properties | dict | Yes | Properties dictionary from find_file_properties() |
Outputs
| Name | Type | Description |
|---|---|---|
| (return) | tuple[bool, str] | (corrupted, reason); (False, "") if no corruption |
Usage Examples
Check File Integrity
from fickling.polyglot import find_file_properties, check_for_corruption
properties = find_file_properties("model.pt")
corrupted, reason = check_for_corruption(properties)
if corrupted:
print(f"CORRUPTED: {reason}")
else:
print("File structure is valid")
Related Pages
Implements Principle
Page Connections
Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment