Skip to content

Fix X-Robots-Tag header valid values check - #40715

Merged
phil-davis merged 9 commits into
owncloud:masterfrom
rizlas:master
Apr 26, 2023
Merged

Fix X-Robots-Tag header valid values check#40715
phil-davis merged 9 commits into
owncloud:masterfrom
rizlas:master

Conversation

@rizlas

@rizlas rizlas commented Mar 30, 2023

Copy link
Copy Markdown
Contributor

Description

Currently the only accepted value for the robots tag is none but:

Related Issue

Motivation and Context

Allow all the possible values of x-robots-tag header and handle duplicate headers if OC is behind a proxy

How Has This Been Tested?

  • test environment: fully working environment with OC 10.12 (docker)
  • test case 1: x-robots-tag header values: 'none, noindex, nofollow, nosnippet, noarchive'
  • test case 2: x-robots-tag header values: 'none, nosnippet, noarchive'
  • test case 3: x-robots-tag header values: 'none'
  • test case 4: x-robots-tag header values: 'nofollow, nosnippet' [security warning raised]
  • test case 5: x-robots-tag header values: 'nosnippet, noarchive' [security warning raised]
  • test case 6: x-robots-tag header values: 'noindex, nofollow'
  • test case 7: x-robots-tag header values: '' [security warning raised]

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)

Checklist:

  • Code changes
  • Unit tests added
  • Acceptance tests added
  • Documentation ticket raised:
  • Changelog item, see TEMPLATE

@update-docs

update-docs Bot commented Mar 30, 2023

Copy link
Copy Markdown

Thanks for opening this pull request! The maintainers of this repository would appreciate it if you would create a changelog item based on your changes.

@CLAassistant

CLAassistant commented Mar 30, 2023

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@rizlas
rizlas marked this pull request as draft March 31, 2023 07:15
@rizlas
rizlas marked this pull request as ready for review March 31, 2023 08:24
Co-authored-by: ho4ho <42564859+ho4ho@users.noreply.github.com>
Comment thread changelog/unreleased/40715 Outdated
Comment thread core/js/setupchecks.js Outdated
@phil-davis

Copy link
Copy Markdown
Contributor

Reviewers - after review is all done, merge this and include in 10.12.1 or wait?

@phil-davis
phil-davis requested a review from IljaN April 2, 2023 09:21
Comment thread core/js/setupchecks.js Outdated
Comment thread core/js/setupchecks.js Outdated
@jvillafanez

Copy link
Copy Markdown
Member

You might also want to create a function in order to move all the checks there. The idea would be to add support for arrays, so you could use 'X-Robots-Tag': 'none' or 'X-Robots-Tag': ['none', 'noindex', 'nofollow'],.

Note that I'm just commenting about the code itself. I don't know if the code is right or wrong.

@jnweiger

jnweiger commented Apr 3, 2023

Copy link
Copy Markdown
Contributor

Reviewers - after review is all done, merge this and include in 10.12.1 or wait?

I'd say wait.
a) because 10.12.1 is about to be shipped. and
b) this one touches security - hardening related topics. We need deeper understanding why we recommend 'none'.
Reference:
https://doc.owncloud.com/server/next/admin_manual/configuration/server/harden_server.html#use-of-security-related-headers-on-the-web-server

My understanding here:
Both alternatives: a) none + optional extra values and also b) noindex + nofollow + optional extra values effectively mean 'none'. So it seems to be safe to me. We need to take care, that in the case b) we need to assert that both are present, and not just one of them. (or one of them combined with none).

@rizlas

rizlas commented Apr 15, 2023

Copy link
Copy Markdown
Contributor Author

@jvillafanez array is used only during validation. It is not a valid type input. Imho a separate function is not needed.

@jnweiger combinations of none, noindex, nofollow, nosnippet, noarchive are 32 (2^5) and they are:

''
none
noindex
nofollow
nosnippet
noarchive
none, noindex
none, nofollow
none, nosnippet
none, noarchive
noindex, nofollow
noindex, nosnippet
noindex, noarchive
nofollow, nosnippet
nofollow, noarchive
nosnippet, noarchive
none, noindex, nofollow
none, noindex, nosnippet
none, noindex, noarchive
none, nofollow, nosnippet
none, nofollow, noarchive
none, nosnippet, noarchive
noindex, nofollow, nosnippet
noindex, nofollow, noarchive
noindex, nosnippet, noarchive
nofollow, nosnippet, noarchive
none, noindex, nofollow, nosnippet
none, noindex, nofollow, noarchive
none, noindex, nosnippet, noarchive
none, nofollow, nosnippet, noarchive
noindex, nofollow, nosnippet, noarchive
none, noindex, nofollow, nosnippet, noarchive

With the current code these combinations are not valid:

''
noindex
nofollow
nosnippet
noarchive
noindex, nosnippet
noindex, noarchive
nofollow, nosnippet
nofollow, noarchive
nosnippet, noarchive
noindex, nosnippet, noarchive
nofollow, nosnippet, noarchive

On the contrary these are valid input:

none
none, noindex
none, nofollow
none, nosnippet
none, noarchive
noindex, nofollow
none, noindex, nofollow
none, noindex, nosnippet
none, noindex, noarchive
none, nofollow, nosnippet
none, nofollow, noarchive
none, nosnippet, noarchive
noindex, nofollow, nosnippet
noindex, nofollow, noarchive
none, noindex, nofollow, nosnippet
none, noindex, nofollow, noarchive
none, noindex, nosnippet, noarchive
none, nofollow, nosnippet, noarchive
noindex, nofollow, nosnippet, noarchive
none, noindex, nofollow, nosnippet, noarchive

@sonarqubecloud

Copy link
Copy Markdown

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
No Duplication information No Duplication information

@jvillafanez jvillafanez left a comment

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.

This should be fine assuming there won't be changes in the checks. I mean, the "X-Robots-Tag" header will be the only exception to the exact match of key - values we're checking.

@phil-davis

Copy link
Copy Markdown
Contributor

10.12.1 has been merged back to master, so we can merge new stuff like this.

@phil-davis
phil-davis merged commit 7297fdd into owncloud:master Apr 26, 2023
@rizlas

rizlas commented Apr 26, 2023

Copy link
Copy Markdown
Contributor Author

Thank you

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.

X-Robots-Tag security check

5 participants