Top Level Namespace
Defined Under Namespace
Modules: OptParseValidator, PublicSuffix, Typhoeus, WPScan Classes: Numeric, OptionParser
Instance Method Summary collapse
-
#classify_slug(slug) ⇒ Symbol
Sanitize and classify a slug.
- #read_json_file(file) ⇒ Object
- #redirect_output_to_file(file) ⇒ Object
-
#yaml_safe_load(path) ⇒ Object
:nocov:.
Instance Method Details
#classify_slug(slug) ⇒ Symbol
Note:
As a class can not start with a digit or underscore, a D_ is put as a prefix in such case. Ugly but well :x Not only used to classify slugs though, but Dynamic Finder names as well
Sanitize and classify a slug
21 22 23 24 25 26 27 28 29 |
# File 'lib/wpscan/helper.rb', line 21 def classify_slug(slug) classified = slug.to_s.gsub(/[^a-z\d-]/i, '-').gsub(/-{1,}/, '_').camelize.to_s classified = "D_#{classified}" if /\d/.match?(classified[0]) # Special case for slugs with all non-latin characters. classified = "HexSlug_#{slug.bytes.map { |i| i.to_s(16) }.join}" if classified.empty? classified.to_sym end |
#read_json_file(file) ⇒ Object
9 10 11 12 13 |
# File 'lib/wpscan/helper.rb', line 9 def read_json_file(file) JSON.parse(File.read(file)) rescue StandardError => e raise "JSON parsing error in #{file} #{e}" end |
#redirect_output_to_file(file) ⇒ Object
4 5 6 7 |
# File 'lib/wpscan/helper.rb', line 4 def redirect_output_to_file(file) $stdout.reopen(file, 'w') $stdout.sync = true end |
#yaml_safe_load(path) ⇒ Object
:nocov:
9 10 11 12 13 14 15 |
# File 'lib/opt_parse_validator/config_files_loader_merger.rb', line 9 def yaml_safe_load(path) if Gem::Version.new(Psych::VERSION) >= Gem::Version.new('3.1.0.pre1') # Ruby 2.6 YAML.safe_load_file(path, permitted_classes: [Regexp]) || {} else YAML.safe_load_file(path, [Regexp]) || {} end end |