Skip to content

Commit

Permalink
Update pre-commit-config hooks versions and apply it
Browse files Browse the repository at this point in the history
  • Loading branch information
TheophileDiot committed Jan 23, 2024
1 parent a0e0d43 commit 73c2ea4
Show file tree
Hide file tree
Showing 18 changed files with 81 additions and 80 deletions.
8 changes: 4 additions & 4 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# See https://pre-commit.com for more information
# See https://pre-commit.com/hooks.html for more hooks
exclude: (^LICENSE.md$|^src/VERSION$|^env/|^src/(bw/misc/root-ca.pem$|deps/src/|common/core/modsecurity/files|ui/static/js/(editor/|utils/purify/|tsparticles\.bundle\.min\.js))|\.(svg|drawio|patch\d?|ascii|tf|tftpl|key)$)
exclude: (^LICENSE.md$|^src/VERSION$|^env/|^src/(bw/misc/root-ca.pem$|deps/src/|common/core/modsecurity/files|ui/static/(js/(editor/|utils/purify/|tsparticles\.bundle\.min\.js)|css/dashboard\.css))|\.(svg|drawio|patch\d?|ascii|tf|tftpl|key)$)
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: c4a0b883114b00d8d76b479c820ce7950211c99b # frozen: v4.5.0
Expand Down Expand Up @@ -30,7 +30,7 @@ repos:
name: Prettier Code Formatter

- repo: https://github.com/JohnnyMorganz/StyLua
rev: f9afc7f33bc19f7708fbc1d7eea0606e0d41080a # frozen: v0.19.1
rev: 84c370104d6a8d1eef00c80a3ebd42f7033aaaad # frozen: v0.20.0
hooks:
- id: stylua-github
exclude: ^src/(bw/lua/middleclass.lua|common/core/antibot/captcha.lua)$
Expand All @@ -50,7 +50,7 @@ repos:
args: ["--max-line-length=250", "--ignore=E266,E402,E722,W503"]

- repo: https://github.com/dosisod/refurb
rev: a7c461fcfaa2ca3248d489cdf7fed8e2d4fd8520 # frozen: v1.26.0
rev: a295cee6d188f5797aefe5d7cf77a353ed48ea93 # frozen: v1.27.0
hooks:
- id: refurb
name: Refurb Python Refactoring Tool
Expand All @@ -62,7 +62,7 @@ repos:
- id: codespell
name: Codespell Spell Checker
exclude: (^src/(ui/templates|common/core/.+/files|bw/loading)/.+.html|modsecurity-rules.conf.*)$
entry: codespell --ignore-regex="(tabEl|Widgits)" --skip src/ui/static/js/utils/flatpickr.js,CHANGELOG.md
entry: codespell --ignore-regex="(tabEl|Widgits)" --skip src/ui/static/js/utils/flatpickr.js,src/ui/static/css/style.css,CHANGELOG.md
language: python
types: [text]

Expand Down
2 changes: 1 addition & 1 deletion src/autoconf/SwarmController.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ def apply_config(self) -> bool:
def __process_event(self, event):
if "Actor" not in event or "ID" not in event["Actor"] or "Type" not in event:
return False
if event["Type"] not in ["service", "config"]:
if event["Type"] not in ("service", "config"):
return False
if event["Type"] == "service":
if event["Actor"]["ID"] in self.__swarm_instances or event["Actor"]["ID"] in self.__swarm_services:
Expand Down
4 changes: 2 additions & 2 deletions src/bw/lua/bunkerweb/utils.lua
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ local decode = cjson.decode
local char = string.char
local random = math.random
local session_start = session.start
local session_open = session.open
local tonumber = tonumber

