MCPcopy Index your code
hub / github.com/microsoft/vscode-cpptools / FingerprintInteractor

Class FingerprintInteractor

Extension/src/SSH/commandInteractors.ts:62–112  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

60}
61
62export class FingerprintInteractor implements IInteractor {
63 static ID = 'fingerprint';
64
65 constructor(private readonly hostName: string, private readonly confirmationProvider: IFingerprintConfirmationProvider) { }
66
67 get id(): string {
68 return FingerprintInteractor.ID;
69 }
70
71 async onData(data: string, cancelToken?: vscode.CancellationToken, extraDetails?: IInteractorDataDetails): Promise<IInteraction> {
72 const fingerprintMatcher: RegExp = /fingerprint\sis\s(.+)\./;
73
74 const result: IInteraction = { postAction: 'keep' };
75 data = data.trim();
76
77 let fingerprintMatch: RegExpMatchArray | null;
78 if (
79 data.includes('Are you sure you want to continue connecting') &&
80 (fingerprintMatch = data.match(fingerprintMatcher))
81 ) {
82 result.postAction = 'consume';
83 const confirmation: string | undefined = await this.confirmationProvider(
84 this.hostName,
85 fingerprintMatch[1],
86 cancelToken
87 );
88 if (confirmation) {
89 result.response = confirmation;
90 } else {
91 result.canceled = true;
92 }
93 } else if (
94 isWindows &&
95 (data.includes('The authenticity of host ') || (data === '' && extraDetails?.detectedServerKey))
96 ) {
97 // hack for #1195
98 // First line local server case (git ssh only gives the first line over ssh_askpass)
99 const key: string = extraDetails?.detectedServerKey || '(unknown)';
100
101 result.postAction = 'consume';
102 const confirmation: string | undefined = await this.confirmationProvider(this.hostName, key, cancelToken);
103 if (confirmation) {
104 result.response = confirmation;
105 } else {
106 result.canceled = true;
107 }
108 }
109
110 return result;
111 }
112}
113
114export class DifferingHostKeyInteractor implements IInteractor {
115 static ID = 'differing host key';

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected