.oO SearXNG Developer Documentation Oo.
|
Functions | |
init (engine_settings) | |
search (query, params) | |
_get_command_to_run (query) | |
_get_results_from_process (results, cmd, pageno) | |
__get_results_limits (pageno) | |
__check_query_params (params) | |
check_parsing_options (engine_settings) | |
__parse_single_result (raw_result) | |
Variables | |
str | engine_type = 'offline' |
bool | paging = True |
list | command = [] |
dict | delimiter = {} |
dict | parse_regex = {} |
str | query_type = '' |
list | query_enum = [] |
dict | environment_variables = {} |
working_dir = realpath('.') | |
str | result_separator = '\n' |
str | result_template = 'key-value.html' |
float | timeout = 4.0 |
_command_logger = logger.getChild('command') | |
dict | _compiled_parse_regex = {} |
With *command engines* administrators can run engines to integrate arbitrary shell commands. .. attention:: When creating and enabling a ``command`` engine on a public instance, you must be careful to avoid leaking private data. The easiest solution is to limit the access by setting ``tokens`` as described in section :ref:`private engines`. The engine base is flexible. Only your imagination can limit the power of this engine (and maybe security concerns). Configuration ============= The following options are available: ``command``: A comma separated list of the elements of the command. A special token ``{{QUERY}}`` tells where to put the search terms of the user. Example: .. code:: yaml ['ls', '-l', '-h', '{{QUERY}}'] ``delimiter``: A mapping containing a delimiter ``char`` and the *titles* of each element in ``keys``. ``parse_regex``: A dict containing the regular expressions for each result key. ``query_type``: The expected type of user search terms. Possible values: ``path`` and ``enum``. ``path``: Checks if the user provided path is inside the working directory. If not, the query is not executed. ``enum``: Is a list of allowed search terms. If the user submits something which is not included in the list, the query returns an error. ``query_enum``: A list containing allowed search terms if ``query_type`` is set to ``enum``. ``working_dir``: The directory where the command has to be executed. Default: ``./``. ``result_separator``: The character that separates results. Default: ``\\n``. Example ======= The example engine below can be used to find files with a specific name in the configured working directory: .. code:: yaml - name: find engine: command command: ['find', '.', '-name', '{{QUERY}}'] query_type: path shortcut: fnd delimiter: chars: ' ' keys: ['line'] Implementations ===============
|
private |
Definition at line 197 of file command.py.
Referenced by searx.engines.command._get_command_to_run().
|
private |
Definition at line 191 of file command.py.
Referenced by searx.engines.command._get_results_from_process().
|
private |
Parses command line output based on configuration
Definition at line 225 of file command.py.
Referenced by searx.engines.command._get_results_from_process().
|
protected |
Definition at line 142 of file command.py.
References searx.engines.command.__check_query_params().
Referenced by searx.engines.command.search().
|
protected |
Definition at line 156 of file command.py.
References searx.engines.command.__get_results_limits(), and searx.engines.command.__parse_single_result().
searx.engines.command.check_parsing_options | ( | engine_settings | ) |
Checks if delimiter based parsing or regex parsing is configured correctly
Definition at line 212 of file command.py.
Referenced by searx.engines.command.init().
searx.engines.command.init | ( | engine_settings | ) |
Definition at line 103 of file command.py.
References searx.engines.command.check_parsing_options().
searx.engines.command.search | ( | query, | |
params ) |
Definition at line 129 of file command.py.
References searx.engines.command._get_command_to_run().
|
protected |
Definition at line 99 of file command.py.
|
protected |
Definition at line 100 of file command.py.
list searx.engines.command.command = [] |
Definition at line 88 of file command.py.
dict searx.engines.command.delimiter = {} |
Definition at line 89 of file command.py.
str searx.engines.command.engine_type = 'offline' |
Definition at line 86 of file command.py.
dict searx.engines.command.environment_variables = {} |
Definition at line 93 of file command.py.
bool searx.engines.command.paging = True |
Definition at line 87 of file command.py.
dict searx.engines.command.parse_regex = {} |
Definition at line 90 of file command.py.
list searx.engines.command.query_enum = [] |
Definition at line 92 of file command.py.
str searx.engines.command.query_type = '' |
Definition at line 91 of file command.py.
str searx.engines.command.result_separator = '\n' |
Definition at line 95 of file command.py.
str searx.engines.command.result_template = 'key-value.html' |
Definition at line 96 of file command.py.
float searx.engines.command.timeout = 4.0 |
Definition at line 97 of file command.py.
searx.engines.command.working_dir = realpath('.') |
Definition at line 94 of file command.py.