From 3dfaa88a1d51473c90ad3fd5babdaae8e24a4c14 Mon Sep 17 00:00:00 2001 From: Robert Brignull Date: Thu, 27 Aug 2020 16:45:28 +0100 Subject: [PATCH] Remove process of auth --- lib/api-client.js | 13 +------------ lib/api-client.js.map | 2 +- src/api-client.ts | 15 +-------------- src/runner.ts | 2 +- 4 files changed, 4 insertions(+), 28 deletions(-) diff --git a/lib/api-client.js b/lib/api-client.js index 7f3e6e693..0534e62a0 100644 --- a/lib/api-client.js +++ b/lib/api-client.js @@ -20,7 +20,7 @@ exports.getApiClient = function (githubAuth, githubUrl, allowLocalRun = false) { throw new Error('Invalid API call in local run'); } return new github.GitHub({ - auth: parseAuth(githubAuth), + auth: githubAuth, baseUrl: getApiUrl(githubUrl), userAgent: "CodeQL Action", log: console_log_level_1.default({ level: "debug" }) @@ -37,17 +37,6 @@ function getApiUrl(githubUrl) { url.pathname = path.join(url.pathname, 'api', 'v3'); return url.toString(); } -// Parses the user input as either a single token, -// or a username and password / PAT. -function parseAuth(auth) { - // Check if it's a username:password pair - const c = auth.indexOf(':'); - if (c !== -1) { - return 'basic ' + Buffer.from(auth).toString('base64'); - } - // Otherwise use the token as it is - return auth; -} // Temporary function to aid in the transition to running on and off of github actions. // Once all code has been coverted this function should be removed or made canonical // and called only from the action entrypoints. diff --git a/lib/api-client.js.map b/lib/api-client.js.map index eca0d44dc..8d3ecd4cb 100644 --- a/lib/api-client.js.map +++ b/lib/api-client.js.map @@ -1 +1 @@ -{"version":3,"file":"api-client.js","sourceRoot":"","sources":["../src/api-client.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,oDAAsC;AACtC,wDAA0C;AAC1C,0EAAgD;AAChD,2CAA6B;AAE7B,iCAAyD;AAE5C,QAAA,YAAY,GAAG,UAAS,UAAkB,EAAE,SAAiB,EAAE,aAAa,GAAG,KAAK;IAC/F,IAAI,iBAAU,EAAE,IAAI,CAAC,aAAa,EAAE;QAClC,MAAM,IAAI,KAAK,CAAC,+BAA+B,CAAC,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,CAAC,CAAC;AACnB,CAAC;AALD,kDAKC"} \ No newline at end of file diff --git a/src/api-client.ts b/src/api-client.ts index c025a8342..91e4faaa1 100644 --- a/src/api-client.ts +++ b/src/api-client.ts @@ -11,7 +11,7 @@ export const getApiClient = function(githubAuth: string, githubUrl: string, allo } return new github.GitHub( { - auth: parseAuth(githubAuth), + auth: githubAuth, baseUrl: getApiUrl(githubUrl), userAgent: "CodeQL Action", log: consoleLogLevel({ level: "debug" }) @@ -32,19 +32,6 @@ function getApiUrl(githubUrl: string): string { return url.toString(); } -// Parses the user input as either a single token, -// or a username and password / PAT. -function parseAuth(auth: string): string { - // Check if it's a username:password pair - const c = auth.indexOf(':'); - if (c !== -1) { - return 'basic ' + Buffer.from(auth).toString('base64'); - } - - // Otherwise use the token as it is - return auth; -} - // Temporary function to aid in the transition to running on and off of github actions. // Once all code has been coverted this function should be removed or made canonical // and called only from the action entrypoints. diff --git a/src/runner.ts b/src/runner.ts index 3eee39219..28560d1d2 100644 --- a/src/runner.ts +++ b/src/runner.ts @@ -84,7 +84,7 @@ program .description('Initializes CodeQL') .requiredOption('--repository ', 'Repository name') .requiredOption('--github-url ', 'URL of GitHub instance') - .requiredOption('--github-auth ', 'GitHub Apps token, or of the form "username:token" if using a personal access token') + .requiredOption('--github-auth ', 'GitHub Apps token or personal access token') .option('--languages ', 'Comma-separated list of languages to analyze. Defaults to trying to detect languages from the repo.') .option('--queries ', 'Comma-separated list of additional queries to run. By default, this overrides the same setting in a configuration file.') .option('--config-file ', 'Path to config file')