mirror of
https://github.com/ParisNeo/lollms.git
synced 2024-12-21 21:47:54 +00:00
enhanced security
This commit is contained in:
parent
412530db16
commit
9d532c2a76
@ -105,7 +105,7 @@ def press_buttons(driver, buttons_to_press=['accept']):
|
|||||||
except:
|
except:
|
||||||
ASCIIColors.warning(f"Couldn't press button {button_to_press} in this page.")
|
ASCIIColors.warning(f"Couldn't press button {button_to_press} in this page.")
|
||||||
|
|
||||||
def scrape_and_save(url, file_path=None, lollms_com=None, chromedriver_path=None, wait_step_delay=1, buttons_to_press=['accept']):
|
def scrape_and_save(url, file_path=None, lollms_com=None, chromedriver_path=None, wait_step_delay=1, buttons_to_press=['accept'], max_size=None):
|
||||||
if not PackageManager.check_package_installed("selenium"):
|
if not PackageManager.check_package_installed("selenium"):
|
||||||
PackageManager.install_package("selenium")
|
PackageManager.install_package("selenium")
|
||||||
if not PackageManager.check_package_installed("bs4"):
|
if not PackageManager.check_package_installed("bs4"):
|
||||||
@ -135,11 +135,12 @@ def scrape_and_save(url, file_path=None, lollms_com=None, chromedriver_path=None
|
|||||||
|
|
||||||
|
|
||||||
if file_path:
|
if file_path:
|
||||||
# Save the text content as a text file
|
if max_size and text_content< max_size:
|
||||||
with open(file_path, 'w', encoding="utf-8") as file:
|
# Save the text content as a text file
|
||||||
file.write(text_content)
|
with open(file_path, 'w', encoding="utf-8") as file:
|
||||||
if lollms_com:
|
file.write(text_content)
|
||||||
lollms_com.info(f"Webpage content saved to {file_path}")
|
if lollms_com:
|
||||||
|
lollms_com.info(f"Webpage content saved to {file_path}")
|
||||||
|
|
||||||
# Close the driver
|
# Close the driver
|
||||||
driver.quit()
|
driver.quit()
|
||||||
|
@ -46,9 +46,9 @@ def sanitize_path_from_endpoint(path: str, error_text="A suspected LFI attack de
|
|||||||
return path
|
return path
|
||||||
|
|
||||||
|
|
||||||
def forbid_remote_access(lollmsElfServer):
|
def forbid_remote_access(lollmsElfServer, exception_text = "This functionality is forbidden if the server is exposed"):
|
||||||
if lollmsElfServer.config.host!="localhost" and lollmsElfServer.config.host!="127.0.0.1":
|
if not lollmsElfServer.config.force_accept_remote_access and lollmsElfServer.config.host!="localhost" and lollmsElfServer.config.host!="127.0.0.1":
|
||||||
raise Exception("This functionality is forbidden if the server is exposed")
|
raise Exception(exception_text)
|
||||||
|
|
||||||
def validate_path(path, allowed_paths:List[str|Path]):
|
def validate_path(path, allowed_paths:List[str|Path]):
|
||||||
# Convert the path to an absolute path
|
# Convert the path to an absolute path
|
||||||
|
Loading…
Reference in New Issue
Block a user