Open quine opened 8 months ago
@quine are you still seeing this issue? Are you able to fix and test it?
@jgadsden Sorry for not getting back to you sooner! Let me go back and check.
thanks, much appreciated @quine - there have been a few changes in this area so it may be working now I am not able to test it myself as I do not have access to a github enterprise account
@jgadsden Roger that. Will test today. 🤞
@jgadsden Unfortunately, it looks like it's still constructing the URL incorrectly:
/api/v3:443/user
As an aside, seems like Octonode is no longer maintained -- repo's been archived.
Okay, so this is still totally an issue with Octonode. I reckon, if it was at all possible to get a change upstream, we could do something like this in octonode/client.coffee, something like :
if @options?.baseapipath and urlFromPath.pathname
urlFromPath.pathname = "#{@options.baseapipath}#{urlFromPath.pathname}"
_url = url.format
protocol: urlFromPath.protocol or @options?.protocol or "https:"
auth: urlFromPath.auth or if @token?.username and @token?.password then "#{@token.username}:#{@token.password}" else ''
hostname: urlFromPath.hostname or @options?.hostname or "api.github.com"
port: urlFromPath.port or @options?.port
pathname: urlFromPath.pathname
query: query
and then update td.server/src/repositories/githubrepo.js like:
const getClient = (accessToken) => {
const enterpriseHostname = env.get().config.GITHUB_ENTERPRISE_HOSTNAME;
if (enterpriseHostname) {
const port = env.get().config.GITHUB_ENTERPRISE_PORT;
const protocol = env.get().config.GITHUB_ENTERPRISE_PROTOCOL;
const enterpriseOpts = { hostname: `${enterpriseHostname}` };
enterpriseOpts.baseapipath = '/api/v3';
if (port) { enterpriseOpts.port = parseInt(port, 10); }
if (protocol) { enterpriseOpts.protocol = protocol; }
return github.client(accessToken, enterpriseOpts);
}
return github.client(accessToken);
};
At least then /api/v3
(or whatever) would be in the correct place in the URL 🙃
IDK, something like that might work, but again...octonode's no longer maintained, and I have no idea if anyone is taking the reins on it.
@quine thank you for getting to the bottom of this - we can keep it open and see if a non-default GITHUB_ENTERPRISE_PORT using octonode can be correctly used
@jgadsden Sure thing. TBH, simplest workaround in the interim is to just not take in/honor the GITHUB_ENTERPRISE_PORT
/ not set enterpriseOpts.port
, but that sort of kneecaps anyone running GHE on something other than 443/tcp
.
Half-jokingly(?), someone could actually take over/fork Octonode -- or...more seriously, and far less appealing I'm sure, switch to something else, such as Octokit.js? 🙁
Describe the bug: Threat Dragon is improperly constructing GitHub Enterprise (GHE) URLs (after initial OAuth login), leading to
404
errors on GHE, with Threat Dragon then returning500
errors.It appears to start here:
The inclusion of both the base path (
/api/v3
) and theport
when constructing the URL for octonode causes the URL to be invalid.Using
github.company.com
as the example...enterpriseOpts
is set to, then:enterpriseOpts { hostname: 'github.company.com/api/v3', port: 443, protocol: 'https' }
this.options.hostname
ishttp://github.company.com/api/v3
, so_url
ends up beinghttps://github.company.com/api/v3:443/user
Expected behaviour: Threat Dragon should properly construct the GHE URL.
Environment:
To Reproduce:
GITHUB_ENTERPRISE_HOSTNAME
in Threat Dragon's env/api/v3/user
returns an errortd.server
logs, displaying error similar to below:https://github.company.com/api/v3:443/user