Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add option to skip non standard flags #46

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions enochecker_test/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ def pytest_addoption(parser):
parser.addoption("--checker-address", action="store", type=str)
parser.addoption("--checker-port", action="store", type=int)
parser.addoption("--service-address", action="store", type=str)
parser.addoption("--skip-non-eno-flags", action="store_true")
parser.addoption("--flag-variants", action="store", type=int)
parser.addoption("--noise-variants", action="store", type=int)
parser.addoption("--havoc-variants", action="store", type=int)
Expand Down
15 changes: 12 additions & 3 deletions enochecker_test/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from urllib3.util.retry import Retry


def run_tests(host, port, service_address, test_expr):
def run_tests(host, port, service_address, test_expr, skip_non_eno_flags: bool):
s = requests.Session()
retry_strategy = Retry(
total=5,
Expand Down Expand Up @@ -44,7 +44,7 @@ def run_tests(host, port, service_address, test_expr):
f"--exploit-variants={info.exploit_variants}",
"--durations=0",
"-v",
]
] + (["--skip-non-eno-flags"] if skip_non_eno_flags else [])

if test_expr:
test_args.append("-k")
Expand Down Expand Up @@ -91,6 +91,11 @@ def main():
help="The address on which the checker can reach the service (defaults to ENOCHECKER_TEST_SERVICE_ADDRESS environment variable)",
default=os.environ.get("ENOCHECKER_TEST_SERVICE_ADDRESS"),
)
parser.add_argument(
"--skip-non-eno-flags",
action="store_true",
help="Skips all test that do not use a ENO[A-Za-z0-9+/=]{48} flag. SHOULD ONLY BE USED AS AN EXCEPTION!!",
)
parser.add_argument(
"testexpr",
help="Specify the tests that should be run in the syntax expected by pytests -k flag, e.g. 'test_getflag' or 'not exploit'. If no expr is specified, all tests will be run.",
Expand All @@ -117,5 +122,9 @@ def main():

logging.basicConfig(level=logging.INFO)
run_tests(
args.checker_address, args.checker_port, args.service_address, args.testexpr
args.checker_address,
args.checker_port,
args.service_address,
args.testexpr,
args.skip_non_eno_flags,
)
13 changes: 10 additions & 3 deletions enochecker_test/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,16 @@ def checker_url(checker_address, checker_port):
return f"http://{checker_address}:{checker_port}"


posible_encodings = ["ascii", "utf8"]


@pytest.fixture(params=posible_encodings)
def encoding(request):
if request.config.getoption("--skip-non-eno-flags") and request.param != "ascii":
pytest.skip("skipped by --skip-non-eno-flags")
return request.param


def pytest_generate_tests(metafunc):
flag_variants: int = metafunc.config.getoption("--flag-variants")
noise_variants: int = metafunc.config.getoption("--noise-variants")
Expand Down Expand Up @@ -80,9 +90,6 @@ def pytest_generate_tests(metafunc):
if "exploit_variants" in metafunc.fixturenames:
metafunc.parametrize("exploit_variants", [exploit_variants])

if "encoding" in metafunc.fixturenames:
metafunc.parametrize("encoding", ["ascii", "utf8"])


def generate_dummyflag(encoding: str) -> str:
if encoding == "utf8":
Expand Down
Loading