Sha256: 58f0057697ed4ab144e5093ce8fa92993b67fc458e43c4e3943e647b9ee65afe

Contents?: true

Size: 1.24 KB

Versions: 721

Compression:

Stored size: 1.24 KB

Contents

# frozen_string_literal: true

require 'jsonpath'

module PWN
  module Plugins
    # This plugin is for leveraging XPath-like searching capabilities for JSON data structures
    module JSONPathify
      # Supported Method Parameters::
      # PWN::Plugins::JSONPathify.search_key(
      #   json_data_struct: "required JSON data structure",
      #   key: "required key to find in JSON data structure. returns key values"
      # )

      public_class_method def self.search_key(opts = {})
        key = opts[:key]
        json_data_struct = opts[:json_data_struct]

        json_path = JsonPath.new("$..#{key}")
        json_path.on(json_data_struct)
      rescue StandardError => e
        raise e
      end

      # Author(s):: 0day Inc. <request.pentest@0dayinc.com>

      public_class_method def self.authors
        "AUTHOR(S):
          0day Inc. <request.pentest@0dayinc.com>
        "
      end

      # Display Usage for this Module

      public_class_method def self.help
        puts %{USAGE:
          json_path_arr = #{self}.search_key(
            json_data_struct: "required JSON data structure",
            key: "required key to find in JSON data structure. returns key values"
          )
          #{self}.authors
        }
      end
    end
  end
end

Version data entries

721 entries across 721 versions & 1 rubygems

Version Path
pwn-0.5.104 lib/pwn/plugins/json_pathify.rb
pwn-0.5.103 lib/pwn/plugins/json_pathify.rb
pwn-0.5.102 lib/pwn/plugins/json_pathify.rb
pwn-0.5.101 lib/pwn/plugins/json_pathify.rb
pwn-0.5.100 lib/pwn/plugins/json_pathify.rb
pwn-0.5.99 lib/pwn/plugins/json_pathify.rb
pwn-0.5.98 lib/pwn/plugins/json_pathify.rb
pwn-0.5.97 lib/pwn/plugins/json_pathify.rb
pwn-0.5.96 lib/pwn/plugins/json_pathify.rb
pwn-0.5.95 lib/pwn/plugins/json_pathify.rb
pwn-0.5.94 lib/pwn/plugins/json_pathify.rb
pwn-0.5.93 lib/pwn/plugins/json_pathify.rb
pwn-0.5.92 lib/pwn/plugins/json_pathify.rb
pwn-0.5.91 lib/pwn/plugins/json_pathify.rb
pwn-0.5.90 lib/pwn/plugins/json_pathify.rb
pwn-0.5.89 lib/pwn/plugins/json_pathify.rb
pwn-0.5.88 lib/pwn/plugins/json_pathify.rb
pwn-0.5.87 lib/pwn/plugins/json_pathify.rb
pwn-0.5.86 lib/pwn/plugins/json_pathify.rb
pwn-0.5.85 lib/pwn/plugins/json_pathify.rb