# frozen_string_literal: truerequire'rack/protection/version'require'rack'moduleRackmoduleProtectionautoload:AuthenticityToken,'rack/protection/authenticity_token'autoload:Base,'rack/protection/base'autoload:CookieTossing,'rack/protection/cookie_tossing'autoload:ContentSecurityPolicy,'rack/protection/content_security_policy'autoload:Encryptor,'rack/protection/encryptor'autoload:EncryptedCookie,'rack/protection/encrypted_cookie'autoload:EscapedParams,'rack/protection/escaped_params'autoload:FormToken,'rack/protection/form_token'autoload:FrameOptions,'rack/protection/frame_options'autoload:HttpOrigin,'rack/protection/http_origin'autoload:IPSpoofing,'rack/protection/ip_spoofing'autoload:JsonCsrf,'rack/protection/json_csrf'autoload:PathTraversal,'rack/protection/path_traversal'autoload:ReferrerPolicy,'rack/protection/referrer_policy'autoload:RemoteReferrer,'rack/protection/remote_referrer'autoload:RemoteToken,'rack/protection/remote_token'autoload:SessionHijacking,'rack/protection/session_hijacking'autoload:StrictTransport,'rack/protection/strict_transport'autoload:XSSHeader,'rack/protection/xss_header'defself.new(app,options={})# does not include: RemoteReferrer, AuthenticityToken and FormTokenexcept=Arrayoptions[:except]use_these=Arrayoptions[:use]ifoptions.fetch(:without_session,false)except+=%i[session_hijacking remote_token]endRack::Builder.newdo# Off by default, unless addeduse::Rack::Protection::AuthenticityToken,optionsifuse_these.include?:authenticity_tokenuse::Rack::Protection::ContentSecurityPolicy,optionsifuse_these.include?:content_security_policyuse::Rack::Protection::CookieTossing,optionsifuse_these.include?:cookie_tossinguse::Rack::Protection::EscapedParams,optionsifuse_these.include?:escaped_paramsuse::Rack::Protection::FormToken,optionsifuse_these.include?:form_tokenuse::Rack::Protection::ReferrerPolicy,optionsifuse_these.include?:referrer_policyuse::Rack::Protection::RemoteReferrer,optionsifuse_these.include?:remote_referreruse::Rack::Protection::StrictTransport,optionsifuse_these.include?:strict_transport# On by default, unless skippeduse::Rack::Protection::FrameOptions,optionsunlessexcept.include?:frame_optionsuse::Rack::Protection::HttpOrigin,optionsunlessexcept.include?:http_originuse::Rack::Protection::IPSpoofing,optionsunlessexcept.include?:ip_spoofinguse::Rack::Protection::JsonCsrf,optionsunlessexcept.include?:json_csrfuse::Rack::Protection::PathTraversal,optionsunlessexcept.include?:path_traversaluse::Rack::Protection::RemoteToken,optionsunlessexcept.include?:remote_tokenuse::Rack::Protection::SessionHijacking,optionsunlessexcept.include?:session_hijackinguse::Rack::Protection::XSSHeader,optionsunlessexcept.include?:xss_headerrunappend.to_appendendend