Class: Contrast::Agent::Reporting::Details::XssMatch
- Defined in:
- lib/contrast/agent/reporting/details/xss_match.rb
Overview
Matcher data for XSS rule.
Constant Summary collapse
- EVIDENCE_START =
/<script.*?>/i.cs__freeze
- EVIDENCE_END =
%r{</script.*?>}i.cs__freeze
Instance Attribute Summary collapse
Instance Method Summary collapse
- #empty? ⇒ Boolean
-
#initialize(xss_string = '') ⇒ XssMatch
constructor
A new instance of XssMatch.
- #to_controlled_hash ⇒ Object
Constructor Details
#initialize(xss_string = '') ⇒ XssMatch
Returns a new instance of XssMatch.
23 24 25 26 27 28 29 30 |
# File 'lib/contrast/agent/reporting/details/xss_match.rb', line 23 def initialize xss_string = '' return if xss_string.empty? @evidence_start = xss_string.index(EVIDENCE_START) @offset = (xss_string[0...@evidence_start] || '').length @evidence = xss_string[@evidence_start...xss_string.index(EVIDENCE_END)].gsub(EVIDENCE_START, ''). gsub(EVIDENCE_END, '') end |
Instance Attribute Details
#evidence ⇒ String
18 19 20 |
# File 'lib/contrast/agent/reporting/details/xss_match.rb', line 18 def evidence @evidence end |
#evidence_start ⇒ Integer
Returns in ms.
16 17 18 |
# File 'lib/contrast/agent/reporting/details/xss_match.rb', line 16 def evidence_start @evidence_start end |
#offset ⇒ Integer
20 21 22 |
# File 'lib/contrast/agent/reporting/details/xss_match.rb', line 20 def offset @offset end |
Instance Method Details
#empty? ⇒ Boolean
40 41 42 |
# File 'lib/contrast/agent/reporting/details/xss_match.rb', line 40 def empty? evidence_start.nil? || evidence.nil? || offset.nil? end |
#to_controlled_hash ⇒ Object
32 33 34 35 36 37 38 |
# File 'lib/contrast/agent/reporting/details/xss_match.rb', line 32 def to_controlled_hash { evidenceStart: evidence_start, evidence: evidence, offset: offset } end |