mirror of
https://github.com/Mailu/Mailu.git
synced 2025-03-03 14:52:36 +02:00
update tabluate. fix audit.py and include in container
This commit is contained in:
parent
8d90a74624
commit
23d0cd0466
@ -43,6 +43,7 @@ COPY --from=assets static ./mailu/ui/static
|
||||
COPY mailu ./mailu
|
||||
COPY migrations ./migrations
|
||||
COPY start.py /start.py
|
||||
COPY audit.py /audit.py
|
||||
|
||||
RUN pybabel compile -d mailu/translations
|
||||
|
||||
|
28
core/admin/audit.py
Normal file → Executable file
28
core/admin/audit.py
Normal file → Executable file
@ -1,14 +1,17 @@
|
||||
from mailu import app
|
||||
#!/usr/bin/python3
|
||||
|
||||
import sys
|
||||
import tabulate
|
||||
|
||||
import mailu
|
||||
app = mailu.create_app()
|
||||
|
||||
|
||||
# Known endpoints without permissions
|
||||
known_missing_permissions = [
|
||||
"index",
|
||||
"static", "bootstrap.static",
|
||||
"admin.static", "admin.login"
|
||||
'index',
|
||||
'static', 'bootstrap.static',
|
||||
'admin.static', 'admin.login'
|
||||
]
|
||||
|
||||
|
||||
@ -16,7 +19,7 @@ known_missing_permissions = [
|
||||
missing_permissions = []
|
||||
permissions = {}
|
||||
for endpoint, function in app.view_functions.items():
|
||||
audit = function.__dict__.get("_audit_permissions")
|
||||
audit = function.__dict__.get('_audit_permissions')
|
||||
if audit:
|
||||
handler, args = audit
|
||||
if args:
|
||||
@ -28,16 +31,15 @@ for endpoint, function in app.view_functions.items():
|
||||
elif endpoint not in known_missing_permissions:
|
||||
missing_permissions.append(endpoint)
|
||||
|
||||
|
||||
# Fail if any endpoint is missing a permission check
|
||||
if missing_permissions:
|
||||
print("The following endpoints are missing permission checks:")
|
||||
print(missing_permissions.join(","))
|
||||
sys.exit(1)
|
||||
|
||||
|
||||
# Display the permissions table
|
||||
print(tabulate.tabulate([
|
||||
[route, *permissions[route.endpoint]]
|
||||
for route in app.url_map.iter_rules() if route.endpoint in permissions
|
||||
]))
|
||||
|
||||
# Warn if any endpoint is missing a permission check
|
||||
if missing_permissions:
|
||||
print()
|
||||
print('The following endpoints are missing permission checks:')
|
||||
print(','.join(missing_permissions))
|
||||
|
||||
|
@ -65,7 +65,7 @@ six==1.15.0
|
||||
socrate==0.1.1
|
||||
SQLAlchemy==1.3.3
|
||||
srslib==0.1.4
|
||||
tabulate==0.8.3
|
||||
tabulate==0.8.9
|
||||
tenacity==5.0.4
|
||||
toml==0.10.2
|
||||
urllib3==1.26.5
|
||||
|
Loading…
x
Reference in New Issue
Block a user