Module: Datadog::AppSec::Assets
- Defined in:
- lib/datadog/appsec/assets.rb
Overview
Helper methods to get vendored assets
Class Method Summary collapse
- .blocked(format: :html) ⇒ Object
- .dir ⇒ Object
- .filepath(filename) ⇒ Object
- .path ⇒ Object
- .read(filename, mode = 'rb') ⇒ Object
- .waf_processors ⇒ Object
- .waf_rules(kind = :recommended) ⇒ Object
- .waf_scanners ⇒ Object
Class Method Details
.blocked(format: :html) ⇒ Object
21 22 23 |
# File 'lib/datadog/appsec/assets.rb', line 21 def blocked(format: :html) (@blocked ||= {})[format] ||= read("blocked.#{format}") end |
.dir ⇒ Object
37 38 39 40 41 |
# File 'lib/datadog/appsec/assets.rb', line 37 def dir # Happens only if this file is evaluated standalone, which should not happen # Necessary to make type-checker happy with a non-nilable return value __dir__ || raise('Unexpected file eval') end |
.filepath(filename) ⇒ Object
29 30 31 |
# File 'lib/datadog/appsec/assets.rb', line 29 def filepath(filename) path.join(filename) end |
.path ⇒ Object
25 26 27 |
# File 'lib/datadog/appsec/assets.rb', line 25 def path Pathname.new(dir).join('assets') end |
.read(filename, mode = 'rb') ⇒ Object
33 34 35 |
# File 'lib/datadog/appsec/assets.rb', line 33 def read(filename, mode = 'rb') File.open(filepath(filename), mode) { |f| f.read || raise('Unexpected nil IO object') } end |
.waf_processors ⇒ Object
13 14 15 |
# File 'lib/datadog/appsec/assets.rb', line 13 def waf_processors read('waf_rules/processors.json') end |
.waf_rules(kind = :recommended) ⇒ Object
9 10 11 |
# File 'lib/datadog/appsec/assets.rb', line 9 def waf_rules(kind = :recommended) read("waf_rules/#{kind}.json") end |
.waf_scanners ⇒ Object
17 18 19 |
# File 'lib/datadog/appsec/assets.rb', line 17 def waf_scanners read('waf_rules/scanners.json') end |