mirror of
https://github.com/prowler-cloud/prowler.git
synced 2026-07-23 20:42:02 +00:00
fix: repository repository_dependency_scanning_enabled check logic (#7834)
This commit is contained in:
@@ -4,6 +4,7 @@ from typing import Union
|
||||
|
||||
from colorama import Fore, Style
|
||||
from github import Auth, Github, GithubIntegration
|
||||
from github.GithubRetry import GithubRetry
|
||||
|
||||
from prowler.config.config import (
|
||||
default_config_file_path,
|
||||
@@ -300,9 +301,10 @@ class GithubProvider(Provider):
|
||||
credentials = self.session
|
||||
|
||||
try:
|
||||
retry_config = GithubRetry(total=3)
|
||||
if credentials.token:
|
||||
auth = Auth.Token(credentials.token)
|
||||
g = Github(auth=auth)
|
||||
g = Github(auth=auth, retry=retry_config)
|
||||
try:
|
||||
identity = GithubIdentityInfo(
|
||||
account_id=g.get_user().id,
|
||||
@@ -318,7 +320,7 @@ class GithubProvider(Provider):
|
||||
|
||||
elif credentials.id != 0 and credentials.key:
|
||||
auth = Auth.AppAuth(credentials.id, credentials.key)
|
||||
gi = GithubIntegration(auth=auth)
|
||||
gi = GithubIntegration(auth=auth, retry=retry_config)
|
||||
try:
|
||||
identity = GithubAppIdentityInfo(app_id=gi.get_app().id)
|
||||
return identity
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
from github import Auth, Github, GithubIntegration
|
||||
from github.GithubRetry import GithubRetry
|
||||
|
||||
from prowler.lib.logger import logger
|
||||
from prowler.providers.github.github_provider import GithubProvider
|
||||
@@ -20,16 +21,17 @@ class GithubService:
|
||||
def __set_clients__(self, session):
|
||||
clients = []
|
||||
try:
|
||||
retry_config = GithubRetry(total=3)
|
||||
if session.token:
|
||||
auth = Auth.Token(session.token)
|
||||
clients = [Github(auth=auth)]
|
||||
clients = [Github(auth=auth, retry=retry_config)]
|
||||
|
||||
elif session.key and session.id:
|
||||
auth = Auth.AppAuth(
|
||||
session.id,
|
||||
session.key,
|
||||
)
|
||||
gi = GithubIntegration(auth=auth)
|
||||
gi = GithubIntegration(auth=auth, retry=retry_config)
|
||||
|
||||
for installation in gi.get_installations():
|
||||
clients.append(installation.get_github_for_installation())
|
||||
|
||||
@@ -136,7 +136,7 @@ class Repository(GithubService):
|
||||
)
|
||||
try:
|
||||
# Use get_dependabot_alerts to check if Dependabot alerts are enabled
|
||||
repo.get_dependabot_alerts()[0]
|
||||
repo.get_dependabot_alerts().totalCount
|
||||
# If the call succeeds, Dependabot is enabled (even if no alerts)
|
||||
dependabot_alerts_enabled = True
|
||||
except Exception as error:
|
||||
|
||||
Reference in New Issue
Block a user