local utils = {}
Expand Down Expand Up @@ -575,7 +574,8 @@ utils.get_session = function(ctx)
return ctx.bw.sessions_session
end
-- Open/create and do an optional refresh
local session, err, exists, refreshed = session_start()
local err, exists, refreshed
session, err, exists, refreshed = session_start()
if not session then
return nil, err
end
Expand Down
2 changes: 0 additions & 2 deletions src/common/core/antibot/antibot.lua
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@ local INFO = ngx.INFO
local tonumber = tonumber
local tostring = tostring
local get_session = utils.get_session
local get_session_data = utils.get_session_data
local set_session_data = utils.set_session_data
local get_deny_status = utils.get_deny_status
local rand = utils.rand
local now = ngx.now
Expand Down
5 changes: 1 addition & 4 deletions src/common/core/customcert/customcert.lua
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,7 @@ function customcert:ssl_certificate()
local data
data, err = self.datastore:get("plugin_customcert_" .. server_name, true)
if not data and err ~= "not found" then
return self:ret(
false,
"error while getting plugin_customcert_" .. server_name .. " from datastore : " .. err
)
return self:ret(false, "error while getting plugin_customcert_" .. server_name .. " from datastore : " .. err)
elseif data then
return self:ret(true, "certificate/key data found", data)
end
Expand Down
5 changes: 1 addition & 4 deletions src/common/core/letsencrypt/letsencrypt.lua
Original file line number Diff line number Diff line change
Expand Up @@ -103,10 +103,7 @@ function letsencrypt:ssl_certificate()
local data
data, err = self.datastore:get("plugin_letsencrypt_" .. server_name, true)
if not data and err ~= "not found" then
return self:ret(
false,
"error while getting plugin_letsencrypt_" .. server_name .. " from datastore : " .. err
)
return self:ret(false, "error while getting plugin_letsencrypt_" .. server_name .. " from datastore : " .. err)
elseif data then
return self:ret(true, "certificate/key data found", data)
end
Expand Down
2 changes: 1 addition & 1 deletion src/common/core/metrics/confs/http/metrics.conf
Original file line number Diff line number Diff line change
@@ -1 +1 @@
lua_shared_dict metrics_datastore {{ METRICS_MEMORY_SIZE }};
lua_shared_dict metrics_datastore {{ METRICS_MEMORY_SIZE }};
2 changes: 1 addition & 1 deletion src/common/core/metrics/confs/stream/metrics.conf
Original file line number Diff line number Diff line change
@@ -1 +1 @@
lua_shared_dict metrics_datastore_stream {{ METRICS_MEMORY_SIZE }};
lua_shared_dict metrics_datastore_stream {{ METRICS_MEMORY_SIZE }};
11 changes: 5 additions & 6 deletions src/common/core/metrics/metrics.lua
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
local cjson = require "cjson"
local class = require "middleclass"
local datastore = require "datastore"
local plugin = require "bunkerweb.plugin"
local utils = require "bunkerweb.utils"
local cjson = require "cjson"
local datastore = require "datastore"

local metrics = class("metrics", plugin)

Expand Down Expand Up @@ -58,7 +58,7 @@ function metrics:log()
code = ngx.status,
["user-agent"] = self.ctx.bw.http_user_agent or "",
reason = reason,
data = data
data = data,
}
local ok
ok, err = self.metrics_datastore:safe_rpush("metrics_requests", encode(request))
Expand All @@ -74,7 +74,6 @@ function metrics:log_default()
end

function metrics:api()

-- Match request
if not match(self.ctx.bw.uri, "^/metrics/requests$") or self.ctx.bw.request_method ~= "GET" then
return self:ret(false, "success")
Expand All @@ -100,9 +99,9 @@ function metrics:api()
if not ok then
self.logger:log(ERR, "can't save request to datastore : " .. err)
end
i = i + 1
i = i + 1
end
return self:ret(true, data, HTTP_OK)
end

return metrics
return metrics
5 changes: 1 addition & 4 deletions src/common/core/selfsigned/selfsigned.lua
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,7 @@ function selfsigned:ssl_certificate()
local data
data, err = self.datastore:get("plugin_selfsigned_" .. server_name, true)
if not data and err ~= "not found" then
return self:ret(
false,
"error while getting plugin_selfsigned_" .. server_name .. " from datastore : " .. err
)
return self:ret(false, "error while getting plugin_selfsigned_" .. server_name .. " from datastore : " .. err)
elseif data then
return self:ret(true, "certificate/key data found", data)
end
Expand Down
4 changes: 2 additions & 2 deletions src/scheduler/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ def api_to_instance(api):
env["DATABASE_URI"] = db.database_uri

# Instantiate scheduler
SCHEDULER = JobScheduler(env.copy() | environ.copy(), logger, INTEGRATION, db=db)
SCHEDULER = JobScheduler(env | environ.copy(), logger, INTEGRATION, db=db)

if INTEGRATION in ("Docker", "Swarm", "Kubernetes", "Autoconf"):
# Automatically setup the scheduler apis
Expand Down Expand Up @@ -464,7 +464,7 @@ def listen_for_instances_reload(db: Database):

if RUN_JOBS_ONCE:
# Update the environment variables of the scheduler
SCHEDULER.env = env.copy() | environ.copy()
SCHEDULER.env = env | environ.copy()
SCHEDULER.setup()

