Skip to content

Protect testcase task-log downloads#5214

Closed
M0nd0R wants to merge 7 commits intogoogle:masterfrom
M0nd0R:fix-task-log-access
Closed

Protect testcase task-log downloads#5214
M0nd0R wants to merge 7 commits intogoogle:masterfrom
M0nd0R:fix-task-log-access

Conversation

@M0nd0R
Copy link
Copy Markdown
Contributor

@M0nd0R M0nd0R commented Mar 21, 2026

This change protects /testcase-detail/task-log by enforcing testcase access checks before returning log content.

It also escapes task log filter values before building the Cloud Logging query so user-controlled task parameters cannot alter the intended filter.

Require testcase access before serving task logs and escape Cloud Logging filter values so task parameters cannot bypass the intended query constraints.
@M0nd0R M0nd0R requested a review from a team as a code owner March 21, 2026 01:59
@google-cla
Copy link
Copy Markdown

google-cla bot commented Mar 21, 2026

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@ViniciustCosta
Copy link
Copy Markdown
Collaborator

/gcbrun

M0nd0R and others added 4 commits March 28, 2026 08:07
Install pipenv into the activated virtualenv before bootstrap runs so the later python3.11 -m pipenv requirements export does not fail when pipenv is only available globally.
@M0nd0R
Copy link
Copy Markdown
Contributor Author

M0nd0R commented Apr 1, 2026

Updated this branch with the latest master and addressed the two concrete CI failures seen on the previous head:

  • basic tests: fixed the task-log handler follow-up formatting/lint issues
  • Kubernetes e2e: switched the bootstrap requirement export calls to use pipenv directly with stderr surfaced, and changed the e2e setup to pipenv sync --dev so CI uses the lockfile instead of relocking

I also verified locally that the task-log filter export commands now succeed, and I checked google/oss-fuzz for a matching source-side dependency on this handler path; there is no direct /testcase-detail/task-log or TaskLogHandler usage there that needs a paired patch.

The new GitHub Actions runs for head e21aa24d21f9df67c90b1748178afb2f77b55d3d are currently awaiting maintainer approval, and the Cloud Build checks will also need a collaborator to rerun /gcbrun for this updated head.

@decoNR
Copy link
Copy Markdown
Contributor

decoNR commented Apr 1, 2026

/gcbrun

M0nd0R and others added 2 commits April 1, 2026 23:20
Keep the task-log changes lint-clean, use pipenv's CLI directly for bootstrap requirement exports so the active interpreter can resolve it more reliably, and switch the Kubernetes e2e setup to sync from the lock file instead of relocking in CI.
@decoNR
Copy link
Copy Markdown
Contributor

decoNR commented Apr 14, 2026

/gcbrun

Copy link
Copy Markdown
Contributor

@decoNR decoNR left a comment

Choose a reason for hiding this comment

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

Hi @M0nd0R , thank you very much for your contribution! Could you please remove the changes that are not related to the task-log issue? Feel free to open another PR for those changes, but FYI, a team member will be working on fixing the CI soon.

@handler.get(handler.TEXT)
def get(self):
"""Serve the task log."""
testcase_id = helpers.cast(flask.request.args.get('testcase_id'), int,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This cast is unnecessary, as data_handler.get_testcase_by_id in check_access_and_get_testcase already handles it. Please remove it.

@M0nd0R
Copy link
Copy Markdown
Contributor Author

M0nd0R commented Apr 14, 2026

I split out the unrelated CI/bootstrap changes and opened a clean replacement PR with only the task-log handler, log-filter, and focused test changes: #5243. Thanks for the review and the note about the CI work on your side.

@M0nd0R
Copy link
Copy Markdown
Contributor Author

M0nd0R commented Apr 14, 2026

Closing this in favor of #5243, which contains only the task-log handler, log-filter, and focused test changes.

@M0nd0R M0nd0R closed this Apr 14, 2026
decoNR pushed a commit that referenced this pull request Apr 15, 2026
This PR is a clean replacement for #5214 with only the task-log fix and
its focused tests.

It adds testcase access checks before returning task logs and quotes
task log filter values before building the Cloud Logging query so
user-controlled task parameters cannot alter the intended filter
constraints.

Verification:
- targeted smoke check: TaskLogHandler now calls
access.check_access_and_get_testcase(123) before fetching logs
- targeted smoke check: injected filter content remains inside the
quoted task_id string literal
- local pytest selection reaches the new tests, but full execution is
blocked here because this environment does not have gcloud for the
datastore emulator
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