Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat: add admin actions audit entries #1234

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

pieterlukasse
Copy link
Contributor

Link to JIRA ticket if there is one: https://ctds-planx.atlassian.net/browse/VADC-1450

New Features

  • add audit log support for /admin/ endpoints
  • add audit decorator to /admin/ endpoints

Dependency updates

@pieterlukasse pieterlukasse force-pushed the feat/add_admin_actions_audit_entry branch from 47bf71b to d51eba6 Compare March 15, 2025 15:29
@coveralls
Copy link

coveralls commented Mar 15, 2025

Pull Request Test Coverage Report for Build 13874215801

Details

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • 79 unchanged lines in 2 files lost coverage.
  • Overall coverage increased (+0.06%) to 74.935%

Files with Coverage Reduction New Missed Lines %
resources/audit/utils.py 5 89.29%
blueprints/admin.py 74 69.86%
Totals Coverage Status
Change from base Build 13792436927: 0.06%
Covered Lines: 8111
Relevant Lines: 10824

💛 - Coveralls

@pieterlukasse pieterlukasse changed the title Feat: add admin actions audit entry Feat: add admin actions audit entries Mar 15, 2025
Copy link

filepath $$\textcolor{#23d18b}{\tt{passed}}$$ $$\textcolor{#f14c4c}{\tt{failed}}$$ $$\textcolor{#ffa500}{\tt{skipped}}$$ SUBTOTAL
$$\textcolor{#23d18b}{\tt{tests/test\_centralized\_auth.py}}$$ $$\textcolor{#23d18b}{\tt{16}}$$ $$\textcolor{#666666}{\tt{0}}$$ $$\textcolor{#666666}{\tt{0}}$$ $$\textcolor{#23d18b}{\tt{16}}$$
$$\textcolor{#f14c4c}{\tt{tests/test\_oauth2.py}}$$ $$\textcolor{#23d18b}{\tt{5}}$$ $$\textcolor{#f14c4c}{\tt{10}}$$ $$\textcolor{#666666}{\tt{0}}$$ $$\textcolor{#f14c4c}{\tt{15}}$$
$$\textcolor{#f14c4c}{\tt{tests/test\_data\_upload.py}}$$ $$\textcolor{#23d18b}{\tt{7}}$$ $$\textcolor{#f14c4c}{\tt{1}}$$ $$\textcolor{#ffa500}{\tt{1}}$$ $$\textcolor{#f14c4c}{\tt{9}}$$
$$\textcolor{#23d18b}{\tt{tests/test\_presigned\_url.py}}$$ $$\textcolor{#23d18b}{\tt{7}}$$ $$\textcolor{#666666}{\tt{0}}$$ $$\textcolor{#666666}{\tt{0}}$$ $$\textcolor{#23d18b}{\tt{7}}$$
$$\textcolor{#23d18b}{\tt{tests/test\_user\_token.py}}$$ $$\textcolor{#23d18b}{\tt{5}}$$ $$\textcolor{#666666}{\tt{0}}$$ $$\textcolor{#666666}{\tt{0}}$$ $$\textcolor{#23d18b}{\tt{5}}$$
$$\textcolor{#23d18b}{\tt{tests/test\_drs\_endpoint.py}}$$ $$\textcolor{#23d18b}{\tt{4}}$$ $$\textcolor{#666666}{\tt{0}}$$ $$\textcolor{#666666}{\tt{0}}$$ $$\textcolor{#23d18b}{\tt{4}}$$
$$\textcolor{#f14c4c}{\tt{tests/test\_ras\_authn.py}}$$ $$\textcolor{#23d18b}{\tt{2}}$$ $$\textcolor{#f14c4c}{\tt{1}}$$ $$\textcolor{#666666}{\tt{0}}$$ $$\textcolor{#f14c4c}{\tt{3}}$$
$$\textcolor{#f14c4c}{\tt{tests/test\_dbgap.py}}$$ $$\textcolor{#23d18b}{\tt{3}}$$ $$\textcolor{#f14c4c}{\tt{1}}$$ $$\textcolor{#ffa500}{\tt{1}}$$ $$\textcolor{#f14c4c}{\tt{5}}$$
$$\textcolor{#23d18b}{\tt{tests/test\_oidc\_client.py}}$$ $$\textcolor{#23d18b}{\tt{2}}$$ $$\textcolor{#666666}{\tt{0}}$$ $$\textcolor{#666666}{\tt{0}}$$ $$\textcolor{#23d18b}{\tt{2}}$$
$$\textcolor{#23d18b}{\tt{tests/test\_client\_credentials.py}}$$ $$\textcolor{#23d18b}{\tt{1}}$$ $$\textcolor{#666666}{\tt{0}}$$ $$\textcolor{#666666}{\tt{0}}$$ $$\textcolor{#23d18b}{\tt{1}}$$
$$\textcolor{#f14c4c}{\tt{tests/test\_audit\_service.py}}$$ $$\textcolor{#666666}{\tt{0}}$$ $$\textcolor{#f14c4c}{\tt{1}}$$ $$\textcolor{#666666}{\tt{0}}$$ $$\textcolor{#f14c4c}{\tt{1}}$$
$$\textcolor{#f14c4c}{\tt{tests/test\_google\_data\_access.py}}$$ $$\textcolor{#666666}{\tt{0}}$$ $$\textcolor{#f14c4c}{\tt{1}}$$ $$\textcolor{#666666}{\tt{0}}$$ $$\textcolor{#f14c4c}{\tt{1}}$$
$$\textcolor{#ffa500}{\tt{tests/test\_register\_user.py}}$$ $$\textcolor{#666666}{\tt{0}}$$ $$\textcolor{#666666}{\tt{0}}$$ $$\textcolor{#ffa500}{\tt{2}}$$ $$\textcolor{#ffa500}{\tt{2}}$$
$$\textcolor{#f14c4c}{\tt{TOTAL}}$$ $$\textcolor{#23d18b}{\tt{52}}$$ $$\textcolor{#f14c4c}{\tt{15}}$$ $$\textcolor{#ffa500}{\tt{4}}$$ $$\textcolor{#f14c4c}{\tt{71}}$$

Please find the detailed integration test report here

Please find the ci env pod logs here

Copy link
Contributor

@paulineribeyre paulineribeyre left a comment

Choose a reason for hiding this comment

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

See feedback in this thread

request_url = _clean_authorization_request_url(
request_url
) # TODO - more than this will be needed for POST requests...
flask.current_app.audit_service_client.create_admin_action_log(
Copy link
Contributor

Choose a reason for hiding this comment

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

The create_admin_action_log method doesn't exist: https://github.com/uc-cdis/fence/blob/dccf559/fence/resources/audit/client.py

This code should fail, I'm very surprised that the existing "admin" unit tests passed. How?!

@@ -391,6 +409,7 @@ def add_project_to_groups(projectname):

@blueprint.route("/projects/<projectname>/bucket/<bucketname>", methods=["POST"])
@admin_login_required
@enable_audit_logging
def create_bucket_in_project(projectname, bucketname):
"""
DEPRECATED: This endpoint is deprecated and will be removed in a future release.
Copy link
Contributor

Choose a reason for hiding this comment

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

why are we adding audit logging to deprecated endpoints?

flask.current_app.audit_service_client.create_admin_action_log(
status_code=response.status_code,
request_url=request_url,
action="admin_action_" + method,
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think audit-logging the request method is useful at all. "admin_action_POST" isn't going to tell you what was changed in the system 🤔

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.

3 participants