Class: EvilFaker::SourceBase

Inherits:
Object
  • Object
show all
Defined in:
lib/evil_faker/source_base.rb

Overview

Base class for per-source namespaces (e.g. Blns): exposes the entire corpus of one source, flattened across all its namespace/subtype files. Complements the category namespaces (Injection, Unicode, ...), which cut across sources -- this cuts across categories instead.

Direct Known Subclasses

Blns, Fuzzdb, IntruderPayloads, PayloadsAllTheThings

Constant Summary collapse

DATA_DIR =
File.expand_path("data/groups", __dir__)

Class Method Summary collapse

Class Method Details

.allObject



17
18
19
20
21
# File 'lib/evil_faker/source_base.rb', line 17

def all
  @all ||= Dir.glob(File.join(DATA_DIR, @source.to_s, "**", "*.txt")).sort.flat_map do |path|
    File.readlines(path, chomp: true)
  end
end

.sample(count = nil) ⇒ Object



23
24
25
26
27
# File 'lib/evil_faker/source_base.rb', line 23

def sample(count = nil)
  return all.sample(count) if count

  all.sample
end

.source(name) ⇒ Object

Declares this namespace's source, read from groups//**/*.txt.



13
14
15
# File 'lib/evil_faker/source_base.rb', line 13

def source(name)
  @source = name
end