Class: Synthra::Types::NaughtyString

Inherits:
Base
  • Object
show all
Defined in:
lib/synthra/types/naughty_string.rb

Overview

Naughty string type generator (stub implementation)

Constant Summary collapse

NAUGHTY_STRINGS =
{
  sql: ["'; DROP TABLE users; --", "' OR '1'='1", "admin'--"],
  xss: ["<script>alert('XSS')</script>", "<img src=x onerror=alert(1)>"],
  path: ["../../../etc/passwd", "..\\..\\..\\windows\\system32"],
  default: ["", "null", "undefined", "\x00", "\n\r"]
}.freeze

Instance Method Summary collapse

Instance Method Details

#generate_edge(rng, context, args) ⇒ Object



20
21
22
# File 'lib/synthra/types/naughty_string.rb', line 20

def generate_edge(rng, context, args)
  rng.sample(["", "\x00", "\n", "\r\n"])
end

#generate_invalid(rng, context, args) ⇒ Object



24
25
26
# File 'lib/synthra/types/naughty_string.rb', line 24

def generate_invalid(rng, context, args)
  rng.sample([nil, 123, [], {}])
end

#generate_random(rng, context, args) ⇒ Object



14
15
16
17
18
# File 'lib/synthra/types/naughty_string.rb', line 14

def generate_random(rng, context, args)
  category = (args[:category] || :default).to_sym
  strings = NAUGHTY_STRINGS[category] || NAUGHTY_STRINGS[:default]
  rng.sample(strings)
end