Skip to content

Commit

Permalink
Hardware-Page Style
Browse files Browse the repository at this point in the history
  • Loading branch information
dslrsiddesh committed Dec 17, 2023
1 parent 8792643 commit 5e088ef
Show file tree
Hide file tree
Showing 9 changed files with 125 additions and 25 deletions.
40 changes: 29 additions & 11 deletions ui/components/hardware/file_systems.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from PyQt6.QtWidgets import QWidget, QVBoxLayout, QLabel, QCheckBox \
, QHBoxLayout, QLineEdit
from PyQt6.QtGui import QIntValidator
from PyQt6.QtCore import Qt
from harden import config_file

class FileSystems(QWidget):
Expand All @@ -11,34 +12,49 @@ def __init__(self):
def init_ui(self):
self.layout = QVBoxLayout()
self.setLayout(self.layout)
self.layout.setSpacing(0)
self.layout.setContentsMargins(0, 0, 0, 0)

self.temp_toml_dict = config_file.read()
self.toml_file_systems = self.temp_toml_dict['file-systems']

self.main_label = QLabel("File Systems")
self.layout.addWidget(self.main_label)
self.main_label.setObjectName("component-title")

# container widget
self.container_widget = QWidget()
self.container_layout = QVBoxLayout()
self.container_widget.setLayout(self.container_layout)
self.layout.addWidget(self.container_widget)
self.container_layout.setSpacing(0)
self.container_layout.setContentsMargins(30, 10, 30, 30)
self.container_widget.setObjectName("container-widget")
self.container_widget.setProperty("class", "file-systems")

# Basic Hardening
self.label_basic = QLabel("# Basic Hardening")
self.layout.addWidget(self.label_basic)
self.label_basic = QLabel("Basic Hardening")
self.container_layout.addWidget(self.label_basic)
self.label_basic.setObjectName("sub-component-title")

# block items
for name, state in self.toml_file_systems['block'].items():
checkbox = QCheckBox(f'Block {name}')
checkbox.setChecked(state)
checkbox.stateChanged.connect(lambda state, name=name: self.save_checkbox_state(state, 'block', name))
self.layout.addWidget(checkbox)
self.container_layout.addWidget(checkbox)

# Intermediate Hardening
self.label_basic = QLabel("# Intermediate Hardening")
self.layout.addWidget(self.label_basic)
self.label_intermediate = QLabel("Intermediate Hardening")
self.container_layout.addWidget(self.label_intermediate)
self.label_intermediate.setObjectName("sub-component-title")

# configure_fs items
for name, state in self.toml_file_systems['configure_fs'].items():
checkbox = QCheckBox(f"Configure /{name.replace('_', '/')}")
checkbox.setChecked(state)
checkbox.stateChanged.connect(lambda state, name=name: self.save_checkbox_state(state, 'configure_fs', name))
self.layout.addWidget(checkbox)
self.container_layout.addWidget(checkbox)

# configure /tmp size
hlayout = QHBoxLayout()
Expand All @@ -52,22 +68,24 @@ def init_ui(self):

hlayout.addWidget(self.configure_label)
hlayout.addWidget(self.size_input)
self.layout.addLayout(hlayout)
self.container_layout.addLayout(hlayout)

# disable_automount
self.disable_auto_mount = QCheckBox('Disable Auto-Mount')
self.disable_auto_mount.setChecked(self.toml_file_systems['disable_automount'])
self.disable_auto_mount.stateChanged.connect(lambda state: self.save_checkbox_state(state, 'disable_automount', None))
self.layout.addWidget(self.disable_auto_mount)
self.container_layout.addWidget(self.disable_auto_mount)

# Advanced Hardening
self.label_basic = QLabel("# Advanced Hardening")
self.layout.addWidget(self.label_basic)
self.label_advanced = QLabel("Advanced Hardening")
self.container_layout.addWidget(self.label_advanced)
self.label_advanced.setObjectName("sub-component-title")


self.enable_aide = QCheckBox('Enable AIDE (Advanced Intrusion Detection Environment)')
self.enable_aide.setChecked(self.toml_file_systems['enable_aide'])
self.enable_aide.stateChanged.connect(lambda state: self.save_checkbox_state(state, 'enable_aide', None))
self.layout.addWidget(self.enable_aide)
self.container_layout.addWidget(self.enable_aide)

def save_checkbox_state(self, state, type, name):
if name:
Expand Down
25 changes: 20 additions & 5 deletions ui/components/hardware/physical_ports.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from PyQt6.QtWidgets import QWidget, QVBoxLayout, QLabel, QCheckBox, QPushButton \
, QTableWidget, QTableWidgetItem, QHBoxLayout
from harden import config_file
from PyQt6.QtCore import Qt

class PhysicalPorts(QWidget):
def __init__(self):
Expand All @@ -19,19 +20,31 @@ def init_ui(self):
hlayout = QHBoxLayout()
hlayout.setSpacing(0)
hlayout.setContentsMargins(0, 0, 0, 0)
hlayout.setAlignment(Qt.AlignmentFlag.AlignLeft)

self.main_label = QLabel("Physical Ports")
hlayout.addWidget(self.main_label)
self.main_label.setObjectName("component-title")

# refresh button
self.refresh_button = QPushButton("Refresh") # no connect function yet
hlayout.addWidget(self.refresh_button)
self.refresh_button.setObjectName("refresh-btn")

self.layout.addLayout(hlayout)

# container widget
self.container_widget = QWidget()
self.container_layout = QVBoxLayout()
self.container_widget.setLayout(self.container_layout)
self.layout.addWidget(self.container_widget)
self.container_layout.setSpacing(0)
self.container_layout.setContentsMargins(30, 20, 30, 30)
self.container_widget.setObjectName("container-widget")

# enable checkbox
self.main_checkbox = QCheckBox("Enable USB Blocking")
self.layout.addWidget(self.main_checkbox)
self.container_layout.addWidget(self.main_checkbox)
self.main_checkbox.setChecked(self.toml_physical_ports['enable'])
self.main_checkbox.stateChanged.connect(self.enable_checkbox_clicked)

Expand All @@ -43,11 +56,12 @@ def init_ui(self):

def block_devices_table(self):
self.block_devices_label = QLabel("Block Devices")
self.layout.addWidget(self.block_devices_label)
self.container_layout.addWidget(self.block_devices_label)
self.block_devices_label.setObjectName("sub-component-title")

self.devices_table = QTableWidget()
self.devices_table.setColumnCount(3)
self.layout.addWidget(self.devices_table)
self.container_layout.addWidget(self.devices_table)

self.devices_table.setHorizontalHeaderLabels(["Device Name", "Device ID", "Allow"])

Expand All @@ -69,11 +83,12 @@ def add_device_rows():

def block_ports_table(self):
self.block_ports_label = QLabel("Block Ports")
self.layout.addWidget(self.block_ports_label)
self.container_layout.addWidget(self.block_ports_label)
self.block_ports_label.setObjectName("sub-component-title")

self.ports_table = QTableWidget()
self.ports_table.setColumnCount(3)
self.layout.addWidget(self.ports_table)
self.container_layout.addWidget(self.ports_table)

self.ports_table.setHorizontalHeaderLabels(["Port ID", "Device Name", "Allow"])

Expand Down
1 change: 1 addition & 0 deletions ui/components/software/apparmor.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ def init_ui(self):

self.main_label = QLabel("AppArmor")
self.layout.addWidget(self.main_label)
self.main_label.setObjectName("component-title")

# Enable Checkbox
checkbox = QCheckBox('Enable')
Expand Down
1 change: 1 addition & 0 deletions ui/components/software/processes.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ def init_ui(self):

