Genuine samples found (3 of the 107 NO SAMPLE):
- 005 (.3gx) via DuckDuckGo: real 3GPP2 file (ftyp brand 3g2a), +magic fix to ftyp3g2
- 373 (.m4v) via DuckDuckGo: complete 1.85 MB .m4v (ftyp brand M4V ), NOT truncated
- 544 (.php4) via Wayback (archived task page -> live file): genuine PHP source; derivation set to text
200 (.EXS) partial -> pass: real EXS24 decode from spec (big-endian SOBT header, 6 fields)
False positives caught and removed by strict validation:
- 51 .axf (Markdown spec), 52 .b (CSS), 130 .dba (SQL .bak), 168 .ecc (404 text),
190 .esd (31-byte text fragment), 545 .phr (SVG image), 719 .taz (Intel HEX),
774 .vdi (QEMU image), 24 .amf (explanatory text, again), 701 .svc (Wayback
capture truncated: 5 MB of 138 MB original), 789 .vrb (HTML page with BOM)
Validation hardened: truncation-at-cap check, no \d{4,} exception in
looks_like_document, UTF-8 BOM stripping, existing files re-validated.
Task 55 (.BAK) deliberately not sampled (generic ext, layout mismatch).
Still no genuine sample: 024 .amf (binary AMF3, no public sample), 701 .svc,
789 .vrb, and ~100 other obscure/proprietary formats.
33 lines
1.2 KiB
Python
33 lines
1.2 KiB
Python
#!/usr/bin/env python3
|
|
"""Re-validate every sample file for the DDG/Wayback target tasks with the
|
|
current strict content_ok, and remove any that fail (false positives kept
|
|
by an earlier, weaker validation). Run after all fetching is done."""
|
|
import json, os, sys
|
|
sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
|
|
import ddg_fetch as df
|
|
|
|
ROOT = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
|
SAMPLES = os.path.join(ROOT, "samples")
|
|
cand = json.load(open(os.path.join(ROOT, "tools/ddg_candidates.json")))
|
|
formats = json.load(open(os.path.join(ROOT, 'src', 'formats.json')))
|
|
removed, kept, skipped = [], [], []
|
|
for k in sorted((x for x in cand if x != "_special"), key=int):
|
|
t = int(k)
|
|
fm = formats.get(k, {})
|
|
ext = (fm.get("ext") or "").lower()
|
|
if not ext:
|
|
continue
|
|
fname = "task-%03d%s" % (t, ext)
|
|
fpath = os.path.join(SAMPLES, fname)
|
|
if not os.path.exists(fpath):
|
|
continue
|
|
ok, reason = df.content_ok(fpath, t, formats, None)
|
|
if ok:
|
|
kept.append((t, fname, reason))
|
|
else:
|
|
os.remove(fpath)
|
|
removed.append((t, fname, reason))
|
|
print("REMOVED task %d %s: %s" % (t, fname, reason))
|
|
print("kept: %s" % kept)
|
|
print("removed: %d, kept: %d" % (len(removed), len(kept)))
|