Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[github] update package/manifest for private repos #1721

Closed
wants to merge 4 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions server.js
Original file line number Diff line number Diff line change
Expand Up @@ -3476,16 +3476,20 @@ cache(function(query_data, match, sendBadge, request) {
var repo = match[4];
var branch = match[5] || 'master';
var format = match[6];
var apiUrl = 'https://raw.githubusercontent.com/' + user + '/' + repo + '/' + branch + '/' + type + '.json';
var hasTokens = !!githubAuth.getTokenDebugInfo({ sanitize: false }).tokens.length;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey, thanks for updating this. This method call is intended for generating debug information and it would be surprising to see it used here. It's also not the right condition. Production uses token rotation, so this will be true, and that's where we want to avoid sending auth information.

I think the thing to check is whether a static token is configured: whether either serverSecrets.gh_token or serverSecrets.gh_client_id is set.

var apiUrl = hasTokens
? githubApiUrl + '/repos/' + user + '/' + repo + '/contents/' + type + '.json?ref=' + branch
: 'https://raw.githubusercontent.com/' + user + '/' + repo + '/' + branch + '/' + type + '.json';
var badgeData = getBadgeData(type, query_data);
request(apiUrl, function(err, res, buffer) {
var requestCallback = function(err, res, buffer) {
if (err != null) {
badgeData.text[1] = 'inaccessible';
sendBadge(format, badgeData);
return;
}
try {
var json_data = JSON.parse(buffer);
if (hasTokens) json_data = JSON.parse(Buffer.from(json_data.content, 'base64'));
switch(info) {
case 'v':
case 'version':
Expand All @@ -3508,7 +3512,9 @@ cache(function(query_data, match, sendBadge, request) {
badgeData.text[1] = 'invalid data';
sendBadge(format, badgeData);
}
});
};
if (hasTokens) githubAuth.request(request, apiUrl, { }, requestCallback);
else request(apiUrl, requestCallback);
}));

// GitHub contributors integration.
Expand Down