Module: PWN::Plugins::DAOMongo
- Defined in:
- lib/pwn/plugins/dao_mongo.rb
Overview
This plugin needs additional development, however, its intent is to be used as a data access object for interacting w/ MongoDB
Class Method Summary collapse
-
.authors ⇒ Object
- Author(s)
-
0day Inc.
-
.connect(opts = {}) ⇒ Object
- Supported Method Parameters
-
PWN::Plugins::DAOMongo.connect( host: ‘optional host or IP defaults to 127.0.0.1’, port: ‘optional port defaults to 27017’, database: ‘optional database name’ ).
-
.disconnect(opts = {}) ⇒ Object
- Supported Method Parameters
-
PWN::Plugins::DAOMongo.disconnect( mongo_conn: mongo_conn ).
-
.help ⇒ Object
Display Usage for this Module.
Class Method Details
.authors ⇒ Object
- Author(s)
-
0day Inc. <[email protected]>
73 74 75 76 77 |
# File 'lib/pwn/plugins/dao_mongo.rb', line 73 public_class_method def self. "AUTHOR(S): 0day Inc. <[email protected]> " end |
.connect(opts = {}) ⇒ Object
- Supported Method Parameters
-
PWN::Plugins::DAOMongo.connect(
host: 'optional host or IP defaults to 127.0.0.1', port: 'optional port defaults to 27017', database: 'optional database name'
)
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/pwn/plugins/dao_mongo.rb', line 17 public_class_method def self.connect(opts = {}) # Set host host = if opts[:host].nil? '127.0.0.1' # Defaults to localhost else opts[:host].to_s end # Set port port = if opts[:port].nil? 27_017 # Defaults to TCP port 27017 else opts[:port].to_i end database = opts[:database].to_s.scrub if opts[:database].nil? mongo_conn = Mongo::Client.new(["#{host}:#{port}"]) else mongo_conn = Mongo::Client.new(["#{host}:#{port}"], database: database) end validate_mongo_conn(mongo_conn: mongo_conn) mongo_conn rescue StandardError => e raise e end |
.disconnect(opts = {}) ⇒ Object
- Supported Method Parameters
-
PWN::Plugins::DAOMongo.disconnect(
mongo_conn: mongo_conn
)
51 52 53 54 55 56 57 |
# File 'lib/pwn/plugins/dao_mongo.rb', line 51 public_class_method def self.disconnect(opts = {}) mongo_conn = opts[:mongo_conn] validate_mongo_conn(mongo_conn: mongo_conn) mongo_conn.close rescue StandardError => e raise e end |
.help ⇒ Object
Display Usage for this Module
81 82 83 84 85 86 87 88 89 90 91 92 93 |
# File 'lib/pwn/plugins/dao_mongo.rb', line 81 public_class_method def self.help puts "USAGE: mongo_conn = #{self}.connect( host: 'optional host or IP defaults to 127.0.0.1', port: 'optional port defaults to 27017', database: 'optional database name' ) #{self}.disconnect(mongo_conn: mongo_conn) #{self}.authors " end |