idx int64 0 24.9k | question stringlengths 68 4.14k | target stringlengths 9 749 |
|---|---|---|
8,600 | def disable_vuln_check ( check_id ) checks = REXML :: XPath . first ( @xml , '//VulnerabilityChecks' ) checks . elements . delete ( "Enabled/Check[@id='#{check_id}']" ) disabled_checks = checks . elements [ 'Disabled' ] || checks . add_element ( 'Disabled' ) disabled_checks . add_element ( 'Check' , { 'id' => check_id ... | Disable individual check for this template . |
8,601 | def remove_vuln_check ( check_id ) checks = REXML :: XPath . first ( @xml , '//VulnerabilityChecks' ) checks . elements . delete ( "Disabled/Check[@id='#{check_id}']" ) checks . elements . delete ( "Enabled/Check[@id='#{check_id}']" ) end | Remove individual check for this template . Removes both enabled and disabled checks . |
8,602 | def save ( nsc ) root = REXML :: XPath . first ( @xml , 'ScanTemplate' ) if root . attributes [ 'id' ] == '#NewScanTemplate#' response = JSON . parse ( AJAX . post ( nsc , '/data/scan/templates' , xml ) ) root . attributes [ 'id' ] = response [ 'value' ] else response = JSON . parse ( AJAX . put ( nsc , "/data/scan/tem... | Save this scan template configuration to a Nexpose console . |
8,603 | def aces_level = ( level ) return if level . nil? return unless [ 'full' , 'default' , 'none' ] . include? level . downcase logging = REXML :: XPath . first ( @xml , 'ScanTemplate/Logging' ) if logging . nil? logging = REXML :: Element . new ( 'Logging' ) @xml . add_element ( logging ) end aces = REXML :: XPath . first... | Enable or disable asset configuration scanning for this template . If the level is not full default or none this is a no - op . |
8,604 | def enable_debug_logging = ( enable ) return if enable . nil? logging = REXML :: XPath . first ( @xml , 'ScanTemplate/Logging' ) if logging . nil? logging = REXML :: Element . new ( 'Logging' ) @xml . add_element ( logging ) end debug_logging = REXML :: XPath . first ( logging , 'debugLogging' ) if debug_logging . nil?... | Enable or disable the debug logging . |
8,605 | def windows_service_editor = ( enable ) cifs_scanner = REXML :: XPath . first ( @xml , 'ScanTemplate/Plugins/Plugin[@name="java/CifsScanner"]' ) param = REXML :: XPath . first ( cifs_scanner , './param[@name="windowsServiceEditor"]' ) if param param . text = ( enable ? '1' : '0' ) else param = REXML :: Element . new ( ... | Enable or disable windows service editor . |
8,606 | def role_listing xml = make_xml ( 'RoleListingRequest' ) r = execute ( xml , '1.2' ) roles = [ ] if r . success r . res . elements . each ( 'RoleListingResponse/RoleSummary' ) do | summary | roles << RoleSummary . parse ( summary ) end end roles end | Returns a summary list of all roles . |
8,607 | def save ( nsc ) if @existing xml = nsc . make_xml ( 'RoleUpdateRequest' ) else xml = nsc . make_xml ( 'RoleCreateRequest' ) end xml . add_element ( as_xml ) response = APIRequest . execute ( nsc . url , xml , '1.2' , { timeout : nsc . timeout , open_timeout : nsc . open_timeout } ) xml = REXML :: XPath . first ( respo... | Create or save a Role to the Nexpose console . |
8,608 | def get ( nsc , uri , content_type = CONTENT_TYPE :: XML , options = { } ) parameterize_uri ( uri , options ) get = Net :: HTTP :: Get . new ( uri ) get . set_content_type ( content_type ) request ( nsc , get ) end | GET call to a Nexpose controller . |
8,609 | def put ( nsc , uri , payload = nil , content_type = CONTENT_TYPE :: XML ) put = Net :: HTTP :: Put . new ( uri ) put . set_content_type ( content_type ) put . body = payload . to_s if payload request ( nsc , put ) end | PUT call to a Nexpose controller . |
8,610 | def post ( nsc , uri , payload = nil , content_type = CONTENT_TYPE :: XML , timeout = nil ) post = Net :: HTTP :: Post . new ( uri ) post . set_content_type ( content_type ) post . body = payload . to_s if payload request ( nsc , post , timeout ) end | POST call to a Nexpose controller . |
8,611 | def patch ( nsc , uri , payload = nil , content_type = CONTENT_TYPE :: XML ) patch = Net :: HTTP :: Patch . new ( uri ) patch . set_content_type ( content_type ) patch . body = payload . to_s if payload request ( nsc , patch ) end | PATCH call to a Nexpose controller . |
8,612 | def form_post ( nsc , uri , parameters , content_type = CONTENT_TYPE :: FORM ) post = Net :: HTTP :: Post . new ( uri ) post . set_content_type ( content_type ) post . set_form_data ( parameters ) request ( nsc , post ) end | POST call to a Nexpose controller that uses a form - post model . This is here to support legacy use of POST in old controllers . |
8,613 | def delete ( nsc , uri , content_type = CONTENT_TYPE :: XML ) delete = Net :: HTTP :: Delete . new ( uri ) delete . set_content_type ( content_type ) request ( nsc , delete ) end | DELETE call to a Nexpose controller . |
8,614 | def get_error_message ( request , response ) version = get_request_api_version ( request ) data_request = use_response_error_message? ( request , response ) return_response = ( version >= 2.1 || data_request ) ( return_response && response . body ) ? "response body: #{response.body}" : "request body: #{request.body}" e... | Get an error message from the response body if the request url api version is 2 . 1 or greater otherwise use the request body |
8,615 | def use_response_error_message? ( request , response ) if ( request . path . include? ( '/data/' ) && ! response . content_type . nil? ) response . content_type . include? 'text/plain' else false end end | Code cleanup to allow for cleaner get_error_message method |
8,616 | def preserving_preference ( nsc , pref ) orig = get_rows ( nsc , pref ) yield ensure set_rows ( nsc , pref , orig ) end | Execute a block of code while presenving the preferences for any underlying table being accessed . Use this method when accessing data tables which are present in the UI to prevent existing row preferences from being set to 500 . |
8,617 | def filter ( field , operator , value = '' ) criterion = Criterion . new ( field , operator , value ) criteria = Criteria . new ( criterion ) search ( criteria ) end | Perform an asset filter search that will locate assets matching the provided conditions . |
8,618 | def search ( criteria ) results = DataTable . _get_json_table ( self , '/data/asset/filterAssets' , criteria . _to_payload ) results . map { | a | FilteredAsset . new ( a ) } end | Perform a search that will match the criteria provided . |
8,619 | def login login_hash = { 'sync-id' => 0 , 'password' => @password , 'user-id' => @username , 'token' => @token } login_hash [ 'silo-id' ] = @silo_id if @silo_id r = execute ( make_xml ( 'LoginRequest' , login_hash ) ) if r . success @session_id = r . sid true end rescue APIError raise AuthenticationFailed . new ( r ) e... | A constructor for Connection |
8,620 | def logout r = execute ( make_xml ( 'LogoutRequest' , { 'sync-id' => 0 } ) ) return true if r . success raise APIError . new ( r , 'Logout failed' ) end | Logout of the current connection |
8,621 | def execute ( xml , version = '1.1' , options = { } ) options . store ( :timeout , @timeout ) unless options . key? ( :timeout ) options . store ( :open_timeout , @open_timeout ) @request_xml = xml . to_s @api_version = version response = APIRequest . execute ( @url , @request_xml , @api_version , options , @trust_stor... | Execute an API request |
8,622 | def download ( url , file_name = nil ) return nil if ( url . nil? || url . empty? ) uri = URI . parse ( url ) http = Net :: HTTP . new ( @host , @port ) http . use_ssl = true if @trust_store . nil? http . verify_mode = OpenSSL :: SSL :: VERIFY_NONE else http . cert_store = @trust_store end headers = { 'Cookie' => "nexp... | Download a specific URL typically a report . Include an optional file_name parameter to write the output to a file . |
8,623 | def find_device_by_address ( address , site_id = nil ) r = execute ( make_xml ( 'SiteDeviceListingRequest' , { 'site-id' => site_id } ) ) if r . success device = REXML :: XPath . first ( r . res , "SiteDeviceListingResponse/SiteDevices/device[@address='#{address}']" ) if device return Device . new ( device . attributes... | Find a Device by its address . |
8,624 | def list_site_devices ( site_id = nil ) r = execute ( make_xml ( 'SiteDeviceListingRequest' , { 'site-id' => site_id } ) ) devices = [ ] if r . success r . res . elements . each ( 'SiteDeviceListingResponse/SiteDevices' ) do | site | site_id = site . attributes [ 'site-id' ] . to_i site . elements . each ( 'device' ) d... | Retrieve a list of all of the assets in a site . |
8,625 | def group_assets ( group_id ) payload = { 'sort' => 'assetName' , 'table-id' => 'group-assets' , 'groupID' => group_id } results = DataTable . _get_json_table ( self , '/data/asset/group' , payload ) results . map { | a | FilteredAsset . new ( a ) } end | Get a list of all assets currently associated with a group . |
8,626 | 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 ) json . map { | vuln | VulnFinding . new ( vuln ) } end | List the vulnerability findings for a given device ID . |
8,627 | 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 | 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 . |
8,628 | 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 |
8,629 | 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 | save an alert for a given site |
8,630 | 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 arr end | Retrieve a list of all users the user is authorized to view or manage . |
8,631 | 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 | Removes a scan engine from the list of available engines . |
8,632 | 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 | Provide a list of current scan activities for a specific Scan Engine . |
8,633 | 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' ] , engine . attributes [ 'address' ] , engine ... | Retrieve a list of all Scan Engines managed by the Security Console . |
8,634 | 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 [ 'id' ] . to_i end en... | Save this engine configuration to the security console . |
8,635 | 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 | Retrieve all vulnerability definitions currently in a Nexpose console . |
8,636 | 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 | Search for any vulnerability definitions which refer to a given CVE . |
8,637 | 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 | VulnerabilityDefinition . new . object_from_hash ( self , e... | Search for any vulnerability definitions which refer to a given reference ID . |
8,638 | 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 | Vulnerabilit... | Search for any vulnerability definitions which refer to a given title . |
8,639 | 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 | Lists all tags |
8,640 | 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 <... | Lists all the tags on an asset |
8,641 | 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 | Lists all the tags on a site |
8,642 | 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 ) en... | Lists all the tags on an asset_group |
8,643 | 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 | Returns the criticality value which takes precedent for an asset |
8,644 | 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 | Set the color but validate it |
8,645 | 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 | Creates and saves a tag to Nexpose console |
8,646 | 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 | Adds a tag to an asset |
8,647 | 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 | Adds a tag to a site |
8,648 | 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 | Adds a tag to an asset group |
8,649 | 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 . nil? res... | Retrieve all active vulnerability exceptions . |
8,650 | 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_element ( comment_xml ) r = execute ( xml , '... | Resubmit a vulnerability exception request with a new comment and reason after an exception has been rejected . |
8,651 | 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_ON_A_SPECIFIC_ASSET xml . add_attributes ( { 'device-id' => @asset_i... | Submit this exception on the security console . |
8,652 | 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 = comment end connection . execute ( xml , '1.2' )... | Approve a vulnerability exception request update comments and expiration dates on vulnerability exceptions that are Under Review . |
8,653 | 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 | Update the expiration date for this exception . The expiration time cannot be in the past . |
8,654 | 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_A_SPECIFIC_ASSET raise Arg... | Validate that this exception meets to requires for the assigned scope . |
8,655 | 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 . |
8,656 | 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/global/maintenance/maintCmd.txml' , parameters ) if ! ! ( xml =~ / ... | 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 . |
8,657 | 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 [ 'reindex' ] = 1 if rei... | 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 . |
8,658 | 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' => password } xml = AJAX . form_post ( nsc , '/admin/global/mainten... | Restore this backup to the Nexpose console . It will restart the console after acknowledging receiving the request . |
8,659 | 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.messag... | Convert a host or IP address to the corresponding HostName or IPRange class . |
8,660 | 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 . |
8,661 | def save ( nsc ) 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_exclusions ( xml , asset_exclusions ) add_control_scanning_to_xml ( xml , control... | Save any updates to this settings object to the Nexpose console . |
8,662 | 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 | Add an asset exclusion setting . |
8,663 | def remove_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_exclusions . reject { | a | a . eql? asset } end | 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 . |
8,664 | 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 | Internal method for updating exclusions before saving . |
8,665 | 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 | Internal method for parsing XML for whether control scanning in enabled . |
8,666 | 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' => enabled ? '1' : '0' ) end ... | Internal method for updating control scanning before saving . |
8,667 | 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 | Internal method for parsing XML for whether asset linking in enabled . |
8,668 | 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 | Internal method for updating asset linking before saving . |
8,669 | 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 | sets the DB2 service |
8,670 | 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 :: Service :: TDS end | sets the Microsoft SQL Server service . |
8,671 | 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 | sets the MySQL Server service . |
8,672 | 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 | sets the Oracle service . |
8,673 | 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 | sets the PostgreSQL service . |
8,674 | def set_remote_execution_service ( username = nil , password = nil ) self . user_name = username self . password = password self . service = Credential :: Service :: REMOTE_EXECUTION end | sets the Remote Execution service . |
8,675 | 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 = password self . priva... | sets the Simple Network Management Protocol v3 service . |
8,676 | 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 = Credential :: Service :: SYBASE end | sets the Sybase SQL Server service . |
8,677 | def set_telnet_service ( username = nil , password = nil ) self . user_name = username self . password = password self . service = Credential :: Service :: TELNET end | sets the Telnet service . |
8,678 | 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 | sets the Web Site HTTP Authentication service . |
8,679 | 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 | Retrieve a list of all users configured on this console . |
8,680 | 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 ( conn ) end connections ... | Retrieve information about all available connections for dynamic discovery of assets including whether or not connections are active . |
8,681 | 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 . |
8,682 | 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? end en... | Create a new discovery connection . |
8,683 | 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/discoveryAsset/discoverAssets' , parameters ) data . map { | a ... | Perform dynamic discover of assets against this connection . |
8,684 | def connect ( nsc ) xml = nsc . make_xml ( 'DiscoveryConnectionConnectRequest' , { 'id' => id } ) response = nsc . execute ( xml , '1.2' ) response . success end | Initiates a connection to a target used for dynamic discovery of assets . As long as a connection is active dynamic discovery is continuous . |
8,685 | 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 . attributes [ 'name' ] , group . attributes [... | Retrieve an array of all asset groups the user is authorized to view or manage . |
8,686 | 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 ( @description ) xml . add_element ( e... | Generate an XML representation of this group configuration |
8,687 | 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 | Launch ad hoc scans against each group of assets per site . |
8,688 | 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 [ :ecs_container_credentials_relati... | get AWS Credentials |
8,689 | 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 . |
8,690 | 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 | Converts the given time to the local timezone and includes the UTC offset in the result . |
8,691 | 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 mid unless yield ( t... | Find the first rule that matches using binary search . |
8,692 | 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 | Get the OpenStruct as encoded BSON . |
8,693 | 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 ) buffer . put_cstring ( fie... | Get the hash as encoded BSON . |
8,694 | def to_bson ( buffer = ByteBuffer . new , validating_keys = Config . validating_keys? ) buffer . put_int32 ( increment ) buffer . put_int32 ( seconds ) end | Instantiate the new timestamp . |
8,695 | 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_type ) buffer . put_... | Get the array as encoded BSON . |
8,696 | def to_bson ( buffer = ByteBuffer . new , validating_keys = Config . validating_keys? ) buffer . put_string ( javascript ) end | Instantiate the new code . |
8,697 | def to_bson ( buffer = ByteBuffer . new , validating_keys = Config . validating_keys? ) to_time . to_bson ( buffer ) end | Get the date time as encoded BSON . |
8,698 | 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 | Instantiate the new code with scope . |
8,699 | 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 | Get the integer as encoded BSON . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.