Skip to content

Admin changes#3737

Open
Ulincsys wants to merge 22 commits intomainfrom
admin-changes
Open

Admin changes#3737
Ulincsys wants to merge 22 commits intomainfrom
admin-changes

Conversation

@Ulincsys
Copy link
Contributor

Description

  • Add admin dashboard
  • Add admin API routes
  • Add admin_required decorator to protect admin routes

Notes for Reviewers

  • There's a lot more work to do on this interface, but I'd like to get it into main so it stays up to date instead of lagging behind again.
  • Admin users cannot be created via the frontend, and must be added via the augur user add command with the --admin flag

Signed commits

  • Yes, I signed my commits.

Ulincsys and others added 22 commits March 20, 2023 18:39
Add @requires_admin decorator
Add clarity to backend start error status

Signed-off-by: Ulincsys <ulincsys@gmail.com>
- Add ssl decorator to config endpoints
- Fix syntax error in admin_required decorator
- Update dashboard endpoint to use config class directly
- Update dashboard styles with more consistent colors
- Implement config update functionality in admin dashboard

Signed-off-by: Ulincsys <28362836a@gmail.com>
Signed-off-by: Ulincsys <ulincsys@gmail.com>
Signed-off-by: Ulincsys <ulincsys@gmail.com>
Signed-off-by: Ulincsys <ulincsys@gmail.com>
Signed-off-by: Ulincsys <ulincsys@gmail.com>
Signed-off-by: Ulincsys <ulincsys@gmail.com>
Signed-off-by: Ulincsys <ulincsys@gmail.com>
Signed-off-by: Ulincsys <ulincsys@gmail.com>
Signed-off-by: Ulincsys <ulincsys@gmail.com>
Signed-off-by: Ulincsys <ulincsys@gmail.com>
Signed-off-by: Ulincsys <ulincsys@gmail.com>
Signed-off-by: Ulincsys <ulincsys@gmail.com>
Signed-off-by: Ulincsys <ulincsys@gmail.com>
Signed-off-by: Ulincsys <ulincsys@gmail.com>
Signed-off-by: Ulincsys <ulincsys@gmail.com>
Signed-off-by: Ulincsys <ulincsys@gmail.com>
Signed-off-by: Ulincsys <ulincsys@gmail.com>
@Ulincsys Ulincsys requested a review from sgoggins as a code owner February 25, 2026 01:17
if signal.getsignal(signal.SIGHUP) != signal.SIG_DFL:
cmd = "nohup " + cmd

Popen(cmd, shell=True)

Check failure

Code scanning / Bandit

subprocess call with shell=True identified, security issue. Error

subprocess call with shell=True identified, security issue.
from ..server import app
import sqlalchemy as s
import json
from subprocess import run, PIPE, Popen

Check notice

Code scanning / Bandit

Consider possible security implications associated with the subprocess module. Note

Consider possible security implications associated with the subprocess module.
@app.route(f"/{AUGUR_API_VERSION}/admin/shutdown")
@admin_required
def shutdown_system():
run("augur backend stop-collection-blocking".split(), stdin=PIPE, stdout=PIPE, stderr=PIPE)

Check notice

Code scanning / Bandit

subprocess call - check for execution of untrusted input. Note

subprocess call - check for execution of untrusted input.
@admin_required
def shutdown_system():
run("augur backend stop-collection-blocking".split(), stdin=PIPE, stdout=PIPE, stderr=PIPE)
Popen("augur backend stop", shell=True, stdin=PIPE, stdout=PIPE, stderr=PIPE)

Check notice

Code scanning / Bandit

Starting a process with a partial executable path Note

Starting a process with a partial executable path
@admin_required
def shutdown_system():
run("augur backend stop-collection-blocking".split(), stdin=PIPE, stdout=PIPE, stderr=PIPE)
Popen("augur backend stop", shell=True, stdin=PIPE, stdout=PIPE, stderr=PIPE)

Check notice

Code scanning / Bandit

subprocess call with shell=True seems safe, but may be changed in the future, consider rewriting without shell Note

subprocess call with shell=True seems safe, but may be changed in the future, consider rewriting without shell
@@ -0,0 +1,29 @@
from subprocess import run, PIPE, Popen

Check notice

Code scanning / Bandit

Consider possible security implications associated with the subprocess module. Note

Consider possible security implications associated with the subprocess module.
# Ignore SIGTERM from parent process (since we're terminating our parent)
signal.signal(signal.SIGTERM, lambda signum, frame: None)