# Only run jobs once
Expand Down
5 changes: 1 addition & 4 deletions src/ui/src/Instances.py
Original file line number Diff line number Diff line change
Expand Up @@ -214,10 +214,7 @@ def get_instances(self) -> list[Instance]:
)
)

instances = sorted(
instances,
key=lambda x: x.name,
)
instances.sort(key=lambda x: x.name)

# Local instance
if Path(sep, "usr", "sbin", "nginx").exists():
Expand Down
17 changes: 10 additions & 7 deletions src/ui/static/account.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,18 @@
<link rel="stylesheet" href="/css/flag-icons.min.css" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>BunkerWeb | Account</title>
<script type="module" crossorigin src="/assets/account-ba9110db.js"></script>
<link rel="modulepreload" crossorigin href="/assets/lang-f5f8ee65.js">
<link rel="modulepreload" crossorigin href="/assets/State-99778106.js">
<link rel="modulepreload" crossorigin href="/assets/Base-fc8c7eae.js">
<link rel="modulepreload" crossorigin href="/assets/Input-294600dd.js">
<link rel="stylesheet" href="/assets/State-26c5bb69.css">
<script
type="module"
crossorigin
src="/assets/account-ba9110db.js"
></script>
<link rel="modulepreload" crossorigin href="/assets/lang-f5f8ee65.js" />
<link rel="modulepreload" crossorigin href="/assets/State-99778106.js" />
<link rel="modulepreload" crossorigin href="/assets/Base-fc8c7eae.js" />
<link rel="modulepreload" crossorigin href="/assets/Input-294600dd.js" />
<link rel="stylesheet" href="/assets/State-26c5bb69.css" />
</head>
<body>
<div id="app"></div>

</body>
</html>
29 changes: 18 additions & 11 deletions src/ui/static/actions.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,26 @@
<link rel="stylesheet" href="/css/flag-icons.min.css" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>BunkerWeb | Actions</title>
<script type="module" crossorigin src="/assets/actions-43d7100c.js"></script>
<link rel="modulepreload" crossorigin href="/assets/lang-f5f8ee65.js">
<link rel="modulepreload" crossorigin href="/assets/State-99778106.js">
<link rel="modulepreload" crossorigin href="/assets/List-82cc034b.js">
<link rel="modulepreload" crossorigin href="/assets/Input-294600dd.js">
<link rel="modulepreload" crossorigin href="/assets/Select-55aa1b49.js">
<link rel="modulepreload" crossorigin href="/assets/Item-e1d34516.js">
<link rel="modulepreload" crossorigin href="/assets/Datepicker-349b9bba.js">
<link rel="stylesheet" href="/assets/State-26c5bb69.css">
<link rel="stylesheet" href="/assets/Datepicker-b3d9355d.css">
<script
type="module"
crossorigin
src="/assets/actions-43d7100c.js"
></script>
<link rel="modulepreload" crossorigin href="/assets/lang-f5f8ee65.js" />
<link rel="modulepreload" crossorigin href="/assets/State-99778106.js" />
<link rel="modulepreload" crossorigin href="/assets/List-82cc034b.js" />
<link rel="modulepreload" crossorigin href="/assets/Input-294600dd.js" />
<link rel="modulepreload" crossorigin href="/assets/Select-55aa1b49.js" />
<link rel="modulepreload" crossorigin href="/assets/Item-e1d34516.js" />
<link
rel="modulepreload"
crossorigin
href="/assets/Datepicker-349b9bba.js"
/>
<link rel="stylesheet" href="/assets/State-26c5bb69.css" />
<link rel="stylesheet" href="/assets/Datepicker-b3d9355d.css" />
</head>
<body>
<div id="app"></div>

