Add ALD Transition Console preview and Astra lab build workflow

This commit is contained in:
scandalist-trash committed 2026-10-27 10:50:43 -04:00
1 parent f330a3c00a
commit e5c6a2fc0e
199 files changed
+9866

No files matched your search

+25
View File
@@ -0,0 +1,25 @@
#include "NativeSshTransport.h"
#include "core/Rules.h"
#include <QFileInfo>
#include <QFile>
#include <QTextCodec>
#include <sys/stat.h>
#include <unistd.h>
#include <stdexcept>
namespace ald {
ProcessSpec NativeSshTransport::windowsTask(const SshTarget &t,const QString &task) {
if(!rules::safeHost(t.host.toStdString())||!rules::safeUser(t.user.toStdString())||t.port==0)throw std::runtime_error("Invalid SSH target; no shell metacharacters accepted");
QFileInfo info(t.knownHosts);struct stat st{};
if(!info.isAbsolute()||lstat(QFile::encodeName(t.knownHosts).constData(),&st)!=0||!S_ISREG(st.st_mode)||(st.st_uid!=getuid()&&st.st_uid!=0)||(st.st_mode&0022))throw std::runtime_error("Select a verified, protected known_hosts file; do not trust a scan without independent fingerprint verification");
// The ONLY remote command data is a compiled, hash-checked, fixed script.
// Host/user/known_hosts are local ssh argument values, never remote source code.
const auto script=QString::fromUtf8(OperationRegistry::task(task));
QTextCodec::ConverterState state(QTextCodec::IgnoreHeader);
const auto encoded=QTextCodec::codecForName("UTF-16LE")->fromUnicode(script.constData(),script.size(),&state).toBase64();
if(encoded.size()+64>7800)throw std::runtime_error("Fixed task exceeds the reviewed remote command size; a separately validated transport contract is required");
ProcessSpec s;s.operationId=task;s.program="/usr/bin/ssh";s.remote=true;s.timeoutMs=120000;s.outputLimit=16*1024*1024;
s.arguments=QStringList{"-F","/dev/null","-T","-a","-x","-o","BatchMode=yes","-o","StrictHostKeyChecking=yes","-o","UserKnownHostsFile="+info.absoluteFilePath(),"-o","GlobalKnownHostsFile=/dev/null","-o","ClearAllForwardings=yes","-o","PermitLocalCommand=no","-o","ControlMaster=no","-o","ControlPath=none","-o","ConnectTimeout=10","-o","ServerAliveInterval=10","-o","ServerAliveCountMax=2","-p",QString::number(t.port),"-l",t.user,"--",t.host,
"powershell.exe -NoLogo -NoProfile -NonInteractive -EncodedCommand "+QString::fromLatin1(encoded)};
return s;
}
}