dx-scanner
dx-scanner copied to clipboard
GitHub doesn't support self-hosted repositories
GitHub can be self-hosted as well as Gitlab.
Hey @adelkahomolova , I am pretty confused. What exactly needs to be done in this issue?
Hi, @hariom1625, thank you for the question. It is necessary to find out which VCS service is used (we support GitLab, GitHub, and Bitbucket). The way, how we found it out is just by URL (checking for "GitHub" string in URL). See ScanningStrategyDetectorUtils.ts As GitHub has also the option to have self-hosted repositories it is necessary to add this support. We've already implemented it for GitLab, so you can get the inspiration there ScanningStrategyDetector.ts Did I answer your question? :)
Hey @adelkahomolova, I would love to trigger this issue and add support for GitHub. Can I go ahead?
Hi, @hariom1625, thank you for the question. It is necessary to find out which VCS service is used (we support GitLab, GitHub, and Bitbucket). The way, how we found it out is just by URL (checking for "GitHub" string in URL). See ScanningStrategyDetectorUtils.ts As GitHub has also the option to have self-hosted repositories it is necessary to add this support. We've already implemented it for GitLab, so you can get the inspiration there ScanningStrategyDetector.ts Did I answer your question? :)
Yes @adelkahomolova, That was helpful :-)
@haardikdharma10 Sure! Go ahead :)
Thanks @adelkahomolova. I'd like some help on getting started. I went through both the files you mentioned above. The question I have is, do I need to change anything in the /src/services folder? I can see the file (GitHubService) but nothing such as githubClient similar to the one in gitlab folder (gitlabClient). Additionally, if you can help me with the files I need to edit, that'd be great :)
@haardikdharma10 Hi! Thank you for your question! There is no client for Github because we are using the Octokit library and it acts as the "Client".
There is a function to detect self-hosted Gitlab called determineGitLabRemoteServiceType: https://github.com/DXHeroes/dx-scanner/blob/master/src/detectors/ScanningStrategyDetector.ts#L193-L221 that is called in the function determineInputType: https://github.com/DXHeroes/dx-scanner/blob/master/src/detectors/ScanningStrategyDetector.ts#L90-L91
The correct solution is to create a similar function that tries to detect Github on a custom URL. E.g. to call endpoint https://api.[CUSTOM_DOMAIN] and it should return a similar response like this: https://api.github.com
According to the response format and some keys, we're able to detect that the custom URL is remote Github on any other domain than github.com.
Do not hesitate to ask us if you have any other questions. 👏
Thank you
@prokopsimek, Thanks a lot for such a brief and prompt response. It cleared almost everything in my head. Just to make sure before starting working on it:
- First thing is to add the two functions (listRepos and listGroups) in the GitHubService.ts file similar to the ones in the GitLabService.ts.
- Second, create a function similar to
determineGitLabRemoteServiceTypeand call it indetermineInputType.
If all of this sounds good to you, can I go ahead and raise a PR?
-
It's not about adding the same methods as we use for GitLab. You have to find out, which endpoints ensure that you can get a valid response. But in the case of getting a list of repositories and lists of groups, the answer is yes. You have to add these methods in GitHubService.ts and than use them for determining.
-
Yes, create similar to
determineGitLabRemoteServiceTypebut call it the same way, sodetermineGitHubRemoteServiceType
If it's now clear to you, go for it! 👍
@haardikdharma10
Thanks a lot! On it.