self.main_label = QLabel("Process Hardening")
self.layout.addWidget(self.main_label)
self.main_label.setObjectName("component-title")

for name, state in self.toml_processes.items():
checkbox = QCheckBox(name.replace('_', ' ').title().replace('Aslr', 'ASLR'))
Expand Down
Binary file added ui/icons/check-solid.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions ui/pages/hardware_page.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from PyQt6.QtWidgets import QWidget, QVBoxLayout
from ui.components.hardware.physical_ports import PhysicalPorts
from ui.components.hardware.file_systems import FileSystems
from PyQt6.QtCore import Qt

class Hardware(QWidget):
def __init__(self):
Expand All @@ -10,6 +11,9 @@ def __init__(self):
def init_ui(self):
self.layout = QVBoxLayout()
self.setLayout(self.layout)
self.layout.setSpacing(0)
self.layout.setContentsMargins(0, 0, 0, 0)
self.layout.setAlignment(Qt.AlignmentFlag.AlignLeft)

self.physical_ports = PhysicalPorts()
self.file_systems = FileSystems()
Expand Down
Binary file removed ui/qss/image.png
Binary file not shown.
77 changes: 69 additions & 8 deletions ui/qss/style.qss
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
QMainWindow {
background-color: rgb(33, 37, 43);
}

#pageBg {
background-color: rgb(40, 44, 52);
border: 1px solid rgb(44, 49, 58);
padding: 20px;
}

QMainWindow {
background-color: rgb(33, 37, 43);
}

#sidebarBg {
background-color: rgb(33, 37, 43);
}
Expand All @@ -18,13 +18,74 @@ QMainWindow {
text-align: left;
padding-left: 15px;
color: rgb(221, 221, 221);
font: 15px;
font: 17px;
font-weight: 400;
}

#sidebarBg QLabel:hover {
background-color: rgb(40, 44, 52)
}

#sidebarBg QLabel:pressed {
background-color: rgb(44, 49, 58)
#component-title {
color: rgb(221, 221, 221);
font: 25px;
font-weight: 600;
padding: 5px;
margin-top: 10px;
}

#sub-component-title {
color: #B6BBC4;
font: 18px;
font-weight: 500;
margin-top: 10px;
margin-bottom: 5px;
}

#refresh-btn {
background-color: #7B66FF;
padding: 4px 13px;
border-radius: 5px;
color: rgb(221, 221, 221);
font: 15px;
font-weight: 500;
margin-left: 20px;
margin-top: 10px;
}
#refresh-btn:hover {
background-color: #6B56FF;
}

QCheckBox {
spacing: 10px;
margin-bottom: 10px;
font: 15px;
font-weight: 500;
}
QCheckBox::indicator {
width: 13px;
height: 13px;
border-radius: 6px;
border: 1.5px solid #B6BBC4;
}
QCheckBox::indicator:checked {
background-color: #6B56FF;
}
QCheckBox::indicator:unchecked {
background-color: #ddd;
}
QCheckBox::indicator:checked:hover {
background-color: #7B66FF;
}
QCheckBox::indicator:unchecked:hover {
background-color: #ccc;
}

#container-widget {
background-color: rgb(33, 37, 43);
border-radius: 15px;
margin-left: 15px;
}

.file-systems QCheckBox {
margin-left: 30px;
}
2 changes: 1 addition & 1 deletion ui/sidebar.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,4 @@ def set_active(self, index):
self.change_page_signal.emit(index)
for i in range(self.layout.count()):
self.layout.itemAt(i).widget().setStyleSheet("")
self.layout.itemAt(index - 1).widget().setStyleSheet("background-color: rgb(44, 49, 58); border-left: 5px solid #7B66FF;")
self.layout.itemAt(index - 1).widget().setStyleSheet("background-color: rgb(44, 49, 58); border-left: 5px solid rgb(189, 147, 249);")

0 comments on commit 5e088ef

Please sign in to comment.