Skip to content

feat: add safetensors loader for structural integrity analysis#197

Open
GangGreenTemperTatum wants to merge 1 commit intomainfrom
feat/safetensors-loader
Open

feat: add safetensors loader for structural integrity analysis#197
GangGreenTemperTatum wants to merge 1 commit intomainfrom
feat/safetensors-loader

Conversation

@GangGreenTemperTatum
Copy link
Collaborator

@GangGreenTemperTatum GangGreenTemperTatum commented Feb 24, 2026

Summary

  • Adds a new safetensors loader that performs static security analysis of .safetensors files without loading model weights into memory
  • Validates header structure (header bombs, truncation, invalid JSON), tensor layout (overlapping byte ranges, out-of-bounds offsets, shape/size mismatches), and metadata (non-string values, URLs, base64, oversized entries)
  • Adds view_extra() dispatcher to view.py with safetensors-specific rendering (file structure, tensor summary, metadata, color-coded findings)

Test plan

  • poetry run ruff check dyana — lint clean
  • poetry run ruff format --check dyana — format clean
  • poetry run mypy --ignore-missing-imports --no-error-summary dyana — type check clean
  • poetry run pytest dyana -v — 189 tests pass (19 new safetensors tests + 7 new view_extra tests)
  • CI pipeline passes

🤖 Generated with Claude Code

Generated Summary:

  • Added support for SafeTensors model files into the Dyana sandbox environment.
  • Implemented a new loader for analyzing SafeTensors files, including validation of header integrity and tensor analysis.
  • Enhanced the README to mention support for SafeTensors files in the description.
  • Refactored CLI code to include a view for the new loader and added error handling for device driver selection.
  • Introduced several tests for the new SafeTensors functionality, ensuring validation and analysis processes are working as expected.
  • New files added:
    • loader.py for SafeTensors processing.
    • main.py for executing the SafeTensors analysis with command-line arguments.
    • Dockerfile and requirements for building the SafeTensors environment.
    • .gitignore for untracked files specific to SafeTensors.
  • The implementation focuses on ensuring structure and integrity while analyzing SafeTensors files, potentially improving user trust in model file validation.

This summary was generated with ❤️ by rigging

Static security analysis of .safetensors files — validates header structure,
detects header bombs, overlapping tensor byte ranges, out-of-bounds offsets,
and suspicious metadata patterns. No model weights loaded into memory.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@dreadnode-renovate-bot dreadnode-renovate-bot bot added type/docs Documentation updates and improvements type/core Changes to core repository files and configurations labels Feb 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type/core Changes to core repository files and configurations type/docs Documentation updates and improvements

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant