Skip to content

fix: require authentication for log downloads - #232

Open
Jozsef Damokos (jozsefdamokos) wants to merge 3 commits into
trunkfrom
fix/migration-log-download-auth
Open

Jozsef Damokos (jozsefdamokos) wants to merge 3 commits into
trunkfrom
fix/migration-log-download-auth

Conversation

@jozsefdamokos

Copy link
Copy Markdown
Member
  • Require authentication and enforce the viewer privilege for log downloads.
  • Replace hidden form submissions on both history pages with authenticated downloads.

fixes: https://github.com/shopware/shopware-private/issues/458

@codecov

codecov Bot commented Oct 8, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 65.36%. Comparing base (6b55c1f) to head (813daf2).

Additional details and impacted files
@@            Coverage Diff            @@
##              trunk     #232   +/-   ##
=========================================
  Coverage     65.36%   65.36%           
  Complexity     4786     4786           
=========================================
  Files           654      654           
  Lines         21758    21758           
=========================================
  Hits          14222    14222           
  Misses         7536     7536           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

});
async onContextDownloadLogFile(runId: string): Promise<void> {
try {
const blob = await this.migrationApiService.downloadLogsOfRun(runId);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Downloading the logs of a run with 50k log entries fails for me after 30 s with "Failed downloading log file.", while the server was still streaming the file. Could the admin client's 30 s timeout cause this? The form post had no client-side limit, core sets it here:

https://github.com/shopware/shopware/blob/f7e74efb144b27a3595fb5ddadf234b671b2dfc8/src/Administration/Resources/app/administration/src/core/factory/http.factory.js#L46

Until that error appeared, nothing showed that the download was in progress.

Seed for a run with 50k log entries
SET @conn = UNHEX('0199c8a0000070008000000000000001');
SET @run = UNHEX('0199c8a0000070008000000000000002');

DELETE FROM swag_migration_logging WHERE run_id = @run;
DELETE FROM swag_migration_run WHERE id = @run;
DELETE FROM swag_migration_connection WHERE id = @conn;

INSERT INTO swag_migration_connection (id, name, profile_name, gateway_name, created_at)
VALUES (@conn, 'Log download repro', 'shopware55', 'local', NOW(3));

INSERT INTO swag_migration_run (id, connection_id, environment_information, step, created_at)
VALUES (@run, @conn, '{"sourceSystemName":"Shopware","sourceSystemVersion":"5.7.18"}', 'finished', NOW(3));

INSERT INTO swag_migration_logging (id, level, code, run_id, created_at, profile_name, gateway_name, user_fixable, entity_name, source_data)
SELECT UNHEX(REPLACE(UUID(), '-', '')), 'error', 'SWAG_MIGRATION__LOG_DOWNLOAD_REPRO', @run, NOW(3), 'shopware55', 'local', 0, 'customer',
    JSON_OBJECT(
        'column_1', 'some source value', 'column_2', 'some source value', 'column_3', 'some source value', 'column_4', 'some source value',
        'column_5', 'some source value', 'column_6', 'some source value', 'column_7', 'some source value', 'column_8', 'some source value',
        'column_9', 'some source value', 'column_10', 'some source value', 'column_11', 'some source value', 'column_12', 'some source value',
        'column_13', 'some source value', 'column_14', 'some source value', 'column_15', 'some source value', 'column_16', 'some source value',
        'column_17', 'some source value', 'column_18', 'some source value', 'column_19', 'some source value', 'column_20', 'some source value'
    )
FROM (SELECT 0 d UNION ALL SELECT 1 UNION ALL SELECT 2 UNION ALL SELECT 3 UNION ALL SELECT 4) a
CROSS JOIN (SELECT 0 d UNION ALL SELECT 1 UNION ALL SELECT 2 UNION ALL SELECT 3 UNION ALL SELECT 4 UNION ALL SELECT 5 UNION ALL SELECT 6 UNION ALL SELECT 7 UNION ALL SELECT 8 UNION ALL SELECT 9) b
CROSS JOIN (SELECT 0 d UNION ALL SELECT 1 UNION ALL SELECT 2 UNION ALL SELECT 3 UNION ALL SELECT 4 UNION ALL SELECT 5 UNION ALL SELECT 6 UNION ALL SELECT 7 UNION ALL SELECT 8 UNION ALL SELECT 9) c
CROSS JOIN (SELECT 0 d UNION ALL SELECT 1 UNION ALL SELECT 2 UNION ALL SELECT 3 UNION ALL SELECT 4 UNION ALL SELECT 5 UNION ALL SELECT 6 UNION ALL SELECT 7 UNION ALL SELECT 8 UNION ALL SELECT 9) e
CROSS JOIN (SELECT 0 d UNION ALL SELECT 1 UNION ALL SELECT 2 UNION ALL SELECT 3 UNION ALL SELECT 4 UNION ALL SELECT 5 UNION ALL SELECT 6 UNION ALL SELECT 7 UNION ALL SELECT 8 UNION ALL SELECT 9) f;

return new JsonResponse([
'total' => \count($cleanResult),
'items' => $cleanResult,
'downloadUrl' => $this->generateUrl(

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Do we still need this?

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.

2 participants