Skip to content

fix(engine-jobs): scope job-log reads and clears to the current tenant (#6606) - #6678

Merged
delchev merged 4 commits into
eclipse-dirigible:masterfrom
NicoleNG18:fix/6606-job-logs-tenant-scoping
Aug 12, 2026
Merged

fix(engine-jobs): scope job-log reads and clears to the current tenant (#6606)#6678
delchev merged 4 commits into
eclipse-dirigible:masterfrom
NicoleNG18:fix/6606-job-logs-tenant-scoping

Conversation

@NicoleNG18

Copy link
Copy Markdown
Contributor

What & why

Fixes #6606.

With multi-tenancy enabled (the default), two job-log endpoints leaked and mutated data across tenants:

  • GET /services/jobs/logs/{job} returned execution logs for every tenant.
  • POST /services/jobs/clear/{job} deleted logs for every tenant.

Both JobLogService.findByJob(...) and JobLogService.deleteAllByJobName(...) built their query-by-example filter from a bare new JobLog(), so the JOBLOG_TENANT_ID column was never part of the probe. A user could see another tenant's logs (which may carry sensitive error messages) and clearing one job wiped the audit trail for all tenants at once.

The fix

The write path already stamps the tenant via the private createJobLog() helper (TenantContext, falling back to the @DefaultTenant when the context is uninitialized). The reads/deletes simply needed to reuse it as the query probe — which is exactly what the two // createJobLog() if we want only logs for the current tenant otherwise new JobLog() comments pointed at:

JobLog filter = createJobLog(); // was: new JobLog()

This mirrors the sibling #6607 TaskStateService fix. No by-id read/delete path exists for job logs, so no extra cross-tenant guard is needed here (unlike TaskState).

No frontend changes — the UI already displays tenant identifiers.

Tests

New JobLogServiceTest (HTTP-free, mocked TenantContext), 8 cases:

  • readsAndClearsAreTenantScoped — regression for Job execution logs are read and cleared across tenants #6606: a tenant neither reads nor clears another tenant's logs.
  • jobTriggeredPersistsTriggeredLog, logMethodsSetTheirStatus — log creation + status mapping (TRIGGRED/LOGGED/ERROR/WARN/INFO).
  • findByJobNormalizesLeadingSlash, deleteAllByJobNameNormalizesLeadingSlash — leading-slash normalization on both paths.
  • logsFallBackToDefaultTenantWhenContextUninitialized — default-tenant fallback.
  • jobFinishedPersistsFinishedLogAndUpdatesJob, jobFailedPersistsFailedLogAndUpdatesJob — the finish/fail paths flip the owning Job status.

Tests run: 8, Failures: 0, Errors: 0. mvn formatter:validate and the release-profile javadoc build both pass on engine-jobs.

🤖 Generated with Claude Code

NicoleNG18 and others added 4 commits August 12, 2026 19:41
eclipse-dirigible#6606)

GET /services/jobs/logs/{job} and POST /services/jobs/clear/{job} built their
query-by-example filter from a bare new JobLog(), so both read and delete
matched every tenant's rows: users saw other tenants' execution logs (which may
carry sensitive error messages) and clearing a job wiped the audit trail across
all tenants.

The write side already stamped the tenant via createJobLog(); reuse it as the
query probe (exactly what the two TODO comments suggested) so findByJob and
deleteAllByJobName filter by JOBLOG_TENANT_ID. Mirrors the eclipse-dirigible#6607 TaskState fix.

Add a tenant-isolation regression test (mocked TenantContext) asserting a tenant
neither reads nor clears another tenant's job logs.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
eclipse-dirigible#6606)

GET /services/jobs/logs/{job} and POST /services/jobs/clear/{job} built their
query-by-example filter from a bare new JobLog(), so both read and delete
matched every tenant's rows: users saw other tenants' execution logs (which may
carry sensitive error messages) and clearing a job wiped the audit trail across
all tenants.

The write side already stamped the tenant via createJobLog(); reuse it as the
query probe (exactly what the two TODO comments suggested) so findByJob and
deleteAllByJobName filter by JOBLOG_TENANT_ID. Mirrors the eclipse-dirigible#6607 TaskState fix.

Add JobLogServiceTest covering the tenant-isolation regression (mocked
TenantContext, a tenant neither reads nor clears another tenant's logs) plus the
log-creation methods and their statuses, leading-slash normalization on
find/delete, the default-tenant fallback when the context is uninitialized, and
the jobFinished/jobFailed paths.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…/NicoleNG18/dirigible into fix/6606-job-logs-tenant-scoping

# Conflicts:
#	components/engine/engine-jobs/src/test/java/org/eclipse/dirigible/components/jobs/service/JobLogServiceTest.java
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@delchev
delchev merged commit 4eb374e into eclipse-dirigible:master Aug 12, 2026
10 checks passed
@NicoleNG18
NicoleNG18 deleted the fix/6606-job-logs-tenant-scoping branch August 13, 2026 12:10
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.

Job execution logs are read and cleared across tenants

2 participants