From 32faf9896a33732f420cd36ddf7c37a5d4c63f8b Mon Sep 17 00:00:00 2001 From: "Andoni A." <14891798+andoniaf@users.noreply.github.com> Date: Thu, 6 Nov 2025 17:47:17 +0100 Subject: [PATCH] fix(github_actions): remove unused GITHUB_USERNAME --- .../getting-started-github-actions.mdx | 3 --- .../github_actions/github_actions_provider.py | 17 ++++------------- .../github_actions/lib/arguments/arguments.py | 13 ++----------- .../test_github_actions_provider.py | 4 ---- 4 files changed, 6 insertions(+), 31 deletions(-) diff --git a/docs/user-guide/providers/github-actions/getting-started-github-actions.mdx b/docs/user-guide/providers/github-actions/getting-started-github-actions.mdx index 7c91dcdcd5..2fe2012d6b 100644 --- a/docs/user-guide/providers/github-actions/getting-started-github-actions.mdx +++ b/docs/user-guide/providers/github-actions/getting-started-github-actions.mdx @@ -67,7 +67,6 @@ Scan a private repository with authentication: ```bash prowler github_actions --repository-url https://github.com/user/private-repo \ - --github-username YOUR_USERNAME \ --personal-access-token YOUR_TOKEN ``` @@ -78,7 +77,6 @@ Authentication for private repositories can be provided using one of the followi - **Personal Access Token:** ```bash prowler github_actions --repository-url https://github.com/org/private-repo \ - --github-username YOUR_USERNAME \ --personal-access-token YOUR_PAT ``` - **OAuth App Token:** @@ -88,7 +86,6 @@ Authentication for private repositories can be provided using one of the followi ``` - If not provided via CLI, the following environment variables will be used: ```bash - export GITHUB_USERNAME=your-username export GITHUB_PERSONAL_ACCESS_TOKEN=your-token # or export GITHUB_OAUTH_APP_TOKEN=your-oauth-token diff --git a/prowler/providers/github_actions/github_actions_provider.py b/prowler/providers/github_actions/github_actions_provider.py index bc96f70690..91f856f6a3 100644 --- a/prowler/providers/github_actions/github_actions_provider.py +++ b/prowler/providers/github_actions/github_actions_provider.py @@ -34,7 +34,6 @@ class GithubActionsProvider(Provider): config_path: str = None, config_content: dict = None, fixer_config: dict = {}, - github_username: str = None, personal_access_token: str = None, oauth_app_token: str = None, ): @@ -51,27 +50,21 @@ class GithubActionsProvider(Provider): if repository_url: oauth_app_token = oauth_app_token or environ.get("GITHUB_OAUTH_APP_TOKEN") - github_username = github_username or environ.get("GITHUB_USERNAME") personal_access_token = personal_access_token or environ.get( "GITHUB_PERSONAL_ACCESS_TOKEN" ) if oauth_app_token: self.oauth_app_token = oauth_app_token - self.github_username = None self.personal_access_token = None self._auth_method = "OAuth App Token" logger.info("Using OAuth App Token for GitHub authentication") - elif github_username and personal_access_token: - self.github_username = github_username + elif personal_access_token: self.personal_access_token = personal_access_token self.oauth_app_token = None self._auth_method = "Personal Access Token" - logger.info( - "Using GitHub username and personal access token for authentication" - ) + logger.info("Using personal access token for authentication") else: - self.github_username = None self.personal_access_token = None self.oauth_app_token = None logger.debug( @@ -318,7 +311,6 @@ class GithubActionsProvider(Provider): def _clone_repository( self, repository_url: str, - github_username: str = None, personal_access_token: str = None, oauth_app_token: str = None, ) -> str: @@ -328,10 +320,10 @@ class GithubActionsProvider(Provider): try: original_url = repository_url - if github_username and personal_access_token: + if personal_access_token: repository_url = repository_url.replace( "https://github.com/", - f"https://{github_username}:{personal_access_token}@github.com/", + f"https://{personal_access_token}@github.com/", ) elif oauth_app_token: repository_url = repository_url.replace( @@ -369,7 +361,6 @@ class GithubActionsProvider(Provider): if self.repository_url: scan_dir = temp_dir = self._clone_repository( self.repository_url, - getattr(self, "github_username", None), getattr(self, "personal_access_token", None), getattr(self, "oauth_app_token", None), ) diff --git a/prowler/providers/github_actions/lib/arguments/arguments.py b/prowler/providers/github_actions/lib/arguments/arguments.py index f128281832..ba66c8edae 100644 --- a/prowler/providers/github_actions/lib/arguments/arguments.py +++ b/prowler/providers/github_actions/lib/arguments/arguments.py @@ -15,12 +15,6 @@ def init_parser(self): github_actions_auth_subparser = github_actions_parser.add_argument_group( "Authentication" ) - github_actions_auth_subparser.add_argument( - "--github-username", - nargs="?", - default=None, - help="GitHub username for authentication when cloning private repositories", - ) github_actions_auth_subparser.add_argument( "--personal-access-token", nargs="?", @@ -75,11 +69,8 @@ def validate_arguments(arguments): if hasattr(arguments, "repository_url") and arguments.repository_url: has_github_auth = False - if hasattr(arguments, "github_username") and hasattr( - arguments, "personal_access_token" - ): - if arguments.github_username and arguments.personal_access_token: - has_github_auth = True + if hasattr(arguments, "personal_access_token") and arguments.personal_access_token: + has_github_auth = True if hasattr(arguments, "oauth_app_token") and arguments.oauth_app_token: has_github_auth = True diff --git a/tests/providers/github_actions/test_github_actions_provider.py b/tests/providers/github_actions/test_github_actions_provider.py index 8761f8b623..3cee0031dd 100644 --- a/tests/providers/github_actions/test_github_actions_provider.py +++ b/tests/providers/github_actions/test_github_actions_provider.py @@ -29,12 +29,10 @@ class TestGithubActionsProvider: with patch.object(GithubActionsProvider, "setup_session", return_value=None): provider = GithubActionsProvider( repository_url="https://github.com/test/repo", - github_username="testuser", personal_access_token="token123", ) assert provider.repository_url == "https://github.com/test/repo" - assert provider.github_username == "testuser" assert provider.personal_access_token == "token123" assert provider.auth_method == "Personal Access Token" @@ -48,7 +46,6 @@ class TestGithubActionsProvider: assert provider.oauth_app_token == "oauth_token123" assert provider.auth_method == "OAuth App Token" - assert provider.github_username is None assert provider.personal_access_token is None def test_process_zizmor_finding(self): @@ -183,7 +180,6 @@ class TestGithubActionsProvider: ): temp_dir = provider._clone_repository( "https://github.com/test/repo", - github_username="user", personal_access_token="token", )