Comparing version 3.1.16 to 3.1.17
@@ -9,2 +9,5 @@ const assert = require('assert'); | ||
const GITHUB_SSO_HELP_DOCUMENTATION = 'https://docs.github.com/articles/authenticating-to-a-github-organization-with-saml-single-sign-on/'; | ||
const GITHUB_AUTH_HELP_DOCUMENTATION = 'https://gist.github.com/trevorlinton/5ea1a1e4afb87377dff68b1e32520e24'; | ||
function format_plugins(plugin) { | ||
@@ -115,6 +118,45 @@ return `**:: ${plugin.name}** | ||
fs.mkdirSync(tmp_dir); | ||
const output = proc.spawnSync('git', ['clone', args.GITHUB_REPO, tmp_dir], { | ||
cwd: process.cwd(), env: process.env, shell: isWindows || undefined, | ||
}); | ||
const gitArgs = (repo) => (['clone', repo, tmp_dir]); | ||
const gitOptions = { | ||
cwd: process.cwd(), | ||
shell: isWindows || undefined, | ||
env: { | ||
...process.env, | ||
GIT_TERMINAL_PROMPT: 0, // Disable git terminal prompting (e.g. username, password) | ||
GIT_SSH_COMMAND: 'ssh -oBatchMode=yes', // Disable ssh prompts (e.g. host key verification) | ||
}, | ||
}; | ||
let output = proc.spawnSync('git', gitArgs(args.GITHUB_REPO), gitOptions); | ||
// User was prompted for username & password. They may have configured SSH authentication | ||
if ( | ||
output.stderr | ||
&& output.stderr.toString().toLowerCase().includes('could not read') | ||
&& output.stderr.toString().toLowerCase().includes('terminal prompts disabled') | ||
) { | ||
// Try ssh authentication instead | ||
let SSH_REPO = args.GITHUB_REPO.replace('https://github.com/', 'ssh://git@github.com/'); | ||
if (SSH_REPO.slice(-1) === '/') { | ||
SSH_REPO = SSH_REPO.slice(0, -1); | ||
} | ||
output = proc.spawnSync('git', gitArgs(SSH_REPO), gitOptions); | ||
// SSH authentication failed. This indicates that SSH auth has not been set up (or has been set up incorrectly) | ||
// If SSO has not been enabled, then kick up to the if statement that handles SSO errors | ||
if ( | ||
output.stderr && !output.stderr.toString().toLowerCase().includes('enabled or enforced saml sso') && ( | ||
output.stderr.toString().toLowerCase().includes('permission denied (publickey)') | ||
|| output.stderr.toString().toLowerCase().includes('host key verification failed') | ||
|| output.stderr.toString().toLowerCase().includes('repository not found') | ||
|| output.stderr.toString().toLowerCase().includes('could not read from remote repository') | ||
) | ||
) { | ||
// Allow the user to be prompted for username and password | ||
delete gitOptions.env.GIT_TERMINAL_PROMPT; | ||
console.log(`\n💡 You may want to change your authentication method (see ${GITHUB_AUTH_HELP_DOCUMENTATION})\n\n`); | ||
output = proc.spawnSync('git', gitArgs(args.GITHUB_REPO), gitOptions); | ||
} | ||
} | ||
if (output.stderr && output.stderr.toString().toLowerCase().includes('authentication failed')) { | ||
@@ -126,6 +168,6 @@ throw new Error('Error accessing plugin repository - The GitHub username and password were incorrect.'); | ||
const parsedOutput = output.stderr.toString().match(/(https:\/\/github.com.*)\s/); | ||
if (parsedOutput.length < 2) { | ||
throw new Error('Error accessing plugin repository - SSO authentication needed.\n\nFor more information, see https://help.github.com/en/github/authenticating-to-github/authorizing-a-personal-access-token-for-use-with-saml-single-sign-on\n'); | ||
if (!parsedOutput || parsedOutput.length < 2) { | ||
throw new Error(`Error accessing plugin repository - SSO authentication needed.\n\nFor more information, see ${GITHUB_SSO_HELP_DOCUMENTATION}\n`); | ||
} | ||
throw new Error(`Error accessing plugin repository - SSO authentication needed\n\nVisit ${parsedOutput[1]} and try your request again.\n\nFor more information, see https://help.github.com/en/github/authenticating-to-github/authorizing-a-personal-access-token-for-use-with-saml-single-sign-on\n`); | ||
throw new Error(`Error accessing plugin repository - SSO authentication needed\n\nVisit ${parsedOutput[1]} and try your request again.\n\nFor more information, see ${GITHUB_SSO_HELP_DOCUMENTATION}\n`); | ||
} | ||
@@ -152,7 +194,7 @@ | ||
if (e.message.indexOf('ENOTEMPTY') > -1) { | ||
appkit.terminal.error('The plugin is already installed (or a plugin with this name), try using "appkit update" instead.'); | ||
appkit.terminal.error(`The plugin is already installed (or a plugin with this name), try using "${path.basename(process.argv[1])} update" instead.`); | ||
} else if (e.message.indexOf('ENOENT') > -1) { | ||
appkit.terminal.error('The github repo provided did not appear to be a valid repo, check the repo URL and try again.'); | ||
appkit.terminal.error(`The plugin's GitHub repo URL did not appear to be a valid repo. Please check the repo URL and try again.\n\nIf you believe the repo URL is correct, you may need to adjust your authentication method.\nSee ${GITHUB_AUTH_HELP_DOCUMENTATION}`); | ||
} else { | ||
appkit.terminal.error(`Unable to install plugin from ${args.GITHUB_REPO}: ${e.message}`); | ||
appkit.terminal.error(`Unable to install plugin from ${args.GITHUB_REPO}: ${e.message}\n\n🤔 Having trouble with authentication? See ${GITHUB_AUTH_HELP_DOCUMENTATION}`); | ||
} | ||
@@ -159,0 +201,0 @@ if (tmp_dir) { |
{ | ||
"name": "akkeris", | ||
"version": "3.1.16", | ||
"version": "3.1.17", | ||
"description": "Akkeris CLI", | ||
@@ -5,0 +5,0 @@ "main": "aka.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Potential vulnerability
Supply chain riskInitial human review suggests the presence of a vulnerability in this package. It is pending further analysis and confirmation.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
273479
7363
11