Skip to content

Commit

Permalink
Require session to list jobs instead of returning empty job list for …
Browse files Browse the repository at this point in the history
…anonymous

Co-authored-by: Nicola Soranzo <[email protected]>
  • Loading branch information
davelopez and nsoranzo committed Jun 10, 2024
1 parent a6b45e5 commit 1e98b9d
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 10 deletions.
11 changes: 3 additions & 8 deletions lib/galaxy/managers/jobs.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,7 @@
date,
datetime,
)
from typing import (
Dict,
Optional,
)
from typing import Dict

import sqlalchemy
from boltons.iterutils import remap
Expand Down Expand Up @@ -109,9 +106,7 @@ def __init__(self, app: StructuredApp):
self.app = app
self.dataset_manager = DatasetManager(app)

def index_query(
self, trans: ProvidesUserContext, payload: JobIndexQueryPayload
) -> Optional[sqlalchemy.engine.Result]:
def index_query(self, trans: ProvidesUserContext, payload: JobIndexQueryPayload) -> sqlalchemy.engine.Result:
"""The caller is responsible for security checks on the resulting job if
history_id, invocation_id, or implicit_collection_jobs_id is set.
Otherwise this will only return the user's jobs or all jobs if the requesting
Expand Down Expand Up @@ -220,7 +215,7 @@ def add_search_criteria(stmt):
elif trans.galaxy_session:
stmt = stmt.where(Job.session_id == trans.galaxy_session.id)
else:
return None
raise RequestParameterInvalidException("A session is required to list jobs for anonymous users")

stmt = build_and_apply_filters(stmt, payload.states, lambda s: model.Job.state == s)
stmt = build_and_apply_filters(stmt, payload.tool_ids, lambda t: model.Job.tool_id == t)
Expand Down
2 changes: 0 additions & 2 deletions lib/galaxy/webapps/galaxy/services/jobs.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,6 @@ def index(
)
jobs = self.job_manager.index_query(trans, payload)
out: List[Dict[str, Any]] = []
if jobs is None:
return out
for job in jobs.yield_per(model.YIELD_PER_ROWS):
# TODO: optimize if this crucial
if check_security_of_jobs and not security_check(trans, job.history, check_accessible=True):
Expand Down

0 comments on commit 1e98b9d

Please sign in to comment.