</body>
</html>
29 changes: 16 additions & 13 deletions src/ui/static/bans.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,24 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>BunkerWeb | Bans</title>
<script type="module" crossorigin src="/assets/bans-04a6a92e.js"></script>
<link rel="modulepreload" crossorigin href="/assets/lang-f5f8ee65.js">
<link rel="modulepreload" crossorigin href="/assets/State-99778106.js">
<link rel="modulepreload" crossorigin href="/assets/Input-294600dd.js">
<link rel="modulepreload" crossorigin href="/assets/Select-55aa1b49.js">
<link rel="modulepreload" crossorigin href="/assets/List-82cc034b.js">
<link rel="modulepreload" crossorigin href="/assets/Item-e1d34516.js">
<link rel="modulepreload" crossorigin href="/assets/Datepicker-349b9bba.js">
<link rel="modulepreload" crossorigin href="/assets/Warning-42bddb5b.js">
<link rel="modulepreload" crossorigin href="/assets/Base-fc8c7eae.js">
<link rel="modulepreload" crossorigin href="/assets/Checkbox-a81c9afa.js">
<link rel="stylesheet" href="/assets/State-26c5bb69.css">
<link rel="stylesheet" href="/assets/Datepicker-b3d9355d.css">
<link rel="modulepreload" crossorigin href="/assets/lang-f5f8ee65.js" />
<link rel="modulepreload" crossorigin href="/assets/State-99778106.js" />
<link rel="modulepreload" crossorigin href="/assets/Input-294600dd.js" />
<link rel="modulepreload" crossorigin href="/assets/Select-55aa1b49.js" />
<link rel="modulepreload" crossorigin href="/assets/List-82cc034b.js" />
<link rel="modulepreload" crossorigin href="/assets/Item-e1d34516.js" />
<link
rel="modulepreload"
crossorigin
href="/assets/Datepicker-349b9bba.js"
/>
<link rel="modulepreload" crossorigin href="/assets/Warning-42bddb5b.js" />
<link rel="modulepreload" crossorigin href="/assets/Base-fc8c7eae.js" />
<link rel="modulepreload" crossorigin href="/assets/Checkbox-a81c9afa.js" />
<link rel="stylesheet" href="/assets/State-26c5bb69.css" />
<link rel="stylesheet" href="/assets/Datepicker-b3d9355d.css" />
</head>
<body>
<div id="app"></div>

</body>
</html>
25 changes: 14 additions & 11 deletions src/ui/static/configs.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,22 @@
<link rel="stylesheet" href="/css/flag-icons.min.css" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>BunkerWeb | Configs</title>
<script type="module" crossorigin src="/assets/configs-86035b54.js"></script>
<link rel="modulepreload" crossorigin href="/assets/lang-f5f8ee65.js">
<link rel="modulepreload" crossorigin href="/assets/State-99778106.js">
<link rel="modulepreload" crossorigin href="/assets/List-82cc034b.js">
<link rel="modulepreload" crossorigin href="/assets/Input-294600dd.js">
<link rel="modulepreload" crossorigin href="/assets/Checkbox-a81c9afa.js">
<link rel="modulepreload" crossorigin href="/assets/Base-27eb0461.js">
<link rel="modulepreload" crossorigin href="/assets/Base-fc8c7eae.js">
<link rel="modulepreload" crossorigin href="/assets/v4-4a60fe23.js">
<link rel="stylesheet" href="/assets/State-26c5bb69.css">
<script
type="module"
crossorigin
src="/assets/configs-86035b54.js"
></script>
<link rel="modulepreload" crossorigin href="/assets/lang-f5f8ee65.js" />
<link rel="modulepreload" crossorigin href="/assets/State-99778106.js" />
<link rel="modulepreload" crossorigin href="/assets/List-82cc034b.js" />
<link rel="modulepreload" crossorigin href="/assets/Input-294600dd.js" />
<link rel="modulepreload" crossorigin href="/assets/Checkbox-a81c9afa.js" />
<link rel="modulepreload" crossorigin href="/assets/Base-27eb0461.js" />
<link rel="modulepreload" crossorigin href="/assets/Base-fc8c7eae.js" />
<link rel="modulepreload" crossorigin href="/assets/v4-4a60fe23.js" />
<link rel="stylesheet" href="/assets/State-26c5bb69.css" />
</head>
<body>
<div id="app"></div>

</body>
</html>
2 changes: 1 addition & 1 deletion src/ui/static/js/bans.js
Original file line number Diff line number Diff line change
Expand Up @@ -543,7 +543,7 @@ class AddBanModal {
}

setDatepicker(id) {
// instanciate datepicker
// instantiate datepicker
const dateOptions = {
locale: "en",
dateFormat: "m/d/Y H:i:S",
Expand Down
4 changes: 2 additions & 2 deletions src/ui/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ def get_range_from_remain(remain):
formats = ["year(s)", "month(s)", "day(s)", "hour(s)", "minute(s)", "second(s)"]
chars = ["year", "month", "day", "hour", "second", "s"]

# start from seconds to years, stop when first 0 occurence
# The remain term is first 0 occurence - 1
# start from seconds to years, stop when first 0 occurrence
# The remain term is first 0 occurrence - 1
for i in range(len(terms)):
# remove letter
num = terms[len(terms) - 1 - i]
Expand Down

0 comments on commit 73c2ea4

Please sign in to comment.