diff --git a/gatox/cli/cli.py b/gatox/cli/cli.py index 9659b7f..e0cd4c0 100644 --- a/gatox/cli/cli.py +++ b/gatox/cli/cli.py @@ -272,8 +272,8 @@ def enumerate(args, parser): args.target )] else: - # Otherwise, simply enumerate all repositories belonging to the user. - repos = gh_enumeration_runner.enumerate_repos([args.target]) + # Otherwise, simply enumerate all repositories belonging to the user. + repos = gh_enumeration_runner.enumerate_user(args.target) elif args.repositories: try: repo_list = util.read_file_and_validate_lines( diff --git a/pyproject.toml b/pyproject.toml index 1b0b43f..30f94e6 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "hatchling.build" [project] name = "gato-x" -version = "0.5.2" +version = "0.5.3" description = "GitHub Actions Enumeration and Attack Framework" readme = "README.md" authors = [ diff --git a/unit_test/test_api.py b/unit_test/test_api.py index 49ea0f1..562fe38 100644 --- a/unit_test/test_api.py +++ b/unit_test/test_api.py @@ -1102,3 +1102,34 @@ def test_graphql_mergedat_query(mock_call_post, mock_call_get): date = api.get_commit_merge_date('testOrg/testRepo', '9659fdc7ba35a9eba00c183bccc67083239383e8') assert date == "2024-06-21T09:57:58Z" + +@patch('gatox.github.api.requests.get') +def test_get_user_type(mock_call_get): + + test_pat = "ghp_AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" + api = Api(test_pat, "2022-11-28") + + mock_call_get.side_effect = [ + MagicMock(status_code=200, json=MagicMock(return_value={'type': 'User'})), + ] + + user_type = api.get_user_type("someUser") + + assert user_type == 'User' + +@patch('gatox.github.api.requests.get') +def test_get_user_repos(mock_call_get): + test_pat = "ghp_AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" + api = Api(test_pat, "2022-11-28") + + mock_call_get.side_effect = [ + MagicMock(status_code=200, json=MagicMock( + return_value=[{'full_name': 'testRepo','archived': False}, + {'full_name': 'testRepo2','archived': False}] + )), + ] + + repos = api.get_user_repos("someUser") + + assert repos[0] == 'testRepo' + assert repos[1] == 'testRepo2' \ No newline at end of file diff --git a/unit_test/test_cli.py b/unit_test/test_cli.py index d5dc2b5..141bef8 100644 --- a/unit_test/test_cli.py +++ b/unit_test/test_cli.py @@ -297,14 +297,12 @@ def test_enum_org(mock_enumerate): @mock.patch("gatox.cli.cli.Enumerator") def test_enum_user(mock_enumerate): - """Test enum command using the organization enumerattion. + """Test enum command using the organization enumeration. """ mock_instance = mock_enumerate.return_value mock_api = mock.MagicMock() - print(mock_instance) - mock_api.check_user.return_value = { "user": 'testUser', "scopes": ['repo', 'workflow'] @@ -314,7 +312,7 @@ def test_enum_user(mock_enumerate): cli.cli(["enum", "-t", "testUser"]) - mock_instance.enumerate_repos.assert_called_once() + mock_instance.enumerate_user.assert_called_once()