id
int32
0
24.9k
repo
stringlengths
5
58
path
stringlengths
9
168
func_name
stringlengths
9
130
original_string
stringlengths
66
10.5k
language
stringclasses
1 value
code
stringlengths
66
10.5k
code_tokens
list
docstring
stringlengths
8
16k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
94
266
18,900
rapid7/nexpose-client
lib/nexpose/device.rb
Nexpose.Connection.list_device_vulns
def list_device_vulns(dev_id) parameters = { 'devid' => dev_id, 'table-id' => 'vulnerability-listing' } json = DataTable._get_json_table(self, '/data/vulnerability/asset-vulnerabilities', parameters) jso...
ruby
def list_device_vulns(dev_id) parameters = { 'devid' => dev_id, 'table-id' => 'vulnerability-listing' } json = DataTable._get_json_table(self, '/data/vulnerability/asset-vulnerabilities', parameters) jso...
[ "def", "list_device_vulns", "(", "dev_id", ")", "parameters", "=", "{", "'devid'", "=>", "dev_id", ",", "'table-id'", "=>", "'vulnerability-listing'", "}", "json", "=", "DataTable", ".", "_get_json_table", "(", "self", ",", "'/data/vulnerability/asset-vulnerabilities'...
List the vulnerability findings for a given device ID. @param [Fixnum] dev_id Unique identifier of a device (asset). @return [Array[VulnFinding]] List of vulnerability findings.
[ "List", "the", "vulnerability", "findings", "for", "a", "given", "device", "ID", "." ]
933fc8c0c85ba11d3e17db1d7f4542816f400d71
https://github.com/rapid7/nexpose-client/blob/933fc8c0c85ba11d3e17db1d7f4542816f400d71/lib/nexpose/device.rb#L85-L92
18,901
rapid7/nexpose-client
lib/nexpose/device.rb
Nexpose.Connection.incomplete_assets
def incomplete_assets(scan_id) uri = "/data/asset/scan/#{scan_id}/incomplete-assets" AJAX.preserving_preference(self, 'scan-incomplete-assets') do data = DataTable._get_json_table(self, uri, {}, 500, nil, false) data.map(&IncompleteAsset.method(:parse_json)) end end
ruby
def incomplete_assets(scan_id) uri = "/data/asset/scan/#{scan_id}/incomplete-assets" AJAX.preserving_preference(self, 'scan-incomplete-assets') do data = DataTable._get_json_table(self, uri, {}, 500, nil, false) data.map(&IncompleteAsset.method(:parse_json)) end end
[ "def", "incomplete_assets", "(", "scan_id", ")", "uri", "=", "\"/data/asset/scan/#{scan_id}/incomplete-assets\"", "AJAX", ".", "preserving_preference", "(", "self", ",", "'scan-incomplete-assets'", ")", "do", "data", "=", "DataTable", ".", "_get_json_table", "(", "self"...
Retrieve a list of assets which are incomplete in a given scan. If called during a scan, this method returns currently incomplete assets which may be in progress. @param [Fixnum] scan_id Unique identifier of a scan. @return [Array[IncompleteAsset]] List of incomplete assets.
[ "Retrieve", "a", "list", "of", "assets", "which", "are", "incomplete", "in", "a", "given", "scan", ".", "If", "called", "during", "a", "scan", "this", "method", "returns", "currently", "incomplete", "assets", "which", "may", "be", "in", "progress", "." ]
933fc8c0c85ba11d3e17db1d7f4542816f400d71
https://github.com/rapid7/nexpose-client/blob/933fc8c0c85ba11d3e17db1d7f4542816f400d71/lib/nexpose/device.rb#L121-L127
18,902
rapid7/nexpose-client
lib/nexpose/alert.rb
Nexpose.Alert.delete
def delete(nsc, site_id) uri = "/api/2.1/site_configurations/#{site_id}/alerts/#{id}" AJAX.delete(nsc, uri, AJAX::CONTENT_TYPE::JSON) end
ruby
def delete(nsc, site_id) uri = "/api/2.1/site_configurations/#{site_id}/alerts/#{id}" AJAX.delete(nsc, uri, AJAX::CONTENT_TYPE::JSON) end
[ "def", "delete", "(", "nsc", ",", "site_id", ")", "uri", "=", "\"/api/2.1/site_configurations/#{site_id}/alerts/#{id}\"", "AJAX", ".", "delete", "(", "nsc", ",", "uri", ",", "AJAX", "::", "CONTENT_TYPE", "::", "JSON", ")", "end" ]
delete an alert from the given site
[ "delete", "an", "alert", "from", "the", "given", "site" ]
933fc8c0c85ba11d3e17db1d7f4542816f400d71
https://github.com/rapid7/nexpose-client/blob/933fc8c0c85ba11d3e17db1d7f4542816f400d71/lib/nexpose/alert.rb#L114-L117
18,903
rapid7/nexpose-client
lib/nexpose/alert.rb
Nexpose.Alert.save
def save(nsc, site_id) validate uri = "/api/2.1/site_configurations/#{site_id}/alerts" id = AJAX.put(nsc, uri, self.to_json, AJAX::CONTENT_TYPE::JSON) @id = id.to_i end
ruby
def save(nsc, site_id) validate uri = "/api/2.1/site_configurations/#{site_id}/alerts" id = AJAX.put(nsc, uri, self.to_json, AJAX::CONTENT_TYPE::JSON) @id = id.to_i end
[ "def", "save", "(", "nsc", ",", "site_id", ")", "validate", "uri", "=", "\"/api/2.1/site_configurations/#{site_id}/alerts\"", "id", "=", "AJAX", ".", "put", "(", "nsc", ",", "uri", ",", "self", ".", "to_json", ",", "AJAX", "::", "CONTENT_TYPE", "::", "JSON",...
save an alert for a given site
[ "save", "an", "alert", "for", "a", "given", "site" ]
933fc8c0c85ba11d3e17db1d7f4542816f400d71
https://github.com/rapid7/nexpose-client/blob/933fc8c0c85ba11d3e17db1d7f4542816f400d71/lib/nexpose/alert.rb#L120-L125
18,904
rapid7/nexpose-client
lib/nexpose/multi_tenant_user.rb
Nexpose.Connection.list_silo_users
def list_silo_users r = execute(make_xml('MultiTenantUserListingRequest'), '1.2') arr = [] if r.success r.res.elements.each('MultiTenantUserListingResponse/MultiTenantUserSummaries/MultiTenantUserSummary') do |user| arr << MultiTenantUserSummary.parse(user) end end ...
ruby
def list_silo_users r = execute(make_xml('MultiTenantUserListingRequest'), '1.2') arr = [] if r.success r.res.elements.each('MultiTenantUserListingResponse/MultiTenantUserSummaries/MultiTenantUserSummary') do |user| arr << MultiTenantUserSummary.parse(user) end end ...
[ "def", "list_silo_users", "r", "=", "execute", "(", "make_xml", "(", "'MultiTenantUserListingRequest'", ")", ",", "'1.2'", ")", "arr", "=", "[", "]", "if", "r", ".", "success", "r", ".", "res", ".", "elements", ".", "each", "(", "'MultiTenantUserListingRespo...
Retrieve a list of all users the user is authorized to view or manage. @return [Array[MultiTenantUserSummary]] Array of MultiTenantUserSummary objects.
[ "Retrieve", "a", "list", "of", "all", "users", "the", "user", "is", "authorized", "to", "view", "or", "manage", "." ]
933fc8c0c85ba11d3e17db1d7f4542816f400d71
https://github.com/rapid7/nexpose-client/blob/933fc8c0c85ba11d3e17db1d7f4542816f400d71/lib/nexpose/multi_tenant_user.rb#L10-L19
18,905
rapid7/nexpose-client
lib/nexpose/engine.rb
Nexpose.Connection.delete_engine
def delete_engine(engine_id, scope = 'silo') xml = make_xml('EngineDeleteRequest', { 'engine-id' => engine_id, 'scope' => scope }) response = execute(xml, '1.2') response.success end
ruby
def delete_engine(engine_id, scope = 'silo') xml = make_xml('EngineDeleteRequest', { 'engine-id' => engine_id, 'scope' => scope }) response = execute(xml, '1.2') response.success end
[ "def", "delete_engine", "(", "engine_id", ",", "scope", "=", "'silo'", ")", "xml", "=", "make_xml", "(", "'EngineDeleteRequest'", ",", "{", "'engine-id'", "=>", "engine_id", ",", "'scope'", "=>", "scope", "}", ")", "response", "=", "execute", "(", "xml", "...
Removes a scan engine from the list of available engines. @param [Fixnum] engine_id Unique ID of an existing engine to remove. @param [String] scope Whether the engine is global or silo scoped. @return [Boolean] true if engine successfully deleted.
[ "Removes", "a", "scan", "engine", "from", "the", "list", "of", "available", "engines", "." ]
933fc8c0c85ba11d3e17db1d7f4542816f400d71
https://github.com/rapid7/nexpose-client/blob/933fc8c0c85ba11d3e17db1d7f4542816f400d71/lib/nexpose/engine.rb#L12-L16
18,906
rapid7/nexpose-client
lib/nexpose/engine.rb
Nexpose.Connection.engine_activity
def engine_activity(engine_id) xml = make_xml('EngineActivityRequest', { 'engine-id' => engine_id }) r = execute(xml) arr = [] if r.success r.res.elements.each('//ScanSummary') do |scan_event| arr << ScanSummary.parse(scan_event) end end arr end
ruby
def engine_activity(engine_id) xml = make_xml('EngineActivityRequest', { 'engine-id' => engine_id }) r = execute(xml) arr = [] if r.success r.res.elements.each('//ScanSummary') do |scan_event| arr << ScanSummary.parse(scan_event) end end arr end
[ "def", "engine_activity", "(", "engine_id", ")", "xml", "=", "make_xml", "(", "'EngineActivityRequest'", ",", "{", "'engine-id'", "=>", "engine_id", "}", ")", "r", "=", "execute", "(", "xml", ")", "arr", "=", "[", "]", "if", "r", ".", "success", "r", "...
Provide a list of current scan activities for a specific Scan Engine. @return [Array[ScanSummary]] Array of ScanSummary objects associated with each active scan on the engine.
[ "Provide", "a", "list", "of", "current", "scan", "activities", "for", "a", "specific", "Scan", "Engine", "." ]
933fc8c0c85ba11d3e17db1d7f4542816f400d71
https://github.com/rapid7/nexpose-client/blob/933fc8c0c85ba11d3e17db1d7f4542816f400d71/lib/nexpose/engine.rb#L55-L65
18,907
rapid7/nexpose-client
lib/nexpose/engine.rb
Nexpose.Connection.list_engines
def list_engines response = execute(make_xml('EngineListingRequest')) arr = [] if response.success response.res.elements.each('//EngineSummary') do |engine| arr << EngineSummary.new(engine.attributes['id'].to_i, engine.attributes['name'], ...
ruby
def list_engines response = execute(make_xml('EngineListingRequest')) arr = [] if response.success response.res.elements.each('//EngineSummary') do |engine| arr << EngineSummary.new(engine.attributes['id'].to_i, engine.attributes['name'], ...
[ "def", "list_engines", "response", "=", "execute", "(", "make_xml", "(", "'EngineListingRequest'", ")", ")", "arr", "=", "[", "]", "if", "response", ".", "success", "response", ".", "res", ".", "elements", ".", "each", "(", "'//EngineSummary'", ")", "do", ...
Retrieve a list of all Scan Engines managed by the Security Console. @return [Array[EngineSummary]] Array of EngineSummary objects associated with each engine associated with this security console.
[ "Retrieve", "a", "list", "of", "all", "Scan", "Engines", "managed", "by", "the", "Security", "Console", "." ]
933fc8c0c85ba11d3e17db1d7f4542816f400d71
https://github.com/rapid7/nexpose-client/blob/933fc8c0c85ba11d3e17db1d7f4542816f400d71/lib/nexpose/engine.rb#L72-L86
18,908
rapid7/nexpose-client
lib/nexpose/engine.rb
Nexpose.Engine.save
def save(connection) xml = '<EngineSaveRequest session-id="' + connection.session_id + '">' xml << to_xml xml << '</EngineSaveRequest>' r = connection.execute(xml, '1.2') if r.success r.res.elements.each('EngineSaveResponse/EngineConfig') do |v| return @id = v.attributes...
ruby
def save(connection) xml = '<EngineSaveRequest session-id="' + connection.session_id + '">' xml << to_xml xml << '</EngineSaveRequest>' r = connection.execute(xml, '1.2') if r.success r.res.elements.each('EngineSaveResponse/EngineConfig') do |v| return @id = v.attributes...
[ "def", "save", "(", "connection", ")", "xml", "=", "'<EngineSaveRequest session-id=\"'", "+", "connection", ".", "session_id", "+", "'\">'", "xml", "<<", "to_xml", "xml", "<<", "'</EngineSaveRequest>'", "r", "=", "connection", ".", "execute", "(", "xml", ",", ...
Save this engine configuration to the security console. @param [Connection] connection Connection to console where site exists. @return [Fixnum] ID assigned to the scan engine.
[ "Save", "this", "engine", "configuration", "to", "the", "security", "console", "." ]
933fc8c0c85ba11d3e17db1d7f4542816f400d71
https://github.com/rapid7/nexpose-client/blob/933fc8c0c85ba11d3e17db1d7f4542816f400d71/lib/nexpose/engine.rb#L210-L221
18,909
rapid7/nexpose-client
lib/nexpose/vuln_def.rb
Nexpose.Connection.all_vulns
def all_vulns uri = '/api/2.0/vulnerability_definitions' resp = AJAX.get(self, uri, AJAX::CONTENT_TYPE::JSON, per_page: 2_147_483_647) json = JSON.parse(resp, symbolize_names: true) json[:resources].map { |e| VulnerabilityDefinition.new.object_from_hash(self, e) } end
ruby
def all_vulns uri = '/api/2.0/vulnerability_definitions' resp = AJAX.get(self, uri, AJAX::CONTENT_TYPE::JSON, per_page: 2_147_483_647) json = JSON.parse(resp, symbolize_names: true) json[:resources].map { |e| VulnerabilityDefinition.new.object_from_hash(self, e) } end
[ "def", "all_vulns", "uri", "=", "'/api/2.0/vulnerability_definitions'", "resp", "=", "AJAX", ".", "get", "(", "self", ",", "uri", ",", "AJAX", "::", "CONTENT_TYPE", "::", "JSON", ",", "per_page", ":", "2_147_483_647", ")", "json", "=", "JSON", ".", "parse", ...
Retrieve all vulnerability definitions currently in a Nexpose console. Note, this can easily take 30 seconds to complete and will load over 55,000 vulnerability definitions. @return [Array[VulnerabilityDefinition]] Collection of vulnerability definitions.
[ "Retrieve", "all", "vulnerability", "definitions", "currently", "in", "a", "Nexpose", "console", "." ]
933fc8c0c85ba11d3e17db1d7f4542816f400d71
https://github.com/rapid7/nexpose-client/blob/933fc8c0c85ba11d3e17db1d7f4542816f400d71/lib/nexpose/vuln_def.rb#L10-L15
18,910
rapid7/nexpose-client
lib/nexpose/vuln_def.rb
Nexpose.Connection.find_vulns_by_cve
def find_vulns_by_cve(cve) uri = '/api/2.0/vulnerability_definitions' resp = AJAX.get(self, uri, AJAX::CONTENT_TYPE::JSON, cve: cve) json = JSON.parse(resp, symbolize_names: true) json[:resources].map { |e| VulnerabilityDefinition.new.object_from_hash(self, e) } end
ruby
def find_vulns_by_cve(cve) uri = '/api/2.0/vulnerability_definitions' resp = AJAX.get(self, uri, AJAX::CONTENT_TYPE::JSON, cve: cve) json = JSON.parse(resp, symbolize_names: true) json[:resources].map { |e| VulnerabilityDefinition.new.object_from_hash(self, e) } end
[ "def", "find_vulns_by_cve", "(", "cve", ")", "uri", "=", "'/api/2.0/vulnerability_definitions'", "resp", "=", "AJAX", ".", "get", "(", "self", ",", "uri", ",", "AJAX", "::", "CONTENT_TYPE", "::", "JSON", ",", "cve", ":", "cve", ")", "json", "=", "JSON", ...
Search for any vulnerability definitions which refer to a given CVE. @param [String] cve A valid CVE. @return [Array[VulnerabilityDefinition]] A list of vuln definitions which check the CVE.
[ "Search", "for", "any", "vulnerability", "definitions", "which", "refer", "to", "a", "given", "CVE", "." ]
933fc8c0c85ba11d3e17db1d7f4542816f400d71
https://github.com/rapid7/nexpose-client/blob/933fc8c0c85ba11d3e17db1d7f4542816f400d71/lib/nexpose/vuln_def.rb#L22-L27
18,911
rapid7/nexpose-client
lib/nexpose/vuln_def.rb
Nexpose.Connection.find_vulns_by_ref
def find_vulns_by_ref(source, id) uri = '/api/2.0/vulnerability_definitions' resp = AJAX.get(self, uri, AJAX::CONTENT_TYPE::JSON, source: source, id: id) json = JSON.parse(resp, symbolize_names: true) json[:resources].map { |e| V...
ruby
def find_vulns_by_ref(source, id) uri = '/api/2.0/vulnerability_definitions' resp = AJAX.get(self, uri, AJAX::CONTENT_TYPE::JSON, source: source, id: id) json = JSON.parse(resp, symbolize_names: true) json[:resources].map { |e| V...
[ "def", "find_vulns_by_ref", "(", "source", ",", "id", ")", "uri", "=", "'/api/2.0/vulnerability_definitions'", "resp", "=", "AJAX", ".", "get", "(", "self", ",", "uri", ",", "AJAX", "::", "CONTENT_TYPE", "::", "JSON", ",", "source", ":", "source", ",", "id...
Search for any vulnerability definitions which refer to a given reference ID. Examples: find_vulns_by_ref('oval', 'OVAL10476') find_vulns_by_ref('bid', 35067) find_vulns_by_ref('secunia', 35188) @param [String] source External vulnerability reference source. @param [String] id Unique vulnerability refere...
[ "Search", "for", "any", "vulnerability", "definitions", "which", "refer", "to", "a", "given", "reference", "ID", "." ]
933fc8c0c85ba11d3e17db1d7f4542816f400d71
https://github.com/rapid7/nexpose-client/blob/933fc8c0c85ba11d3e17db1d7f4542816f400d71/lib/nexpose/vuln_def.rb#L42-L50
18,912
rapid7/nexpose-client
lib/nexpose/vuln_def.rb
Nexpose.Connection.find_vulns_by_title
def find_vulns_by_title(title, all_words = true) uri = '/api/2.0/vulnerability_definitions' params = { title: title, all_words: all_words } resp = AJAX.get(self, uri, AJAX::CONTENT_TYPE::JSON, params) json = JSON.parse(resp, symbolize_names: true) json[:resources].map { |e| Vulnerab...
ruby
def find_vulns_by_title(title, all_words = true) uri = '/api/2.0/vulnerability_definitions' params = { title: title, all_words: all_words } resp = AJAX.get(self, uri, AJAX::CONTENT_TYPE::JSON, params) json = JSON.parse(resp, symbolize_names: true) json[:resources].map { |e| Vulnerab...
[ "def", "find_vulns_by_title", "(", "title", ",", "all_words", "=", "true", ")", "uri", "=", "'/api/2.0/vulnerability_definitions'", "params", "=", "{", "title", ":", "title", ",", "all_words", ":", "all_words", "}", "resp", "=", "AJAX", ".", "get", "(", "sel...
Search for any vulnerability definitions which refer to a given title. Note: This method will return a maximum of 500 results. If the search yields a high number of results, consider add more specific words to the title. @param [String] title A (partial) title to search for. @param [Boolean] all_words Whether to...
[ "Search", "for", "any", "vulnerability", "definitions", "which", "refer", "to", "a", "given", "title", "." ]
933fc8c0c85ba11d3e17db1d7f4542816f400d71
https://github.com/rapid7/nexpose-client/blob/933fc8c0c85ba11d3e17db1d7f4542816f400d71/lib/nexpose/vuln_def.rb#L64-L70
18,913
rapid7/nexpose-client
lib/nexpose/tag.rb
Nexpose.Connection.tags
def tags tag_summary = [] tags = JSON.parse(AJAX.get(self, '/api/2.0/tags', AJAX::CONTENT_TYPE::JSON, { per_page: 2_147_483_647 })) tags['resources'].each do |json| tag_summary << TagSummary.parse(json) end tag_summary end
ruby
def tags tag_summary = [] tags = JSON.parse(AJAX.get(self, '/api/2.0/tags', AJAX::CONTENT_TYPE::JSON, { per_page: 2_147_483_647 })) tags['resources'].each do |json| tag_summary << TagSummary.parse(json) end tag_summary end
[ "def", "tags", "tag_summary", "=", "[", "]", "tags", "=", "JSON", ".", "parse", "(", "AJAX", ".", "get", "(", "self", ",", "'/api/2.0/tags'", ",", "AJAX", "::", "CONTENT_TYPE", "::", "JSON", ",", "{", "per_page", ":", "2_147_483_647", "}", ")", ")", ...
Lists all tags @return [Array[TagSummary]] List of current tags.
[ "Lists", "all", "tags" ]
933fc8c0c85ba11d3e17db1d7f4542816f400d71
https://github.com/rapid7/nexpose-client/blob/933fc8c0c85ba11d3e17db1d7f4542816f400d71/lib/nexpose/tag.rb#L9-L16
18,914
rapid7/nexpose-client
lib/nexpose/tag.rb
Nexpose.Connection.asset_tags
def asset_tags(asset_id) tag_summary = [] asset_tag = JSON.parse(AJAX.get(self, "/api/2.0/assets/#{asset_id}/tags", AJAX::CONTENT_TYPE::JSON, { per_page: 2_147_483_647 })) asset_tag['resources'].select { |r| r['asset_ids'].find { |i| i == asset_id } }.each do |json| tag_summary << TagSummary...
ruby
def asset_tags(asset_id) tag_summary = [] asset_tag = JSON.parse(AJAX.get(self, "/api/2.0/assets/#{asset_id}/tags", AJAX::CONTENT_TYPE::JSON, { per_page: 2_147_483_647 })) asset_tag['resources'].select { |r| r['asset_ids'].find { |i| i == asset_id } }.each do |json| tag_summary << TagSummary...
[ "def", "asset_tags", "(", "asset_id", ")", "tag_summary", "=", "[", "]", "asset_tag", "=", "JSON", ".", "parse", "(", "AJAX", ".", "get", "(", "self", ",", "\"/api/2.0/assets/#{asset_id}/tags\"", ",", "AJAX", "::", "CONTENT_TYPE", "::", "JSON", ",", "{", "...
Lists all the tags on an asset @param [Fixnum] asset_id of the asset to list the applied tags for @return [Array[TagSummary]] list of tags on asset
[ "Lists", "all", "the", "tags", "on", "an", "asset" ]
933fc8c0c85ba11d3e17db1d7f4542816f400d71
https://github.com/rapid7/nexpose-client/blob/933fc8c0c85ba11d3e17db1d7f4542816f400d71/lib/nexpose/tag.rb#L32-L39
18,915
rapid7/nexpose-client
lib/nexpose/tag.rb
Nexpose.Connection.site_tags
def site_tags(site_id) tag_summary = [] site_tag = JSON.parse(AJAX.get(self, "/api/2.0/sites/#{site_id}/tags", AJAX::CONTENT_TYPE::JSON, { per_page: 2_147_483_647 })) site_tag['resources'].each do |json| tag_summary << TagSummary.parse(json) end tag_summary end
ruby
def site_tags(site_id) tag_summary = [] site_tag = JSON.parse(AJAX.get(self, "/api/2.0/sites/#{site_id}/tags", AJAX::CONTENT_TYPE::JSON, { per_page: 2_147_483_647 })) site_tag['resources'].each do |json| tag_summary << TagSummary.parse(json) end tag_summary end
[ "def", "site_tags", "(", "site_id", ")", "tag_summary", "=", "[", "]", "site_tag", "=", "JSON", ".", "parse", "(", "AJAX", ".", "get", "(", "self", ",", "\"/api/2.0/sites/#{site_id}/tags\"", ",", "AJAX", "::", "CONTENT_TYPE", "::", "JSON", ",", "{", "per_p...
Lists all the tags on a site @param [Fixnum] site_id id of the site to get the applied tags @return [Array[TagSummary]] list of tags on site
[ "Lists", "all", "the", "tags", "on", "a", "site" ]
933fc8c0c85ba11d3e17db1d7f4542816f400d71
https://github.com/rapid7/nexpose-client/blob/933fc8c0c85ba11d3e17db1d7f4542816f400d71/lib/nexpose/tag.rb#L56-L63
18,916
rapid7/nexpose-client
lib/nexpose/tag.rb
Nexpose.Connection.asset_group_tags
def asset_group_tags(asset_group_id) tag_summary = [] asset_group_tag = JSON.parse(AJAX.get(self, "/api/2.0/asset_groups/#{asset_group_id}/tags", AJAX::CONTENT_TYPE::JSON, { per_page: 2_147_483_647 })) asset_group_tag['resources'].each do |json| tag_summary << TagSummary.parse(json) end ...
ruby
def asset_group_tags(asset_group_id) tag_summary = [] asset_group_tag = JSON.parse(AJAX.get(self, "/api/2.0/asset_groups/#{asset_group_id}/tags", AJAX::CONTENT_TYPE::JSON, { per_page: 2_147_483_647 })) asset_group_tag['resources'].each do |json| tag_summary << TagSummary.parse(json) end ...
[ "def", "asset_group_tags", "(", "asset_group_id", ")", "tag_summary", "=", "[", "]", "asset_group_tag", "=", "JSON", ".", "parse", "(", "AJAX", ".", "get", "(", "self", ",", "\"/api/2.0/asset_groups/#{asset_group_id}/tags\"", ",", "AJAX", "::", "CONTENT_TYPE", "::...
Lists all the tags on an asset_group @param [Fixnum] asset_group_id id of the group on which tags are listed @return [Array[TagSummary]] list of tags on asset group
[ "Lists", "all", "the", "tags", "on", "an", "asset_group" ]
933fc8c0c85ba11d3e17db1d7f4542816f400d71
https://github.com/rapid7/nexpose-client/blob/933fc8c0c85ba11d3e17db1d7f4542816f400d71/lib/nexpose/tag.rb#L80-L87
18,917
rapid7/nexpose-client
lib/nexpose/tag.rb
Nexpose.Connection.selected_criticality_tag
def selected_criticality_tag(asset_id) selected_criticality = AJAX.get(self, "/data/asset/#{asset_id}/selected-criticality-tag") selected_criticality.empty? ? nil : JSON.parse(selected_criticality)['name'] end
ruby
def selected_criticality_tag(asset_id) selected_criticality = AJAX.get(self, "/data/asset/#{asset_id}/selected-criticality-tag") selected_criticality.empty? ? nil : JSON.parse(selected_criticality)['name'] end
[ "def", "selected_criticality_tag", "(", "asset_id", ")", "selected_criticality", "=", "AJAX", ".", "get", "(", "self", ",", "\"/data/asset/#{asset_id}/selected-criticality-tag\"", ")", "selected_criticality", ".", "empty?", "?", "nil", ":", "JSON", ".", "parse", "(", ...
Returns the criticality value which takes precedent for an asset @param [Fixnum] asset_id id of asset on which criticality tag is selected @return [String] selected_criticality string of the relevant criticality; nil if not tagged
[ "Returns", "the", "criticality", "value", "which", "takes", "precedent", "for", "an", "asset" ]
933fc8c0c85ba11d3e17db1d7f4542816f400d71
https://github.com/rapid7/nexpose-client/blob/933fc8c0c85ba11d3e17db1d7f4542816f400d71/lib/nexpose/tag.rb#L106-L109
18,918
rapid7/nexpose-client
lib/nexpose/tag.rb
Nexpose.Tag.color=
def color=(hex) valid_colors = Type::Color.constants.map { |c| Type::Color.const_get(c) } unless hex.nil? || valid_colors.include?(hex.to_s.downcase) raise ArgumentError, "Unable to set color to an invalid color.\nUse one of #{valid_colors}" end @color = hex end
ruby
def color=(hex) valid_colors = Type::Color.constants.map { |c| Type::Color.const_get(c) } unless hex.nil? || valid_colors.include?(hex.to_s.downcase) raise ArgumentError, "Unable to set color to an invalid color.\nUse one of #{valid_colors}" end @color = hex end
[ "def", "color", "=", "(", "hex", ")", "valid_colors", "=", "Type", "::", "Color", ".", "constants", ".", "map", "{", "|", "c", "|", "Type", "::", "Color", ".", "const_get", "(", "c", ")", "}", "unless", "hex", ".", "nil?", "||", "valid_colors", "."...
Set the color but validate it
[ "Set", "the", "color", "but", "validate", "it" ]
933fc8c0c85ba11d3e17db1d7f4542816f400d71
https://github.com/rapid7/nexpose-client/blob/933fc8c0c85ba11d3e17db1d7f4542816f400d71/lib/nexpose/tag.rb#L218-L225
18,919
rapid7/nexpose-client
lib/nexpose/tag.rb
Nexpose.Tag.save
def save(connection) params = to_json if @id == -1 uri = AJAX.post(connection, '/api/2.0/tags', params, AJAX::CONTENT_TYPE::JSON) @id = uri.split('/').last.to_i else AJAX.put(connection, "/api/2.0/tags/#{@id}", params, AJAX::CONTENT_TYPE::JSON) end @id end
ruby
def save(connection) params = to_json if @id == -1 uri = AJAX.post(connection, '/api/2.0/tags', params, AJAX::CONTENT_TYPE::JSON) @id = uri.split('/').last.to_i else AJAX.put(connection, "/api/2.0/tags/#{@id}", params, AJAX::CONTENT_TYPE::JSON) end @id end
[ "def", "save", "(", "connection", ")", "params", "=", "to_json", "if", "@id", "==", "-", "1", "uri", "=", "AJAX", ".", "post", "(", "connection", ",", "'/api/2.0/tags'", ",", "params", ",", "AJAX", "::", "CONTENT_TYPE", "::", "JSON", ")", "@id", "=", ...
Creates and saves a tag to Nexpose console @param [Connection] connection Nexpose connection @return [Fixnum] ID of saved tag
[ "Creates", "and", "saves", "a", "tag", "to", "Nexpose", "console" ]
933fc8c0c85ba11d3e17db1d7f4542816f400d71
https://github.com/rapid7/nexpose-client/blob/933fc8c0c85ba11d3e17db1d7f4542816f400d71/lib/nexpose/tag.rb#L267-L276
18,920
rapid7/nexpose-client
lib/nexpose/tag.rb
Nexpose.Tag.add_to_asset
def add_to_asset(connection, asset_id) params = to_json_for_add url = "/api/2.0/assets/#{asset_id}/tags" uri = AJAX.post(connection, url, params, AJAX::CONTENT_TYPE::JSON) @id = uri.split('/').last.to_i end
ruby
def add_to_asset(connection, asset_id) params = to_json_for_add url = "/api/2.0/assets/#{asset_id}/tags" uri = AJAX.post(connection, url, params, AJAX::CONTENT_TYPE::JSON) @id = uri.split('/').last.to_i end
[ "def", "add_to_asset", "(", "connection", ",", "asset_id", ")", "params", "=", "to_json_for_add", "url", "=", "\"/api/2.0/assets/#{asset_id}/tags\"", "uri", "=", "AJAX", ".", "post", "(", "connection", ",", "url", ",", "params", ",", "AJAX", "::", "CONTENT_TYPE"...
Adds a tag to an asset @param [Connection] connection Nexpose connection @param [Fixnum] asset_id of the asset to be tagged @return [Fixnum] ID of applied tag
[ "Adds", "a", "tag", "to", "an", "asset" ]
933fc8c0c85ba11d3e17db1d7f4542816f400d71
https://github.com/rapid7/nexpose-client/blob/933fc8c0c85ba11d3e17db1d7f4542816f400d71/lib/nexpose/tag.rb#L340-L345
18,921
rapid7/nexpose-client
lib/nexpose/tag.rb
Nexpose.Tag.add_to_site
def add_to_site(connection, site_id) params = to_json_for_add url = "/api/2.0/sites/#{site_id}/tags" uri = AJAX.post(connection, url, params, AJAX::CONTENT_TYPE::JSON) @id = uri.split('/').last.to_i end
ruby
def add_to_site(connection, site_id) params = to_json_for_add url = "/api/2.0/sites/#{site_id}/tags" uri = AJAX.post(connection, url, params, AJAX::CONTENT_TYPE::JSON) @id = uri.split('/').last.to_i end
[ "def", "add_to_site", "(", "connection", ",", "site_id", ")", "params", "=", "to_json_for_add", "url", "=", "\"/api/2.0/sites/#{site_id}/tags\"", "uri", "=", "AJAX", ".", "post", "(", "connection", ",", "url", ",", "params", ",", "AJAX", "::", "CONTENT_TYPE", ...
Adds a tag to a site @param [Connection] connection Nexpose connection @param [Fixnum] site_id of the site to be tagged @return [Fixnum] ID of applied tag
[ "Adds", "a", "tag", "to", "a", "site" ]
933fc8c0c85ba11d3e17db1d7f4542816f400d71
https://github.com/rapid7/nexpose-client/blob/933fc8c0c85ba11d3e17db1d7f4542816f400d71/lib/nexpose/tag.rb#L353-L358
18,922
rapid7/nexpose-client
lib/nexpose/tag.rb
Nexpose.Tag.add_to_group
def add_to_group(connection, group_id) params = to_json_for_add url = "/api/2.0/asset_groups/#{group_id}/tags" uri = AJAX.post(connection, url, params, AJAX::CONTENT_TYPE::JSON) @id = uri.split('/').last.to_i end
ruby
def add_to_group(connection, group_id) params = to_json_for_add url = "/api/2.0/asset_groups/#{group_id}/tags" uri = AJAX.post(connection, url, params, AJAX::CONTENT_TYPE::JSON) @id = uri.split('/').last.to_i end
[ "def", "add_to_group", "(", "connection", ",", "group_id", ")", "params", "=", "to_json_for_add", "url", "=", "\"/api/2.0/asset_groups/#{group_id}/tags\"", "uri", "=", "AJAX", ".", "post", "(", "connection", ",", "url", ",", "params", ",", "AJAX", "::", "CONTENT...
Adds a tag to an asset group @param [Connection] connection Nexpose connection @param [Fixnum] group_id id of the asset group to be tagged @return [Fixnum] ID of applied tag
[ "Adds", "a", "tag", "to", "an", "asset", "group" ]
933fc8c0c85ba11d3e17db1d7f4542816f400d71
https://github.com/rapid7/nexpose-client/blob/933fc8c0c85ba11d3e17db1d7f4542816f400d71/lib/nexpose/tag.rb#L366-L371
18,923
rapid7/nexpose-client
lib/nexpose/vuln_exception.rb
Nexpose.Connection.list_vuln_exceptions
def list_vuln_exceptions(status = nil) unless is_valid_vuln_exception_status?(status) raise "Unknown Status ~> '#{status}' :: For available options refer to Nexpose::VulnException::Status" end status = Nexpose::VulnException::Status.const_get(status_string_to_constant(status)) unless status.n...
ruby
def list_vuln_exceptions(status = nil) unless is_valid_vuln_exception_status?(status) raise "Unknown Status ~> '#{status}' :: For available options refer to Nexpose::VulnException::Status" end status = Nexpose::VulnException::Status.const_get(status_string_to_constant(status)) unless status.n...
[ "def", "list_vuln_exceptions", "(", "status", "=", "nil", ")", "unless", "is_valid_vuln_exception_status?", "(", "status", ")", "raise", "\"Unknown Status ~> '#{status}' :: For available options refer to Nexpose::VulnException::Status\"", "end", "status", "=", "Nexpose", "::", ...
Retrieve all active vulnerability exceptions. @param [String] status Filter exceptions by the current status. @see Nexpose::VulnException::Status @return [Array[VulnException]] List of matching vulnerability exceptions.
[ "Retrieve", "all", "active", "vulnerability", "exceptions", "." ]
933fc8c0c85ba11d3e17db1d7f4542816f400d71
https://github.com/rapid7/nexpose-client/blob/933fc8c0c85ba11d3e17db1d7f4542816f400d71/lib/nexpose/vuln_exception.rb#L12-L64
18,924
rapid7/nexpose-client
lib/nexpose/vuln_exception.rb
Nexpose.Connection.resubmit_vuln_exception
def resubmit_vuln_exception(id, comment, reason = nil) options = { 'exception-id' => id } options['reason'] = reason if reason xml = make_xml('VulnerabilityExceptionResubmitRequest', options) comment_xml = make_xml('comment', {}, comment, false) xml.add_elemen...
ruby
def resubmit_vuln_exception(id, comment, reason = nil) options = { 'exception-id' => id } options['reason'] = reason if reason xml = make_xml('VulnerabilityExceptionResubmitRequest', options) comment_xml = make_xml('comment', {}, comment, false) xml.add_elemen...
[ "def", "resubmit_vuln_exception", "(", "id", ",", "comment", ",", "reason", "=", "nil", ")", "options", "=", "{", "'exception-id'", "=>", "id", "}", "options", "[", "'reason'", "]", "=", "reason", "if", "reason", "xml", "=", "make_xml", "(", "'Vulnerabilit...
Resubmit a vulnerability exception request with a new comment and reason after an exception has been rejected. You can only resubmit a request that has a "Rejected" status; if an exception is "Approved" or "Under Review" you will receive an error message stating that the exception request cannot be resubmitted. ...
[ "Resubmit", "a", "vulnerability", "exception", "request", "with", "a", "new", "comment", "and", "reason", "after", "an", "exception", "has", "been", "rejected", "." ]
933fc8c0c85ba11d3e17db1d7f4542816f400d71
https://github.com/rapid7/nexpose-client/blob/933fc8c0c85ba11d3e17db1d7f4542816f400d71/lib/nexpose/vuln_exception.rb#L80-L88
18,925
rapid7/nexpose-client
lib/nexpose/vuln_exception.rb
Nexpose.VulnException.save
def save(connection, comment = nil) validate xml = connection.make_xml('VulnerabilityExceptionCreateRequest') xml.add_attributes({ 'vuln-id' => @vuln_id, 'scope' => @scope, 'reason' => @reason }) case @scope when Scope::ALL_INSTANCES_O...
ruby
def save(connection, comment = nil) validate xml = connection.make_xml('VulnerabilityExceptionCreateRequest') xml.add_attributes({ 'vuln-id' => @vuln_id, 'scope' => @scope, 'reason' => @reason }) case @scope when Scope::ALL_INSTANCES_O...
[ "def", "save", "(", "connection", ",", "comment", "=", "nil", ")", "validate", "xml", "=", "connection", ".", "make_xml", "(", "'VulnerabilityExceptionCreateRequest'", ")", "xml", ".", "add_attributes", "(", "{", "'vuln-id'", "=>", "@vuln_id", ",", "'scope'", ...
Submit this exception on the security console. @param [Connection] connection Connection to security console. @return [Fixnum] Newly assigned exception ID.
[ "Submit", "this", "exception", "on", "the", "security", "console", "." ]
933fc8c0c85ba11d3e17db1d7f4542816f400d71
https://github.com/rapid7/nexpose-client/blob/933fc8c0c85ba11d3e17db1d7f4542816f400d71/lib/nexpose/vuln_exception.rb#L205-L232
18,926
rapid7/nexpose-client
lib/nexpose/vuln_exception.rb
Nexpose.VulnException.approve
def approve(connection, comment = nil) xml = connection.make_xml('VulnerabilityExceptionApproveRequest', { 'exception-id' => @id }) if comment cxml = REXML::Element.new('comment') cxml.add_text(comment) xml.add_element(cxml) @reviewer_comment =...
ruby
def approve(connection, comment = nil) xml = connection.make_xml('VulnerabilityExceptionApproveRequest', { 'exception-id' => @id }) if comment cxml = REXML::Element.new('comment') cxml.add_text(comment) xml.add_element(cxml) @reviewer_comment =...
[ "def", "approve", "(", "connection", ",", "comment", "=", "nil", ")", "xml", "=", "connection", ".", "make_xml", "(", "'VulnerabilityExceptionApproveRequest'", ",", "{", "'exception-id'", "=>", "@id", "}", ")", "if", "comment", "cxml", "=", "REXML", "::", "E...
Approve a vulnerability exception request, update comments and expiration dates on vulnerability exceptions that are "Under Review". @param [Connection] connection Connection to security console. @param [String] comment Comment to accompany the approval. @return [Boolean] Whether or not the approval was accepted b...
[ "Approve", "a", "vulnerability", "exception", "request", "update", "comments", "and", "expiration", "dates", "on", "vulnerability", "exceptions", "that", "are", "Under", "Review", "." ]
933fc8c0c85ba11d3e17db1d7f4542816f400d71
https://github.com/rapid7/nexpose-client/blob/933fc8c0c85ba11d3e17db1d7f4542816f400d71/lib/nexpose/vuln_exception.rb#L271-L282
18,927
rapid7/nexpose-client
lib/nexpose/vuln_exception.rb
Nexpose.VulnException.update_expiration_date
def update_expiration_date(connection, new_date) xml = connection.make_xml('VulnerabilityExceptionUpdateExpirationDateRequest', { 'exception-id' => @id, 'expiration-date' => new_date }) connection.execute(xml, '1.2').success end
ruby
def update_expiration_date(connection, new_date) xml = connection.make_xml('VulnerabilityExceptionUpdateExpirationDateRequest', { 'exception-id' => @id, 'expiration-date' => new_date }) connection.execute(xml, '1.2').success end
[ "def", "update_expiration_date", "(", "connection", ",", "new_date", ")", "xml", "=", "connection", ".", "make_xml", "(", "'VulnerabilityExceptionUpdateExpirationDateRequest'", ",", "{", "'exception-id'", "=>", "@id", ",", "'expiration-date'", "=>", "new_date", "}", "...
Update the expiration date for this exception. The expiration time cannot be in the past. @param [Connection] connection Connection to security console. @param [String] new_date Date in the format "YYYY-MM-DD". @return [Boolean] Whether the update was successfully submitted.
[ "Update", "the", "expiration", "date", "for", "this", "exception", ".", "The", "expiration", "time", "cannot", "be", "in", "the", "past", "." ]
933fc8c0c85ba11d3e17db1d7f4542816f400d71
https://github.com/rapid7/nexpose-client/blob/933fc8c0c85ba11d3e17db1d7f4542816f400d71/lib/nexpose/vuln_exception.rb#L358-L363
18,928
rapid7/nexpose-client
lib/nexpose/vuln_exception.rb
Nexpose.VulnException.validate
def validate raise ArgumentError.new('No vuln_id.') unless @vuln_id raise ArgumentError.new('No scope.') unless @scope raise ArgumentError.new('No reason.') unless @reason case @scope when Scope::ALL_INSTANCES @asset_id = @port = @vuln_key = nil when Scope::ALL_INSTANCES_ON_...
ruby
def validate raise ArgumentError.new('No vuln_id.') unless @vuln_id raise ArgumentError.new('No scope.') unless @scope raise ArgumentError.new('No reason.') unless @reason case @scope when Scope::ALL_INSTANCES @asset_id = @port = @vuln_key = nil when Scope::ALL_INSTANCES_ON_...
[ "def", "validate", "raise", "ArgumentError", ".", "new", "(", "'No vuln_id.'", ")", "unless", "@vuln_id", "raise", "ArgumentError", ".", "new", "(", "'No scope.'", ")", "unless", "@scope", "raise", "ArgumentError", ".", "new", "(", "'No reason.'", ")", "unless",...
Validate that this exception meets to requires for the assigned scope.
[ "Validate", "that", "this", "exception", "meets", "to", "requires", "for", "the", "assigned", "scope", "." ]
933fc8c0c85ba11d3e17db1d7f4542816f400d71
https://github.com/rapid7/nexpose-client/blob/933fc8c0c85ba11d3e17db1d7f4542816f400d71/lib/nexpose/vuln_exception.rb#L367-L386
18,929
rapid7/nexpose-client
lib/nexpose/maint.rb
Nexpose.Connection.list_backups
def list_backups data = DataTable._get_dyn_table(self, '/data/admin/backups?tableID=BackupSynopsis') data.map { |b| Backup.parse(b) } end
ruby
def list_backups data = DataTable._get_dyn_table(self, '/data/admin/backups?tableID=BackupSynopsis') data.map { |b| Backup.parse(b) } end
[ "def", "list_backups", "data", "=", "DataTable", ".", "_get_dyn_table", "(", "self", ",", "'/data/admin/backups?tableID=BackupSynopsis'", ")", "data", ".", "map", "{", "|", "b", "|", "Backup", ".", "parse", "(", "b", ")", "}", "end" ]
Retrieve a list of all backups currently stored on the Console. @return [Array[Backup]] List of backups.
[ "Retrieve", "a", "list", "of", "all", "backups", "currently", "stored", "on", "the", "Console", "." ]
933fc8c0c85ba11d3e17db1d7f4542816f400d71
https://github.com/rapid7/nexpose-client/blob/933fc8c0c85ba11d3e17db1d7f4542816f400d71/lib/nexpose/maint.rb#L9-L12
18,930
rapid7/nexpose-client
lib/nexpose/maint.rb
Nexpose.Connection.backup
def backup(platform_independent = false, description = nil) parameters = { 'backup_desc' => description, 'cmd' => 'backup', 'platform_independent' => platform_independent, 'targetTask' => 'backupRestore' } xml = AJAX.form_post(self, '/admin/glob...
ruby
def backup(platform_independent = false, description = nil) parameters = { 'backup_desc' => description, 'cmd' => 'backup', 'platform_independent' => platform_independent, 'targetTask' => 'backupRestore' } xml = AJAX.form_post(self, '/admin/glob...
[ "def", "backup", "(", "platform_independent", "=", "false", ",", "description", "=", "nil", ")", "parameters", "=", "{", "'backup_desc'", "=>", "description", ",", "'cmd'", "=>", "'backup'", ",", "'platform_independent'", "=>", "platform_independent", ",", "'targe...
Create a backup of this security console's data. A restart will be initiated in order to put the product into maintenance mode while the backup is made. It will then restart automatically. @param [Boolean] platform_independent Whether to make a platform independent backup. @param [String] description A note abo...
[ "Create", "a", "backup", "of", "this", "security", "console", "s", "data", ".", "A", "restart", "will", "be", "initiated", "in", "order", "to", "put", "the", "product", "into", "maintenance", "mode", "while", "the", "backup", "is", "made", ".", "It", "wi...
933fc8c0c85ba11d3e17db1d7f4542816f400d71
https://github.com/rapid7/nexpose-client/blob/933fc8c0c85ba11d3e17db1d7f4542816f400d71/lib/nexpose/maint.rb#L24-L33
18,931
rapid7/nexpose-client
lib/nexpose/maint.rb
Nexpose.Connection.db_maintenance
def db_maintenance(clean_up = false, compress = false, reindex = false) return unless compress || clean_up || reindex parameters = { 'cmd' => 'startMaintenance', 'targetTask' => 'dbMaintenance' } parameters['cleanup'] = 1 if clean_up parameters['compress'] = 1 if compress parameters['rein...
ruby
def db_maintenance(clean_up = false, compress = false, reindex = false) return unless compress || clean_up || reindex parameters = { 'cmd' => 'startMaintenance', 'targetTask' => 'dbMaintenance' } parameters['cleanup'] = 1 if clean_up parameters['compress'] = 1 if compress parameters['rein...
[ "def", "db_maintenance", "(", "clean_up", "=", "false", ",", "compress", "=", "false", ",", "reindex", "=", "false", ")", "return", "unless", "compress", "||", "clean_up", "||", "reindex", "parameters", "=", "{", "'cmd'", "=>", "'startMaintenance'", ",", "'t...
Initiate database maintenance tasks to improve database performance and consistency. A restart will be initiated in order to put the product into maintenance mode while the tasks are run. It will then restart automatically. @param [Boolean] clean_up Removes any unnecessary data from the database. @param [Boolean]...
[ "Initiate", "database", "maintenance", "tasks", "to", "improve", "database", "performance", "and", "consistency", ".", "A", "restart", "will", "be", "initiated", "in", "order", "to", "put", "the", "product", "into", "maintenance", "mode", "while", "the", "tasks"...
933fc8c0c85ba11d3e17db1d7f4542816f400d71
https://github.com/rapid7/nexpose-client/blob/933fc8c0c85ba11d3e17db1d7f4542816f400d71/lib/nexpose/maint.rb#L47-L57
18,932
rapid7/nexpose-client
lib/nexpose/maint.rb
Nexpose.Backup.restore
def restore(nsc, password = nil) raise 'Supplied Password is incorrect for restoring this Backup.' if invalid_backup_password?(nsc, password) parameters = { 'backupid' => @name, 'cmd' => 'restore', 'targetTask' => 'backupRestore', 'password' => ...
ruby
def restore(nsc, password = nil) raise 'Supplied Password is incorrect for restoring this Backup.' if invalid_backup_password?(nsc, password) parameters = { 'backupid' => @name, 'cmd' => 'restore', 'targetTask' => 'backupRestore', 'password' => ...
[ "def", "restore", "(", "nsc", ",", "password", "=", "nil", ")", "raise", "'Supplied Password is incorrect for restoring this Backup.'", "if", "invalid_backup_password?", "(", "nsc", ",", "password", ")", "parameters", "=", "{", "'backupid'", "=>", "@name", ",", "'cm...
Restore this backup to the Nexpose console. It will restart the console after acknowledging receiving the request. @param [Connection] nsc An active connection to a Nexpose console. @param [String] (Optional) The password to use when restoring the backup. @return [Boolean] Whether the request was received.
[ "Restore", "this", "backup", "to", "the", "Nexpose", "console", ".", "It", "will", "restart", "the", "console", "after", "acknowledging", "receiving", "the", "request", "." ]
933fc8c0c85ba11d3e17db1d7f4542816f400d71
https://github.com/rapid7/nexpose-client/blob/933fc8c0c85ba11d3e17db1d7f4542816f400d71/lib/nexpose/maint.rb#L102-L112
18,933
rapid7/nexpose-client
lib/nexpose/util.rb
Nexpose.HostOrIP.convert
def convert(asset) ips = asset.split('-').map(&:strip) IPAddr.new(ips[0]) IPAddr.new(ips[1]) if ips[1] IPRange.new(ips[0], ips[1]) rescue ArgumentError => e if e.message == 'invalid address' HostName.new(asset) else raise "Unable to parse asset: '#{asset}'. #{e.me...
ruby
def convert(asset) ips = asset.split('-').map(&:strip) IPAddr.new(ips[0]) IPAddr.new(ips[1]) if ips[1] IPRange.new(ips[0], ips[1]) rescue ArgumentError => e if e.message == 'invalid address' HostName.new(asset) else raise "Unable to parse asset: '#{asset}'. #{e.me...
[ "def", "convert", "(", "asset", ")", "ips", "=", "asset", ".", "split", "(", "'-'", ")", ".", "map", "(", ":strip", ")", "IPAddr", ".", "new", "(", "ips", "[", "0", "]", ")", "IPAddr", ".", "new", "(", "ips", "[", "1", "]", ")", "if", "ips", ...
Convert a host or IP address to the corresponding HostName or IPRange class. If the String cannot be converted, it will raise an error. @param [String] asset String representation of an IP or host name. @return [IPRange|HostName] Valid class, if it can be converted.
[ "Convert", "a", "host", "or", "IP", "address", "to", "the", "corresponding", "HostName", "or", "IPRange", "class", "." ]
933fc8c0c85ba11d3e17db1d7f4542816f400d71
https://github.com/rapid7/nexpose-client/blob/933fc8c0c85ba11d3e17db1d7f4542816f400d71/lib/nexpose/util.rb#L52-L63
18,934
rapid7/nexpose-client
lib/nexpose/util.rb
Nexpose.Attributes.to_hash
def to_hash(arr) arr.map(&:flatten).map { |p| { 'key' => p.first.to_s, 'value' => p.last.to_s } } end
ruby
def to_hash(arr) arr.map(&:flatten).map { |p| { 'key' => p.first.to_s, 'value' => p.last.to_s } } end
[ "def", "to_hash", "(", "arr", ")", "arr", ".", "map", "(", ":flatten", ")", ".", "map", "{", "|", "p", "|", "{", "'key'", "=>", "p", ".", "first", ".", "to_s", ",", "'value'", "=>", "p", ".", "last", ".", "to_s", "}", "}", "end" ]
Convert an array of attributes into a hash consumable by the API. @param [Array[Hash]] arr Array of attributes to convert. @return [Array[Hash]] Array formatted as expected by the API.
[ "Convert", "an", "array", "of", "attributes", "into", "a", "hash", "consumable", "by", "the", "API", "." ]
933fc8c0c85ba11d3e17db1d7f4542816f400d71
https://github.com/rapid7/nexpose-client/blob/933fc8c0c85ba11d3e17db1d7f4542816f400d71/lib/nexpose/util.rb#L122-L124
18,935
rapid7/nexpose-client
lib/nexpose/global_settings.rb
Nexpose.GlobalSettings.save
def save(nsc) # load method can return XML missing this required attribute. unless REXML::XPath.first(xml, '//*[@recalculation_duration]') risk_model = REXML::XPath.first(xml, '//riskModel') risk_model.add_attribute('recalculation_duration', 'do_not_recalculate') end replace_exc...
ruby
def save(nsc) # load method can return XML missing this required attribute. unless REXML::XPath.first(xml, '//*[@recalculation_duration]') risk_model = REXML::XPath.first(xml, '//riskModel') risk_model.add_attribute('recalculation_duration', 'do_not_recalculate') end replace_exc...
[ "def", "save", "(", "nsc", ")", "# load method can return XML missing this required attribute.", "unless", "REXML", "::", "XPath", ".", "first", "(", "xml", ",", "'//*[@recalculation_duration]'", ")", "risk_model", "=", "REXML", "::", "XPath", ".", "first", "(", "xm...
Save any updates to this settings object to the Nexpose console. @param [Connection] nsc Connection to a Nexpose console. @return [Boolean] Whether saving was successful.
[ "Save", "any", "updates", "to", "this", "settings", "object", "to", "the", "Nexpose", "console", "." ]
933fc8c0c85ba11d3e17db1d7f4542816f400d71
https://github.com/rapid7/nexpose-client/blob/933fc8c0c85ba11d3e17db1d7f4542816f400d71/lib/nexpose/global_settings.rb#L38-L51
18,936
rapid7/nexpose-client
lib/nexpose/global_settings.rb
Nexpose.GlobalSettings.add_exclusion
def add_exclusion(host_or_ip) asset = host_or_ip unless host_or_ip.respond_to?(:host) || host_or_ip.respond_to?(:from) asset = HostOrIP.convert(host_or_ip) end @asset_exclusions << asset end
ruby
def add_exclusion(host_or_ip) asset = host_or_ip unless host_or_ip.respond_to?(:host) || host_or_ip.respond_to?(:from) asset = HostOrIP.convert(host_or_ip) end @asset_exclusions << asset end
[ "def", "add_exclusion", "(", "host_or_ip", ")", "asset", "=", "host_or_ip", "unless", "host_or_ip", ".", "respond_to?", "(", ":host", ")", "||", "host_or_ip", ".", "respond_to?", "(", ":from", ")", "asset", "=", "HostOrIP", ".", "convert", "(", "host_or_ip", ...
Add an asset exclusion setting. @param [IPRange|HostName|String] host_or_ip Host or IP (range) to exclude from scanning by the Nexpose console.
[ "Add", "an", "asset", "exclusion", "setting", "." ]
933fc8c0c85ba11d3e17db1d7f4542816f400d71
https://github.com/rapid7/nexpose-client/blob/933fc8c0c85ba11d3e17db1d7f4542816f400d71/lib/nexpose/global_settings.rb#L58-L64
18,937
rapid7/nexpose-client
lib/nexpose/global_settings.rb
Nexpose.GlobalSettings.remove_exclusion
def remove_exclusion(host_or_ip) asset = host_or_ip unless host_or_ip.respond_to?(:host) || host_or_ip.respond_to?(:from) # Attept to convert String to appropriate object. asset = HostOrIP.convert(host_or_ip) end @asset_exclusions = asset_exclusions.reject { |a| a.eql? asset } ...
ruby
def remove_exclusion(host_or_ip) asset = host_or_ip unless host_or_ip.respond_to?(:host) || host_or_ip.respond_to?(:from) # Attept to convert String to appropriate object. asset = HostOrIP.convert(host_or_ip) end @asset_exclusions = asset_exclusions.reject { |a| a.eql? asset } ...
[ "def", "remove_exclusion", "(", "host_or_ip", ")", "asset", "=", "host_or_ip", "unless", "host_or_ip", ".", "respond_to?", "(", ":host", ")", "||", "host_or_ip", ".", "respond_to?", "(", ":from", ")", "# Attept to convert String to appropriate object.", "asset", "=", ...
Remove an asset exclusion setting. If you need to remove a range of IPs, be sure to explicitly supply an IPRange object to the method. @param [IPRange|HostName|String] host_or_ip Host or IP (range) to remove from the exclusion list.
[ "Remove", "an", "asset", "exclusion", "setting", ".", "If", "you", "need", "to", "remove", "a", "range", "of", "IPs", "be", "sure", "to", "explicitly", "supply", "an", "IPRange", "object", "to", "the", "method", "." ]
933fc8c0c85ba11d3e17db1d7f4542816f400d71
https://github.com/rapid7/nexpose-client/blob/933fc8c0c85ba11d3e17db1d7f4542816f400d71/lib/nexpose/global_settings.rb#L73-L80
18,938
rapid7/nexpose-client
lib/nexpose/global_settings.rb
Nexpose.GlobalSettings.replace_exclusions
def replace_exclusions(xml, exclusions) xml.elements.delete('//ExcludedHosts') elem = xml.root.add_element('ExcludedHosts') exclusions.each do |exclusion| elem.add_element(exclusion.as_xml) end end
ruby
def replace_exclusions(xml, exclusions) xml.elements.delete('//ExcludedHosts') elem = xml.root.add_element('ExcludedHosts') exclusions.each do |exclusion| elem.add_element(exclusion.as_xml) end end
[ "def", "replace_exclusions", "(", "xml", ",", "exclusions", ")", "xml", ".", "elements", ".", "delete", "(", "'//ExcludedHosts'", ")", "elem", "=", "xml", ".", "root", ".", "add_element", "(", "'ExcludedHosts'", ")", "exclusions", ".", "each", "do", "|", "...
Internal method for updating exclusions before saving.
[ "Internal", "method", "for", "updating", "exclusions", "before", "saving", "." ]
933fc8c0c85ba11d3e17db1d7f4542816f400d71
https://github.com/rapid7/nexpose-client/blob/933fc8c0c85ba11d3e17db1d7f4542816f400d71/lib/nexpose/global_settings.rb#L95-L101
18,939
rapid7/nexpose-client
lib/nexpose/global_settings.rb
Nexpose.GlobalSettings.parse_control_scanning_from_xml
def parse_control_scanning_from_xml(xml) enabled = false if elem = REXML::XPath.first(xml, '//enableControlsScan[@enabled]') enabled = elem.attribute('enabled').value.to_i == 1 end enabled end
ruby
def parse_control_scanning_from_xml(xml) enabled = false if elem = REXML::XPath.first(xml, '//enableControlsScan[@enabled]') enabled = elem.attribute('enabled').value.to_i == 1 end enabled end
[ "def", "parse_control_scanning_from_xml", "(", "xml", ")", "enabled", "=", "false", "if", "elem", "=", "REXML", "::", "XPath", ".", "first", "(", "xml", ",", "'//enableControlsScan[@enabled]'", ")", "enabled", "=", "elem", ".", "attribute", "(", "'enabled'", "...
Internal method for parsing XML for whether control scanning in enabled.
[ "Internal", "method", "for", "parsing", "XML", "for", "whether", "control", "scanning", "in", "enabled", "." ]
933fc8c0c85ba11d3e17db1d7f4542816f400d71
https://github.com/rapid7/nexpose-client/blob/933fc8c0c85ba11d3e17db1d7f4542816f400d71/lib/nexpose/global_settings.rb#L104-L110
18,940
rapid7/nexpose-client
lib/nexpose/global_settings.rb
Nexpose.GlobalSettings.add_control_scanning_to_xml
def add_control_scanning_to_xml(xml, enabled) if elem = REXML::XPath.first(xml, '//enableControlsScan') elem.attributes['enabled'] = enabled ? '1' : '0' else elem = REXML::Element.new('ControlsScan', xml.root) elem.add_element('enableControlsScan', 'enabled' ...
ruby
def add_control_scanning_to_xml(xml, enabled) if elem = REXML::XPath.first(xml, '//enableControlsScan') elem.attributes['enabled'] = enabled ? '1' : '0' else elem = REXML::Element.new('ControlsScan', xml.root) elem.add_element('enableControlsScan', 'enabled' ...
[ "def", "add_control_scanning_to_xml", "(", "xml", ",", "enabled", ")", "if", "elem", "=", "REXML", "::", "XPath", ".", "first", "(", "xml", ",", "'//enableControlsScan'", ")", "elem", ".", "attributes", "[", "'enabled'", "]", "=", "enabled", "?", "'1'", ":...
Internal method for updating control scanning before saving.
[ "Internal", "method", "for", "updating", "control", "scanning", "before", "saving", "." ]
933fc8c0c85ba11d3e17db1d7f4542816f400d71
https://github.com/rapid7/nexpose-client/blob/933fc8c0c85ba11d3e17db1d7f4542816f400d71/lib/nexpose/global_settings.rb#L113-L121
18,941
rapid7/nexpose-client
lib/nexpose/global_settings.rb
Nexpose.GlobalSettings.parse_asset_linking_from_xml
def parse_asset_linking_from_xml(xml) enabled = true if elem = REXML::XPath.first(xml, '//AssetCorrelation[@enabled]') enabled = elem.attribute('enabled').value.to_i == 1 end enabled end
ruby
def parse_asset_linking_from_xml(xml) enabled = true if elem = REXML::XPath.first(xml, '//AssetCorrelation[@enabled]') enabled = elem.attribute('enabled').value.to_i == 1 end enabled end
[ "def", "parse_asset_linking_from_xml", "(", "xml", ")", "enabled", "=", "true", "if", "elem", "=", "REXML", "::", "XPath", ".", "first", "(", "xml", ",", "'//AssetCorrelation[@enabled]'", ")", "enabled", "=", "elem", ".", "attribute", "(", "'enabled'", ")", ...
Internal method for parsing XML for whether asset linking in enabled.
[ "Internal", "method", "for", "parsing", "XML", "for", "whether", "asset", "linking", "in", "enabled", "." ]
933fc8c0c85ba11d3e17db1d7f4542816f400d71
https://github.com/rapid7/nexpose-client/blob/933fc8c0c85ba11d3e17db1d7f4542816f400d71/lib/nexpose/global_settings.rb#L124-L130
18,942
rapid7/nexpose-client
lib/nexpose/global_settings.rb
Nexpose.GlobalSettings.add_asset_linking_to_xml
def add_asset_linking_to_xml(xml, enabled) elem = REXML::XPath.first(xml, '//AssetCorrelation') return nil unless elem elem.attributes['enabled'] = enabled ? '1' : '0' end
ruby
def add_asset_linking_to_xml(xml, enabled) elem = REXML::XPath.first(xml, '//AssetCorrelation') return nil unless elem elem.attributes['enabled'] = enabled ? '1' : '0' end
[ "def", "add_asset_linking_to_xml", "(", "xml", ",", "enabled", ")", "elem", "=", "REXML", "::", "XPath", ".", "first", "(", "xml", ",", "'//AssetCorrelation'", ")", "return", "nil", "unless", "elem", "elem", ".", "attributes", "[", "'enabled'", "]", "=", "...
Internal method for updating asset linking before saving.
[ "Internal", "method", "for", "updating", "asset", "linking", "before", "saving", "." ]
933fc8c0c85ba11d3e17db1d7f4542816f400d71
https://github.com/rapid7/nexpose-client/blob/933fc8c0c85ba11d3e17db1d7f4542816f400d71/lib/nexpose/global_settings.rb#L133-L138
18,943
rapid7/nexpose-client
lib/nexpose/credential_helper.rb
Nexpose.CredentialHelper.set_db2_service
def set_db2_service(database = nil, username = nil, password = nil) self.database = database self.user_name = username self.password = password self.service = Credential::Service::DB2 end
ruby
def set_db2_service(database = nil, username = nil, password = nil) self.database = database self.user_name = username self.password = password self.service = Credential::Service::DB2 end
[ "def", "set_db2_service", "(", "database", "=", "nil", ",", "username", "=", "nil", ",", "password", "=", "nil", ")", "self", ".", "database", "=", "database", "self", ".", "user_name", "=", "username", "self", ".", "password", "=", "password", "self", "...
sets the DB2 service
[ "sets", "the", "DB2", "service" ]
933fc8c0c85ba11d3e17db1d7f4542816f400d71
https://github.com/rapid7/nexpose-client/blob/933fc8c0c85ba11d3e17db1d7f4542816f400d71/lib/nexpose/credential_helper.rb#L14-L19
18,944
rapid7/nexpose-client
lib/nexpose/credential_helper.rb
Nexpose.CredentialHelper.set_tds_service
def set_tds_service(database = nil, domain = nil, username = nil, password = nil) self.database = database self.domain = domain self.use_windows_auth = domain.nil? self.user_name = username self.password = password self.service = Credential::...
ruby
def set_tds_service(database = nil, domain = nil, username = nil, password = nil) self.database = database self.domain = domain self.use_windows_auth = domain.nil? self.user_name = username self.password = password self.service = Credential::...
[ "def", "set_tds_service", "(", "database", "=", "nil", ",", "domain", "=", "nil", ",", "username", "=", "nil", ",", "password", "=", "nil", ")", "self", ".", "database", "=", "database", "self", ".", "domain", "=", "domain", "self", ".", "use_windows_aut...
sets the Microsoft SQL Server service.
[ "sets", "the", "Microsoft", "SQL", "Server", "service", "." ]
933fc8c0c85ba11d3e17db1d7f4542816f400d71
https://github.com/rapid7/nexpose-client/blob/933fc8c0c85ba11d3e17db1d7f4542816f400d71/lib/nexpose/credential_helper.rb#L43-L50
18,945
rapid7/nexpose-client
lib/nexpose/credential_helper.rb
Nexpose.CredentialHelper.set_mysql_service
def set_mysql_service(database = nil, username = nil, password = nil) self.database = database self.user_name = username self.password = password self.service = Credential::Service::MYSQL end
ruby
def set_mysql_service(database = nil, username = nil, password = nil) self.database = database self.user_name = username self.password = password self.service = Credential::Service::MYSQL end
[ "def", "set_mysql_service", "(", "database", "=", "nil", ",", "username", "=", "nil", ",", "password", "=", "nil", ")", "self", ".", "database", "=", "database", "self", ".", "user_name", "=", "username", "self", ".", "password", "=", "password", "self", ...
sets the MySQL Server service.
[ "sets", "the", "MySQL", "Server", "service", "." ]
933fc8c0c85ba11d3e17db1d7f4542816f400d71
https://github.com/rapid7/nexpose-client/blob/933fc8c0c85ba11d3e17db1d7f4542816f400d71/lib/nexpose/credential_helper.rb#L69-L74
18,946
rapid7/nexpose-client
lib/nexpose/credential_helper.rb
Nexpose.CredentialHelper.set_oracle_service
def set_oracle_service(sid = nil, username = nil, password = nil) self.database = sid self.user_name = username self.password = password self.service = Credential::Service::ORACLE end
ruby
def set_oracle_service(sid = nil, username = nil, password = nil) self.database = sid self.user_name = username self.password = password self.service = Credential::Service::ORACLE end
[ "def", "set_oracle_service", "(", "sid", "=", "nil", ",", "username", "=", "nil", ",", "password", "=", "nil", ")", "self", ".", "database", "=", "sid", "self", ".", "user_name", "=", "username", "self", ".", "password", "=", "password", "self", ".", "...
sets the Oracle service.
[ "sets", "the", "Oracle", "service", "." ]
933fc8c0c85ba11d3e17db1d7f4542816f400d71
https://github.com/rapid7/nexpose-client/blob/933fc8c0c85ba11d3e17db1d7f4542816f400d71/lib/nexpose/credential_helper.rb#L77-L82
18,947
rapid7/nexpose-client
lib/nexpose/credential_helper.rb
Nexpose.CredentialHelper.set_postgresql_service
def set_postgresql_service(database = nil, username = nil, password = nil) self.database = database self.user_name = username self.password = password self.service = Credential::Service::POSTGRESQL end
ruby
def set_postgresql_service(database = nil, username = nil, password = nil) self.database = database self.user_name = username self.password = password self.service = Credential::Service::POSTGRESQL end
[ "def", "set_postgresql_service", "(", "database", "=", "nil", ",", "username", "=", "nil", ",", "password", "=", "nil", ")", "self", ".", "database", "=", "database", "self", ".", "user_name", "=", "username", "self", ".", "password", "=", "password", "sel...
sets the PostgreSQL service.
[ "sets", "the", "PostgreSQL", "service", "." ]
933fc8c0c85ba11d3e17db1d7f4542816f400d71
https://github.com/rapid7/nexpose-client/blob/933fc8c0c85ba11d3e17db1d7f4542816f400d71/lib/nexpose/credential_helper.rb#L92-L97
18,948
rapid7/nexpose-client
lib/nexpose/credential_helper.rb
Nexpose.CredentialHelper.set_remote_execution_service
def set_remote_execution_service(username = nil, password = nil) self.user_name = username self.password = password self.service = Credential::Service::REMOTE_EXECUTION end
ruby
def set_remote_execution_service(username = nil, password = nil) self.user_name = username self.password = password self.service = Credential::Service::REMOTE_EXECUTION end
[ "def", "set_remote_execution_service", "(", "username", "=", "nil", ",", "password", "=", "nil", ")", "self", ".", "user_name", "=", "username", "self", ".", "password", "=", "password", "self", ".", "service", "=", "Credential", "::", "Service", "::", "REMO...
sets the Remote Execution service.
[ "sets", "the", "Remote", "Execution", "service", "." ]
933fc8c0c85ba11d3e17db1d7f4542816f400d71
https://github.com/rapid7/nexpose-client/blob/933fc8c0c85ba11d3e17db1d7f4542816f400d71/lib/nexpose/credential_helper.rb#L100-L104
18,949
rapid7/nexpose-client
lib/nexpose/credential_helper.rb
Nexpose.CredentialHelper.set_snmpv3_service
def set_snmpv3_service(authentication_type = Credential::AuthenticationType::NOAUTH, username = nil, password = nil, privacy_type = Credential::PrivacyType::NOPRIV, privacy_password = nil) self.authentication_type = authentication_type self.user_name = username self.password = pas...
ruby
def set_snmpv3_service(authentication_type = Credential::AuthenticationType::NOAUTH, username = nil, password = nil, privacy_type = Credential::PrivacyType::NOPRIV, privacy_password = nil) self.authentication_type = authentication_type self.user_name = username self.password = pas...
[ "def", "set_snmpv3_service", "(", "authentication_type", "=", "Credential", "::", "AuthenticationType", "::", "NOAUTH", ",", "username", "=", "nil", ",", "password", "=", "nil", ",", "privacy_type", "=", "Credential", "::", "PrivacyType", "::", "NOPRIV", ",", "p...
sets the Simple Network Management Protocol v3 service.
[ "sets", "the", "Simple", "Network", "Management", "Protocol", "v3", "service", "." ]
933fc8c0c85ba11d3e17db1d7f4542816f400d71
https://github.com/rapid7/nexpose-client/blob/933fc8c0c85ba11d3e17db1d7f4542816f400d71/lib/nexpose/credential_helper.rb#L134-L141
18,950
rapid7/nexpose-client
lib/nexpose/credential_helper.rb
Nexpose.CredentialHelper.set_sybase_service
def set_sybase_service(database = nil, domain = nil, username = nil, password = nil) self.database = database self.domain = domain self.use_windows_auth = domain.nil? self.user_name = username self.password = password self.service = Credentia...
ruby
def set_sybase_service(database = nil, domain = nil, username = nil, password = nil) self.database = database self.domain = domain self.use_windows_auth = domain.nil? self.user_name = username self.password = password self.service = Credentia...
[ "def", "set_sybase_service", "(", "database", "=", "nil", ",", "domain", "=", "nil", ",", "username", "=", "nil", ",", "password", "=", "nil", ")", "self", ".", "database", "=", "database", "self", ".", "domain", "=", "domain", "self", ".", "use_windows_...
sets the Sybase SQL Server service.
[ "sets", "the", "Sybase", "SQL", "Server", "service", "." ]
933fc8c0c85ba11d3e17db1d7f4542816f400d71
https://github.com/rapid7/nexpose-client/blob/933fc8c0c85ba11d3e17db1d7f4542816f400d71/lib/nexpose/credential_helper.rb#L144-L151
18,951
rapid7/nexpose-client
lib/nexpose/credential_helper.rb
Nexpose.CredentialHelper.set_telnet_service
def set_telnet_service(username = nil, password = nil) self.user_name = username self.password = password self.service = Credential::Service::TELNET end
ruby
def set_telnet_service(username = nil, password = nil) self.user_name = username self.password = password self.service = Credential::Service::TELNET end
[ "def", "set_telnet_service", "(", "username", "=", "nil", ",", "password", "=", "nil", ")", "self", ".", "user_name", "=", "username", "self", ".", "password", "=", "password", "self", ".", "service", "=", "Credential", "::", "Service", "::", "TELNET", "en...
sets the Telnet service.
[ "sets", "the", "Telnet", "service", "." ]
933fc8c0c85ba11d3e17db1d7f4542816f400d71
https://github.com/rapid7/nexpose-client/blob/933fc8c0c85ba11d3e17db1d7f4542816f400d71/lib/nexpose/credential_helper.rb#L154-L158
18,952
rapid7/nexpose-client
lib/nexpose/credential_helper.rb
Nexpose.CredentialHelper.set_http_service
def set_http_service(domain = nil, username = nil, password = nil) self.domain = domain self.user_name = username self.password = password self.service = Credential::Service::HTTP end
ruby
def set_http_service(domain = nil, username = nil, password = nil) self.domain = domain self.user_name = username self.password = password self.service = Credential::Service::HTTP end
[ "def", "set_http_service", "(", "domain", "=", "nil", ",", "username", "=", "nil", ",", "password", "=", "nil", ")", "self", ".", "domain", "=", "domain", "self", ".", "user_name", "=", "username", "self", ".", "password", "=", "password", "self", ".", ...
sets the Web Site HTTP Authentication service.
[ "sets", "the", "Web", "Site", "HTTP", "Authentication", "service", "." ]
933fc8c0c85ba11d3e17db1d7f4542816f400d71
https://github.com/rapid7/nexpose-client/blob/933fc8c0c85ba11d3e17db1d7f4542816f400d71/lib/nexpose/credential_helper.rb#L161-L166
18,953
rapid7/nexpose-client
lib/nexpose/user.rb
Nexpose.Connection.list_users
def list_users r = execute(make_xml('UserListingRequest')) arr = [] if r.success r.res.elements.each('UserListingResponse/UserSummary') do |summary| arr << UserSummary.parse(summary) end end arr end
ruby
def list_users r = execute(make_xml('UserListingRequest')) arr = [] if r.success r.res.elements.each('UserListingResponse/UserSummary') do |summary| arr << UserSummary.parse(summary) end end arr end
[ "def", "list_users", "r", "=", "execute", "(", "make_xml", "(", "'UserListingRequest'", ")", ")", "arr", "=", "[", "]", "if", "r", ".", "success", "r", ".", "res", ".", "elements", ".", "each", "(", "'UserListingResponse/UserSummary'", ")", "do", "|", "s...
Retrieve a list of all users configured on this console. @return [Array[UserSummary]] Array of users.
[ "Retrieve", "a", "list", "of", "all", "users", "configured", "on", "this", "console", "." ]
933fc8c0c85ba11d3e17db1d7f4542816f400d71
https://github.com/rapid7/nexpose-client/blob/933fc8c0c85ba11d3e17db1d7f4542816f400d71/lib/nexpose/user.rb#L10-L19
18,954
rapid7/nexpose-client
lib/nexpose/discovery.rb
Nexpose.Connection.list_discovery_connections
def list_discovery_connections xml = make_xml('DiscoveryConnectionListingRequest') response = execute(xml, '1.2') connections = [] response.res.elements.each('DiscoveryConnectionListingResponse/DiscoveryConnectionSummary') do |conn| connections << DiscoveryConnection.parse(con...
ruby
def list_discovery_connections xml = make_xml('DiscoveryConnectionListingRequest') response = execute(xml, '1.2') connections = [] response.res.elements.each('DiscoveryConnectionListingResponse/DiscoveryConnectionSummary') do |conn| connections << DiscoveryConnection.parse(con...
[ "def", "list_discovery_connections", "xml", "=", "make_xml", "(", "'DiscoveryConnectionListingRequest'", ")", "response", "=", "execute", "(", "xml", ",", "'1.2'", ")", "connections", "=", "[", "]", "response", ".", "res", ".", "elements", ".", "each", "(", "'...
Retrieve information about all available connections for dynamic discovery of assets, including whether or not connections are active.
[ "Retrieve", "information", "about", "all", "available", "connections", "for", "dynamic", "discovery", "of", "assets", "including", "whether", "or", "not", "connections", "are", "active", "." ]
933fc8c0c85ba11d3e17db1d7f4542816f400d71
https://github.com/rapid7/nexpose-client/blob/933fc8c0c85ba11d3e17db1d7f4542816f400d71/lib/nexpose/discovery.rb#L8-L16
18,955
rapid7/nexpose-client
lib/nexpose/discovery.rb
Nexpose.Connection.delete_discovery_connection
def delete_discovery_connection(id) xml = make_xml('DiscoveryConnectionDeleteRequest', { 'id' => id }) response = execute(xml, '1.2') response.success end
ruby
def delete_discovery_connection(id) xml = make_xml('DiscoveryConnectionDeleteRequest', { 'id' => id }) response = execute(xml, '1.2') response.success end
[ "def", "delete_discovery_connection", "(", "id", ")", "xml", "=", "make_xml", "(", "'DiscoveryConnectionDeleteRequest'", ",", "{", "'id'", "=>", "id", "}", ")", "response", "=", "execute", "(", "xml", ",", "'1.2'", ")", "response", ".", "success", "end" ]
Delete an existing connection to a target used for dynamic discovery of assets. @param [Fixnum] id ID of an existing discovery connection.
[ "Delete", "an", "existing", "connection", "to", "a", "target", "used", "for", "dynamic", "discovery", "of", "assets", "." ]
933fc8c0c85ba11d3e17db1d7f4542816f400d71
https://github.com/rapid7/nexpose-client/blob/933fc8c0c85ba11d3e17db1d7f4542816f400d71/lib/nexpose/discovery.rb#L23-L27
18,956
rapid7/nexpose-client
lib/nexpose/discovery.rb
Nexpose.DiscoveryConnection.create
def create(nsc) xml = nsc.make_xml('DiscoveryConnectionCreateRequest') xml.add_element(as_xml) response = nsc.execute(xml, '1.2') if response.success ret = REXML::XPath.first(response.res, 'DiscoveryConnectionCreateResponse') @id = ret.attributes['id'].to_i unless ret.nil? ...
ruby
def create(nsc) xml = nsc.make_xml('DiscoveryConnectionCreateRequest') xml.add_element(as_xml) response = nsc.execute(xml, '1.2') if response.success ret = REXML::XPath.first(response.res, 'DiscoveryConnectionCreateResponse') @id = ret.attributes['id'].to_i unless ret.nil? ...
[ "def", "create", "(", "nsc", ")", "xml", "=", "nsc", ".", "make_xml", "(", "'DiscoveryConnectionCreateRequest'", ")", "xml", ".", "add_element", "(", "as_xml", ")", "response", "=", "nsc", ".", "execute", "(", "xml", ",", "'1.2'", ")", "if", "response", ...
Create a new discovery connection. @param [String] name Name to assign to this connection. @param [String] address IP or fully qualified domain name of the connection server. @param [String] user User name for credentials on this connection. @param [String] password Password for credentials on this connection....
[ "Create", "a", "new", "discovery", "connection", "." ]
933fc8c0c85ba11d3e17db1d7f4542816f400d71
https://github.com/rapid7/nexpose-client/blob/933fc8c0c85ba11d3e17db1d7f4542816f400d71/lib/nexpose/discovery.rb#L117-L126
18,957
rapid7/nexpose-client
lib/nexpose/discovery.rb
Nexpose.DiscoveryConnection.discover
def discover(nsc, criteria = nil) parameters = { 'table-id' => 'assetdiscovery', 'sort' => 'assetDiscoveryName', 'searchCriteria' => criteria.nil? ? 'null' : criteria.to_json, 'configID' => @id } data = DataTable._get_json_table(nsc, '/data/disc...
ruby
def discover(nsc, criteria = nil) parameters = { 'table-id' => 'assetdiscovery', 'sort' => 'assetDiscoveryName', 'searchCriteria' => criteria.nil? ? 'null' : criteria.to_json, 'configID' => @id } data = DataTable._get_json_table(nsc, '/data/disc...
[ "def", "discover", "(", "nsc", ",", "criteria", "=", "nil", ")", "parameters", "=", "{", "'table-id'", "=>", "'assetdiscovery'", ",", "'sort'", "=>", "'assetDiscoveryName'", ",", "'searchCriteria'", "=>", "criteria", ".", "nil?", "?", "'null'", ":", "criteria"...
Perform dynamic discover of assets against this connection. @param [Connection] nsc Connection to a console. @param [Criteria] criteria Criteria search object narrowing which assets to filter. @return [Array[DiscoveredAsset]] All discovered assets matching the criteria.
[ "Perform", "dynamic", "discover", "of", "assets", "against", "this", "connection", "." ]
933fc8c0c85ba11d3e17db1d7f4542816f400d71
https://github.com/rapid7/nexpose-client/blob/933fc8c0c85ba11d3e17db1d7f4542816f400d71/lib/nexpose/discovery.rb#L157-L164
18,958
rapid7/nexpose-client
lib/nexpose/discovery.rb
Nexpose.DiscoveryConnection.connect
def connect(nsc) xml = nsc.make_xml('DiscoveryConnectionConnectRequest', { 'id' => id }) response = nsc.execute(xml, '1.2') response.success end
ruby
def connect(nsc) xml = nsc.make_xml('DiscoveryConnectionConnectRequest', { 'id' => id }) response = nsc.execute(xml, '1.2') response.success end
[ "def", "connect", "(", "nsc", ")", "xml", "=", "nsc", ".", "make_xml", "(", "'DiscoveryConnectionConnectRequest'", ",", "{", "'id'", "=>", "id", "}", ")", "response", "=", "nsc", ".", "execute", "(", "xml", ",", "'1.2'", ")", "response", ".", "success", ...
Initiates a connection to a target used for dynamic discovery of assets. As long as a connection is active, dynamic discovery is continuous. @param [Connection] nsc Connection to a console.
[ "Initiates", "a", "connection", "to", "a", "target", "used", "for", "dynamic", "discovery", "of", "assets", ".", "As", "long", "as", "a", "connection", "is", "active", "dynamic", "discovery", "is", "continuous", "." ]
933fc8c0c85ba11d3e17db1d7f4542816f400d71
https://github.com/rapid7/nexpose-client/blob/933fc8c0c85ba11d3e17db1d7f4542816f400d71/lib/nexpose/discovery.rb#L171-L175
18,959
rapid7/nexpose-client
lib/nexpose/group.rb
Nexpose.Connection.list_asset_groups
def list_asset_groups r = execute(make_xml('AssetGroupListingRequest')) groups = [] if r.success r.res.elements.each('AssetGroupListingResponse/AssetGroupSummary') do |group| groups << AssetGroupSummary.new(group.attributes['id'].to_i, group....
ruby
def list_asset_groups r = execute(make_xml('AssetGroupListingRequest')) groups = [] if r.success r.res.elements.each('AssetGroupListingResponse/AssetGroupSummary') do |group| groups << AssetGroupSummary.new(group.attributes['id'].to_i, group....
[ "def", "list_asset_groups", "r", "=", "execute", "(", "make_xml", "(", "'AssetGroupListingRequest'", ")", ")", "groups", "=", "[", "]", "if", "r", ".", "success", "r", ".", "res", ".", "elements", ".", "each", "(", "'AssetGroupListingResponse/AssetGroupSummary'"...
Retrieve an array of all asset groups the user is authorized to view or manage. @return [Array[AssetGroupSummary]] Array of AssetGroupSummary objects.
[ "Retrieve", "an", "array", "of", "all", "asset", "groups", "the", "user", "is", "authorized", "to", "view", "or", "manage", "." ]
933fc8c0c85ba11d3e17db1d7f4542816f400d71
https://github.com/rapid7/nexpose-client/blob/933fc8c0c85ba11d3e17db1d7f4542816f400d71/lib/nexpose/group.rb#L24-L37
18,960
rapid7/nexpose-client
lib/nexpose/group.rb
Nexpose.AssetGroup.as_xml
def as_xml xml = REXML::Element.new('AssetGroup') xml.attributes['id'] = @id xml.attributes['name'] = @name xml.attributes['description'] = @description if @description && !@description.empty? elem = REXML::Element.new('Description') elem.add_text(@descript...
ruby
def as_xml xml = REXML::Element.new('AssetGroup') xml.attributes['id'] = @id xml.attributes['name'] = @name xml.attributes['description'] = @description if @description && !@description.empty? elem = REXML::Element.new('Description') elem.add_text(@descript...
[ "def", "as_xml", "xml", "=", "REXML", "::", "Element", ".", "new", "(", "'AssetGroup'", ")", "xml", ".", "attributes", "[", "'id'", "]", "=", "@id", "xml", ".", "attributes", "[", "'name'", "]", "=", "@name", "xml", ".", "attributes", "[", "'descriptio...
Generate an XML representation of this group configuration @return [String] XML valid for submission as part of other requests.
[ "Generate", "an", "XML", "representation", "of", "this", "group", "configuration" ]
933fc8c0c85ba11d3e17db1d7f4542816f400d71
https://github.com/rapid7/nexpose-client/blob/933fc8c0c85ba11d3e17db1d7f4542816f400d71/lib/nexpose/group.rb#L102-L124
18,961
rapid7/nexpose-client
lib/nexpose/group.rb
Nexpose.AssetGroup.rescan_assets
def rescan_assets(connection) scans = {} sites_ids = @assets.map(&:site_id).uniq sites_ids.each do |site_id| to_scan = @assets.select { |d| d.site_id == site_id } scans[site_id] = connection.scan_devices(to_scan) end scans end
ruby
def rescan_assets(connection) scans = {} sites_ids = @assets.map(&:site_id).uniq sites_ids.each do |site_id| to_scan = @assets.select { |d| d.site_id == site_id } scans[site_id] = connection.scan_devices(to_scan) end scans end
[ "def", "rescan_assets", "(", "connection", ")", "scans", "=", "{", "}", "sites_ids", "=", "@assets", ".", "map", "(", ":site_id", ")", ".", "uniq", "sites_ids", ".", "each", "do", "|", "site_id", "|", "to_scan", "=", "@assets", ".", "select", "{", "|",...
Launch ad hoc scans against each group of assets per site. @param [Connection] connection Connection to console where asset group is configured. @return [Hash] Hash of site ID to Scan launch information for each scan.
[ "Launch", "ad", "hoc", "scans", "against", "each", "group", "of", "assets", "per", "site", "." ]
933fc8c0c85ba11d3e17db1d7f4542816f400d71
https://github.com/rapid7/nexpose-client/blob/933fc8c0c85ba11d3e17db1d7f4542816f400d71/lib/nexpose/group.rb#L142-L150
18,962
atomita/fluent-plugin-aws-elasticsearch-service
lib/fluent/plugin/out_aws-elasticsearch-service.rb
Fluent::Plugin.AwsElasticsearchServiceOutput.credentials
def credentials(opts) calback = lambda do credentials = nil unless opts[:access_key_id].empty? or opts[:secret_access_key].empty? credentials = Aws::Credentials.new opts[:access_key_id], opts[:secret_access_key] else if opts[:assume_role_arn].nil? if opts[:e...
ruby
def credentials(opts) calback = lambda do credentials = nil unless opts[:access_key_id].empty? or opts[:secret_access_key].empty? credentials = Aws::Credentials.new opts[:access_key_id], opts[:secret_access_key] else if opts[:assume_role_arn].nil? if opts[:e...
[ "def", "credentials", "(", "opts", ")", "calback", "=", "lambda", "do", "credentials", "=", "nil", "unless", "opts", "[", ":access_key_id", "]", ".", "empty?", "or", "opts", "[", ":secret_access_key", "]", ".", "empty?", "credentials", "=", "Aws", "::", "C...
get AWS Credentials
[ "get", "AWS", "Credentials" ]
907bd77c292469f074185d7ddc3ba73f5c45258b
https://github.com/atomita/fluent-plugin-aws-elasticsearch-service/blob/907bd77c292469f074185d7ddc3ba73f5c45258b/lib/fluent/plugin/out_aws-elasticsearch-service.rb#L70-L102
18,963
panthomakos/timezone
lib/timezone/zone.rb
Timezone.Zone.local_to_utc
def local_to_utc(time) time = sanitize(time) (time - rule_for_local(time).rules.first[OFFSET_BIT]).utc end
ruby
def local_to_utc(time) time = sanitize(time) (time - rule_for_local(time).rules.first[OFFSET_BIT]).utc end
[ "def", "local_to_utc", "(", "time", ")", "time", "=", "sanitize", "(", "time", ")", "(", "time", "-", "rule_for_local", "(", "time", ")", ".", "rules", ".", "first", "[", "OFFSET_BIT", "]", ")", ".", "utc", "end" ]
Converts the given local time to the UTC equivalent. @param time [#to_time] the local time @return [Time] the time in UTC @note The UTC equivalent is a "best guess". There are cases where local times do not map to UTC at all (during a time skip forward). There are also cases where local times map to two dist...
[ "Converts", "the", "given", "local", "time", "to", "the", "UTC", "equivalent", "." ]
23acc721a6b1df1fde840cf05ab097b5d59925f0
https://github.com/panthomakos/timezone/blob/23acc721a6b1df1fde840cf05ab097b5d59925f0/lib/timezone/zone.rb#L109-L113
18,964
panthomakos/timezone
lib/timezone/zone.rb
Timezone.Zone.time_with_offset
def time_with_offset(time) time = sanitize(time) utc = utc_to_local(time) offset = utc_offset(time) Time.new( utc.year, utc.month, utc.day, utc.hour, utc.min, utc.sec + utc.subsec, offset ) end
ruby
def time_with_offset(time) time = sanitize(time) utc = utc_to_local(time) offset = utc_offset(time) Time.new( utc.year, utc.month, utc.day, utc.hour, utc.min, utc.sec + utc.subsec, offset ) end
[ "def", "time_with_offset", "(", "time", ")", "time", "=", "sanitize", "(", "time", ")", "utc", "=", "utc_to_local", "(", "time", ")", "offset", "=", "utc_offset", "(", "time", ")", "Time", ".", "new", "(", "utc", ".", "year", ",", "utc", ".", "month"...
Converts the given time to the local timezone and includes the UTC offset in the result. @param time [#to_time] the source time @return [Time] the time in the local timezone with the UTC offset
[ "Converts", "the", "given", "time", "to", "the", "local", "timezone", "and", "includes", "the", "UTC", "offset", "in", "the", "result", "." ]
23acc721a6b1df1fde840cf05ab097b5d59925f0
https://github.com/panthomakos/timezone/blob/23acc721a6b1df1fde840cf05ab097b5d59925f0/lib/timezone/zone.rb#L120-L135
18,965
panthomakos/timezone
lib/timezone/zone.rb
Timezone.Zone.binary_search
def binary_search(time, from = 0, to = nil, &block) to = private_rules.length - 1 if to.nil? return from if from == to mid = (from + to).div(2) unless yield(time, private_rules[mid]) return binary_search(time, mid + 1, to, &block) end return mid if mid.zero? return...
ruby
def binary_search(time, from = 0, to = nil, &block) to = private_rules.length - 1 if to.nil? return from if from == to mid = (from + to).div(2) unless yield(time, private_rules[mid]) return binary_search(time, mid + 1, to, &block) end return mid if mid.zero? return...
[ "def", "binary_search", "(", "time", ",", "from", "=", "0", ",", "to", "=", "nil", ",", "&", "block", ")", "to", "=", "private_rules", ".", "length", "-", "1", "if", "to", ".", "nil?", "return", "from", "if", "from", "==", "to", "mid", "=", "(", ...
Find the first rule that matches using binary search.
[ "Find", "the", "first", "rule", "that", "matches", "using", "binary", "search", "." ]
23acc721a6b1df1fde840cf05ab097b5d59925f0
https://github.com/panthomakos/timezone/blob/23acc721a6b1df1fde840cf05ab097b5d59925f0/lib/timezone/zone.rb#L253-L269
18,966
mongodb/bson-ruby
lib/bson/open_struct.rb
BSON.OpenStruct.to_bson
def to_bson(buffer = ByteBuffer.new, validating_keys = Config.validating_keys?) if Environment.ruby_1_9? marshal_dump.dup else to_h end.to_bson(buffer, validating_keys) end
ruby
def to_bson(buffer = ByteBuffer.new, validating_keys = Config.validating_keys?) if Environment.ruby_1_9? marshal_dump.dup else to_h end.to_bson(buffer, validating_keys) end
[ "def", "to_bson", "(", "buffer", "=", "ByteBuffer", ".", "new", ",", "validating_keys", "=", "Config", ".", "validating_keys?", ")", "if", "Environment", ".", "ruby_1_9?", "marshal_dump", ".", "dup", "else", "to_h", "end", ".", "to_bson", "(", "buffer", ",",...
Get the OpenStruct as encoded BSON. @example Get the OpenStruct object as encoded BSON. OpenStruct.new({ "field" => "value" }).to_bson @return [ BSON::ByteBuffer ] The buffer with the encoded object. @see http://bsonspec.org/#/specification @since 4.2.0
[ "Get", "the", "OpenStruct", "as", "encoded", "BSON", "." ]
297af124a7462f522b75fe9851ac81ce4fd33b0f
https://github.com/mongodb/bson-ruby/blob/297af124a7462f522b75fe9851ac81ce4fd33b0f/lib/bson/open_struct.rb#L35-L41
18,967
mongodb/bson-ruby
lib/bson/hash.rb
BSON.Hash.to_bson
def to_bson(buffer = ByteBuffer.new, validating_keys = Config.validating_keys?) if buffer.respond_to?(:put_hash) buffer.put_hash(self, validating_keys) else position = buffer.length buffer.put_int32(0) each do |field, value| buffer.put_byte(value.bson_type) ...
ruby
def to_bson(buffer = ByteBuffer.new, validating_keys = Config.validating_keys?) if buffer.respond_to?(:put_hash) buffer.put_hash(self, validating_keys) else position = buffer.length buffer.put_int32(0) each do |field, value| buffer.put_byte(value.bson_type) ...
[ "def", "to_bson", "(", "buffer", "=", "ByteBuffer", ".", "new", ",", "validating_keys", "=", "Config", ".", "validating_keys?", ")", "if", "buffer", ".", "respond_to?", "(", ":put_hash", ")", "buffer", ".", "put_hash", "(", "self", ",", "validating_keys", ")...
Get the hash as encoded BSON. @example Get the hash as encoded BSON. { "field" => "value" }.to_bson @return [ BSON::ByteBuffer ] The buffer with the encoded object. @see http://bsonspec.org/#/specification @since 2.0.0
[ "Get", "the", "hash", "as", "encoded", "BSON", "." ]
297af124a7462f522b75fe9851ac81ce4fd33b0f
https://github.com/mongodb/bson-ruby/blob/297af124a7462f522b75fe9851ac81ce4fd33b0f/lib/bson/hash.rb#L40-L54
18,968
mongodb/bson-ruby
lib/bson/timestamp.rb
BSON.Timestamp.to_bson
def to_bson(buffer = ByteBuffer.new, validating_keys = Config.validating_keys?) buffer.put_int32(increment) buffer.put_int32(seconds) end
ruby
def to_bson(buffer = ByteBuffer.new, validating_keys = Config.validating_keys?) buffer.put_int32(increment) buffer.put_int32(seconds) end
[ "def", "to_bson", "(", "buffer", "=", "ByteBuffer", ".", "new", ",", "validating_keys", "=", "Config", ".", "validating_keys?", ")", "buffer", ".", "put_int32", "(", "increment", ")", "buffer", ".", "put_int32", "(", "seconds", ")", "end" ]
Instantiate the new timestamp. @example Instantiate the timestamp. BSON::Timestamp.new(5, 30) @param [ Integer ] seconds The number of seconds. @param [ Integer ] increment The increment value. @since 2.0.0 Get the timestamp as its encoded raw BSON bytes. @example Get the timestamp as BSON. timestamp.to...
[ "Instantiate", "the", "new", "timestamp", "." ]
297af124a7462f522b75fe9851ac81ce4fd33b0f
https://github.com/mongodb/bson-ruby/blob/297af124a7462f522b75fe9851ac81ce4fd33b0f/lib/bson/timestamp.rb#L114-L117
18,969
mongodb/bson-ruby
lib/bson/array.rb
BSON.Array.to_bson
def to_bson(buffer = ByteBuffer.new, validating_keys = Config.validating_keys?) if buffer.respond_to?(:put_array) buffer.put_array(self, validating_keys) else position = buffer.length buffer.put_int32(0) each_with_index do |value, index| buffer.put_byte(value.bson_t...
ruby
def to_bson(buffer = ByteBuffer.new, validating_keys = Config.validating_keys?) if buffer.respond_to?(:put_array) buffer.put_array(self, validating_keys) else position = buffer.length buffer.put_int32(0) each_with_index do |value, index| buffer.put_byte(value.bson_t...
[ "def", "to_bson", "(", "buffer", "=", "ByteBuffer", ".", "new", ",", "validating_keys", "=", "Config", ".", "validating_keys?", ")", "if", "buffer", ".", "respond_to?", "(", ":put_array", ")", "buffer", ".", "put_array", "(", "self", ",", "validating_keys", ...
Get the array as encoded BSON. @example Get the array as encoded BSON. [ 1, 2, 3 ].to_bson @note Arrays are encoded as documents, where the index of the value in the array is the actual key. @return [ BSON::ByteBuffer ] The buffer with the encoded object. @see http://bsonspec.org/#/specification @since ...
[ "Get", "the", "array", "as", "encoded", "BSON", "." ]
297af124a7462f522b75fe9851ac81ce4fd33b0f
https://github.com/mongodb/bson-ruby/blob/297af124a7462f522b75fe9851ac81ce4fd33b0f/lib/bson/array.rb#L43-L57
18,970
mongodb/bson-ruby
lib/bson/code.rb
BSON.Code.to_bson
def to_bson(buffer = ByteBuffer.new, validating_keys = Config.validating_keys?) buffer.put_string(javascript) # @todo: was formerly to_bson_string end
ruby
def to_bson(buffer = ByteBuffer.new, validating_keys = Config.validating_keys?) buffer.put_string(javascript) # @todo: was formerly to_bson_string end
[ "def", "to_bson", "(", "buffer", "=", "ByteBuffer", ".", "new", ",", "validating_keys", "=", "Config", ".", "validating_keys?", ")", "buffer", ".", "put_string", "(", "javascript", ")", "# @todo: was formerly to_bson_string", "end" ]
Instantiate the new code. @example Instantiate the new code. BSON::Code.new("this.value = 5") @param [ String ] javascript The javascript code. @since 2.0.0 Encode the javascript code. @example Encode the code. code.to_bson @return [ BSON::ByteBuffer ] The buffer with the encoded object. @see http://...
[ "Instantiate", "the", "new", "code", "." ]
297af124a7462f522b75fe9851ac81ce4fd33b0f
https://github.com/mongodb/bson-ruby/blob/297af124a7462f522b75fe9851ac81ce4fd33b0f/lib/bson/code.rb#L84-L86
18,971
mongodb/bson-ruby
lib/bson/date_time.rb
BSON.DateTime.to_bson
def to_bson(buffer = ByteBuffer.new, validating_keys = Config.validating_keys?) to_time.to_bson(buffer) end
ruby
def to_bson(buffer = ByteBuffer.new, validating_keys = Config.validating_keys?) to_time.to_bson(buffer) end
[ "def", "to_bson", "(", "buffer", "=", "ByteBuffer", ".", "new", ",", "validating_keys", "=", "Config", ".", "validating_keys?", ")", "to_time", ".", "to_bson", "(", "buffer", ")", "end" ]
Get the date time as encoded BSON. @example Get the date time as encoded BSON. DateTime.new(2012, 1, 1, 0, 0, 0).to_bson @return [ BSON::ByteBuffer ] The buffer with the encoded object. @see http://bsonspec.org/#/specification @since 2.1.0
[ "Get", "the", "date", "time", "as", "encoded", "BSON", "." ]
297af124a7462f522b75fe9851ac81ce4fd33b0f
https://github.com/mongodb/bson-ruby/blob/297af124a7462f522b75fe9851ac81ce4fd33b0f/lib/bson/date_time.rb#L37-L39
18,972
mongodb/bson-ruby
lib/bson/code_with_scope.rb
BSON.CodeWithScope.to_bson
def to_bson(buffer = ByteBuffer.new, validating_keys = Config.validating_keys?) position = buffer.length buffer.put_int32(0) buffer.put_string(javascript) scope.to_bson(buffer) buffer.replace_int32(position, buffer.length - position) end
ruby
def to_bson(buffer = ByteBuffer.new, validating_keys = Config.validating_keys?) position = buffer.length buffer.put_int32(0) buffer.put_string(javascript) scope.to_bson(buffer) buffer.replace_int32(position, buffer.length - position) end
[ "def", "to_bson", "(", "buffer", "=", "ByteBuffer", ".", "new", ",", "validating_keys", "=", "Config", ".", "validating_keys?", ")", "position", "=", "buffer", ".", "length", "buffer", ".", "put_int32", "(", "0", ")", "buffer", ".", "put_string", "(", "jav...
Instantiate the new code with scope. @example Instantiate the code with scope. BSON::CodeWithScope.new("this.value = name", name: "sid") @param [ String ] javascript The javascript code. @param [ Hash ] scope The variable scope. @since 2.0.0 Encode the javascript code with scope. @example Encode the code w...
[ "Instantiate", "the", "new", "code", "with", "scope", "." ]
297af124a7462f522b75fe9851ac81ce4fd33b0f
https://github.com/mongodb/bson-ruby/blob/297af124a7462f522b75fe9851ac81ce4fd33b0f/lib/bson/code_with_scope.rb#L90-L96
18,973
mongodb/bson-ruby
lib/bson/integer.rb
BSON.Integer.to_bson
def to_bson(buffer = ByteBuffer.new, validating_keys = Config.validating_keys?) if bson_int32? buffer.put_int32(self) elsif bson_int64? buffer.put_int64(self) else out_of_range! end end
ruby
def to_bson(buffer = ByteBuffer.new, validating_keys = Config.validating_keys?) if bson_int32? buffer.put_int32(self) elsif bson_int64? buffer.put_int64(self) else out_of_range! end end
[ "def", "to_bson", "(", "buffer", "=", "ByteBuffer", ".", "new", ",", "validating_keys", "=", "Config", ".", "validating_keys?", ")", "if", "bson_int32?", "buffer", ".", "put_int32", "(", "self", ")", "elsif", "bson_int64?", "buffer", ".", "put_int64", "(", "...
Get the integer as encoded BSON. @example Get the integer as encoded BSON. 1024.to_bson @return [ BSON::ByteBuffer ] The buffer with the encoded object. @see http://bsonspec.org/#/specification @since 2.0.0
[ "Get", "the", "integer", "as", "encoded", "BSON", "." ]
297af124a7462f522b75fe9851ac81ce4fd33b0f
https://github.com/mongodb/bson-ruby/blob/297af124a7462f522b75fe9851ac81ce4fd33b0f/lib/bson/integer.rb#L106-L114
18,974
mongodb/bson-ruby
lib/bson/object_id.rb
BSON.ObjectId.to_bson
def to_bson(buffer = ByteBuffer.new, validating_keys = Config.validating_keys?) buffer.put_bytes(generate_data) end
ruby
def to_bson(buffer = ByteBuffer.new, validating_keys = Config.validating_keys?) buffer.put_bytes(generate_data) end
[ "def", "to_bson", "(", "buffer", "=", "ByteBuffer", ".", "new", ",", "validating_keys", "=", "Config", ".", "validating_keys?", ")", "buffer", ".", "put_bytes", "(", "generate_data", ")", "end" ]
Get the object id as it's raw BSON data. @example Get the raw bson bytes. object_id.to_bson @note Since Moped's BSON and MongoDB BSON before 2.0.0 have different internal representations, we will attempt to repair the data for cases where the object was instantiated in a non-standard way. (Like a Marsha...
[ "Get", "the", "object", "id", "as", "it", "s", "raw", "BSON", "data", "." ]
297af124a7462f522b75fe9851ac81ce4fd33b0f
https://github.com/mongodb/bson-ruby/blob/297af124a7462f522b75fe9851ac81ce4fd33b0f/lib/bson/object_id.rb#L172-L174
18,975
mongodb/bson-ruby
lib/bson/true_class.rb
BSON.TrueClass.to_bson
def to_bson(buffer = ByteBuffer.new, validating_keys = Config.validating_keys?) buffer.put_byte(TRUE_BYTE) end
ruby
def to_bson(buffer = ByteBuffer.new, validating_keys = Config.validating_keys?) buffer.put_byte(TRUE_BYTE) end
[ "def", "to_bson", "(", "buffer", "=", "ByteBuffer", ".", "new", ",", "validating_keys", "=", "Config", ".", "validating_keys?", ")", "buffer", ".", "put_byte", "(", "TRUE_BYTE", ")", "end" ]
Get the true boolean as encoded BSON. @example Get the true boolean as encoded BSON. true.to_bson @return [ BSON::ByteBuffer ] The buffer with the encoded object. @see http://bsonspec.org/#/specification @since 2.0.0
[ "Get", "the", "true", "boolean", "as", "encoded", "BSON", "." ]
297af124a7462f522b75fe9851ac81ce4fd33b0f
https://github.com/mongodb/bson-ruby/blob/297af124a7462f522b75fe9851ac81ce4fd33b0f/lib/bson/true_class.rb#L52-L54
18,976
mongodb/bson-ruby
lib/bson/binary.rb
BSON.Binary.to_bson
def to_bson(buffer = ByteBuffer.new, validating_keys = Config.validating_keys?) position = buffer.length buffer.put_int32(0) buffer.put_byte(SUBTYPES[type]) buffer.put_int32(data.bytesize) if type == :old buffer.put_bytes(data.force_encoding(BINARY)) buffer.replace_int32(position, bu...
ruby
def to_bson(buffer = ByteBuffer.new, validating_keys = Config.validating_keys?) position = buffer.length buffer.put_int32(0) buffer.put_byte(SUBTYPES[type]) buffer.put_int32(data.bytesize) if type == :old buffer.put_bytes(data.force_encoding(BINARY)) buffer.replace_int32(position, bu...
[ "def", "to_bson", "(", "buffer", "=", "ByteBuffer", ".", "new", ",", "validating_keys", "=", "Config", ".", "validating_keys?", ")", "position", "=", "buffer", ".", "length", "buffer", ".", "put_int32", "(", "0", ")", "buffer", ".", "put_byte", "(", "SUBTY...
Encode the binary type @example Encode the binary. binary.to_bson @return [ BSON::ByteBuffer ] The buffer with the encoded object. @see http://bsonspec.org/#/specification @since 2.0.0
[ "Encode", "the", "binary", "type" ]
297af124a7462f522b75fe9851ac81ce4fd33b0f
https://github.com/mongodb/bson-ruby/blob/297af124a7462f522b75fe9851ac81ce4fd33b0f/lib/bson/binary.rb#L134-L141
18,977
mongodb/bson-ruby
lib/bson/registry.rb
BSON.Registry.get
def get(byte, field = nil) if type = MAPPINGS[byte] || (byte.is_a?(String) && type = MAPPINGS[byte.ord]) type else handle_unsupported_type!(byte, field) end end
ruby
def get(byte, field = nil) if type = MAPPINGS[byte] || (byte.is_a?(String) && type = MAPPINGS[byte.ord]) type else handle_unsupported_type!(byte, field) end end
[ "def", "get", "(", "byte", ",", "field", "=", "nil", ")", "if", "type", "=", "MAPPINGS", "[", "byte", "]", "||", "(", "byte", ".", "is_a?", "(", "String", ")", "&&", "type", "=", "MAPPINGS", "[", "byte", ".", "ord", "]", ")", "type", "else", "h...
Get the class for the single byte identifier for the type in the BSON specification. @example Get the type for the byte. BSON::Registry.get("\x01") @return [ Class ] The corresponding Ruby class for the type. @see http://bsonspec.org/#/specification @since 2.0.0
[ "Get", "the", "class", "for", "the", "single", "byte", "identifier", "for", "the", "type", "in", "the", "BSON", "specification", "." ]
297af124a7462f522b75fe9851ac81ce4fd33b0f
https://github.com/mongodb/bson-ruby/blob/297af124a7462f522b75fe9851ac81ce4fd33b0f/lib/bson/registry.rb#L42-L48
18,978
mongodb/bson-ruby
lib/bson/date.rb
BSON.Date.to_bson
def to_bson(buffer = ByteBuffer.new, validating_keys = Config.validating_keys?) buffer.put_int64((jd - DATE_REFERENCE) * MILLISECONDS_IN_DAY) end
ruby
def to_bson(buffer = ByteBuffer.new, validating_keys = Config.validating_keys?) buffer.put_int64((jd - DATE_REFERENCE) * MILLISECONDS_IN_DAY) end
[ "def", "to_bson", "(", "buffer", "=", "ByteBuffer", ".", "new", ",", "validating_keys", "=", "Config", ".", "validating_keys?", ")", "buffer", ".", "put_int64", "(", "(", "jd", "-", "DATE_REFERENCE", ")", "*", "MILLISECONDS_IN_DAY", ")", "end" ]
Get the date as encoded BSON. @example Get the date as encoded BSON. Date.new(2012, 1, 1).to_bson @return [ BSON::ByteBuffer ] The buffer with the encoded object. @see http://bsonspec.org/#/specification @since 2.1.0
[ "Get", "the", "date", "as", "encoded", "BSON", "." ]
297af124a7462f522b75fe9851ac81ce4fd33b0f
https://github.com/mongodb/bson-ruby/blob/297af124a7462f522b75fe9851ac81ce4fd33b0f/lib/bson/date.rb#L47-L49
18,979
mongodb/bson-ruby
lib/bson/regexp.rb
BSON.Regexp.to_bson
def to_bson(buffer = ByteBuffer.new, validating_keys = Config.validating_keys?) buffer.put_cstring(source) buffer.put_cstring(bson_options) end
ruby
def to_bson(buffer = ByteBuffer.new, validating_keys = Config.validating_keys?) buffer.put_cstring(source) buffer.put_cstring(bson_options) end
[ "def", "to_bson", "(", "buffer", "=", "ByteBuffer", ".", "new", ",", "validating_keys", "=", "Config", ".", "validating_keys?", ")", "buffer", ".", "put_cstring", "(", "source", ")", "buffer", ".", "put_cstring", "(", "bson_options", ")", "end" ]
Get the regular expression as encoded BSON. @example Get the regular expression as encoded BSON. %r{\d+}.to_bson @note From the BSON spec: The first cstring is the regex pattern, the second is the regex options string. Options are identified by characters, which must be stored in alphabetical order. Val...
[ "Get", "the", "regular", "expression", "as", "encoded", "BSON", "." ]
297af124a7462f522b75fe9851ac81ce4fd33b0f
https://github.com/mongodb/bson-ruby/blob/297af124a7462f522b75fe9851ac81ce4fd33b0f/lib/bson/regexp.rb#L92-L95
18,980
mongodb/bson-ruby
lib/bson/time.rb
BSON.Time.to_bson
def to_bson(buffer = ByteBuffer.new, validating_keys = Config.validating_keys?) buffer.put_int64((to_i * 1000) + (usec / 1000)) end
ruby
def to_bson(buffer = ByteBuffer.new, validating_keys = Config.validating_keys?) buffer.put_int64((to_i * 1000) + (usec / 1000)) end
[ "def", "to_bson", "(", "buffer", "=", "ByteBuffer", ".", "new", ",", "validating_keys", "=", "Config", ".", "validating_keys?", ")", "buffer", ".", "put_int64", "(", "(", "to_i", "*", "1000", ")", "+", "(", "usec", "/", "1000", ")", ")", "end" ]
Get the time as encoded BSON. @example Get the time as encoded BSON. Time.new(2012, 1, 1, 0, 0, 0).to_bson @return [ BSON::ByteBuffer ] The buffer with the encoded object. @see http://bsonspec.org/#/specification @since 2.0.0
[ "Get", "the", "time", "as", "encoded", "BSON", "." ]
297af124a7462f522b75fe9851ac81ce4fd33b0f
https://github.com/mongodb/bson-ruby/blob/297af124a7462f522b75fe9851ac81ce4fd33b0f/lib/bson/time.rb#L40-L42
18,981
mongodb/bson-ruby
lib/bson/document.rb
BSON.Document.fetch
def fetch(key, *args, &block) key = convert_key(key) super(key, *args, &block) end
ruby
def fetch(key, *args, &block) key = convert_key(key) super(key, *args, &block) end
[ "def", "fetch", "(", "key", ",", "*", "args", ",", "&", "block", ")", "key", "=", "convert_key", "(", "key", ")", "super", "(", "key", ",", "args", ",", "block", ")", "end" ]
Get a value from the document for the provided key. Can use string or symbol access, with string access being the faster of the two. @overload fetch(key) Returns a value from the hash for the given key. If the key does not exist, raises KeyError exception. @overload fetch(key, default) Returns a value fro...
[ "Get", "a", "value", "from", "the", "document", "for", "the", "provided", "key", ".", "Can", "use", "string", "or", "symbol", "access", "with", "string", "access", "being", "the", "faster", "of", "the", "two", "." ]
297af124a7462f522b75fe9851ac81ce4fd33b0f
https://github.com/mongodb/bson-ruby/blob/297af124a7462f522b75fe9851ac81ce4fd33b0f/lib/bson/document.rb#L68-L71
18,982
mongodb/bson-ruby
lib/bson/document.rb
BSON.Document.merge!
def merge!(other) other.each_pair do |key, value| value = yield(convert_key(key), self[key], convert_value(value)) if block_given? && self[key] self[key] = value end self end
ruby
def merge!(other) other.each_pair do |key, value| value = yield(convert_key(key), self[key], convert_value(value)) if block_given? && self[key] self[key] = value end self end
[ "def", "merge!", "(", "other", ")", "other", ".", "each_pair", "do", "|", "key", ",", "value", "|", "value", "=", "yield", "(", "convert_key", "(", "key", ")", ",", "self", "[", "key", "]", ",", "convert_value", "(", "value", ")", ")", "if", "block...
Merge this document with another document, returning the same document in the process. @example Merge with another document. document.merge(name: "Bob") @param [ BSON::Document, Hash ] other The document/hash to merge with. @return [ BSON::Document ] The result of the merge. @since 3.0.0
[ "Merge", "this", "document", "with", "another", "document", "returning", "the", "same", "document", "in", "the", "process", "." ]
297af124a7462f522b75fe9851ac81ce4fd33b0f
https://github.com/mongodb/bson-ruby/blob/297af124a7462f522b75fe9851ac81ce4fd33b0f/lib/bson/document.rb#L200-L206
18,983
mongodb/bson-ruby
lib/bson/symbol.rb
BSON.Symbol.to_bson_key
def to_bson_key(validating_keys = Config.validating_keys?) if validating_keys raise BSON::String::IllegalKey.new(self) if BSON::String::ILLEGAL_KEY =~ self end self end
ruby
def to_bson_key(validating_keys = Config.validating_keys?) if validating_keys raise BSON::String::IllegalKey.new(self) if BSON::String::ILLEGAL_KEY =~ self end self end
[ "def", "to_bson_key", "(", "validating_keys", "=", "Config", ".", "validating_keys?", ")", "if", "validating_keys", "raise", "BSON", "::", "String", "::", "IllegalKey", ".", "new", "(", "self", ")", "if", "BSON", "::", "String", "::", "ILLEGAL_KEY", "=~", "s...
Get the symbol as a BSON key name encoded C symbol. @example Get the symbol as a key name. :test.to_bson_key @return [ String ] The encoded symbol as a BSON key. @see http://bsonspec.org/#/specification @since 2.0.0
[ "Get", "the", "symbol", "as", "a", "BSON", "key", "name", "encoded", "C", "symbol", "." ]
297af124a7462f522b75fe9851ac81ce4fd33b0f
https://github.com/mongodb/bson-ruby/blob/297af124a7462f522b75fe9851ac81ce4fd33b0f/lib/bson/symbol.rb#L73-L78
18,984
YorickPeterse/ruby-lint
lib/ruby-lint/inspector.rb
RubyLint.Inspector.inspect_methods
def inspect_methods return [] unless constant.respond_to?(:methods) methods = get_methods.map do |name| method_information(:method, name) end return methods.sort_by(&:name) end
ruby
def inspect_methods return [] unless constant.respond_to?(:methods) methods = get_methods.map do |name| method_information(:method, name) end return methods.sort_by(&:name) end
[ "def", "inspect_methods", "return", "[", "]", "unless", "constant", ".", "respond_to?", "(", ":methods", ")", "methods", "=", "get_methods", ".", "map", "do", "|", "name", "|", "method_information", "(", ":method", ",", "name", ")", "end", "return", "methods...
Returns an Array containing all method objects sorted by their names. @return [Array]
[ "Returns", "an", "Array", "containing", "all", "method", "objects", "sorted", "by", "their", "names", "." ]
87842ae295c2283d8e02d951781189486a7cc970
https://github.com/YorickPeterse/ruby-lint/blob/87842ae295c2283d8e02d951781189486a7cc970/lib/ruby-lint/inspector.rb#L94-L102
18,985
YorickPeterse/ruby-lint
lib/ruby-lint/inspector.rb
RubyLint.Inspector.inspect_modules
def inspect_modules modules = [] if constant.respond_to?(:ancestors) parent = inspect_superclass # Take all the modules included *directly* into the constant. modules = constant.ancestors.take_while do |ancestor| parent && ancestor != parent end # Get rid...
ruby
def inspect_modules modules = [] if constant.respond_to?(:ancestors) parent = inspect_superclass # Take all the modules included *directly* into the constant. modules = constant.ancestors.take_while do |ancestor| parent && ancestor != parent end # Get rid...
[ "def", "inspect_modules", "modules", "=", "[", "]", "if", "constant", ".", "respond_to?", "(", ":ancestors", ")", "parent", "=", "inspect_superclass", "# Take all the modules included *directly* into the constant.", "modules", "=", "constant", ".", "ancestors", ".", "ta...
Returns the modules that are included in the constant. @return [Array]
[ "Returns", "the", "modules", "that", "are", "included", "in", "the", "constant", "." ]
87842ae295c2283d8e02d951781189486a7cc970
https://github.com/YorickPeterse/ruby-lint/blob/87842ae295c2283d8e02d951781189486a7cc970/lib/ruby-lint/inspector.rb#L124-L142
18,986
YorickPeterse/ruby-lint
lib/ruby-lint/inspector.rb
RubyLint.Inspector.inspect_superclass
def inspect_superclass parent = nil if constant.respond_to?(:superclass) \ and constant.superclass \ and constant.superclass.name return constant.superclass end return parent end
ruby
def inspect_superclass parent = nil if constant.respond_to?(:superclass) \ and constant.superclass \ and constant.superclass.name return constant.superclass end return parent end
[ "def", "inspect_superclass", "parent", "=", "nil", "if", "constant", ".", "respond_to?", "(", ":superclass", ")", "and", "constant", ".", "superclass", "and", "constant", ".", "superclass", ".", "name", "return", "constant", ".", "superclass", "end", "return", ...
Returns the superclass of the current constant or `nil` if there is none. @return [Mixed]
[ "Returns", "the", "superclass", "of", "the", "current", "constant", "or", "nil", "if", "there", "is", "none", "." ]
87842ae295c2283d8e02d951781189486a7cc970
https://github.com/YorickPeterse/ruby-lint/blob/87842ae295c2283d8e02d951781189486a7cc970/lib/ruby-lint/inspector.rb#L149-L159
18,987
YorickPeterse/ruby-lint
lib/ruby-lint/inspector.rb
RubyLint.Inspector.get_methods
def get_methods(getter = :methods) parent = inspect_superclass || Object diff = constant.__send__(getter, false) - parent.__send__(getter, false) methods = diff | constant.__send__(getter, false) # If the constant manually defines the initialize method (= private) # we'll also ...
ruby
def get_methods(getter = :methods) parent = inspect_superclass || Object diff = constant.__send__(getter, false) - parent.__send__(getter, false) methods = diff | constant.__send__(getter, false) # If the constant manually defines the initialize method (= private) # we'll also ...
[ "def", "get_methods", "(", "getter", "=", ":methods", ")", "parent", "=", "inspect_superclass", "||", "Object", "diff", "=", "constant", ".", "__send__", "(", "getter", ",", "false", ")", "-", "parent", ".", "__send__", "(", "getter", ",", "false", ")", ...
Gets the methods of the current constant minus those defined in Object. @param [Symbol] getter @return [Array]
[ "Gets", "the", "methods", "of", "the", "current", "constant", "minus", "those", "defined", "in", "Object", "." ]
87842ae295c2283d8e02d951781189486a7cc970
https://github.com/YorickPeterse/ruby-lint/blob/87842ae295c2283d8e02d951781189486a7cc970/lib/ruby-lint/inspector.rb#L167-L181
18,988
YorickPeterse/ruby-lint
lib/ruby-lint/inspector.rb
RubyLint.Inspector.resolve_constant
def resolve_constant(constant) current = Object final = nil constant.split('::').each do |segment| if current.const_defined?(segment) current = final = current.const_get(segment) else raise( ArgumentError, "Constant #{segment} does not exi...
ruby
def resolve_constant(constant) current = Object final = nil constant.split('::').each do |segment| if current.const_defined?(segment) current = final = current.const_get(segment) else raise( ArgumentError, "Constant #{segment} does not exi...
[ "def", "resolve_constant", "(", "constant", ")", "current", "=", "Object", "final", "=", "nil", "constant", ".", "split", "(", "'::'", ")", ".", "each", "do", "|", "segment", "|", "if", "current", ".", "const_defined?", "(", "segment", ")", "current", "=...
Converts a String based constant path into an actual constant. @param [String] constant @return [Class] @raise [ArgumentError] Raised when one of the segments doesn't exist.
[ "Converts", "a", "String", "based", "constant", "path", "into", "an", "actual", "constant", "." ]
87842ae295c2283d8e02d951781189486a7cc970
https://github.com/YorickPeterse/ruby-lint/blob/87842ae295c2283d8e02d951781189486a7cc970/lib/ruby-lint/inspector.rb#L243-L259
18,989
YorickPeterse/ruby-lint
lib/ruby-lint/iterator.rb
RubyLint.Iterator.execute_callback
def execute_callback(name, *args) return unless respond_to?(name) unless arity_cache.key?(name) arity_cache[name] = method(name).arity end if arity_cache[name] == 0 send(name) else send(name, *args) end end
ruby
def execute_callback(name, *args) return unless respond_to?(name) unless arity_cache.key?(name) arity_cache[name] = method(name).arity end if arity_cache[name] == 0 send(name) else send(name, *args) end end
[ "def", "execute_callback", "(", "name", ",", "*", "args", ")", "return", "unless", "respond_to?", "(", "name", ")", "unless", "arity_cache", ".", "key?", "(", "name", ")", "arity_cache", "[", "name", "]", "=", "method", "(", "name", ")", ".", "arity", ...
Executes the specified callback method if it exists. @param [String|Symbol] name The name of the callback method to execute. @param [Array] args Arguments to pass to the callback method.
[ "Executes", "the", "specified", "callback", "method", "if", "it", "exists", "." ]
87842ae295c2283d8e02d951781189486a7cc970
https://github.com/YorickPeterse/ruby-lint/blob/87842ae295c2283d8e02d951781189486a7cc970/lib/ruby-lint/iterator.rb#L115-L127
18,990
YorickPeterse/ruby-lint
lib/ruby-lint/constant_path.rb
RubyLint.ConstantPath.constant_segments
def constant_segments(node = self.node) segments = [] if has_child_node?(node) segments.concat(constant_segments(node.children[0])) end segments << [node.type, name_for_node(node)] return segments end
ruby
def constant_segments(node = self.node) segments = [] if has_child_node?(node) segments.concat(constant_segments(node.children[0])) end segments << [node.type, name_for_node(node)] return segments end
[ "def", "constant_segments", "(", "node", "=", "self", ".", "node", ")", "segments", "=", "[", "]", "if", "has_child_node?", "(", "node", ")", "segments", ".", "concat", "(", "constant_segments", "(", "node", ".", "children", "[", "0", "]", ")", ")", "e...
Returns an Array containing the segments of a constant path. @param [RubyLint::AST::Node] node @return [Array<Array(Symbol,String)>]
[ "Returns", "an", "Array", "containing", "the", "segments", "of", "a", "constant", "path", "." ]
87842ae295c2283d8e02d951781189486a7cc970
https://github.com/YorickPeterse/ruby-lint/blob/87842ae295c2283d8e02d951781189486a7cc970/lib/ruby-lint/constant_path.rb#L74-L84
18,991
YorickPeterse/ruby-lint
lib/ruby-lint/constant_loader.rb
RubyLint.ConstantLoader.bootstrap
def bootstrap types = VariablePredicates::RUBY_CLASSES.values (BOOTSTRAP_CONSTS | types).each do |name| load_constant(name) end BOOTSTRAP_GVARS.each do |gvar| definitions.define_global_variable(gvar) end end
ruby
def bootstrap types = VariablePredicates::RUBY_CLASSES.values (BOOTSTRAP_CONSTS | types).each do |name| load_constant(name) end BOOTSTRAP_GVARS.each do |gvar| definitions.define_global_variable(gvar) end end
[ "def", "bootstrap", "types", "=", "VariablePredicates", "::", "RUBY_CLASSES", ".", "values", "(", "BOOTSTRAP_CONSTS", "|", "types", ")", ".", "each", "do", "|", "name", "|", "load_constant", "(", "name", ")", "end", "BOOTSTRAP_GVARS", ".", "each", "do", "|",...
Bootstraps various core definitions.
[ "Bootstraps", "various", "core", "definitions", "." ]
87842ae295c2283d8e02d951781189486a7cc970
https://github.com/YorickPeterse/ruby-lint/blob/87842ae295c2283d8e02d951781189486a7cc970/lib/ruby-lint/constant_loader.rb#L49-L59
18,992
YorickPeterse/ruby-lint
lib/ruby-lint/constant_loader.rb
RubyLint.ConstantLoader.load_nested_constant
def load_nested_constant(constant) if constant.start_with?("::") constant = constant.sub(/^::/, "") else # ["A", "B", "C"] -> ["A::B::C", "A::B", "A"] namespaces = module_nesting.size.downto(1).map do |n| module_nesting.take(n).join("::") end namespaces.eac...
ruby
def load_nested_constant(constant) if constant.start_with?("::") constant = constant.sub(/^::/, "") else # ["A", "B", "C"] -> ["A::B::C", "A::B", "A"] namespaces = module_nesting.size.downto(1).map do |n| module_nesting.take(n).join("::") end namespaces.eac...
[ "def", "load_nested_constant", "(", "constant", ")", "if", "constant", ".", "start_with?", "(", "\"::\"", ")", "constant", "=", "constant", ".", "sub", "(", "/", "/", ",", "\"\"", ")", "else", "# [\"A\", \"B\", \"C\"] -> [\"A::B::C\", \"A::B\", \"A\"]", "namespaces"...
Tries to load the definitions for the given constant. Takes into account what modules we are in to resolve the constant name. @param [String] constant name, possibly unqualified
[ "Tries", "to", "load", "the", "definitions", "for", "the", "given", "constant", ".", "Takes", "into", "account", "what", "modules", "we", "are", "in", "to", "resolve", "the", "constant", "name", "." ]
87842ae295c2283d8e02d951781189486a7cc970
https://github.com/YorickPeterse/ruby-lint/blob/87842ae295c2283d8e02d951781189486a7cc970/lib/ruby-lint/constant_loader.rb#L131-L145
18,993
YorickPeterse/ruby-lint
lib/ruby-lint/constant_loader.rb
RubyLint.ConstantLoader.load_constant
def load_constant(constant) return if loaded?(constant) registry.load(constant) return unless registry.include?(constant) apply(constant) end
ruby
def load_constant(constant) return if loaded?(constant) registry.load(constant) return unless registry.include?(constant) apply(constant) end
[ "def", "load_constant", "(", "constant", ")", "return", "if", "loaded?", "(", "constant", ")", "registry", ".", "load", "(", "constant", ")", "return", "unless", "registry", ".", "include?", "(", "constant", ")", "apply", "(", "constant", ")", "end" ]
Tries to load the definitions for the given constant. @param [String] constant
[ "Tries", "to", "load", "the", "definitions", "for", "the", "given", "constant", "." ]
87842ae295c2283d8e02d951781189486a7cc970
https://github.com/YorickPeterse/ruby-lint/blob/87842ae295c2283d8e02d951781189486a7cc970/lib/ruby-lint/constant_loader.rb#L152-L160
18,994
YorickPeterse/ruby-lint
lib/ruby-lint/configuration.rb
RubyLint.Configuration.report_levels=
def report_levels=(given) available = self.class.available_report_levels levels = [] given.each do |level| levels << available[level] if available[level] end if levels.empty? levels = default_report_levels end @report_levels = levels end
ruby
def report_levels=(given) available = self.class.available_report_levels levels = [] given.each do |level| levels << available[level] if available[level] end if levels.empty? levels = default_report_levels end @report_levels = levels end
[ "def", "report_levels", "=", "(", "given", ")", "available", "=", "self", ".", "class", ".", "available_report_levels", "levels", "=", "[", "]", "given", ".", "each", "do", "|", "level", "|", "levels", "<<", "available", "[", "level", "]", "if", "availab...
Sets a list of the enabled report levels. @param [Array] given The report levels specified by the user. @return [Array]
[ "Sets", "a", "list", "of", "the", "enabled", "report", "levels", "." ]
87842ae295c2283d8e02d951781189486a7cc970
https://github.com/YorickPeterse/ruby-lint/blob/87842ae295c2283d8e02d951781189486a7cc970/lib/ruby-lint/configuration.rb#L135-L148
18,995
YorickPeterse/ruby-lint
lib/ruby-lint/configuration.rb
RubyLint.Configuration.analysis_classes=
def analysis_classes=(names) classes = [] available = self.class.available_analysis_classes names.each do |name| classes << available[name] if available[name] end if classes.empty? classes = default_analysis_classes end @analysis_classes = classes end
ruby
def analysis_classes=(names) classes = [] available = self.class.available_analysis_classes names.each do |name| classes << available[name] if available[name] end if classes.empty? classes = default_analysis_classes end @analysis_classes = classes end
[ "def", "analysis_classes", "=", "(", "names", ")", "classes", "=", "[", "]", "available", "=", "self", ".", "class", ".", "available_analysis_classes", "names", ".", "each", "do", "|", "name", "|", "classes", "<<", "available", "[", "name", "]", "if", "a...
Sets a collection of the analysis constants to use. @param [Array] names The analysis names as given by the user. @return [Array]
[ "Sets", "a", "collection", "of", "the", "analysis", "constants", "to", "use", "." ]
87842ae295c2283d8e02d951781189486a7cc970
https://github.com/YorickPeterse/ruby-lint/blob/87842ae295c2283d8e02d951781189486a7cc970/lib/ruby-lint/configuration.rb#L174-L187
18,996
YorickPeterse/ruby-lint
lib/ruby-lint/rake_task.rb
RubyLint.RakeTask.run_task
def run_task config = create_configuration runner = RubyLint::Runner.new(config) list = FileList.new output = runner.analyze(list.process(files)) puts(output) unless output.empty? end
ruby
def run_task config = create_configuration runner = RubyLint::Runner.new(config) list = FileList.new output = runner.analyze(list.process(files)) puts(output) unless output.empty? end
[ "def", "run_task", "config", "=", "create_configuration", "runner", "=", "RubyLint", "::", "Runner", ".", "new", "(", "config", ")", "list", "=", "FileList", ".", "new", "output", "=", "runner", ".", "analyze", "(", "list", ".", "process", "(", "files", ...
Processes a list of files and writes the output to STDOUT.
[ "Processes", "a", "list", "of", "files", "and", "writes", "the", "output", "to", "STDOUT", "." ]
87842ae295c2283d8e02d951781189486a7cc970
https://github.com/YorickPeterse/ruby-lint/blob/87842ae295c2283d8e02d951781189486a7cc970/lib/ruby-lint/rake_task.rb#L73-L80
18,997
YorickPeterse/ruby-lint
lib/ruby-lint/file_scanner.rb
RubyLint.FileScanner.build_constant_paths_cache
def build_constant_paths_cache(constant) paths = match_globbed_files(constant_to_path(constant)) # Lets see if we can find anything when using dashes for the directory # names instead of underscores. if paths.empty? paths = match_globbed_files(constant_to_dashed_path(constant)) en...
ruby
def build_constant_paths_cache(constant) paths = match_globbed_files(constant_to_path(constant)) # Lets see if we can find anything when using dashes for the directory # names instead of underscores. if paths.empty? paths = match_globbed_files(constant_to_dashed_path(constant)) en...
[ "def", "build_constant_paths_cache", "(", "constant", ")", "paths", "=", "match_globbed_files", "(", "constant_to_path", "(", "constant", ")", ")", "# Lets see if we can find anything when using dashes for the directory", "# names instead of underscores.", "if", "paths", ".", "...
Searches all the files that could potentially define the given constant and caches them. @param [String] constant
[ "Searches", "all", "the", "files", "that", "could", "potentially", "define", "the", "given", "constant", "and", "caches", "them", "." ]
87842ae295c2283d8e02d951781189486a7cc970
https://github.com/YorickPeterse/ruby-lint/blob/87842ae295c2283d8e02d951781189486a7cc970/lib/ruby-lint/file_scanner.rb#L130-L154
18,998
YorickPeterse/ruby-lint
lib/ruby-lint/runner.rb
RubyLint.Runner.parse_file
def parse_file(parser, file) return parser.parse(File.read(file, :encoding => Encoding::UTF_8), file) end
ruby
def parse_file(parser, file) return parser.parse(File.read(file, :encoding => Encoding::UTF_8), file) end
[ "def", "parse_file", "(", "parser", ",", "file", ")", "return", "parser", ".", "parse", "(", "File", ".", "read", "(", "file", ",", ":encoding", "=>", "Encoding", "::", "UTF_8", ")", ",", "file", ")", "end" ]
Parses the given file and returns an Array containing all the associated AST nodes and comments. @param [RubyLint::Parser] parser @param [String] file @return [Array]
[ "Parses", "the", "given", "file", "and", "returns", "an", "Array", "containing", "all", "the", "associated", "AST", "nodes", "and", "comments", "." ]
87842ae295c2283d8e02d951781189486a7cc970
https://github.com/YorickPeterse/ruby-lint/blob/87842ae295c2283d8e02d951781189486a7cc970/lib/ruby-lint/runner.rb#L71-L73
18,999
YorickPeterse/ruby-lint
lib/ruby-lint/runner.rb
RubyLint.Runner.run_analysis
def run_analysis(ast, vm, report) classes = configuration.analysis_classes.select do |const| const.analyze?(ast, vm) end classes.each do |const| instance = const.new( :vm => vm, :report => report, :config => configuration ) instance.i...
ruby
def run_analysis(ast, vm, report) classes = configuration.analysis_classes.select do |const| const.analyze?(ast, vm) end classes.each do |const| instance = const.new( :vm => vm, :report => report, :config => configuration ) instance.i...
[ "def", "run_analysis", "(", "ast", ",", "vm", ",", "report", ")", "classes", "=", "configuration", ".", "analysis_classes", ".", "select", "do", "|", "const", "|", "const", ".", "analyze?", "(", "ast", ",", "vm", ")", "end", "classes", ".", "each", "do...
Runs all the registered analysis classes. @param [RubyLint::AST::Node] ast @param [RubyLint::VirtualMachine] vm @param [RubyLint::Report] report
[ "Runs", "all", "the", "registered", "analysis", "classes", "." ]
87842ae295c2283d8e02d951781189486a7cc970
https://github.com/YorickPeterse/ruby-lint/blob/87842ae295c2283d8e02d951781189486a7cc970/lib/ruby-lint/runner.rb#L137-L151