run("augur backend stop-collection-blocking", shell=True, stderr=PIPE, stdout=PIPE, stdin=PIPE)

Check notice

Code scanning / Bandit

Starting a process with a partial executable path Note

Starting a process with a partial executable path
# Ignore SIGTERM from parent process (since we're terminating our parent)
signal.signal(signal.SIGTERM, lambda signum, frame: None)

run("augur backend stop-collection-blocking", shell=True, stderr=PIPE, stdout=PIPE, stdin=PIPE)

Check notice

Code scanning / Bandit

subprocess call with shell=True seems safe, but may be changed in the future, consider rewriting without shell Note

subprocess call with shell=True seems safe, but may be changed in the future, consider rewriting without shell
signal.signal(signal.SIGTERM, lambda signum, frame: None)

run("augur backend stop-collection-blocking", shell=True, stderr=PIPE, stdout=PIPE, stdin=PIPE)
Popen("augur backend stop", shell=True, stderr=PIPE, stdout=PIPE, stdin=PIPE).wait()

Check notice

Code scanning / Bandit

Starting a process with a partial executable path Note

Starting a process with a partial executable path
signal.signal(signal.SIGTERM, lambda signum, frame: None)

run("augur backend stop-collection-blocking", shell=True, stderr=PIPE, stdout=PIPE, stdin=PIPE)
Popen("augur backend stop", shell=True, stderr=PIPE, stdout=PIPE, stdin=PIPE).wait()

Check notice

Code scanning / Bandit

subprocess call with shell=True seems safe, but may be changed in the future, consider rewriting without shell Note

subprocess call with shell=True seems safe, but may be changed in the future, consider rewriting without shell
import beaker

from flask import request, jsonify, current_app
from flask import request, jsonify, current_app, abort

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[pylint] reported by reviewdog 🐶
W0611: Unused current_app imported from flask (unused-import)

@@ -38,6 +40,13 @@ def unsupported_method(error):

return render_message("405 - Method not supported", "The resource you are trying to access does not support the request method used"), 405

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[pylint] reported by reviewdog 🐶
E0602: Undefined variable 'render_message' (undefined-variable)

if AUGUR_API_VERSION in str(request.url_rule):
return jsonify({"status": "Forbidden"}), 403

return render_message("403 - Forbidden", "You do not have permission to view this page"), 403

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[pylint] reported by reviewdog 🐶
E0602: Undefined variable 'render_message' (undefined-variable)

raise e

return render_message("500 - Internal Server Error", "An error occurred while trying to service your request. Please try again, and if the issue persists, please file a GitHub issue with the below error message:", error=stacktrace), 500
return render_message("500 - Internal Server Error", """An error occurred while trying to service your request.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[pylint] reported by reviewdog 🐶
E0602: Undefined variable 'render_message' (undefined-variable)

@@ -98,19 +120,16 @@ def load_user(user_id):
@login_manager.request_loader
def load_user_request(request):

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[pylint] reported by reviewdog 🐶
W0621: Redefining name 'request' from outer scope (line 1) (redefined-outer-name)

from .init import logger
from .url_converters import *

from functools import wraps

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[pylint] reported by reviewdog 🐶
W0611: Unused wraps imported from functools (unused-import)

@@ -112,6 +119,10 @@ def repo_card_view():
@app.route('/collection/status')
def status_view():
return render_module("status", title="Status")

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[pylint] reported by reviewdog 🐶
E0602: Undefined variable 'render_module' (undefined-variable)


@app.route('/connection_status')
def server_ping_frontend():
return render_module("ping")

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[pylint] reported by reviewdog 🐶
E0602: Undefined variable 'render_module' (undefined-variable)

@@ -318,6 +329,7 @@ def user_group_view(group = None):
return render_module("user-group-repos-table", title="Repos", repos=data, query_key=query, activePage=params["page"], pages=page_count, offset=pagination_offset, PS="user_group_view", reverse = rev, sorting = params.get("sort"), group=group)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[pylint] reported by reviewdog 🐶
E0602: Undefined variable 'render_module' (undefined-variable)

backend_config = requestJson("config/get", False)
backend_config = AugurConfig(logger, db_session).load_config()

with get_session() as session:

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[pylint] reported by reviewdog 🐶
W0621: Redefining name 'session' from outer scope (line 8) (redefined-outer-name)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant