KC7-Foundation / kc7

A cybersecurity game in Azure Data Explorer
https://kc7cyber.com
Apache License 2.0
162 stars 14 forks source link

Abstract hostname to host class #122

Closed kkneomis closed 1 year ago

kkneomis commented 1 year ago

Host are now in their own class. There are two kinds: endpoints and servers

class Host(db.Model):
    """
    A class to model a host/machine
    """

    __tablename__ = 'hosts'
    id = db.Column(db.Integer, primary_key=True)
    name = db.Column(db.String(100))
    host_type = db.Column(db.String(50))
    ....

class Endpoint(Host):
    """
    A class to model a endpoint 
    Endpoints are devices like laptops and desktop used by individual users
    From simplification, we have a 1-1 relationship for User <-> Endpoint
    """
    employee_id = db.Column(db.Integer, db.ForeignKey('employee.id'))

    def __init__(self, name: str) -> None:
        super().__init__(name, host_type="endpoint")

class Server(Host):
    """
    A class to model a server 
    Servers are not directly associated with any one user
    Servers can be of multiple types including
    - Exchange, SSH, VPN, File, Web
    """
    company_id = db.Column(db.Integer, db.ForeignKey('company.id'))

    ...

There is a 1-1 relationship between users and endpoints There is a 1-many relationship between the company and servers

Employee hostnames are now derives from endpoints names