MCPcopy Create free account
hub / github.com/dedsec1121fk/DedSec / _validate_report_upload

Function _validate_report_upload

Scripts/ButSystem.py:17319–17336  ·  view source on GitHub ↗

Validate report attachment size and return (safe_name, mime).

(file_storage)

Source from the content-addressed store, hash-verified

17317 aid: Parameter.
17318
17319Returns:
17320 Varies.
17321"""
17322 owner = current_user()
17323 conn = db_connect()
17324 row = conn.execute("""
17325 SELECT a.stored_path, e.owner
17326 FROM profiler_attachments a
17327 JOIN profiler_entries e ON e.id=a.entry_id
17328 WHERE a.id=?
17329 """, (aid,)).fetchone()
17330 if not row or row["owner"] != owner:
17331 conn.close()
17332 abort(404)
17333 sp = row["stored_path"]
17334 conn.execute("DELETE FROM profiler_attachments WHERE id=?", (aid,))
17335 conn.commit()
17336 conn.close()
17337 try:
17338 if sp and os.path.exists(sp):
17339 os.remove(sp)

Callers 2

_report_store_attachmentFunction · 0.70

Calls 2

guess_mimeFunction · 0.70
_filestorage_sizeFunction · 0.70

Tested by

no test coverage detected