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

CLI support for before_request #769

Open
asbjornu opened this issue Sep 22, 2022 · 0 comments
Open

CLI support for before_request #769

asbjornu opened this issue Sep 22, 2022 · 0 comments

Comments

@asbjornu
Copy link
Contributor

While #758 lays some great groundwork for a fresh new CLI, there is afaict. still no support for highly dynamic features such as HTMLProofer::Runner#before_request. I need before_request to add authorization headers for specific external URLs.

The reason I would like support for before_request in the CLI is because I would like to stop using HTMLProofer as a Ruby Gem and instead move to the HTMLProofer GitHub Action. Until the GitHub Action supports before_request, I can't move away from the Ruby Gem.

Perhaps a binding-scoped eval would provide enough security and flexibility? Bound to the request object, something like this should be possible to implement without sacrificing security too much, imho:

htmlproofer --before_request="options[:headers]['Authorization'] = 'Bearer ' + env['GITHUB_TOKEN'] if URI(base_url).host.match('github\.(com|io)$')"

I think env would have to be exposed, so it's probably better to create a new object that exposes the Request object alongside ENV and a few other useful things. In GitHub Actions, I suppose it's possible to interpolate GITHUB_TOKEN like so:

    - uses: chabad360/htmlproofer@master
        with:
          arguments: --before_request="options[:headers]['Authorization'] = 'Bearer ${{ secrets.GITHUB_TOKEN }}' if URI(base_url).host.match('github\.(com|io)$')"

Thoughts?

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

No branches or pull requests

1 participant