From d2183d3a9cc2b020ae1f0a2043b77976cfe51ac6 Mon Sep 17 00:00:00 2001 From: LeonKohli <98176333+LeonKohli@users.noreply.github.com> Date: Wed, 7 Feb 2024 00:09:35 +0100 Subject: [PATCH 1/8] Add database configuration and models --- database/ip_atlas.db | Bin 0 -> 73728 bytes ip-atlas/app.py | 31 ++++++++--- ip-atlas/database.py | 3 ++ ip-atlas/models.py | 103 ++++++++++++++++++++++++++++++++++++ ip-atlas/routes/atlas.py | 14 ++++- ip-atlas/testdatenfiller.py | 41 ++++++++++++-- 6 files changed, 179 insertions(+), 13 deletions(-) create mode 100644 database/ip_atlas.db create mode 100644 ip-atlas/database.py create mode 100644 ip-atlas/models.py diff --git a/database/ip_atlas.db b/database/ip_atlas.db new file mode 100644 index 0000000000000000000000000000000000000000..b83a961cf0df1d2ebfe59b0d206bb45ab1dec2da GIT binary patch literal 73728 zcmeHwdw3khm2XR})^yKQS4oy-S(YD?Wm%GC%hNsmm}z5MvMoRG6F)J=7CqBF_Skx% z836_iQ3&L9NkRf4`G6&FzT}2YayNwJ2C_Fx$R^p4$IXi*OK!4+?B*sU3khGoEX(da zr+Q{AuYqs&pL|(v>BIURRac)r^{Z2-9$nQOxNKLU6n5q(r^o$LXG&_4>guGS&Q3{^ zz7PNA!N1B+69^5JKLG3I$gd=RUm869Ej{*6QnT`}65Bw3M(?J(^}p38$n}Xw6Z_*# zdx!d>IvM-t#;?X6f-K@kFd!HZ34Oe%V`sa4al^LFcBudv}ct@4;L4?ccF`c>mGPog+s(`wBrnrfuE3e`LqDJ($*4 zeoBAm{*kRC`$zU{9y!p7X+@qp-alJlv9@K)>Tc=ch2hyt{>frhXu6B?pLy- za=m|c9*MQ>1zU_)v1Q!Pjru__9Ttlho1@oY&Kw1=WYL@~{pS)j)sJ(rF{B1#pbnf@ zvI4L5zkVnlYcq_xHw^Grbn#OzPDzxX8wHDtufIy;xPUoiO3)2vnieWg>xdnpR!5zCtFzcBAa;Yy9kgf?Qg30N*8kZMNPE1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-5v>7O8+eqj!AFj!k{d@B@(WX-W&-> zr8jY5jV!$}5-yi+i-aT6tz1|wOK*sT!_qC0a7cPR7Y1Z$HWD^UuZux(ULHG;^2P`UHbl5;J;(X-B@y`h0w(&ac$b|UPt zBV1u|Y?f0IcAF6{H#j!Q$q2jFM%X#Xk;!W!T(&yGr2`zPyeh&a{ShwiaWN zmm4Egln5Id8XGiRC*V*IivgOZ;rss}@tnl|0JHz6*$>$_*q7M)!OVV@ zz6@scaq{o**8Z2|C*(WiE9490)8wP%esU*y3wa&P=FbqH93i{NCXyzDWCdA7nn)wO zqkryC8~?@A1OtKr!GK^uFd!HZ3PJ%iO7$u(C0Adojz-eSThtR=TDyOvdOVWI8`UehH0Zsc9Ro>L2c<8*PQ8LBuDRwD z>d{ED->P2DrPXc!S3ANpu9klHYxOWs94H=84@J_kW!gc0d6jhk{ptapxXRz6?dOU8 z(u1E;u|JS$yCDZ3`EdOJ7`| zZU(VlU7i`#Hu1zR>5mzCX->a8! zX=&f5)OC?GakJ`iX~}}GXc>@Xb&2%f$JI1XTs#zLE>B!6-L+bEcw)z{m72{HJEYkg zRf{Js()zR%Ph2G3`+#P0v0eK8Evmt0KCkxj#QD;_>PjxPbU12H zBw5qy3NFp-d8gVPN!#w$mV+d#&C*}osdn+i=F4x^I(cG~^xZdU%gW+k)oDw)$fO^f zQ0Qg!cAixqXjd0Rsn=KMb18n^2h^5GI{pTA9+$KQZ-Q6-=m(m-3EuXjr0)BS$|9+In?^yB)tGck zyQ=fV*lwZ`p4ce;&QcRRvGF=rjdMwHZ&bBNI#Z{qJY$3O{QK1yPi$}+)kZGK6O)?4 oFU!*N-%=ZRVtsxM>_9*(>ifT>)+>@GtI~5%#p*z+R~K*nf6a-CS^xk5 literal 0 HcmV?d00001 diff --git a/ip-atlas/app.py b/ip-atlas/app.py index 7466b2b..05d3070 100644 --- a/ip-atlas/app.py +++ b/ip-atlas/app.py @@ -1,15 +1,32 @@ from flask import Flask -import secrets -from routes import atlas, settings - +import os +from database import db atlasapp = Flask(__name__, static_folder="static", template_folder="templates") -atlasapp.secret_key = secrets.token_hex(16) -# ? Blueprints -atlasapp.register_blueprint(atlas.bp_atlas) -atlasapp.register_blueprint(settings.bp_settings) +# Configure the database URI +database_dir = os.path.join(os.getcwd(), "database") +if not os.path.exists(database_dir): + os.makedirs(database_dir) +atlasapp.config["SQLALCHEMY_DATABASE_URI"] = "sqlite:///" + os.path.join( + database_dir, "ip_atlas.db" +) +atlasapp.config["SQLALCHEMY_TRACK_MODIFICATIONS"] = False + + +# Register the blueprints +from routes.atlas import bp_atlas +from routes.settings import bp_settings +atlasapp.register_blueprint(bp_atlas) +atlasapp.register_blueprint(bp_settings) + +# Initialize SQLAlchemy with the Flask app +db.init_app(atlasapp) if __name__ == "__main__": + with atlasapp.app_context(): + from models import * + + db.create_all() atlasapp.run(debug=True, host="0.0.0.0", port=5000) diff --git a/ip-atlas/database.py b/ip-atlas/database.py new file mode 100644 index 0000000..f0b13d6 --- /dev/null +++ b/ip-atlas/database.py @@ -0,0 +1,3 @@ +from flask_sqlalchemy import SQLAlchemy + +db = SQLAlchemy() diff --git a/ip-atlas/models.py b/ip-atlas/models.py new file mode 100644 index 0000000..b7724dd --- /dev/null +++ b/ip-atlas/models.py @@ -0,0 +1,103 @@ +from database import db +from sqlalchemy.orm import relationship +from sqlalchemy.orm import validates +import ipaddress +from sqlalchemy import Column, Integer, String, Boolean, DateTime, ForeignKey +from datetime import datetime + + +class Host(db.Model): + __tablename__ = "hosts" + id = Column(Integer, primary_key=True, autoincrement=True) + hostname = Column(String, unique=True, nullable=False, index=True) + ipv4 = Column(String, nullable=False, index=True) + ipv6 = Column(String, index=True) + cidr = Column(Integer) + deleted = Column(Boolean, default=False) + ports = relationship("Port", back_populates="host") + tags = relationship("HostTag", back_populates="host") + + @validates("ipv4", "ipv6") + def validate_ip(self, key, address): + if address: + try: + ip_obj = ipaddress.ip_address(address) + if (key == "ipv4" and ip_obj.version != 4) or ( + key == "ipv6" and ip_obj.version != 6 + ): + raise ValueError(f"Invalid {key} address: {address}") + return str(ip_obj) + except ValueError: + raise ValueError(f"Invalid {key} address: {address}") + return address + + +class Tag(db.Model): + __tablename__ = "tags" + id = Column(Integer, primary_key=True, autoincrement=True) + tag_name = Column(String, unique=True, nullable=False, index=True) + deleted = Column(Boolean, default=False) + hosts = relationship("HostTag", back_populates="tag") + + +class HostTag(db.Model): + __tablename__ = "host_tags" + host_id = Column(Integer, ForeignKey("hosts.id"), primary_key=True) + tag_id = Column(Integer, ForeignKey("tags.id"), primary_key=True) + host = relationship("Host", back_populates="tags") + tag = relationship("Tag", back_populates="hosts") + + +class Port(db.Model): + __tablename__ = "ports" + id = Column(Integer, primary_key=True, autoincrement=True) + host_id = Column(Integer, ForeignKey("hosts.id")) + port_number = Column(Integer, nullable=False) + deleted = Column(Boolean, default=False) + host = relationship("Host", back_populates="ports") + + +class AuditLog(db.Model): + __tablename__ = "audit_logs" + id = Column(Integer, primary_key=True, autoincrement=True) + action_type = Column(String, nullable=False) + table_name = Column(String, nullable=False) + record_id = Column(Integer, nullable=False) + timestamp = Column(DateTime, default=datetime.utcnow) + user = Column(String, nullable=False) + + +class Statistics(db.Model): + __tablename__ = "statistics" + id = Column(Integer, primary_key=True, autoincrement=True) + stat_key = Column(String, nullable=False, index=True) + stat_value = Column(Integer, nullable=False) + last_updated = Column(DateTime, default=datetime.utcnow, onupdate=datetime.utcnow) + + +class DiscoveredDevice(db.Model): + __tablename__ = "discovered_devices" + id = Column(Integer, primary_key=True, autoincrement=True) + mac_address = Column(String, nullable=False, index=True) + ipv4 = Column(String, nullable=False, index=True) + ipv6 = Column(String, index=True) + hostname = Column(String, index=True) + first_seen = Column(DateTime, default=datetime.utcnow) + last_seen = Column(DateTime, default=datetime.utcnow, onupdate=datetime.utcnow) + deleted = Column(Boolean, default=False) + vendor = Column(String) + ignore = Column(Boolean, default=False) + + @validates("ipv4", "ipv6") + def validate_ip(self, key, address): + if address: + try: + ip_obj = ipaddress.ip_address(address) + if (key == "ipv4" and ip_obj.version != 4) or ( + key == "ipv6" and ip_obj.version != 6 + ): + raise ValueError(f"Invalid {key} address: {address}") + return str(ip_obj) + except ValueError: + raise ValueError(f"Invalid {key} address: {address}") + return address diff --git a/ip-atlas/routes/atlas.py b/ip-atlas/routes/atlas.py index ec81d31..3926853 100644 --- a/ip-atlas/routes/atlas.py +++ b/ip-atlas/routes/atlas.py @@ -2,6 +2,7 @@ from jinja2 import TemplateNotFound from helper import * from filter import * +from models import Host, Port, Tag bp_atlas = Blueprint("atlas", __name__) @@ -15,8 +16,17 @@ def index(): @bp_atlas.route("/ip/list") def list(): - createJson() - data = loadJson() + hosts = Host.query.all() + data = {"hosts": []} + for host in hosts: + host_data = { + "id": host.id, + "name": host.hostname, + "ip": host.ipv4, # Assuming ipv4 is the primary IP to display + "ports": [port.port_number for port in host.ports], + "tags": [host_tag.tag.tag_name for host_tag in host.tags], # Adjusted line + } + data["hosts"].append(host_data) return render_template("ip/list.html", data=data) diff --git a/ip-atlas/testdatenfiller.py b/ip-atlas/testdatenfiller.py index c565f3c..5288055 100644 --- a/ip-atlas/testdatenfiller.py +++ b/ip-atlas/testdatenfiller.py @@ -1,17 +1,50 @@ -from helper import writeJson from faker import Faker +from sqlalchemy import create_engine +from sqlalchemy.orm import sessionmaker +from models import db, Host, Tag, Port, HostTag +import random +from app import atlasapp + +# Assuming your database URI is stored in a variable or directly provided +DATABASE_URI = atlasapp.config["SQLALCHEMY_DATABASE_URI"] +engine = create_engine(DATABASE_URI) +Session = sessionmaker(bind=engine) fake = Faker() def generate_test_data(num_hosts=50): + session = Session() for i in range(1, num_hosts + 1): hostname = f"Host{i}" ipv4 = fake.ipv4_private(network=False, address_class=None) - tags = [fake.word(), fake.word(), "test"] ipv6 = fake.ipv6(network=False) - ports = [fake.random_int(min=1, max=65535) for _ in range(2)] - writeJson(hostname, ipv4, tags, ipv6, ports) + ports_numbers = [fake.random_int(min=1, max=65535) for _ in range(2)] + + # Create Host instance + host = Host(hostname=hostname, ipv4=ipv4, ipv6=ipv6) + session.add(host) + session.commit() # Commit to assign an ID to the host + + # Create Port instances + for port_number in ports_numbers: + port = Port(host_id=host.id, port_number=port_number) + session.add(port) + + # Create and associate Tags + tags = [fake.word(), fake.word(), "test"] + for tag_name in tags: + tag = session.query(Tag).filter_by(tag_name=tag_name).first() + if not tag: + tag = Tag(tag_name=tag_name) + session.add(tag) + session.commit() # Commit to assign an ID to the tag + + # Create association between host and tag + host_tag = HostTag(host_id=host.id, tag_id=tag.id) + session.add(host_tag) + + session.commit() generate_test_data() From 0934c292fab62868e51250feef66de1c3c1d8232 Mon Sep 17 00:00:00 2001 From: FischLord Date: Wed, 7 Feb 2024 08:09:58 +0100 Subject: [PATCH 2/8] Update settings.json --- .vscode/settings.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.vscode/settings.json b/.vscode/settings.json index 4001588..a1c1c6d 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -7,5 +7,6 @@ "test_*.py" ], "python.testing.pytestEnabled": false, - "python.testing.unittestEnabled": true + "python.testing.unittestEnabled": true, + "sqltools.useNodeRuntime": true } \ No newline at end of file From 672f7e5146c56debd52bb165889f38253d5b1a26 Mon Sep 17 00:00:00 2001 From: FischLord Date: Wed, 7 Feb 2024 11:04:30 +0100 Subject: [PATCH 3/8] crud angelegt --- .vscode/settings.json | 11 ++++++++++- ip-atlas/crud.py | 22 ++++++++++++++++++++++ ip-atlas/models.py | 2 -- ip-atlas/routes/atlas.py | 12 ------------ requirements.txt | 1 + 5 files changed, 33 insertions(+), 15 deletions(-) create mode 100644 ip-atlas/crud.py diff --git a/.vscode/settings.json b/.vscode/settings.json index a1c1c6d..7392424 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -8,5 +8,14 @@ ], "python.testing.pytestEnabled": false, "python.testing.unittestEnabled": true, - "sqltools.useNodeRuntime": true + "sqltools.useNodeRuntime": true, + "sqltools.connections": [ + { + "previewLimit": 100, + "driver": "SQLite", + "name": "IP-Atlas", + "group": "IP-Atlas", + "database": "${workspaceFolder:IP-Atlas}/database/ip_atlas.db" + } + ] } \ No newline at end of file diff --git a/ip-atlas/crud.py b/ip-atlas/crud.py new file mode 100644 index 0000000..88b06b2 --- /dev/null +++ b/ip-atlas/crud.py @@ -0,0 +1,22 @@ +# this Script contains the CRUD operations for the ip-atlas database +# Author: Janneck Lehmann +# Date: 2024-02-07 +from models import Host, Port, Tag + + +# function which reads all hosts from the database where the attribute deleted is set to false +def read_all_hosts(): + hosts = Host.query.filter_by(deleted=False).all() + return hosts + +# hosts = Host.query.all() +# data = {"hosts": []} +# for host in hosts: +# host_data = { +# "id": host.id, +# "name": host.hostname, +# "ip": host.ipv4, # Assuming ipv4 is the primary IP to display +# "ports": [port.port_number for port in host.ports], +# "tags": [host_tag.tag.tag_name for host_tag in host.tags], # Adjusted line +# } +# data["hosts"].append(host_data) \ No newline at end of file diff --git a/ip-atlas/models.py b/ip-atlas/models.py index b7724dd..8ea38ba 100644 --- a/ip-atlas/models.py +++ b/ip-atlas/models.py @@ -12,7 +12,6 @@ class Host(db.Model): hostname = Column(String, unique=True, nullable=False, index=True) ipv4 = Column(String, nullable=False, index=True) ipv6 = Column(String, index=True) - cidr = Column(Integer) deleted = Column(Boolean, default=False) ports = relationship("Port", back_populates="host") tags = relationship("HostTag", back_populates="host") @@ -53,7 +52,6 @@ class Port(db.Model): id = Column(Integer, primary_key=True, autoincrement=True) host_id = Column(Integer, ForeignKey("hosts.id")) port_number = Column(Integer, nullable=False) - deleted = Column(Boolean, default=False) host = relationship("Host", back_populates="ports") diff --git a/ip-atlas/routes/atlas.py b/ip-atlas/routes/atlas.py index 3926853..7c7fd51 100644 --- a/ip-atlas/routes/atlas.py +++ b/ip-atlas/routes/atlas.py @@ -2,7 +2,6 @@ from jinja2 import TemplateNotFound from helper import * from filter import * -from models import Host, Port, Tag bp_atlas = Blueprint("atlas", __name__) @@ -16,17 +15,6 @@ def index(): @bp_atlas.route("/ip/list") def list(): - hosts = Host.query.all() - data = {"hosts": []} - for host in hosts: - host_data = { - "id": host.id, - "name": host.hostname, - "ip": host.ipv4, # Assuming ipv4 is the primary IP to display - "ports": [port.port_number for port in host.ports], - "tags": [host_tag.tag.tag_name for host_tag in host.tags], # Adjusted line - } - data["hosts"].append(host_data) return render_template("ip/list.html", data=data) diff --git a/requirements.txt b/requirements.txt index a231b7b..5218b9c 100644 --- a/requirements.txt +++ b/requirements.txt @@ -8,3 +8,4 @@ MarkupSafe==2.1.4 python-dateutil==2.8.2 six==1.16.0 Werkzeug==3.0.1 +flask_sqlalchemy \ No newline at end of file From 503bf455c8855b9f5f61b7fd5725342a58ec8177 Mon Sep 17 00:00:00 2001 From: FischLord Date: Wed, 7 Feb 2024 11:58:12 +0100 Subject: [PATCH 4/8] CRUD funktionen am werkeln --- .vscode/settings.json | 7 +++---- database/ip_atlas.db | Bin 73728 -> 73728 bytes ip-atlas/crud.py | 38 +++++++++++++++++++++++++++----------- ip-atlas/helper.py | 23 +++++++++++++++++++++++ ip-atlas/routes/atlas.py | 2 ++ 5 files changed, 55 insertions(+), 15 deletions(-) diff --git a/.vscode/settings.json b/.vscode/settings.json index 7392424..1ab66e5 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -11,11 +11,10 @@ "sqltools.useNodeRuntime": true, "sqltools.connections": [ { - "previewLimit": 100, + "previewLimit": 50, "driver": "SQLite", - "name": "IP-Atlas", - "group": "IP-Atlas", - "database": "${workspaceFolder:IP-Atlas}/database/ip_atlas.db" + "database": "${workspaceFolder:IP-Atlas}/database/ip_atlas.db", + "name": "ip-atlas" } ] } \ No newline at end of file diff --git a/database/ip_atlas.db b/database/ip_atlas.db index b83a961cf0df1d2ebfe59b0d206bb45ab1dec2da..891031f42ce8725b2334e3f8d3ec751519343929 100644 GIT binary patch literal 73728 zcmeHwd3YRGm2b7GOI6)n_g>4EEbo$S*^<1pyVmY5FOqD_OKi)I<0ZD^DAirnwi0b= zNp?&&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8gVPN!#w$mV+d#&C*}osdn+i=F4x^I(cG~^xZdU%gW+k)oDw)$fO^f zQ0Qg!cAixqXjd0Rsn=KMb18n^2h^5GI{pTA9+$KQZ-Q6-=m(m-3EuXjr0)BS$|9+In?^yB)tGck zyQ=fV*lwZ`p4ce;&QcRRvGF=rjdMwHZ&bBNI#Z{qJY$3O{QK1yPi$}+)kZGK6O)?4 oFU!*N-%=ZRVtsxM>_9*(>ifT>)+>@GtI~5%#p*z+R~K*nf6a-CS^xk5 diff --git a/ip-atlas/crud.py b/ip-atlas/crud.py index 88b06b2..5769135 100644 --- a/ip-atlas/crud.py +++ b/ip-atlas/crud.py @@ -2,21 +2,37 @@ # Author: Janneck Lehmann # Date: 2024-02-07 from models import Host, Port, Tag +from sqlalchemy import create_engine +from sqlalchemy.orm import sessionmaker +from app import atlasapp +from helper import * +DATABASE_URI = atlasapp.config["SQLALCHEMY_DATABASE_URI"] +engine = create_engine(DATABASE_URI) +Session = sessionmaker(bind=engine) + +# function which converts the given data from db to the json format +def convert_to_json_format(hosts): + data = {"hosts": []} + for host in hosts: + host_data = { + "id": host.id, + "name": host.hostname, + "ip": host.ipv4, + "ports": [port.port_number for port in host.ports], + "tags": [host_tag.tag.tag_name for host_tag in host.tags], + } + data["hosts"].append(host_data) + return data # function which reads all hosts from the database where the attribute deleted is set to false def read_all_hosts(): hosts = Host.query.filter_by(deleted=False).all() return hosts -# hosts = Host.query.all() -# data = {"hosts": []} -# for host in hosts: -# host_data = { -# "id": host.id, -# "name": host.hostname, -# "ip": host.ipv4, # Assuming ipv4 is the primary IP to display -# "ports": [port.port_number for port in host.ports], -# "tags": [host_tag.tag.tag_name for host_tag in host.tags], # Adjusted line -# } -# data["hosts"].append(host_data) \ No newline at end of file +# function which writes the given data to the database +def write_to_db(host_data): + session = Session() + hostname = host_data.get("name") + ipv4 = host_data.get("ipv4") + diff --git a/ip-atlas/helper.py b/ip-atlas/helper.py index 8cecf01..5ae3858 100644 --- a/ip-atlas/helper.py +++ b/ip-atlas/helper.py @@ -2,6 +2,29 @@ import os import platform import subprocess +from models import Host, Port, Tag +from sqlalchemy import create_engine +from sqlalchemy.orm import sessionmaker +from app import atlasapp + +DATABASE_URI = atlasapp.config["SQLALCHEMY_DATABASE_URI"] +engine = create_engine(DATABASE_URI) +Session = sessionmaker(bind=engine) + +#! db functions + +# function which checks if the given tag exists in the database and returns the id if it exists +def tag_exists(tag_name, method="bool"): + session = Session() + tag = session.query(Tag).filter_by(tag_name=tag_name).first() + session.close() + if method == "id": + if tag: + return tag.id + else: + return None + else: + return tag is not None # checks if the json document is there diff --git a/ip-atlas/routes/atlas.py b/ip-atlas/routes/atlas.py index 7c7fd51..645d6eb 100644 --- a/ip-atlas/routes/atlas.py +++ b/ip-atlas/routes/atlas.py @@ -2,6 +2,7 @@ from jinja2 import TemplateNotFound from helper import * from filter import * +from crud import * bp_atlas = Blueprint("atlas", __name__) @@ -15,6 +16,7 @@ def index(): @bp_atlas.route("/ip/list") def list(): + data = convert_to_json_format(read_all_hosts()) return render_template("ip/list.html", data=data) From e1c3e8c71793c47b6ccbdbc0ba542e35e351a134 Mon Sep 17 00:00:00 2001 From: FischLord Date: Wed, 7 Feb 2024 14:35:01 +0100 Subject: [PATCH 5/8] db angepasst + session entfernt --- database/ip_atlas.db | Bin 73728 -> 0 bytes ip-atlas/crud.py | 63 ++++++++++++++++++++++++--------------- ip-atlas/helper.py | 11 +------ ip-atlas/models.py | 1 + ip-atlas/routes/atlas.py | 5 +++- 5 files changed, 45 insertions(+), 35 deletions(-) delete mode 100644 database/ip_atlas.db diff --git a/database/ip_atlas.db b/database/ip_atlas.db deleted file mode 100644 index 891031f42ce8725b2334e3f8d3ec751519343929..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 73728 zcmeHwd3YRGm2b7GOI6)n_g>4EEbo$S*^<1pyVmY5FOqD_OKi)I<0ZD^DAirnwi0b= zNp?&&L>58@$OJ;(<3Zq?e1Qt z_DAhTO=|qE`Z=f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824 bytes ip-atlas/crud.py | 4 ++-- ip-atlas/models.py | 10 ++++++++-- ip-atlas/testdatenfiller.py | 8 +++++++- 4 files changed, 17 insertions(+), 5 deletions(-) create mode 100644 database/ip_atlas.db diff --git a/database/ip_atlas.db b/database/ip_atlas.db new file mode 100644 index 0000000000000000000000000000000000000000..8ca75c8b66d0fd3cbedb7fe24908308c76c40656 GIT binary patch literal 77824 zcmeHw33wdEm48dER`<+wRmqZNS+-?emMvM0*58{4vM%Ll&jZR0CF(>?ZJT}U!u zz<@Xt5&|SZj)f48Bn!C{2qc7%-7I8D!sZ}cOV}hEAO|EN0YVZs&OmQCvl<6cXCcy!PiZ!v@#p`t=q+R`Ej!lUq82fyLZ z6cDPyKL9Hx$tMyY72;=nhseJdYNcHQ+rX;m$LL=21i3)HGWJL;8*Pq!I5JhaP!X!1 zk{_&YhD!X0Gr$?(4E+Djz{K)exnbtaii`J-JJ|tmWO#IZY~`{d)GgoK-?z2DWozHE zb^R@E#nQHx&S<3IwyfE(wSQIr=9Uc`x3+B9wr<^mmT2VQ@YwkNW5=+_Z?#@c%eQ_HhFNIwp<7afgm0yQpJ9OVHr2Wd6U8Q&Gv}VZzQ7M@g%xZs>2W z5DG)Cch1e_y-B;vJP!6kN-$_;&5#YDYdw{XsWw=k9)KFb^R z-2JY1Rw3t&?Jta+WxlzX75Q7UVMYJWmJ_#Z*|?$Q&8@+5(AqUoOXP-)aDMGCoPW^C z?RQ*v)EgUnvm#oC8Iu&8$eKx2x+Ws3+^`0W>i7#rA(cbUp!a5rNEsG|txsf5c)aUq ztgP`#z1a-43^QO1QYSJ2k9A$VG%7b}TE(T^{wjL&S>9X{E1oy-ZErsQ7u>|8L1@|D zw|V*MzT=%BPMH%ONQDPNZ;695xh!881s6Kzc|$EL!1r!lv%Vjz4mfXB>Usm-xaYPk z+qiLEf8PeIc$PQh4v$XO*j6|&G(76HO|EsE4*-W7?J7j%2CKDVLJB9-*tj!Z7#lC- z#`dGQ|B!d&SW)!9kJ_y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(6+~2XZaE&3^$r;Xg#OWEZ^2zmhB>I_V_M@N{1#qWTB**YIrr2kQ6Kht&t* zx&9~ATjAaPtJTZZ^VL!Hpt?`p3h(Xr{hfMW-fhkRXMi)n8Q=_X1~>zp0nWhRhJi5d z|EX1s`{(QktfH58Wzb>|eQXZ&bn1 zA0qxM`ecm#E921y1w(&`_`md!jIn=Z&-t?z4E-VEzx<*w_P_378Dsy-?uM%s4E-Sq zaBoF1_SZij#{M@x8pi&wU7%p>4_SbV4-|v{>TSi~|3Vf9|G)pQV(@?3Jz?oHa9Wu|H%1 zKK`G@;D3Irg2BHyOZd#9F#5ml>SFZ2;}bGQ{}A*4M8V)6(g05_Q84<4p#Qy@F#NyW z3B&(e7lz^g555tG|2Ndg82(o_tazpv{Trr?(SPN%**`1>|5a}fga4PV4}<>~uMC6# z|9T+|{-5ttF!+Zwz~{zgjQ%TYFZ`a2!GC3KH!Qwx<~SXGV*m|BUY{82XD;`0-#d_MiGf82jJ&d@=SP=uj~BhmimAugVzwSE@bn zF!sOb;bQDxaYHfo?=WSI{VSvLf-v;I>`4Vfe@Fs+MJ>kuu>l2Re^C+M^$P`qe~9_7 z`Id~)f2BP1)nf2}zN=vHFIEd5x;u>iuedji{;zsY!RQ}C`fptUPyBu9&rgK$|1((` k{;zBjWDNh|4J7CP0o! Date: Wed, 7 Feb 2024 15:53:52 +0100 Subject: [PATCH 7/8] Update crud.py --- ip-atlas/crud.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ip-atlas/crud.py b/ip-atlas/crud.py index 79aafc5..fe9de76 100644 --- a/ip-atlas/crud.py +++ b/ip-atlas/crud.py @@ -14,7 +14,7 @@ def convert_to_json_format(host): "name": host.hostname, "ip": host.ipv4, "ipv6": host.ipv6, - "portsFB": [port.port_number for port in host.ports], + "portsFB": [portFB.portFB_number for portFB in host.portsFB], "tags": [host_tag.tag.tag_name for host_tag in host.tags], } return host_data From 61aa1e3f2edfee18bc032a09edb207f76ac03f19 Mon Sep 17 00:00:00 2001 From: FischLord Date: Wed, 7 Feb 2024 15:56:52 +0100 Subject: [PATCH 8/8] Update list.html --- ip-atlas/templates/ip/list.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ip-atlas/templates/ip/list.html b/ip-atlas/templates/ip/list.html index 4ebb9bf..3b6c6fa 100644 --- a/ip-atlas/templates/ip/list.html +++ b/ip-atlas/templates/ip/list.html @@ -140,7 +140,7 @@

IP Adressen

class="transition duration-150 ease-in-out border-b hover:bg-gray-700 hover:bg-opacity-25"> {{ host.name }} {{ host.ip }} - {{ host.ports|join(", ") }} + {{ host.portsFB|join(", ") }} {% if host.tags %} {{ host.tags|join(", ") }}