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
permalink .blocked(format: :html) ⇒ Object
[View source]
21 22 23 |
# File 'lib/datadog/appsec/assets.rb', line 21 def blocked(format: :html) (@blocked ||= {})[format] ||= read("blocked.#{format}") end |
permalink .dir ⇒ Object
[View source]
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 |
permalink .filepath(filename) ⇒ Object
[View source]
29 30 31 |
# File 'lib/datadog/appsec/assets.rb', line 29 def filepath(filename) path.join(filename) end |
permalink .path ⇒ Object
[View source]
25 26 27 |
# File 'lib/datadog/appsec/assets.rb', line 25 def path Pathname.new(dir).join('assets') end |
permalink .read(filename, mode = 'rb') ⇒ Object
[View source]
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 |
permalink .waf_processors ⇒ Object
[View source]
13 14 15 |
# File 'lib/datadog/appsec/assets.rb', line 13 def waf_processors read('waf_rules/processors.json') end |
permalink .waf_rules(kind = :recommended) ⇒ Object
[View source]
9 10 11 |
# File 'lib/datadog/appsec/assets.rb', line 9 def waf_rules(kind = :recommended) read("waf_rules/#{kind}.json") end |
permalink .waf_scanners ⇒ Object
[View source]
17 18 19 |
# File 'lib/datadog/appsec/assets.rb', line 17 def waf_scanners read('waf_rules/scanners.json') end |