Skip to content

Conversation

perlpunk
Copy link
Contributor

This reverts #6793, #6759 (exceptions from redirection).
Then I amend #6804 to only keep the log_url helper, and in the next commit I only use it for files generated by the test, as files generated by openQA itself should be safe.
In the last commit I remove the redirection and replace it by serving the files as attachments if necessary.

Issue: https://progress.opensuse.org/issues/189888

Probably some tests will fail

my $file_security_policy = $self->app->config->{global}->{file_security_policy};
my $allow_insecure = $file_security_policy eq 'insecure-browsing';
if ($file_security_policy =~ m/^domain:/ and my $file_domain = $self->app->config->{global}->{file_domain}) {
$allow_insecure = 1 if $file_domain eq $self->req->url->to_abs->host_port;
Copy link
Contributor

Choose a reason for hiding this comment

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

maybe you can skip some assignments here. And use directly $headers->content_disposition("attachment; filename=$filename;").
To me it looks like

if ($file_security_policy =~ m/^domain:/ and my $file_domain = $self->app->config->{global}->{file_domain}) {
    if $file_domain eq $self->req->url->to_abs->host_port || $filetype !~ m/(html|svg)/) && $ext ne 'iso' {
        $headers->content_disposition("attachment; filename=$filename;");}}```

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't see how that helps.
First, the logic seems to be reversed (if the current domain is the file domain, serve as attachment -> no, it should not be served as an attachment in that case).
Second, why do all this and then repeat calling $headers->content_disposition(...) below? Note that this needs to be called even if if (my $filetype = $self->app->types->type($ext)) is false.
Give me a full patch instead so I can better see what you mean. As it is, it doesn't make sense to me.

perlpunk and others added 5 commits October 21, 2025 12:01
Replace the `url_for` with helper functions which return the domain
name whenever this is applicable based on the setting.

- Link to domain for download assets like iso and `Uploaded
logs` (includes also vars.json)
- Link to domain for the video replay
- No change in the redirection, assuming that this is out of scope
here, and that in general it stays despite the direct link in the
href.

issue: https://progress.opensuse.org/issues/189888
Signed-off-by: Ioannis Bonatakis <[email protected]>

Amended by: [email protected]

Remove changes in templates && tests, see following commit
Serve as attachment when:
* file_security_policy=domain:... and
  * file is requested under normal domain
  * file is html or svg

Remove all redirection handling, as we have direct links to the file domain
@codecov
Copy link

codecov bot commented Oct 21, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 99.26%. Comparing base (ad78558) to head (f46916c).
⚠️ Report is 2 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #6810   +/-   ##
=======================================
  Coverage   99.26%   99.26%           
=======================================
  Files         402      402           
  Lines       41373    41394   +21     
=======================================
+ Hits        41067    41088   +21     
  Misses        306      306           

☔ View full report in Codecov by Sentry.
📢 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.

to avoid too much repetition
@perlpunk
Copy link
Contributor Author

I added a couple of tests for all three file_security_policy settings.

@perlpunk perlpunk marked this pull request as ready for review October 21, 2025 15:58
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