Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
91 changes: 82 additions & 9 deletions gui/src/main.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { invoke } from "@tauri-apps/api/core";
import { invoke } from "@tauri-apps/api/core";
import { open } from "@tauri-apps/plugin-dialog";
import "./styles.css";

Expand Down Expand Up @@ -241,6 +241,51 @@ function setError(message: string) {
verdictMessage.textContent = message;
}

function getLocalizedResult(result: AnalysisResult) {
const level = result.risk_level.toLowerCase();

if (mode === "dynamic") {
if (language === "tr") {
return {
title: "Dinamik analiz tamamlandı",
message: "Çalıştırma davranışı raporlandı. Detayları aşağıdan incele.",
};
}

return {
title: "Dynamic analysis completed",
message: "Runtime behavior was reported. Review the details below.",
};
}

if (level === "high" || result.risk_score >= 50) {
return {
title: language === "tr" ? "Zararlı olabilir" : "Potentially malicious",
message:
language === "tr"
? "Yüksek riskli göstergeler bulundu. Dosyayı izole ortam dışında çalıştırma."
: "High-risk indicators were found. Do not run this file outside an isolated environment.",
};
}

if (level === "medium" || result.risk_score >= 20) {
return {
title: language === "tr" ? "Şüpheli dosya" : "Suspicious file",
message:
language === "tr"
? "Dosyada şüpheli API kullanımları veya riskli bölümler bulundu."
: "Suspicious API usage or risky sections were found in the file.",
};
}

return {
title: language === "tr" ? "Temiz görünüyor" : "Looks clean",
message:
language === "tr"
? "Statik analizde yüksek riskli belirti bulunmadı."
: "No high-risk indicators were found during static analysis.",
};
}
function setResult(result: AnalysisResult) {
lastResult = result;
const level = result.risk_level.toLowerCase();
Expand All @@ -256,8 +301,10 @@ function setResult(result: AnalysisResult) {
verdictIcon.textContent = "✓";
}

verdictTitle.textContent = result.verdict;
verdictMessage.textContent = result.message;
const localizedResult = getLocalizedResult(result);

verdictTitle.textContent = localizedResult.title;
verdictMessage.textContent = localizedResult.message;
riskLevelValue.textContent = result.risk_level || "-";
riskScoreValue.textContent = String(result.risk_score ?? "-");
fileSizeValue.textContent = result.file_size ? `${result.file_size} bytes` : "-";
Expand Down Expand Up @@ -325,23 +372,46 @@ fileButton.addEventListener("click", async () => {
});

analyzeButton.addEventListener("click", async () => {
const currentText = t();

if (!filePath) {
setError(t().selectFileError);
setError(currentText.selectFileError);
return;
}

if (mode === "dynamic" && !filePath.toLowerCase().endsWith(".exe")) {
setError(
language === "tr"
? "Dinamik analiz sadece çalıştırılabilir .exe dosyaları için kullanılmalıdır."
: "Dynamic analysis should only be used with executable .exe files."
);
return;
}

analyzeButton.disabled = true;
statusText.textContent = t().running;
statusText.textContent = currentText.running;
setRunning();

try {
const outputDirectory = outputInput.value.trim() || "reports";
const command = mode === "static" ? "run_static_analysis" : "run_dynamic_analysis";
const payload = mode === "static"
? { filePath, outputDirectory }
: { filePath, outputDirectory, timeoutSeconds: Number(timeoutInput.value || "30") };

const command =
mode === "static" ? "run_static_analysis" : "run_dynamic_analysis";

const payload =
mode === "static"
? {
filePath: filePath,
outputDirectory,
}
: {
filePath: filePath,
outputDirectory,
timeoutSeconds: Number(timeoutInput.value || "30"),
};

const result = await invoke<AnalysisResult>(command, payload);

setResult(result);
statusText.textContent = t().complete;
} catch (error) {
Expand Down Expand Up @@ -438,3 +508,6 @@ function startMatrix() {

renderText();
startMatrix();



Loading