Soft merge branch "dev" into branch "v2"

This commit is contained in:
Théophile Diot 2023-11-13 10:07:48 +00:00
commit 429e0cadca
No known key found for this signature in database
GPG Key ID: 248FEA4BAE400D06
9 changed files with 93 additions and 92 deletions

26
.gitattributes vendored
View File

@ -1,15 +1,17 @@
* text=auto eol=lf
# Folders
src/deps/src/** linguist-vendored
src/common/core/modsecurity/files/** linguist-vendored
src/ui/static/js/editor/** linguist-vendored
src/ui/static/js/utils/purify/** linguist-vendored
src/ui/static/webfonts/** linguist-vendored
src/deps/src/** -text -eol linguist-vendored=true
src/common/core/modsecurity/files/** -text -eol linguist-vendored=true
src/ui/static/js/editor/** -text -eol linguist-vendored=true
src/ui/static/js/utils/purify/** -text -eol linguist-vendored=true
src/ui/static/webfonts/** -text -eol linguist-vendored=true
# Files
src/deps/misc/lua-pack.Makefile -linguist-vendored
src/deps/misc/ngx_http_modsecurity_access.c -linguist-vendored
src/ui/static/css/datepicker-foundation.css -linguist-vendored
src/ui/static/css/flatpickr.css -linguist-vendored
src/ui/static/css/flatpickr.dark.css -linguist-vendored
src/ui/static/js/tsparticles.bundle.min.js -linguist-vendored
src/ui/static/js/utils/flatpickr.js -linguist-vendored
src/deps/misc/lua-pack.Makefile -linguist-vendored=true
src/deps/misc/ngx_http_modsecurity_access.c -linguist-vendored=true
src/ui/static/css/datepicker-foundation.css -linguist-vendored=true
src/ui/static/css/flatpickr.css -linguist-vendored=true
src/ui/static/css/flatpickr.dark.css -linguist-vendored=true
src/ui/static/js/tsparticles.bundle.min.js -linguist-vendored=true
src/ui/static/js/utils/flatpickr.js -linguist-vendored=true

View File

@ -23,7 +23,7 @@ jobs:
with:
name: BunkerWeb_documentation_v${{ inputs.VERSION }}.pdf
# Create tag
- uses: rickstaa/action-create-tag@37d6cf3fd9b51a3c065493422911b035f73f55b2 # v1.6.6
- uses: rickstaa/action-create-tag@861755f3fcbce1b21a65c17bad10e7d35c27b6d9 # v1.7.1
name: Create tag
if: inputs.VERSION != 'testing'
with:
@ -31,7 +31,7 @@ jobs:
message: "v${{ inputs.VERSION }}"
force_push_tag: true
# Create tag
- uses: rickstaa/action-create-tag@37d6cf3fd9b51a3c065493422911b035f73f55b2 # v1.6.6
- uses: rickstaa/action-create-tag@861755f3fcbce1b21a65c17bad10e7d35c27b6d9 # v1.7.1
name: Create tag
if: inputs.VERSION == 'testing'
with:

View File

@ -42,7 +42,7 @@ jobs:
- name: Check out repository code
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
- name: Install ruby
uses: ruby/setup-ruby@54a18e26dbbb1eabc604f317ade9a5788dddef81 # v1.159.0
uses: ruby/setup-ruby@036ef458ddccddb148a2b9fb67e95a22fdbf728b # v1.160.0
with:
ruby-version: "3.0"
- name: Install packagecloud

View File

@ -87,4 +87,4 @@ content = doc.read()
doc = StringIO(content.replace("\\|", "|"))
doc.seek(0)
Path("docs", "settings.md").write_text(doc.read())
Path("docs", "settings.md").write_text(doc.read(), encoding="utf-8")

View File

@ -61,7 +61,7 @@ RUN apk add --no-cache bash && \
chmod 750 /usr/share/bunkerweb/helpers/*.sh /usr/share/bunkerweb/autoconf/*.py /usr/share/bunkerweb/autoconf/entrypoint.sh /usr/share/bunkerweb/deps/python/bin/*
# Fix CVEs
RUN apk add --no-cache "libcrypto3>=3.1.4-r0" "libssl3>=3.1.4-r0"
RUN apk add --no-cache "libcrypto3>=3.1.4-r1" "libssl3>=3.1.4-r1"
WORKDIR /usr/share/bunkerweb/autoconf

View File

@ -74,7 +74,7 @@ RUN apk add --no-cache bash nodejs npm && \
ln -s /proc/1/fd/2 /var/log/bunkerweb/ui.log
# Fix CVEs
RUN apk add --no-cache "libcrypto3>=3.1.4-r0" "libssl3>=3.1.4-r0"
RUN apk add --no-cache "libcrypto3>=3.1.4-r1" "libssl3>=3.1.4-r1"
# Change working directory
WORKDIR /usr/share/bunkerweb/ui

View File

@ -1,72 +1,72 @@
# -*- coding: utf-8 -*-
import requests, traceback, json # noqa: E401
from werkzeug.exceptions import HTTPException
from werkzeug.sansio.response import Response
def get_core_format_res(path, method, data, message, retry=1):
# Retry limit
if retry == 5:
raise HTTPException(response=Response(status=500), description="Max retry to core for same request exceeded")
req = None
# Try request core
try:
req = req_core(path, method)
# Case 503, retry request
if req.status_code == 503:
return get_core_format_res(path, method, data, message, retry + 1)
# Case error
if req == "error":
raise HTTPException(response=Response(status=500), description="Impossible to connect to CORE API")
except:
raise HTTPException(response=Response(status=500), description="Impossible to connect to CORE API")
# Case response from core, format response for client
try:
data = req.text
obj = json.loads(req.text)
if isinstance(obj, dict):
data = obj.get("message", obj)
if isinstance(data, dict):
data = data.get("data", data)
data = json.dumps(data, skipkeys=True, allow_nan=True, indent=6)
print(req.status_code)
print(req.status_code == requests.codes.ok)
return {"type": "success" if str(req.status_code).startswith("2") else "error", "status": str(req.status_code), "message": message, "data": data}
# Case impossible to format
except:
print(traceback.format_exc())
def req_core(path, method, data=None):
# Request core api and store response
req = None
try:
if method.upper() == "GET":
req = requests.get(path)
if method.upper() == "POST":
req = requests.post(path, data=data)
if method.upper() == "DELETE":
req = requests.delete(path, data=data)
if method.upper() == "PATCH":
req = requests.patch(path, data=data)
if method.upper() == "PUT":
req = requests.put(path, data=data)
return req
# Case no response from core
except:
return "error"
def exception_res(status_code, path, detail):
return {"type": "error", "status": status_code, "message": f"{path} {detail}", "data": "{}"}
# -*- coding: utf-8 -*-
import requests, traceback, json # noqa: E401
from werkzeug.exceptions import HTTPException
from werkzeug.sansio.response import Response
def get_core_format_res(path, method, data, message, retry=1):
# Retry limit
if retry == 5:
raise HTTPException(response=Response(status=500), description="Max retry to core for same request exceeded")
req = None
# Try request core
try:
req = req_core(path, method)
# Case 503, retry request
if req.status_code == 503:
return get_core_format_res(path, method, data, message, retry + 1)
# Case error
if req == "error":
raise HTTPException(response=Response(status=500), description="Impossible to connect to CORE API")
except:
raise HTTPException(response=Response(status=500), description="Impossible to connect to CORE API")
# Case response from core, format response for client
try:
data = req.text
obj = json.loads(req.text)
if isinstance(obj, dict):
data = obj.get("message", obj)
if isinstance(data, dict):
data = data.get("data", data)
data = json.dumps(data, skipkeys=True, allow_nan=True, indent=6)
print(req.status_code)
print(req.status_code == requests.codes.ok)
return {"type": "success" if str(req.status_code).startswith("2") else "error", "status": str(req.status_code), "message": message, "data": data}
# Case impossible to format
except:
print(traceback.format_exc())
def req_core(path, method, data=None):
# Request core api and store response
req = None
try:
if method.upper() == "GET":
req = requests.get(path)
if method.upper() == "POST":
req = requests.post(path, data=data)
if method.upper() == "DELETE":
req = requests.delete(path, data=data)
if method.upper() == "PATCH":
req = requests.patch(path, data=data)
if method.upper() == "PUT":
req = requests.put(path, data=data)
return req
# Case no response from core
except:
return "error"
def exception_res(status_code, path, detail):
return {"type": "error", "status": status_code, "message": f"{path} {detail}", "data": "{}"}

View File

@ -3,4 +3,3 @@ redis==5.0.1
requests==2.31.0
selenium==4.15.2
uvicorn[standard]==0.24.0
uvicorn[standard]==0.24.0

View File

@ -5,7 +5,6 @@ from functools import partial
from os import getenv, listdir
from os.path import join
from pathlib import Path
from subprocess import PIPE, run
from time import sleep
from traceback import format_exc
from typing import List, Union
@ -20,6 +19,7 @@ from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.remote.webelement import WebElement
from selenium.webdriver.support import expected_conditions as EC
from selenium.common.exceptions import ElementClickInterceptedException, TimeoutException, WebDriverException
from subprocess import run, PIPE
ready = False
retries = 0