class Change(BaseModel): __tablename__ = "changes" json = db.Column(JSONType) # Relationships cve_id = db.Column(UUIDType(binary=False), db.ForeignKey("cves.id")) cve = db.relationship("Cve", back_populates="changes") task_id = db.Column(UUIDType(binary=False), db.ForeignKey("tasks.id")) task = db.relationship("Task", back_populates="changes") events = db.relationship("Event", back_populates="change")
class Event(BaseModel): __tablename__ = "events" type = db.Column(ChoiceType(EVENT_TYPES)) details = db.Column(JSONType) review = db.Column(db.Boolean, default=False) # Relationships cve_id = db.Column(UUIDType(binary=False), db.ForeignKey("cves.id")) cve = db.relationship("Cve", back_populates="events") change_id = db.Column(UUIDType(binary=False), db.ForeignKey("changes.id")) change = db.relationship("Change", back_populates="events") alerts = db.relationship("Alert", secondary=alerts_events) def __repr__(self): return "<Event {}>".format(self.type)
class CveTag(BaseModel): __tablename__ = "cves_tags" tags = db.Column(JSONB) # Relationships user_id = db.Column(UUIDType(binary=False), db.ForeignKey("users.id")) user = db.relationship("User", back_populates="cve_tags") cve_id = db.Column(UUIDType(binary=False), db.ForeignKey("cves.id")) # Index __table_args__ = (db.Index("ix_cves_tags", tags, postgresql_using="gin"), ) def __repr__(self): return "<CveTag {}>".format(self.id)
class Product(BaseModel): __tablename__ = "products" name = db.Column(db.String(), nullable=False, index=True) # Relationships vendor_id = db.Column(UUIDType(binary=False), db.ForeignKey("vendors.id")) vendor = db.relationship("Vendor", back_populates="products") users = db.relationship("User", secondary=users_products) def __repr__(self): return "<Product {}>".format(self.name)
class Alert(BaseModel): __tablename__ = "alerts" details = db.Column(JSONType) notify = db.Column(db.Boolean, default=False) # Relationships events = db.relationship("Event", secondary=alerts_events) user_id = db.Column(UUIDType(binary=False), db.ForeignKey("users.id")) user = db.relationship("User", back_populates="alerts") cve_id = db.Column(UUIDType(binary=False), db.ForeignKey("cves.id")) cve = db.relationship("Cve", back_populates="alerts") report_id = db.Column(UUIDType(binary=False), db.ForeignKey("reports.id"), nullable=True) report = db.relationship("Report", back_populates="alerts") def __repr__(self): return "<Alert {}>".format(self.id)
class Report(BaseModel): __tablename__ = "reports" public_link = db.Column(db.String(), default=generate_public_link) seen = db.Column(db.Boolean(), default=False) details = db.Column(JSONType) user_id = db.Column(UUIDType(binary=False), db.ForeignKey("users.id")) user = db.relationship("User", back_populates="reports") alerts = db.relationship("Alert", back_populates="report") def __repr__(self): return "<Report {}>".format(self.id)
class UserTag(BaseModel): __tablename__ = "users_tags" name = db.Column(db.String(), nullable=False) description = db.Column(db.String()) color = db.Column(db.String(), nullable=False) # Relationships user_id = db.Column(UUIDType(binary=False), db.ForeignKey("users.id"), nullable=False) user = db.relationship("User", back_populates="tags") __table_args__ = (UniqueConstraint("name", "user_id", name="ix_userstags_name_userid"), ) def __repr__(self): return "<UserTag {}>".format(self.id)
onupdate=db.func.now(), nullable=False, ) def to_dict(self, attrs): return {attr: str(getattr(self, attr)) for attr in attrs} def __repr__(self): return """<{} '{}'>""".format(self.__class__.__name__, self.id) users_vendors = db.Table( "users_vendors", db.Column("user_id", UUIDType(binary=False), db.ForeignKey("users.id"), primary_key=True), db.Column( "vendor_id", UUIDType(binary=False), db.ForeignKey("vendors.id"), primary_key=True, ), ) users_products = db.Table( "users_products", db.Column("user_id", UUIDType(binary=False), db.ForeignKey("users.id"), primary_key=True),