Ranks catalogued engine versions by how much of their CMC_* surface they share,
which (unlike a binary fuzzy hash) stays meaningful across compilers — the golden
pair PIKLIB8/MSVC6 vs bloomoodll/MSVC8 scores 85%.
- similarity.py: jaccard, surface_similarity (per-axis + pooled overall),
fuzzy_similarity (ssdeep via ppdeep, secondary signal)
- service.similar_snapshots + GET /snapshots/{id}/similar?min=N (SimilarHit)
- UI: "Podobne wersje" panel in the snapshot browser (overlap bar + ⇄ diff)
- tests: 6 new (jaccard, identical/disjoint, golden pair 0<x<100, fuzzy,
endpoint + min filter) -> 28/28
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
65 lines
1.4 KiB
Python
65 lines
1.4 KiB
Python
"""Pydantic request/response models."""
|
||
|
||
from __future__ import annotations
|
||
|
||
from datetime import datetime
|
||
|
||
from pydantic import BaseModel, ConfigDict
|
||
|
||
|
||
class GameCreate(BaseModel):
|
||
name: str
|
||
notes: str | None = None
|
||
|
||
|
||
class GameOut(BaseModel):
|
||
model_config = ConfigDict(from_attributes=True)
|
||
id: int
|
||
name: str
|
||
notes: str | None = None
|
||
|
||
|
||
class SnapshotOut(BaseModel):
|
||
model_config = ConfigDict(from_attributes=True)
|
||
id: int
|
||
game_id: int | None
|
||
binary_name: str
|
||
sha256: str
|
||
engine: str | None
|
||
compiler: str | None
|
||
schema_version: int | None
|
||
n_types: int
|
||
n_methods: int
|
||
n_events: int
|
||
n_fields: int
|
||
created_at: datetime
|
||
|
||
|
||
class SnapshotDetail(SnapshotOut):
|
||
data: dict
|
||
|
||
|
||
class GameDetail(GameOut):
|
||
snapshots: list[SnapshotOut] = []
|
||
|
||
|
||
class SimilarHit(BaseModel):
|
||
snapshot: SnapshotOut
|
||
overall: int # pooled surface-overlap score 0–100
|
||
fuzzy: int | None # ssdeep similarity of the raw binary, when available
|
||
axes: dict # per-axis {shared, only_a, only_b, score}
|
||
|
||
|
||
class JobOut(BaseModel):
|
||
model_config = ConfigDict(from_attributes=True)
|
||
id: int
|
||
rq_id: str | None
|
||
status: str
|
||
source_name: str
|
||
game_name: str | None
|
||
snapshot_id: int | None
|
||
dll_name: str | None
|
||
error: str | None
|
||
created_at: datetime
|
||
updated_at: datetime
|