Rework ssh host key check

This commit is contained in:
crschnick 2024-04-13 21:07:38 +00:00
parent f585969233
commit 4c26c84a70
14 changed files with 45 additions and 3 deletions

View file

@ -29,8 +29,8 @@ public class SecretManager {
}
public static synchronized SecretQueryProgress expectAskpass(
UUID request, UUID storeId, List<SecretQuery> suppliers, SecretQuery fallback, CountDown countDown) {
var p = new SecretQueryProgress(request, storeId, suppliers, fallback, countDown);
UUID request, UUID storeId, List<SecretQuery> suppliers, SecretQuery fallback, List<SecretQueryFilter> filters, CountDown countDown) {
var p = new SecretQueryProgress(request, storeId, suppliers, fallback, filters, countDown);
progress.add(p);
return p;
}
@ -56,7 +56,7 @@ public class SecretManager {
}
var uuid = UUID.randomUUID();
var p = expectAskpass(uuid, secretId, List.of(strategy.query()), SecretQuery.prompt(false), CountDown.of());
var p = expectAskpass(uuid, secretId, List.of(strategy.query()), SecretQuery.prompt(false), List.of(), CountDown.of());
p.preAdvance(sub);
var r = p.process(prompt);
completeRequest(uuid);

View file

@ -0,0 +1,10 @@
package io.xpipe.app.util;
import io.xpipe.core.util.SecretValue;
import java.util.Optional;
public interface SecretQueryFilter {
Optional<SecretValue> filter(String prompt);
}

View file

@ -18,6 +18,7 @@ public class SecretQueryProgress {
private final UUID storeId;
private final List<SecretQuery> suppliers;
private final SecretQuery fallback;
private final List<SecretQueryFilter> filters;
private final List<String> seenPrompts;
private final CountDown countDown;
private boolean requestCancelled;
@ -27,11 +28,13 @@ public class SecretQueryProgress {
@NonNull UUID storeId,
@NonNull List<SecretQuery> suppliers,
@NonNull SecretQuery fallback,
@NonNull List<SecretQueryFilter> filters,
@NonNull CountDown countDown) {
this.requestId = requestId;
this.storeId = storeId;
this.suppliers = new ArrayList<>(suppliers);
this.fallback = fallback;
this.filters = filters;
this.countDown = countDown;
this.seenPrompts = new ArrayList<>();
}
@ -49,6 +52,13 @@ public class SecretQueryProgress {
return null;
}
for (SecretQueryFilter filter : filters) {
var o = filter.filter(prompt);
if (o.isPresent()) {
return o.get();
}
}
var seenBefore = seenPrompts.contains(prompt);
if (!seenBefore) {
seenPrompts.add(prompt);

View file

@ -297,3 +297,5 @@ openAsRoot=Als Root öffnen
openInVsCodeRemote=Öffnen in VSCode remote
openInWSL=In WSL öffnen
launch=Starten
sshTrustKeyHeader=Der Hostschlüssel ist nicht bekannt und du hast die manuelle Überprüfung des Hostschlüssels aktiviert.
sshTrustKeyTitle=Unbekannter Host-Schlüssel

View file

@ -296,3 +296,5 @@ openAsRoot=Open as root
openInVsCodeRemote=Open in VSCode remote
openInWSL=Open in WSL
launch=Launch
sshTrustKeyHeader=The host key is not known, and you have enabled manual host key verification.
sshTrustKeyTitle=Unknown host key

View file

@ -295,3 +295,5 @@ openAsRoot=Abrir como raíz
openInVsCodeRemote=Abrir en VSCode remoto
openInWSL=Abrir en WSL
launch=Inicia
sshTrustKeyHeader=No se conoce la clave del host y has activado la verificación manual de la clave del host.
sshTrustKeyTitle=Clave de host desconocida

View file

@ -295,3 +295,5 @@ openAsRoot=Ouvrir en tant que racine
openInVsCodeRemote=Ouvrir en VSCode à distance
openInWSL=Ouvrir en WSL
launch=Lancer
sshTrustKeyHeader=La clé de l'hôte n'est pas connue et tu as activé la vérification manuelle de la clé de l'hôte.
sshTrustKeyTitle=Clé d'hôte inconnue

View file

@ -295,3 +295,5 @@ openAsRoot=Apri come root
openInVsCodeRemote=Aprire in VSCode remoto
openInWSL=Aprire in WSL
launch=Lancio
sshTrustKeyHeader=La chiave host non è nota e hai attivato la verifica manuale della chiave host.
sshTrustKeyTitle=Chiave host sconosciuta

View file

@ -295,3 +295,5 @@ openAsRoot=ルートとして開く
openInVsCodeRemote=VSCodeリモートで開く
openInWSL=WSLで開く
launch=起動
sshTrustKeyHeader=ホスト鍵が不明で、手動ホスト鍵検証を有効にしている。
sshTrustKeyTitle=不明なホストキー

View file

@ -295,3 +295,5 @@ openAsRoot=Openen als root
openInVsCodeRemote=Openen in VSCode op afstand
openInWSL=Openen in WSL
launch=Start
sshTrustKeyHeader=De hostsleutel is niet bekend en je hebt handmatige hostsleutelverificatie ingeschakeld.
sshTrustKeyTitle=Onbekende hostsleutel

View file

@ -295,3 +295,5 @@ openAsRoot=Abre como raiz
openInVsCodeRemote=Abre no VSCode remoto
openInWSL=Abre em WSL
launch=Lança
sshTrustKeyHeader=A chave do anfitrião não é conhecida e activaste a verificação manual da chave do anfitrião.
sshTrustKeyTitle=Chave de anfitrião desconhecida

View file

@ -295,3 +295,5 @@ openAsRoot=Открыть как корень
openInVsCodeRemote=Открыть в VSCode remote
openInWSL=Открыть в WSL
launch=Запустите
sshTrustKeyHeader=Ключ хоста неизвестен, и ты включил ручную проверку ключа хоста.
sshTrustKeyTitle=Неизвестный ключ хоста

View file

@ -295,3 +295,5 @@ openAsRoot=Kök olarak aç
openInVsCodeRemote=VSCode remote'da açın
openInWSL=WSL'de Açık
launch=Fırlatma
sshTrustKeyHeader=Ana bilgisayar anahtarı bilinmiyor ve manuel ana bilgisayar anahtarı doğrulamasını etkinleştirdiniz.
sshTrustKeyTitle=Bilinmeyen ana bilgisayar anahtarı

View file

@ -295,3 +295,5 @@ openAsRoot=以根用户身份打开
openInVsCodeRemote=在 VSCode 远程中打开
openInWSL=在 WSL 中打开
launch=启动
sshTrustKeyHeader=主机密钥未知,您已启用手动主机密钥验证。
sshTrustKeyTitle=未知主机密钥