Codebase list python-faraday / 726f6e9
Refresh patches Sophie Brun 3 years ago
7 changed file(s) with 84 addition(s) and 124 deletion(s). Raw diff Collapse all Expand all
+0
-24
debian/patches/Fix-for-pytest-6.patch less more
0 From: Sophie Brun <[email protected]>
1 Date: Wed, 10 Feb 2021 15:00:49 +0100
2 Subject: Fix for pytest 6
3
4 pytest.PytestDeprecationWarning: Passing arguments to pytest.fixture()
5 as positional arguments is deprecated - pass them as a keyword argument
6 instead.
7 ---
8 tests/test_api_preferences.py | 2 +-
9 1 file changed, 1 insertion(+), 1 deletion(-)
10
11 diff --git a/tests/test_api_preferences.py b/tests/test_api_preferences.py
12 index 5662466..3edcfe3 100644
13 --- a/tests/test_api_preferences.py
14 +++ b/tests/test_api_preferences.py
15 @@ -7,7 +7,7 @@ from faraday.server.api.modules.preferences import PreferencesView
16 from tests.utils.url import v2_to_v3
17
18
19 -pytest.fixture('logged_user')
20 +pytest.fixture(params=['logged_user'])
21 class TestPreferences(GenericAPITest):
22 model = User
23 factory = UserFactory
22 Subject: Remove failing tests
33
44 ---
5 tests/test_searcher.py | 880 -------------------------------------
6 tests/test_server_utils_filters.py | 249 -----------
7 2 files changed, 1129 deletions(-)
5 tests/test_searcher.py | 882 -------------------------------------
6 tests/test_server_utils_filters.py | 246 -----------
7 2 files changed, 1128 deletions(-)
88 delete mode 100644 tests/test_searcher.py
99 delete mode 100644 tests/test_server_utils_filters.py
1010
1111 diff --git a/tests/test_searcher.py b/tests/test_searcher.py
1212 deleted file mode 100644
13 index 44ef49d..0000000
13 index 3c1af9d..0000000
1414 --- a/tests/test_searcher.py
1515 +++ /dev/null
16 @@ -1,880 +0,0 @@
16 @@ -1,882 +0,0 @@
1717 -
1818 -import json
1919 -
2222 -from faraday.searcher.api import Api
2323 -from faraday.searcher.searcher import Searcher
2424 -from faraday.searcher.sqlapi import SqlApi
25 -from faraday.server.models import Service, Host, VulnerabilityWeb
25 -from faraday.server.models import Service, Host, VulnerabilityWeb, Rule
2626 -from faraday.server.models import Vulnerability, CommandObject
2727 -from faraday.server.schemas import WorkerRuleSchema
2828 -from faraday.utils.smtp import MailNotification
3636 - ActionFactory,
3737 - RuleActionFactory,
3838 - UserFactory,
39 - ConditionFactory,
3940 -)
4041 -from tests.factories import WorkspaceFactory, VulnerabilityFactory
4142 -
544545 - searcher.process(rules)
545546 - vuln = session.query(Vulnerability).get(vuln_id)
546547 - assert vuln.severity == 'informational'
547 -
548548 -
549549 - @pytest.mark.parametrize("api", [
550550 - lambda workspace, test_client, session: Api(workspace.name, test_client, session, username='test',
871871 - assert vulns_count == 10
872872 -
873873 - searcher = Searcher(api(workspace, test_client, session))
874 - rule_disabled = RuleFactory.create(object="severity=low", disabled=True, workspace=workspace)
875 - rule_enabled = RuleFactory.create(object="severity=medium", disabled=False, workspace=workspace)
874 - rule_disabled: Rule = RuleFactory.create(disabled=True, workspace=workspace)
875 - rule_enabled = RuleFactory.create(disabled=False, workspace=workspace)
876 - rule_disabled.conditions = [ConditionFactory.create(field='severity', value="low")]
877 - rule_enabled.conditions = [ConditionFactory.create(field='severity', value="medium")]
876878 -
877879 - action = ActionFactory.create(command='DELETE')
878880 - session.add(action)
896898 - assert vulns_count == 5
897899 diff --git a/tests/test_server_utils_filters.py b/tests/test_server_utils_filters.py
898900 deleted file mode 100644
899 index efde1ed..0000000
901 index 377c99c..0000000
900902 --- a/tests/test_server_utils_filters.py
901903 +++ /dev/null
902 @@ -1,249 +0,0 @@
904 @@ -1,246 +0,0 @@
903905 -import pytest
904906 -
905907 -from marshmallow.exceptions import ValidationError
906908 -
907909 -from faraday.server.utils.filters import FilterSchema
908910 -from faraday.server.utils.filters import FlaskRestlessSchema
909 -from faraday.server.models import VulnerabilityWeb
910911 -
911912 -
912913 -class TestFilters:
922923 -
923924 - def test_restless_using_order_by(self):
924925 - test_filter = {
925 - "order_by":[
926 - {"field":"host__vulnerability_critical_generic_count"},
927 - {"field":"host__vulnerability_high_generic_count"},
928 - {"field":"host__vulnerability_medium_generic_count"},
926 - "order_by": [
927 - {"field": "host__vulnerability_critical_generic_count"},
928 - {"field": "host__vulnerability_high_generic_count"},
929 - {"field": "host__vulnerability_medium_generic_count"},
929930 - ],
930931 - "filters": [{
931932 - "or": [
938939 - res = FlaskRestlessSchema().load(test_filter)
939940 - assert res == test_filter
940941 -
941 -
942942 - def test_FlaskRestlessSchema_(self):
943943 - test_filter = [{"name": "severity", "op": "eq", "val": "low"}]
944944 - res = FlaskRestlessSchema().load(test_filter)
947947 - def test_simple_and_operator(self):
948948 - test_filter = {"filters": [
949949 - {'and': [
950 - {"name": "severity", "op": "eq", "val": "low"},
951 - {"name": "severity", "op": "eq", "val": "medium"}
952 - ]
950 - {"name": "severity", "op": "eq", "val": "low"},
951 - {"name": "severity", "op": "eq", "val": "medium"}
952 - ]
953953 - }
954954 -
955955 - ]}
10841084 - else:
10851085 - assert and_op == {"name": "severity", "op": "eq", "val": "high"}
10861086 -
1087 -
10881087 - def test_case_1(self):
10891088 - filter_schema = FilterSchema()
10901089 - filters = {'filters': [{"name": "confirmed", "op": "==", "val": "true"}]}
10991098 -
11001099 - def test_case_3(self):
11011100 - filters = {'filters': [
1101 - {"and": [
11021102 - {"and": [
1103 - {"and": [
1104 - {"name": "severity", "op": "eq", "val": "critical"},
1105 - {"name": "confirmed", "op": "==", "val": "true"}
1106 - ]},
1107 - {"name": "host__os", "op": "has", "val": "Linux"}
1108 - ]}
1109 - ]}
1110 - res = FilterSchema().load(filters)
1111 - assert res == filters
1112 -
1113 - def test_test_case_recursive(self):
1114 - filters = {"filters":
1115 - [{"or":[
1116 - {"name":"severity","op":"eq","val":"medium"},
1117 - {"or":[
1118 - {"name":"severity","op":"eq","val":"high"},
1119 - {"and":[
1120 - {"and":[
1121 - {"name":"severity","op":"eq","val":"critical"},
1122 - {"name":"confirmed","op":"==","val":"true"}
1123 - ]},
1124 - {"name":"host__os","op":"has","val":"Linux"}
1125 - ]}
1126 - ]}
1103 - {"name": "severity", "op": "eq", "val": "critical"},
1104 - {"name": "confirmed", "op": "==", "val": "true"}
1105 - ]},
1106 - {"name": "host__os", "op": "has", "val": "Linux"}
11271107 - ]}
11281108 - ]}
11291109 - res = FilterSchema().load(filters)
11301110 - assert res == filters
11311111 -
1112 - def test_test_case_recursive(self):
1113 - filters = {"filters":
1114 - [{"or": [
1115 - {"name": "severity", "op": "eq", "val": "medium"},
1116 - {"or": [
1117 - {"name": "severity", "op": "eq", "val": "high"},
1118 - {"and": [
1119 - {"and": [
1120 - {"name": "severity", "op": "eq", "val": "critical"},
1121 - {"name": "confirmed", "op": "==", "val": "true"}
1122 - ]},
1123 - {"name": "host__os", "op": "has", "val": "Linux"}
1124 - ]}
1125 - ]}
1126 - ]}
1127 - ]}
1128 - res = FilterSchema().load(filters)
1129 - assert res == filters
1130 -
11321131 - def test_case_recursive_2(self):
11331132 - filters = {'filters': [
1134 - {"and": [
1135 - {"and": [
1136 - {"name": "severity", "op": "eq", "val": "critical"},
1137 - {"name": "confirmed", "op": "==", "val": "true"}
1138 - ]},
1139 - {"name": "host__os", "op": "has", "val": "Linux"}
1140 - ]}
1141 - ]}
1133 - {"and": [
1134 - {"and": [
1135 - {"name": "severity", "op": "eq", "val": "critical"},
1136 - {"name": "confirmed", "op": "==", "val": "true"}
1137 - ]},
1138 - {"name": "host__os", "op": "has", "val": "Linux"}
1139 - ]}
1140 - ]}
11421141 -
11431142 - res = FilterSchema().load(filters)
11441143 - assert res == filters
55 faraday/manage.py | 2 +-
66 faraday/server/api/modules/token.py | 2 +-
77 faraday/server/app.py | 6 +++---
8 faraday/server/commands/change_password.py | 4 ++--
8 faraday/server/commands/change_password.py | 2 +-
99 faraday/server/commands/initdb.py | 2 +-
1010 faraday/server/models.py | 2 +-
11 tests/test_command_change_password.py | 4 ++--
12 7 files changed, 11 insertions(+), 11 deletions(-)
11 tests/test_command_change_password.py | 2 +-
12 7 files changed, 9 insertions(+), 9 deletions(-)
1313
1414 diff --git a/faraday/manage.py b/faraday/manage.py
15 index 973dc59..b84a1ab 100755
15 index 2fd12d0..dfa1ac2 100755
1616 --- a/faraday/manage.py
1717 +++ b/faraday/manage.py
18 @@ -53,7 +53,7 @@ from faraday.server.commands import import_vulnerability_template
18 @@ -55,7 +55,7 @@ from faraday.server.commands import import_vulnerability_template
1919 from faraday.server.models import db, User
20 from faraday.server.web import app
20 from faraday.server.web import get_app
2121 from faraday_plugins.plugins.manager import PluginsManager
2222 -from flask_security.utils import hash_password
2323 +from faraday.flask_security.utils import hash_password
2424
25 CONTEXT_SETTINGS = dict(help_option_names=['-h', '--help'])
2526
26 CONTEXT_SETTINGS = dict(help_option_names=['-h', '--help'])
2727 diff --git a/faraday/server/api/modules/token.py b/faraday/server/api/modules/token.py
28 index ede88ed..30949da 100644
28 index 68cc969..7b69e62 100644
2929 --- a/faraday/server/api/modules/token.py
3030 +++ b/faraday/server/api/modules/token.py
3131 @@ -3,7 +3,7 @@ import logging
3232
3333 from itsdangerous import TimedJSONWebSignatureSerializer
34 from flask import Blueprint, g, request
34 from flask import Blueprint, request
3535 -from flask_security.utils import hash_data
3636 +from faraday.flask_security.utils import hash_data
3737 from flask import current_app as app
3838 from marshmallow import Schema
39
39 import flask_login
4040 diff --git a/faraday/server/app.py b/faraday/server/app.py
41 index 61bef35..df5336e 100644
41 index 3b91230..a50f87e 100644
4242 --- a/faraday/server/app.py
4343 +++ b/faraday/server/app.py
44 @@ -20,12 +20,12 @@ import flask
44 @@ -22,12 +22,12 @@ import flask_login
4545 from flask import Flask, session, g, request
4646 from flask.json import JSONEncoder
4747 from flask_sqlalchemy import get_debug_queries
5858 get_message,
5959 verify_and_update_password,
6060 diff --git a/faraday/server/commands/change_password.py b/faraday/server/commands/change_password.py
61 index 42a7b1d..cfd6559 100644
61 index d0729ff..30b96c1 100644
6262 --- a/faraday/server/commands/change_password.py
6363 +++ b/faraday/server/commands/change_password.py
6464 @@ -1,6 +1,6 @@
65 from faraday.server.web import app
65 from faraday.server.web import get_app
6666 from faraday.server.models import User, db
6767 -from flask_security.utils import hash_password
6868 +from faraday.flask_security.utils import hash_password
6969
7070
7171 def changes_password(username, password):
72 @@ -13,4 +13,4 @@ def changes_password(username, password):
73 print("Password changed succesfully")
74 else:
75 print("User not found in Faraday's Database")
76 -# I'm Py3
77 \ No newline at end of file
78 +# I'm Py3
7972 diff --git a/faraday/server/commands/initdb.py b/faraday/server/commands/initdb.py
80 index d09b84b..175c369 100644
73 index 836bdcc..7546e11 100644
8174 --- a/faraday/server/commands/initdb.py
8275 +++ b/faraday/server/commands/initdb.py
8376 @@ -28,7 +28,7 @@ from faraday.server.utils.database import is_unique_constraint_violation
9083 from colorama import init
9184 from colorama import Fore
9285 diff --git a/faraday/server/models.py b/faraday/server/models.py
93 index 8114087..fddf7c0 100644
86 index 17a7776..20ceafa 100644
9487 --- a/faraday/server/models.py
9588 +++ b/faraday/server/models.py
96 @@ -46,7 +46,7 @@ from flask_sqlalchemy import (
89 @@ -47,7 +47,7 @@ from flask_sqlalchemy import (
9790 from depot.fields.sqlalchemy import UploadedFileField
9891
9992 from faraday.server.fields import JSONType
10396 )
10497
10598 diff --git a/tests/test_command_change_password.py b/tests/test_command_change_password.py
106 index 99efcbd..0bec8c7 100644
99 index 637eb2b..0bec8c7 100644
107100 --- a/tests/test_command_change_password.py
108101 +++ b/tests/test_command_change_password.py
109102 @@ -1,4 +1,4 @@
112105
113106 from faraday.server.commands.change_password import changes_password
114107 from faraday.server.models import User
115 @@ -15,4 +15,4 @@ def test_changes_password_command(session):
116 user = User.query.filter_by(username='test_change_pass').first()
117
118 assert not verify_password('old_pass', user.password)
119 - assert verify_password('new_pass', user.password)
120 \ No newline at end of file
121 + assert verify_password('new_pass', user.password)
88 installed: apt does that at the installation.
99 Author: Sophie Brun <[email protected]>
1010 Forwarded: not-needed
11 Last-Update: 2020-04-23
11 Last-Update: 2021-05-20
1212 ---
1313 faraday/manage.py | 10 +++++-----
1414 faraday/start_server.py | 3 ---
1515 2 files changed, 5 insertions(+), 8 deletions(-)
1616
1717 diff --git a/faraday/manage.py b/faraday/manage.py
18 index 16d8f57..ecde322 100755
18 index 171b8ed..6deb21d 100755
1919 --- a/faraday/manage.py
2020 +++ b/faraday/manage.py
21 @@ -126,9 +126,9 @@ def sql_shell():
21 @@ -128,9 +128,9 @@ def sql_shell():
2222 @click.command(help='Checks configuration and faraday status.')
2323 @click.option('--check_postgresql', default=False, is_flag=True)
2424 @click.option('--check_faraday', default=False, is_flag=True)
2727 @click.option('--check_config', default=False, is_flag=True)
2828 -def status_check(check_postgresql, check_faraday, check_dependencies, check_config):
2929 +def status_check(check_postgresql, check_faraday, check_config):
30
3130 selected = False
3231 exit_code = 0
33 @@ -142,9 +142,9 @@ def status_check(check_postgresql, check_faraday, check_dependencies, check_conf
32 if check_postgresql:
33 @@ -143,9 +143,9 @@ def status_check(check_postgresql, check_faraday, check_dependencies, check_conf
3434 status_check_functions.print_faraday_status()
3535 selected = True
3636
4444 if check_config:
4545 status_check_functions.print_config_status()
4646 diff --git a/faraday/start_server.py b/faraday/start_server.py
47 index e16b9b8..682e85d 100644
47 index 1f6cdc8..cdcd6f7 100644
4848 --- a/faraday/start_server.py
4949 +++ b/faraday/start_server.py
50 @@ -110,7 +110,6 @@ def main():
50 @@ -111,7 +111,6 @@ def main():
5151 check_postgresql()
5252 parser = argparse.ArgumentParser()
5353 parser.add_argument('--debug', action='store_true', help='run Faraday Server in debug mode')
5555 parser.add_argument('--no-setup', action='store_true', help=argparse.SUPPRESS)
5656 parser.add_argument('--port', help='Overides server.ini port configuration')
5757 parser.add_argument('--websocket_port', help='Overides server.ini websocket port configuration')
58 @@ -133,8 +132,6 @@ def main():
58 @@ -134,8 +133,6 @@ def main():
5959 if result == 0:
6060 logger.error("Faraday Server port in use. Check your processes and run the server again...")
6161 sys.exit(1)
22 use-packaged-filteralchemy.patch
33 Remove-failing-tests.patch
44 Use-local-flask-security.patch
5 Fix-for-pytest-6.patch
1414 1 file changed, 1 insertion(+), 1 deletion(-)
1515
1616 diff --git a/requirements.txt b/requirements.txt
17 index f1d8dcf..bd30423 100644
17 index ff32180..efb2b8c 100644
1818 --- a/requirements.txt
1919 +++ b/requirements.txt
20 @@ -25,7 +25,7 @@ tqdm>=4.15.0
20 @@ -26,7 +26,7 @@ tqdm>=4.15.0
2121 twisted>=18.9.0
2222 webargs>=7.0.0
2323 marshmallow-sqlalchemy
1313 2 files changed, 4 insertions(+), 1 deletion(-)
1414
1515 diff --git a/faraday/manage.py b/faraday/manage.py
16 index ecde322..973dc59 100755
16 index 6deb21d..2fd12d0 100755
1717 --- a/faraday/manage.py
1818 +++ b/faraday/manage.py
19 @@ -26,6 +26,9 @@ if platform.system() == "Linux":
19 @@ -28,6 +28,9 @@ if platform.system() == "Linux":
2020 except KeyError:
2121 pass
2222
2727 import requests
2828 import alembic.command
2929 diff --git a/requirements.txt b/requirements.txt
30 index bedeaf8..f1d8dcf 100644
30 index 26c7d70..ff32180 100644
3131 --- a/requirements.txt
3232 +++ b/requirements.txt
33 @@ -14,7 +14,7 @@ Flask-Security-Too>=3.4.4,<4.0.0
33 @@ -15,7 +15,7 @@ bleach>=3.3.0
3434 marshmallow>=3.0.0,<3.11.0
3535 Pillow>=4.2.1
3636 psycopg2