Building 70 Projects ranging from beginner to advanced so anyone can — learn from, build upon, use as a reference, or even copy directly. Owned by my cybersecurity company 👇
Go aicertificationcloud-engineeringcybercybersecuritycybersecurity-analystcybersecurity-certificationcybersecurity-certificationscybersecurity-educationcybersecurity-jobscybersecurity-portfoliocybersecurity-projectscybersecurity-toolsgrchackinglearningpentestingproject-repositoryprojetcspython
"""
ⒸAngelaMos | 2025
Attachment.py
"""
from __future__ import annotations
from typing import TYPE_CHECKING
from uuid import UUID
from sqlalchemy import BigInteger, ForeignKey, String
from sqlalchemy.orm import (
Mapped,
mapped_column,
relationship,
)
from config import (
FILENAME_MAX_LENGTH,
MIME_TYPE_MAX_LENGTH,
STORAGE_PATH_MAX_LENGTH,
)
from core.Base import (
Base,
TimestampMixin,
UUIDMixin,
)
if TYPE_CHECKING:
from report.Report import Report
class Attachment(Base, UUIDMixin, TimestampMixin):
"""
File attachment on a vulnerability report
"""
__tablename__ = "attachments"
report_id: Mapped[UUID] = mapped_column(
ForeignKey("reports.id",
ondelete = "CASCADE"),
index = True,
)
comment_id: Mapped[UUID | None] = mapped_column(
ForeignKey("comments.id",
ondelete = "SET NULL"),
default = None,
)
filename: Mapped[str] = mapped_column(
String(FILENAME_MAX_LENGTH),
)
storage_path: Mapped[str] = mapped_column(
String(STORAGE_PATH_MAX_LENGTH),
)
mime_type: Mapped[str] = mapped_column(
String(MIME_TYPE_MAX_LENGTH),
)
size_bytes: Mapped[int] = mapped_column(BigInteger)
report: Mapped[Report] = relationship(
back_populates = "attachments",
lazy = "raise",
)