mirror of
https://github.com/AikidoSec/safe-chain.git
synced 2026-05-26 12:10:49 +00:00
Mac: use uninstaller script
This commit is contained in:
parent
81bf46d3c1
commit
2073140d1b
2 changed files with 22 additions and 53 deletions
|
|
@ -3,31 +3,31 @@ import { createHash } from "crypto";
|
||||||
import { pipeline } from "stream/promises";
|
import { pipeline } from "stream/promises";
|
||||||
import fetch from "make-fetch-happen";
|
import fetch from "make-fetch-happen";
|
||||||
|
|
||||||
const ULTIMATE_VERSION = "v0.2.2";
|
const ULTIMATE_VERSION = "v0.2.3";
|
||||||
|
|
||||||
export const DOWNLOAD_URLS = {
|
export const DOWNLOAD_URLS = {
|
||||||
win32: {
|
win32: {
|
||||||
x64: {
|
x64: {
|
||||||
url: `https://github.com/AikidoSec/safechain-internals/releases/download/${ULTIMATE_VERSION}/SafeChainUltimate-windows-amd64.msi`,
|
url: `https://github.com/AikidoSec/safechain-internals/releases/download/${ULTIMATE_VERSION}/SafeChainUltimate-windows-amd64.msi`,
|
||||||
checksum:
|
checksum:
|
||||||
"sha256:82d6939579c23c357d0f6d368001a5ac8dc66ce13d32ee1700467555ee97e10a",
|
"sha256:bd196ae05b876588f828a57c4d19b3e7ad96ba40007cf2b36693dc6e792d28cc",
|
||||||
},
|
},
|
||||||
arm64: {
|
arm64: {
|
||||||
url: `https://github.com/AikidoSec/safechain-internals/releases/download/${ULTIMATE_VERSION}/SafeChainUltimate-windows-arm64.msi`,
|
url: `https://github.com/AikidoSec/safechain-internals/releases/download/${ULTIMATE_VERSION}/SafeChainUltimate-windows-arm64.msi`,
|
||||||
checksum:
|
checksum:
|
||||||
"sha256:d626da40e3d0c4e02a36e6c7e309f18f0ffde64e97a4f2fefd4b25722842ac19",
|
"sha256:79e046f24405e869494291e77c6d8640c8dc58d2ac1db87d3038e9eb8afbdc8b",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
darwin: {
|
darwin: {
|
||||||
x64: {
|
x64: {
|
||||||
url: `https://github.com/AikidoSec/safechain-internals/releases/download/${ULTIMATE_VERSION}/SafeChainUltimate-darwin-amd64.pkg`,
|
url: `https://github.com/AikidoSec/safechain-internals/releases/download/${ULTIMATE_VERSION}/SafeChainUltimate-darwin-amd64.pkg`,
|
||||||
checksum:
|
checksum:
|
||||||
"sha256:d7c31914deff8b332bf3d0e18ed00660e47ace87f06f22606c7866f7e0809507",
|
"sha256:99868cb663eef44d063d995d2dcc063f55b10eb719ee945d05fe8cf5fef5e2a5",
|
||||||
},
|
},
|
||||||
arm64: {
|
arm64: {
|
||||||
url: `https://github.com/AikidoSec/safechain-internals/releases/download/${ULTIMATE_VERSION}/SafeChainUltimate-darwin-arm64.pkg`,
|
url: `https://github.com/AikidoSec/safechain-internals/releases/download/${ULTIMATE_VERSION}/SafeChainUltimate-darwin-arm64.pkg`,
|
||||||
checksum:
|
checksum:
|
||||||
"sha256:73b092689e00c98e3c376afa50fc3477cedfd01445a113d42b36c5fcd956a6f4",
|
"sha256:000b334c2eb85d8692be5d23af73f8b9fb686c9db726992223187b341ea79306",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
import { tmpdir } from "os";
|
import { tmpdir } from "os";
|
||||||
import { unlinkSync, rmSync } from "fs";
|
import { unlinkSync } from "fs";
|
||||||
import { join } from "path";
|
import { join } from "path";
|
||||||
import { execSync } from "child_process";
|
import { execSync, spawnSync } from "child_process";
|
||||||
import { ui } from "../environment/userInteraction.js";
|
import { ui } from "../environment/userInteraction.js";
|
||||||
import { printVerboseAndSafeSpawn } from "../utils/safeSpawn.js";
|
import { printVerboseAndSafeSpawn } from "../utils/safeSpawn.js";
|
||||||
import { downloadAgentToFile, getAgentVersion } from "./downloadAgent.js";
|
import { downloadAgentToFile, getAgentVersion } from "./downloadAgent.js";
|
||||||
|
|
@ -73,6 +73,9 @@ export async function installOnMacOS() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const MACOS_UNINSTALL_SCRIPT =
|
||||||
|
"/Library/Application Support/AikidoSecurity/SafeChainUltimate/scripts/uninstall";
|
||||||
|
|
||||||
export async function uninstallOnMacOS() {
|
export async function uninstallOnMacOS() {
|
||||||
if (!requireRootPrivileges("sudo safe-chain ultimate uninstall")) {
|
if (!requireRootPrivileges("sudo safe-chain ultimate uninstall")) {
|
||||||
return;
|
return;
|
||||||
|
|
@ -85,14 +88,20 @@ export async function uninstallOnMacOS() {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
ui.writeInformation("⏹️ Stopping service...");
|
ui.writeInformation("🗑️ Uninstalling SafeChain Ultimate...");
|
||||||
await stopService();
|
ui.writeVerbose(`Running: ${MACOS_UNINSTALL_SCRIPT}`);
|
||||||
|
|
||||||
ui.writeInformation("🗑️ Removing files...");
|
const result = spawnSync(MACOS_UNINSTALL_SCRIPT, {
|
||||||
removeKnownFiles();
|
stdio: "inherit",
|
||||||
|
shell: true,
|
||||||
|
});
|
||||||
|
|
||||||
ui.writeInformation("🧹 Forgetting package receipt...");
|
if (result.status !== 0) {
|
||||||
forgetPackage();
|
ui.writeError(
|
||||||
|
`Uninstall script failed (exit code: ${result.status}). Please try again or remove manually.`,
|
||||||
|
);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
ui.emptyLine();
|
ui.emptyLine();
|
||||||
ui.writeInformation("✅ SafeChain Ultimate has been uninstalled.");
|
ui.writeInformation("✅ SafeChain Ultimate has been uninstalled.");
|
||||||
|
|
@ -111,46 +120,6 @@ function isPackageInstalled() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function stopService() {
|
|
||||||
const result = await printVerboseAndSafeSpawn(
|
|
||||||
"launchctl",
|
|
||||||
["bootout", `system/${MACOS_PKG_IDENTIFIER}`],
|
|
||||||
{ stdio: "pipe" },
|
|
||||||
);
|
|
||||||
|
|
||||||
if (result.status !== 0) {
|
|
||||||
ui.writeVerbose("Service not running (will continue with uninstall).");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const MACOS_KNOWN_PATHS = [
|
|
||||||
"/Library/Application Support/AikidoSecurity/SafeChainUltimate",
|
|
||||||
"/Library/Logs/AikidoSecurity/SafeChainUltimate",
|
|
||||||
`/Library/LaunchDaemons/${MACOS_PKG_IDENTIFIER}.plist`,
|
|
||||||
];
|
|
||||||
|
|
||||||
function removeKnownFiles() {
|
|
||||||
for (const filePath of MACOS_KNOWN_PATHS) {
|
|
||||||
try {
|
|
||||||
rmSync(filePath, { recursive: true, force: true });
|
|
||||||
ui.writeVerbose(`Removed: ${filePath}`);
|
|
||||||
} catch {
|
|
||||||
ui.writeVerbose(`Failed to remove: ${filePath}`);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function forgetPackage() {
|
|
||||||
try {
|
|
||||||
execSync(`pkgutil --forget ${MACOS_PKG_IDENTIFIER}`, {
|
|
||||||
encoding: "utf8",
|
|
||||||
stdio: "pipe",
|
|
||||||
});
|
|
||||||
} catch {
|
|
||||||
ui.writeVerbose("Failed to forget package receipt.");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {string} pkgPath
|
* @param {string} pkgPath
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue