def __init__(self, timeout=30): scheme_args = {'title': "Website Availability Check", 'description': "Connects to a website in order to obtain performance statistics", 'use_external_validation': "true", 'streaming_mode': "xml", 'use_single_instance': "true"} args = [ Field("title", "Title", "A short description (typically just the domain name)", empty_allowed=False), URLField("url", "URL", "The URL to connect to (must be be either HTTP or HTTPS protocol)", empty_allowed=False), DurationField("interval", "Interval", "The interval defining how often to perform the check; can include time units (e.g. 15m for 15 minutes, 8h for 8 hours)", empty_allowed=False), Field("configuration", "Configuration", "Defines a specific proxy configuration to use (in website_monitoring.spec) if not using the default; only used if you want to have multiple proxy servers", none_allowed=True, empty_allowed=True), Field("client_certificate", "Client Certificate Path", "Defines the path to the client certificate (if the website requires client SSL authentication)", none_allowed=True, empty_allowed=True), Field("client_certificate_key", "Client Certificate Key Path", "Defines the path to the client certificate key (necessary of the key is in a separate file from the certificate)", none_allowed=True, empty_allowed=True), Field("username", "Username", "The username to use for authenticating (only HTTP authentication supported)", none_allowed=True, empty_allowed=True, required_on_create=False, required_on_edit=False), Field("password", "Password", "The password to use for authenticating (only HTTP authentication supported)", none_allowed=True, empty_allowed=True, required_on_create=False, required_on_edit=False) ] ModularInput.__init__( self, scheme_args, args, logger_name='web_availability_modular_input' ) if timeout > 0: self.timeout = timeout else: self.timeout = 30
def handle_results(self, results, session_key, in_preview): # FYI: we ignore results since this is a generating command # Make sure that the url field was provided if self.url is None: self.logger.warn("No url was provided") return # Parse the URL url_field = URLField('name', 'title', 'description') url_parsed = url_field.to_python(self.url) # Do the web-ping result = WebPing.ping(url_parsed, logger=self.logger, should_contain_string=self.expected_string, return_headers=self.return_headers) # Prep the result dictionary data = { 'response_code': result.response_code if result.response_code > 0 else '', 'total_time': round(result.request_time, 2) if result.request_time > 0 else '', 'timed_out': result.timed_out, 'url': result.url } # Add the MD5 of the response if available if result.response_md5 is not None: data['content_md5'] = result.response_md5 # Add the SHA-224 of the response if available if result.response_sha224 is not None: data['content_sha224'] = result.response_sha224 # Add the size of the response if available if result.response_size is not None: data['content_size'] = result.response_size # Add the variable noting if the expected string was present if result.has_expected_string is not None: data['has_expected_string'] = str( result.has_expected_string).lower() # Add the the headers if present if result.headers is not None: for header in result.headers: data['header_' + header] = result.headers[header] # Output the results self.output_results([data])
def __init__(self): scheme_args = {'title': "Syndication Feed (RSS, ATOM, RDF)", 'description': "Import syndication feeds (RSS, ATOM, RDF)", 'use_external_validation': "true", 'streaming_mode': "xml", 'use_single_instance': "true"} args = [ URLField("url", "Feed URL", "The URL of the feed to input", empty_allowed=False), BooleanField("include_only_changed", "Include only new or changed entries", "Only include entries that has not been indexed yet (won't get items that were already observed)", empty_allowed=False), Field("username", "Username", "The username to use for authenticating (only HTTP authentication supported)", none_allowed=True, empty_allowed=True, required_on_create=False, required_on_edit=False), Field("password", "Password", "The password to use for authenticating (only HTTP authentication supported)", none_allowed=True, empty_allowed=True, required_on_create=False, required_on_edit=False), DurationField("interval", "Interval", "The interval defining how often to import the feed; can include time units (e.g. 15m for 15 minutes, 8h for 8 hours)", empty_allowed=False), BooleanField("clean_html", "Convert HTML to Text", "Convert HTML to human readable text", empty_allowed=False) ] ModularInput.__init__( self, scheme_args, args, logger_name='syndication_modular_input' )
def __init__(self, timeout=30, **kwargs): scheme_args = { 'title': "Web-pages", 'description': "Retrieve information from web-pages", 'use_external_validation': "true", 'streaming_mode': "xml", 'use_single_instance': "true" } args = [ Field("title", "Title", "A short description (typically just the domain name)", empty_allowed=False), URLField( "url", "URL", "The URL to connect to (must be be either HTTP or HTTPS protocol)", empty_allowed=False, require_https_on_cloud=True), DurationField( "interval", "Interval", "The interval defining how often to perform the check; can include time units (e.g. 15m for 15 minutes, 8h for 8 hours)", empty_allowed=False), IntegerField("timeout", "Timeout", 'The timeout (in number of seconds)', none_allowed=True, empty_allowed=True), SelectorField( "selector", "Selector", "A selector that will match the data you want to retrieve", none_allowed=True, empty_allowed=True), # HTTP client options Field("user_agent", "User Agent", "The user-agent to use when communicating with the server", none_allowed=True, empty_allowed=True, required_on_create=False, required_on_edit=False), Field("browser", "Browser", 'The browser to use', none_allowed=True, empty_allowed=True), # Output options ListField("name_attributes", "Field Name Attributes", "A list of attributes to use for assigning a field name", none_allowed=True, empty_allowed=True, required_on_create=False, required_on_edit=False), BooleanField("use_element_name", "Use Element Name as Field Name", "Use the element's tag name as the field name", none_allowed=True, empty_allowed=True, required_on_create=False, required_on_edit=False), BooleanField("output_as_mv", "Output as Multi-value Field", "Output the matches as multi-value field", none_allowed=True, empty_allowed=True, required_on_create=False, required_on_edit=False), StaticListField("output_results", "Indicates when results output should be created", "Output the matches only when results changed", none_allowed=True, empty_allowed=True, required_on_create=False, required_on_edit=False, valid_values=WebInput.OUTPUT_RESULTS_OPTIONS), BooleanField("raw_content", "Raw content", "Return the raw content returned by the server", none_allowed=True, empty_allowed=True, required_on_create=False, required_on_edit=False), BooleanField("empty_matches", "Empty matches", "Include empty rows (otherwise, they are excluded)", none_allowed=True, empty_allowed=True, required_on_create=False, required_on_edit=False), Field( "text_separator", "Text Separator", 'A string that will be placed between the extracted values (e.g. a separator of ":" for a match against "<a>tree</a><a>frog</a>" would return "tree:frog")', none_allowed=True, empty_allowed=True), # Spidering options IntegerField( "page_limit", "Discovered page limit", "A limit on the number of pages that will be auto-discovered", none_allowed=True, empty_allowed=True, required_on_create=False, required_on_edit=False), IntegerField( "depth_limit", "Depth limit", "A limit on how many levels deep the search for pages will go", none_allowed=True, empty_allowed=True, required_on_create=False, required_on_edit=False), Field( "url_filter", "URL Filter", "A wild-card that will indicate which pages it should search for matches in", none_allowed=True, empty_allowed=True, required_on_create=False, required_on_edit=False), # Authentication options Field("username", "Username", "The username to use for authenticating", none_allowed=True, empty_allowed=True, required_on_create=False, required_on_edit=False), Field("password", "Password", "The password to use for authenticating", none_allowed=True, empty_allowed=True, required_on_create=False, required_on_edit=False), Field("username_field", "Username field", "The name of the username field on the login form", none_allowed=True, empty_allowed=True, required_on_create=False, required_on_edit=False), Field("password_field", "Password field", "The name of the password field on the login form", none_allowed=True, empty_allowed=True, required_on_create=False, required_on_edit=False), URLField("authentication_url", "Authentication URL", "The URL of the login form", none_allowed=True, empty_allowed=True, required_on_create=False, required_on_edit=False, require_https_on_cloud=True) ] ModularInput.__init__(self, scheme_args, args, logger_name='web_input_modular_input', logger_level=logging.INFO) if timeout > 0: self.timeout = timeout else: self.timeout = 30