Skip to content

Commit

Permalink
Merge branch 'dev' of gitlab.com:faradaysec/faraday-client
Browse files Browse the repository at this point in the history
  • Loading branch information
EricHorvat committed May 11, 2021
2 parents 5c66dcf + 3b6477e commit b73f989
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 15 deletions.
4 changes: 2 additions & 2 deletions faraday_client/bin/autoclose_vulns.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@


def get_vulns_from_workspace(session, url, workspace):
vulns = session.get('{url}/_api/v2/ws/{ws_name}/vulns/'\
vulns = session.get('{url}/_api/v3/ws/{ws_name}/vulns'\
.format(url=url, ws_name=workspace))

return vulns.json()
Expand All @@ -37,7 +37,7 @@ def close_vulns(session, url, workspace, vulns, duration_time):
# If elapsed time since creation is greater than duration time, the vuln will be closed
if elapsed_time.total_seconds() > duration_time and vuln['value']['status'] != 'closed':
vuln['value']['status'] = 'closed'
close = session.put('{url}/_api/v2/ws/{ws_name}/vulns/{vuln_id}/'\
close = session.put('{url}/_api/v3/ws/{ws_name}/vulns/{vuln_id}'\
.format(url=url,
ws_name=workspace,
vuln_id=vuln['id']
Expand Down
2 changes: 1 addition & 1 deletion faraday_client/bin/create_xlsx_report.py
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ def main(workspace='', args=None, parser=None):

session = Session()
session.post(models.server.SERVER_URL + '/_api/login', json={'email': models.server.AUTH_USER, 'password': models.server.AUTH_PASS})
vulns = session.get(models.server.SERVER_URL + '/_api/v2/ws/' + workspace + '/vulns')
vulns = session.get(models.server.SERVER_URL + '/_api/v3/ws/' + workspace + '/vulns')

parser.add_argument('-o', '--output', help='Output xlsx file report', required=True)
parsed_args = parser.parse_args(args)
Expand Down
6 changes: 3 additions & 3 deletions faraday_client/bin/fbruteforce_services.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ def search_hosts_by_service(workspace, b_service):

def total_credentials(workspace):
json_creds = server._get(
SERVER_URL + "/_api/v2/ws/%s/credential" % workspace)
SERVER_URL + "/_api/v3/ws/%s/credential" % workspace)

return len(json_creds["rows"])

Expand All @@ -75,7 +75,7 @@ def get_credentials(workspace, key):
credentials = ""

json_creds = server._get(
SERVER_URL + "/_api/v2/ws/%s/credential" % workspace)
SERVER_URL + "/_api/v3/ws/%s/credential" % workspace)

if len(json_creds["rows"]) > 0:

Expand All @@ -93,7 +93,7 @@ def show_table_services(workspace):
table = ""

j_parsed = server._get(
SERVER_URL + "/_api/v2/ws/%s/services/count?group_by=name" % workspace)
SERVER_URL + "/_api/v3/ws/%s/services/count?group_by=name" % workspace)

if len(j_parsed["groups"]) > 0:

Expand Down
2 changes: 1 addition & 1 deletion faraday_client/persistence/server/changes_stream.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ def on_open(self):

response = _post(
_create_server_api_url() +
'/ws/{}/websocket_token/'.format(self.workspace_name),
'/ws/{}/websocket_token'.format(self.workspace_name),
expected_response=200)
token = response['token']
self.ws.send(json.dumps({
Expand Down
12 changes: 6 additions & 6 deletions faraday_client/persistence/server/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ def _get_base_server_url():

def _create_server_api_url():
"""Return the server's api url."""
return "{0}/_api/v2".format(_get_base_server_url())
return "{0}/_api/v3".format(_get_base_server_url())

def _create_server_get_url(workspace_name, object_name=None, object_id=None, **params):
"""Creates a url to get from the server. Takes the workspace name
Expand All @@ -103,7 +103,7 @@ def _create_server_get_url(workspace_name, object_name=None, object_id=None, **p
Return the get_url as a string.
"""
get_url = "/{0}".format(object_name) if object_name else ""
get_url += "/{0}/".format(object_id) if object_id else ""
get_url += "/{0}".format(object_id) if object_id else ""
get_url = '{0}/ws/{1}{2}'.format(_create_server_api_url(),
workspace_name,
get_url)
Expand All @@ -116,7 +116,7 @@ def _create_server_post_url(workspace_name, obj_type, command_id):
object_end_point_name = OBJECT_TYPE_END_POINT_MAPPER[obj_type]
if obj_type == 'comment':
object_end_point_name = object_end_point_name.strip('/') + '_unique/'
post_url = '{0}/ws/{1}/{2}/'.format(server_api_url, workspace_name, object_end_point_name)
post_url = '{0}/ws/{1}/{2}'.format(server_api_url, workspace_name, object_end_point_name)
if command_id:
get_params = {'command_id': command_id}
post_url += '?' + urlencode(get_params)
Expand All @@ -126,7 +126,7 @@ def _create_server_post_url(workspace_name, obj_type, command_id):
def _create_server_put_url(workspace_name, obj_type, obj_id, command_id):
server_api_url = _create_server_api_url()
object_end_point_name = OBJECT_TYPE_END_POINT_MAPPER[obj_type]
put_url = '{0}/ws/{1}/{2}/{3}/'.format(server_api_url, workspace_name, object_end_point_name, obj_id)
put_url = '{0}/ws/{1}/{2}/{3}'.format(server_api_url, workspace_name, object_end_point_name, obj_id)
if command_id:
get_params = {'command_id': command_id}
put_url += '?' + urlencode(get_params)
Expand Down Expand Up @@ -156,7 +156,7 @@ def _create_couch_db_url(workspace_name):

def _create_server_db_url(workspace_name):
server_api_url = _create_server_api_url()
db_url = '{0}/ws/'.format(server_api_url)
db_url = '{0}/ws'.format(server_api_url)
return db_url


Expand Down Expand Up @@ -1671,7 +1671,7 @@ def check_server_url(url_to_test):
False otherwise.
"""
try:
resp = _get("{0}/_api/v2/info".format(url_to_test))
resp = _get("{0}/_api/v3/info".format(url_to_test))
return 'Faraday Server' in resp
except Exception as ex:
logger.exception(ex)
Expand Down
4 changes: 2 additions & 2 deletions faraday_client/plugins/controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ def processOutput(self, plugin, output, command, isReport=False):
data['tool'] = data['command']
data.pop('id_available')
res = requests.put(
f'{base_url}/_api/v2/ws/{command.workspace}/commands/{command_id}/',
f'{base_url}/_api/v3/ws/{command.workspace}/commands/{command_id}',
json=data,
cookies=cookies)
logger.info(f'Sent command duration {res.status_code}')
Expand All @@ -142,7 +142,7 @@ def send_data(self, workspace, data):
cookies = _conf().getFaradaySessionCookies()
base_url = _get_base_server_url()
res = requests.post(
f'{base_url}/_api/v2/ws/{workspace}/bulk_create/',
f'{base_url}/_api/v3/ws/{workspace}/bulk_create',
cookies=cookies,
json=json.loads(data))
if res.status_code != 201:
Expand Down

0 comments on commit b73f989

Please sign in to comment.