Remove all traces of the old askpass trampoline script 🔥 🎉

This commit is contained in:
Sergio Padrino 2021-08-17 13:24:30 +02:00
parent 132c8dd7db
commit 9704466f42
16 changed files with 2 additions and 148 deletions

View file

@ -13,7 +13,6 @@ module.exports = {
'!**/vendor/**',
'!**/*.d.*',
// not focused on testing these areas currently
'!src/ask-pass/**/*',
'!src/cli/**/*',
'!src/crash/**/*',
'!src/highlighter/**/*',

View file

@ -1,26 +0,0 @@
import { getKeyForEndpoint } from '../lib/auth'
import { TokenStore } from '../lib/stores/token-store'
/** Parse the GIT_ASKPASS prompt and determine the appropriate response. */
export async function responseForPrompt(
prompt: string
): Promise<string | null> {
const username = process.env.DESKTOP_USERNAME
if (username == null || username.length === 0) {
return null
}
if (prompt.startsWith('Username')) {
return username
} else if (prompt.startsWith('Password')) {
const endpoint = process.env.DESKTOP_ENDPOINT
if (endpoint == null || endpoint.length === 0) {
return null
}
const key = getKeyForEndpoint(endpoint)
return await TokenStore.getItem(key, username)
}
return null
}

View file

@ -1,13 +0,0 @@
/**
* This will be run by the `ask-pass-trampoline`.
*/
import { responseForPrompt } from './ask-pass'
const prompt = process.argv[2]
responseForPrompt(prompt).then(response => {
if (response) {
process.stdout.write(response)
process.stdout.end()
}
})

View file

@ -47,11 +47,6 @@ export function enableHideWhitespaceInDiffOption(): boolean {
return true
}
/** Should the app use the shiny new TCP-based trampoline? */
export function enableDesktopTrampoline(): boolean {
return true
}
/**
* Should we use the new diff viewer for unified diffs?
*/

View file

@ -39,12 +39,7 @@ declare const __UPDATES_URL__: string
* The currently executing process kind, this is specific to desktop
* and identifies the processes that we have.
*/
declare const __PROCESS_KIND__:
| 'main'
| 'ui'
| 'crash'
| 'askpass'
| 'highlighter'
declare const __PROCESS_KIND__: 'main' | 'ui' | 'crash' | 'highlighter'
/**
* The IdleDeadline interface is used as the data type of the input parameter to

View file

@ -1,7 +1,6 @@
import { trampolineServer } from './trampoline-server'
import { withTrampolineToken } from './trampoline-tokens'
import * as Path from 'path'
import { enableDesktopTrampoline } from '../feature-flag'
import { getDesktopTrampolineFilename } from 'desktop-trampoline'
import { TrampolineCommandIdentifier } from '../trampoline/trampoline-command'
import { getSSHEnvironment } from '../ssh/ssh'
@ -24,10 +23,6 @@ import {
export async function withTrampolineEnv<T>(
fn: (env: Object) => Promise<T>
): Promise<T> {
const askPassPath = enableDesktopTrampoline()
? getDesktopTrampolinePath()
: getAskPassTrampolinePath()
const sshEnv = await getSSHEnvironment()
return withTrampolineToken(async token => {
@ -45,14 +40,10 @@ export async function withTrampolineEnv<T>(
const result = await fn({
DESKTOP_PORT: await trampolineServer.getPort(),
DESKTOP_TRAMPOLINE_TOKEN: token,
GIT_ASKPASS: askPassPath,
GIT_ASKPASS: getDesktopTrampolinePath(),
DESKTOP_TRAMPOLINE_IDENTIFIER: TrampolineCommandIdentifier.AskPass,
...sshEnv,
// Env variables specific to the old askpass trampoline
DESKTOP_PATH: process.execPath,
DESKTOP_ASKPASS_SCRIPT: getAskPassScriptPath(),
})
await storePendingSSHKeyPassphrase(token)
@ -73,15 +64,6 @@ export function getDesktopTrampolinePath(): string {
)
}
function getAskPassTrampolinePath(): string {
const extension = __WIN32__ ? 'bat' : 'sh'
return Path.resolve(__dirname, 'static', `ask-pass-trampoline.${extension}`)
}
function getAskPassScriptPath(): string {
return Path.resolve(__dirname, 'ask-pass.js')
}
/** Returns the path of the ssh-wrapper binary. */
export function getSSHWrapperPath(): string {
return Path.resolve(__dirname, 'desktop-trampoline', 'ssh-wrapper')

View file

@ -1,6 +1,5 @@
import { createServer, AddressInfo, Server, Socket } from 'net'
import split2 from 'split2'
import { enableDesktopTrampoline } from '../feature-flag'
import { sendNonFatalException } from '../helpers/non-fatal-exception'
import { askpassTrampolineHandler } from './trampoline-askpass-handler'
import {
@ -51,11 +50,6 @@ export class TrampolineServer {
}
private async listen(): Promise<void> {
if (!enableDesktopTrampoline()) {
this.listeningPromise = Promise.resolve()
return this.listeningPromise
}
this.listeningPromise = new Promise((resolve, reject) => {
// Observe errors while trying to start the server
this.server.on('error', error => {

View file

@ -1,3 +0,0 @@
#!/bin/sh
ELECTRON_RUN_AS_NODE=1 "$DESKTOP_PATH" "$DESKTOP_ASKPASS_SCRIPT" "$@"

View file

@ -1,3 +0,0 @@
#!/bin/sh
ELECTRON_RUN_AS_NODE=1 "$DESKTOP_PATH" "$DESKTOP_ASKPASS_SCRIPT" "$@"

View file

@ -1,9 +0,0 @@
@echo off
setlocal
set ELECTRON_RUN_AS_NODE=1
set ELECTRON_NO_ATTACH_CONSOLE=1
"%DESKTOP_PATH%" "%DESKTOP_ASKPASS_SCRIPT%" %*
endlocal

View file

@ -130,18 +130,6 @@ export const renderer = merge({}, commonConfig, {
],
})
export const askPass = merge({}, commonConfig, {
entry: { 'ask-pass': path.resolve(__dirname, 'src/ask-pass/main') },
target: 'node',
plugins: [
new webpack.DefinePlugin(
Object.assign({}, replacements, {
__PROCESS_KIND__: JSON.stringify('askpass'),
})
),
],
})
export const crash = merge({}, commonConfig, {
entry: { crash: path.resolve(__dirname, 'src/crash/index') },
target: 'electron-renderer',

View file

@ -9,7 +9,6 @@ const config: webpack.Configuration = {
}
const mainConfig = merge({}, common.main, config)
const askPassConfig = merge({}, common.askPass, config)
const cliConfig = merge({}, common.cli, config)
const highlighterConfig = merge({}, common.highlighter, config)
@ -80,7 +79,6 @@ const crashConfig = merge({}, common.crash, config, {
export default [
mainConfig,
rendererConfig,
askPassConfig,
crashConfig,
cliConfig,
highlighterConfig,

View file

@ -11,7 +11,6 @@ const config: webpack.Configuration = {
}
const mainConfig = merge({}, common.main, config)
const askPassConfig = merge({}, common.askPass, config)
const cliConfig = merge({}, common.cli, config)
const highlighterConfig = merge({}, common.highlighter, config)
@ -65,7 +64,6 @@ const crashConfig = merge({}, common.crash, config, {
export default [
mainConfig,
rendererConfig,
askPassConfig,
crashConfig,
cliConfig,
highlighterConfig,

View file

@ -10,7 +10,6 @@
- [Enable Mandatory ASLR triggers cygheap errors](#enable-mandatory-aslr-triggers-cygheap-errors)
- [I get a black screen when launching Desktop](#i-get-a-black-screen-when-launching-desktop)
- [Failed to open CA file after an update](#failed-to-open-ca-file-after-an-update)
- [`ask-pass-trampoline.bat` errors](#ask-pass-trampolinebat-errors)
- [Authentication errors due to modified registry entries](#authentication-errors-due-to-modified-registry-entries)
# Known Issues
@ -193,37 +192,6 @@ file:"C:\ProgramData/Git/config" http.sslcainfo=[some value here]
sslCAInfo = [some value here]
```
### `ask-pass-trampoline.bat` errors
Related issues: - [#2623](https://github.com/desktop/desktop/issues/2623), [#4124](https://github.com/desktop/desktop/issues/4124), [#6882](https://github.com/desktop/desktop/issues/6882), [#6789](https://github.com/desktop/desktop/issues/6879)
An example of the error message:
```
The system cannot find the path specified.
error: unable to read askpass response from 'C:\Users\User\AppData\Local\GitHubDesktop\app-1.6.2\resources\app\static\ask-pass-trampoline.bat'
fatal: could not read Username for 'https://github.com': terminal prompts disabled"
```
Known causes and workarounds:
**If you're experiencing this error, please download the [beta version](https://github.com/desktop/desktop#beta-channel) where it should hopefully be solved.**
- Modifying the `AutoRun` registry entry. To check if this entry has been modified open `Regedit.exe` and navigate to `HKEY_CURRENT_USER\Software\Microsoft\Command Processor\autorun` and `HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Command Processor\autorun` to see if there is anything set (sometimes applications will also modify this). See [#6789](https://github.com/desktop/desktop/issues/6879#issuecomment-471042891) and [#2623](https://github.com/desktop/desktop/issues/2623#issuecomment-334305916) for examples of this.
- Special characters in your Windows username like a `&` or `-` can cause this error to be thrown. See [#7064](https://github.com/desktop/desktop/issues/7064) for an example of this. Try installing GitHub Desktop in a new user account to verify if this is the case.
- Antivirus software can sometimes prevent GitHub Desktop from installing correctly. If you are running antivirus software that could be causing this try temporarily disabling it and reinstalling GitHub Desktop.
- Restrictive permissions on your Windows user account. If you are running GitHub Desktop as a non-admin user try launching the application as an administrator (right-click -> `Run as administrator`). See [#5082](https://github.com/desktop/desktop/issues/5082#issuecomment-483067198).
- If none of these potential causes are present on your machine, try performing a fresh installation of GitHub Desktop to see if that gets things working again. Here are the steps you can take to do that:
1. Close GitHub Desktop
2. Delete the `%AppData%\GitHub Desktop\` directory
3. Delete the `%LocalAppData%\GitHubDesktop\` directory
4. Reinstall GitHub Desktop from [desktop.github.com](https://desktop.github.com)
### Authentication errors due to modified registry entries
Related issue: [#2623](https://github.com/desktop/desktop/issues/2623)

View file

@ -101,14 +101,6 @@ initializes to perform asynchronous computation of syntax highlighting in diffs.
Modules and logic that Desktop uses to show a default UI when an unhandled error
occurs that crashes the main application.
### AskPass script - `app/src/ask-pass`
Modules and logic that Desktop uses to act as a credential helper for it's Git
operations, bypassing whatever the user has set in config. This is a separate
component because Desktop will spawn Git which can only spawn another program,
so Desktop sets this script as the program to execute if Git encounters an
authentication prompt.
### Command Line Interface - `app/src/cli`
Module and logic to be bundled for the `github` command line interface that

View file

@ -20,7 +20,6 @@ The webpack configuration files organize the source files into these targets:
- `renderer.js` - logic in the renderer process in Electron
- `crash.js` - specialised UI for displaying an error that crashed the app
- `highlighter.js` - logic for syntax highlighting, which runs in a web worker
- `ask-pass.js` - logic for handling authentication requests from Git
- `cli.js` - logic for the `github` command line interface
Webpack also handles these steps: