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

DSL for rulesets #10

Open
boardfish opened this issue Aug 6, 2021 · 0 comments
Open

DSL for rulesets #10

boardfish opened this issue Aug 6, 2021 · 0 comments

Comments

@boardfish
Copy link
Owner

boardfish commented Aug 6, 2021

When writing up this feature request for Rails, I realized what the ruleset DSL could look like:

# config/ruleset/stripe/js.rb
# Ruleset for Stripe's JS library.
ruleset do
  connect_src 'https://api.stripe.com'
  frame_src 'https://js.stripe.com', 'https://hooks.stripe.com'
  script_src 'https://js.stripe.com'
  other_src 'https://example.com'
  # A common problem is that some rules are environment-specific.
  group :development do
    other_src 'https://example2.com'
  end
end

Remaining questions I have around this are:

  • What if an entire ruleset should only load in development?
  • What about lambda conditions for groups?

In order to implement this, we'll need to support the same declaration being fired multiple times as compounding on the same rule, so:

  other_src 'https://example.com'
  # A common problem is that some rules are environment-specific.
  group :development do
    other_src 'https://example2.com'
  end

would result in:

other-src: https://example.com, https://example2.com
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