Skip to content

Commit

Permalink
fix none args.modules case
Browse files Browse the repository at this point in the history
  • Loading branch information
bretfourbe committed Nov 21, 2023
1 parent 5cd689f commit cd6e9e1
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
14 changes: 14 additions & 0 deletions tests/cli/test_options.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,3 +203,17 @@ async def test_is_mod_cms_set(mock_is_mod_cms_set, _, __):
with mock.patch.object(sys, "argv", testargs):
await wapiti_main()
mock_is_mod_cms_set.assert_called_once()


@pytest.mark.asyncio
@mock.patch("wapitiCore.main.wapiti.Wapiti.browse")
@mock.patch("wapitiCore.main.wapiti.Wapiti.attack")
async def test_basic_usage(_, __):
"""Test without option"""
testsagrs = [
"wapiti",
"--url", "http://testphp.vulnweb.com/"
]

with mock.patch.object(sys, "argv", testsagrs):
await wapiti_main()
4 changes: 2 additions & 2 deletions wapitiCore/main/wapiti.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ def is_valid_endpoint(url_type, url: str):


def is_mod_cms_set(args):
if "cms" in args.modules:
if args.modules and "cms" in args.modules:
return True
logging.error("Error: Invalid option --cms, module cms is required when this option is used")
return False
Expand Down Expand Up @@ -301,7 +301,7 @@ async def wapiti_main():
)
attack_options["cms"] = args.cms

if "cms" in args.modules and not args.cms:
if args.modules and "cms" in args.modules and not args.cms:
attack_options["cms"] = "drupal,joomla,prestashop"

if args.skipped_parameters:
Expand Down

0 comments on commit cd6e9e1

Please sign in to comment.