Skip to content

Commit

Permalink
[3.0.38] Fix: server configurations and documentation path
Browse files Browse the repository at this point in the history
  • Loading branch information
mauricelambert committed Jun 27, 2024
1 parent e44731f commit 753f84a
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 6 deletions.
2 changes: 1 addition & 1 deletion WebScripts/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
This tool runs CLI scripts and displays output in a Web Interface.
"""

__version__ = "3.0.36"
__version__ = "3.0.38"
__author__ = "Maurice Lambert"
__author_email__ = "mauricelambert434@gmail.com"
__maintainer__ = "Maurice Lambert"
Expand Down
2 changes: 1 addition & 1 deletion WebScripts/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
This tool runs CLI scripts and displays output in a Web Interface.
"""

__version__ = "3.0.36"
__version__ = "3.0.38"
__author__ = "Maurice Lambert"
__author_email__ = "mauricelambert434@gmail.com"
__maintainer__ = "Maurice Lambert"
Expand Down
20 changes: 16 additions & 4 deletions WebScripts/harden.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

###################
# This tool runs CLI scripts and displays output in a Web Interface.
# Copyright (C) 2021, 2022, 2023 Maurice Lambert
# Copyright (C) 2021, 2022, 2023, 2024 Maurice Lambert

# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
Expand All @@ -25,7 +25,7 @@
This file hardens the WebScripts installation and configuration.
"""

__version__ = "0.0.8"
__version__ = "0.0.9"
__author__ = "Maurice Lambert"
__author_email__ = "mauricelambert434@gmail.com"
__maintainer__ = "Maurice Lambert"
Expand All @@ -39,7 +39,7 @@
__url__ = "https://github.com/mauricelambert/WebScripts"

copyright = """
WebScripts Copyright (C) 2021, 2022, 2023 Maurice Lambert
WebScripts Copyright (C) 2021, 2022, 2023, 2024 Maurice Lambert
This program comes with ABSOLUTELY NO WARRANTY.
This is free software, and you are welcome to redistribute it
under certain conditions.
Expand Down Expand Up @@ -71,6 +71,7 @@
abspath,
basename,
exists,
normpath,
)
from importlib.util import spec_from_loader, module_from_spec
from logging import FileHandler, Formatter, getLogger, Logger
Expand Down Expand Up @@ -207,6 +208,7 @@ def __init__(
directory: str = None,
):
self.admin_password = admin_password
self.documentation_paths = []
self.json_only = json_only
self.owner = owner or getuser()
self.directory = directory or getcwd()
Expand Down Expand Up @@ -293,7 +295,11 @@ def harden_server(self, section: dict, directory: str) -> None:
if self.is_windows:
path_.insert(1, "..")

section["modules_path"] = abspath(join(*path_, "modules"))
self.documentation_paths = section["documentations_path"] = [
normpath(abspath(join(self.directory, x)))
for x in section["documentations_path"]
]
section["modules_path"] = [normpath(abspath(join(*path_, "modules")))]
section["data_dir"] = abspath(join(self.directory, "data"))
section["json_scripts_config"] = self.get_files_from_glob_path(
path_, section["json_scripts_config"]
Expand Down Expand Up @@ -369,6 +375,12 @@ def linux_hardening_file_permissions(self) -> None:
chmod(logs, 0o700) # nosec
chown(logs, pw_uid, pw_gid)

for documentation_path in self.documentation_paths:
documentation_directory = dirname(documentation_path)
makedirs(documentation_directory, exist_ok=True)
chmod(documentation_directory, 0o700) # nosec
chown(documentation_directory, pw_uid, pw_gid)

def linux_file_permissions(self, filename: str) -> None:
"""
This method changes files permissions on Linux.
Expand Down

0 comments on commit 753f84a

Please sign in to comment.