Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add redirects to central security.txt #236

Merged
merged 3 commits into from
Oct 28, 2021
Merged

Conversation

OllieJC
Copy link
Member

@OllieJC OllieJC commented Oct 27, 2021

As per guidance on the gds-way about security.txt and vulnerability disclosure, this PR adds a couple of HTML files (and a _config.yml file enabling the .well-known directory) that redirect to the Cabinet Office central security.txt: https://github.com/alphagov/security.txt

You can see the redirects in action on GitHub Pages in my fork here:

Here's a testing site about security.txt files on GitHub Pages too: https://gh-pages-securitytxt.github.io/

source/_config.yml Outdated Show resolved Hide resolved
Copy link
Contributor

@jamietanna jamietanna left a comment

Choose a reason for hiding this comment

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

Thanks for contributing 🙌

Just need to validate this locally

Copy link
Contributor

@jamietanna jamietanna left a comment

Choose a reason for hiding this comment

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

Hey @OllieJC did you check this locally? I'm seeing that this isn't redirecting properly locally - whereas it does when you are deploying to GH pages.

Thinking about it the _config.yml is a Jekyll file, not a Middleman file, so could be that's why it's working on your site? But that can't be right, as some of the site has built successfully from Middleman code 🤔

@jamietanna
Copy link
Contributor

I'm currently looking at attempting to use redirect in Middleman, and spotted alphagov/tech-docs-gem#256

@jamietanna
Copy link
Contributor

Hey @OllieJC, as per alphagov/tech-docs-gem#256 (comment) I've managed to get this working through pure Middleman redirects - are you happy if I amend your branch with the changes?

Again, thanks for raising this 🙌

@OllieJC
Copy link
Member Author

OllieJC commented Oct 28, 2021

Hi @jamietanna, sure give it a go! I have a feeling it might not work when deployed to GitHub Pages because it is very basic hosting that doesn't allow mime type changes etc.
I found a good way to test the built files locally was running:

bundle exec middleman build
cd build/
python3 -m http.server

..and navigating to http://localhost:8000

@OllieJC
Copy link
Member Author

OllieJC commented Oct 28, 2021

Although, I think Middleman just creates those same HTML pages, right? If so, yeah it should work! I'll try it in my branch and recommit :)

@jamietanna
Copy link
Contributor

Thanks! Yeah I think I've narrowed it down to needing the below to cover both cases:

# required for local
page "/security.txt", content_type: 'text/html'
redirect 'security.txt', to: 'https://security-redirect.example.com/.well-known/security.txt'
# required for hosting
redirect 'security.txt.html', to: 'https://security-redirect.example.com/.well-known/security.txt'

@OllieJC
Copy link
Member Author

OllieJC commented Oct 28, 2021

So those security.txt.html files don't work with gh-pages, I've instead done:

redirect "security.txt/index.html", to: "https://security-redirect.example.com/.well-known/security.txt"
redirect ".well-known/security.txt/index.html", to: "https://security-redirect.example.com/.well-known/security.txt"

Which works locally and on gh-pages :)

Edit: changed ' to " for linting

config.rb Show resolved Hide resolved
Copy link
Contributor

@jamietanna jamietanna left a comment

Choose a reason for hiding this comment

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

Thanks for contributing, and sorry it was a bit all over the place 😁

@jamietanna jamietanna merged commit fec9158 into co-cddo:main Oct 28, 2021
@jamietanna
Copy link
Contributor

Just double checked and it's all working 🙌

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