mirror of
https://github.com/prowler-cloud/prowler.git
synced 2026-07-24 04:51:51 +00:00
fix(github_actions): remove unused GITHUB_USERNAME
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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),
|
||||
)
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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",
|
||||
)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user