Ejemplo n.º 1
0
def test_get_radare_endpoint():
    config = get_config_for_testing()

    assert config.get('ExpertSettings', 'nginx') == 'false'
    assert get_radare_endpoint(config) == 'http://localhost:8000'

    config.set('ExpertSettings', 'nginx', 'true')
    assert get_radare_endpoint(config) == 'https://localhost/radare'
Ejemplo n.º 2
0
 def _show_radare(self, uid):
     host, post_path = get_radare_endpoint(self._config), '/v1/retrieve'
     with ConnectTo(FrontEndDbInterface, self._config) as sc:
         object_exists = sc.existence_quick_check(uid)
     if not object_exists:
         return render_template('uid_not_found.html', uid=uid)
     with ConnectTo(InterComFrontEndBinding, self._config) as sc:
         result = sc.get_binary_and_filename(uid)
     if result is None:
         return render_template('error.html', message='timeout')
     binary, _ = result
     try:
         response = requests.post('{}{}'.format(host, post_path), data=binary, verify=False)
         if response.status_code != 200:
             raise TimeoutError(response.text)
         target_link = '{}{}m/'.format(host, response.json()['endpoint'])
         sleep(1)
         return redirect(target_link)
     except (requests.exceptions.ConnectionError, TimeoutError, KeyError) as error:
         return render_template('error.html', message=str(error))