Skip to content

Commit 00a3a11

Browse files
committed
default to running all commands except tailscale up silently
To avoid leaking any potentially sensitive information, all commands are now run without logging to the console. Logging can be enabled by turning on debug logging as described at https://docs.github.com/en/actions/how-tos/monitor-workflows/enable-debug-logging. Updates tailscale/corp#33405 Signed-off-by: Percy Wegmann <percy@tailscale.com>
1 parent ac425ca commit 00a3a11

2 files changed

Lines changed: 197 additions & 79 deletions

File tree

dist/index.js

Lines changed: 91 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -41129,26 +41129,17 @@ const cmdTailscale = "tailscale";
4112941129
const cmdTailscaleFullPath = "/usr/local/bin/tailscale";
4113041130
const cmdTailscaled = "tailscaled";
4113141131
const cmdTailscaledFullPath = "/usr/local/bin/tailscaled";
41132-
const platformWin32 = "win32";
41133-
const platformDarwin = "darwin";
4113441132
const runnerLinux = "Linux";
4113541133
const runnerWindows = "Windows";
4113641134
const runnerMacOS = "macOS";
4113741135
const versionLatest = "latest";
4113841136
const versionUnstable = "unstable";
4113941137
// Cross-platform Tailscale local API status check
4114041138
async function getTailscaleStatus() {
41141-
const { exitCode, stdout, stderr } = await exec.getExecOutput(cmdTailscale, ["status", "--json"], {
41142-
silent: true,
41143-
ignoreReturnCode: true,
41144-
});
41145-
if (exitCode !== 0) {
41146-
process.stderr.write(stderr);
41147-
throw new Error(`tailscale status failed with exit code ${exitCode}`);
41148-
}
41149-
if (core.isDebug()) {
41150-
process.stdout.write(stdout);
41151-
}
41139+
const { stdout } = await execSilent("get tailscale status", cmdTailscale, [
41140+
"status",
41141+
"--json",
41142+
]);
4115241143
return JSON.parse(stdout);
4115341144
}
4115441145
async function run() {
@@ -41236,7 +41227,12 @@ async function pingHost(host) {
4123641227
core.debug(`Waiting ${waitTime} milliseconds before pinging`);
4123741228
await (0, promises_1.setTimeout)(waitTime);
4123841229
}
41239-
let result = await exec.getExecOutput(cmdTailscale, ["ping", "-c", "1", host], { ignoreReturnCode: true });
41230+
let result = await execSilent("ping host", cmdTailscale, [
41231+
"ping",
41232+
"-c",
41233+
"1",
41234+
host,
41235+
]);
4124041236
if (result.exitCode === 0) {
4124141237
core.info(`✅ Ping host ${host} reachable via direct connection!`);
4124241238
return;
@@ -41284,7 +41280,8 @@ async function resolveVersion(version, runnerOS) {
4128441280
}
4128541281
if (version === versionLatest || version === versionUnstable) {
4128641282
let path = version === versionUnstable ? versionUnstable : "stable";
41287-
const { stdout } = await exec.getExecOutput("curl", [
41283+
let pkg = `https://pkgs.tailscale.com/${path}/?mode=json`;
41284+
const { stdout } = await execSilent(`curl ${pkg}`, "curl", [
4128841285
"-H",
4128941286
"user-agent:action-setup-tailscale",
4129041287
"-s",
@@ -41389,7 +41386,7 @@ async function installTailscaleLinux(config, toolPath) {
4138941386
// Get SHA256 if not provided
4139041387
if (!config.sha256Sum) {
4139141388
const shaUrl = `${baseUrl}/tailscale_${config.resolvedVersion}_${config.arch}.tgz.sha256`;
41392-
const { stdout } = await exec.getExecOutput("curl", [
41389+
const { stdout } = await execSilent(`curl {shaUrl}`, "curl", [
4139341390
"-H",
4139441391
"user-agent:action-setup-tailscale",
4139541392
"-L",
@@ -41418,15 +41415,23 @@ async function installTailscaleLinux(config, toolPath) {
4141841415
fs.copyFileSync(path.join(extractedDir, cmdTailscale), path.join(toolPath, cmdTailscale));
4141941416
fs.copyFileSync(path.join(extractedDir, cmdTailscaled), path.join(toolPath, cmdTailscaled));
4142041417
// Install binaries to /usr/local/bin
41421-
await exec.exec("sudo", [
41418+
await execSilent("copy tailscale binaries to /usr/local/bin", "sudo", [
4142241419
"cp",
4142341420
path.join(toolPath, cmdTailscale),
4142441421
path.join(toolPath, cmdTailscaled),
4142541422
"/usr/local/bin",
4142641423
]);
4142741424
// Make sure they're executable
41428-
await exec.exec("sudo", ["chmod", "+x", cmdTailscaleFullPath]);
41429-
await exec.exec("sudo", ["chmod", "+x", cmdTailscaledFullPath]);
41425+
await execSilent("chmod tailscale binary", "sudo", [
41426+
"chmod",
41427+
"+x",
41428+
cmdTailscaleFullPath,
41429+
]);
41430+
await execSilent("chmod tailscaled binary", "sudo", [
41431+
"chmod",
41432+
"+x",
41433+
cmdTailscaledFullPath,
41434+
]);
4143041435
}
4143141436
async function installTailscaleWindows(config, toolPath, fromCache = false) {
4143241437
// Create tool directory
@@ -41450,7 +41455,7 @@ async function installTailscaleWindows(config, toolPath, fromCache = false) {
4145041455
// Get SHA256 if not provided
4145141456
if (!config.sha256Sum) {
4145241457
const shaUrl = `${baseUrl}/tailscale-setup-${config.resolvedVersion}-${config.arch}.msi.sha256`;
41453-
const { stdout } = await exec.getExecOutput("curl", [
41458+
const { stdout } = await execSilent(`curl ${shaUrl}`, "curl", [
4145441459
"-H",
4145541460
"user-agent:action-setup-tailscale",
4145641461
"-L",
@@ -41478,7 +41483,7 @@ async function installTailscaleWindows(config, toolPath, fromCache = false) {
4147841483
}
4147941484
}
4148041485
// Install MSI (same for both fresh and cached)
41481-
await exec.exec("msiexec.exe", [
41486+
await execSilent("install msi", "msiexec.exe", [
4148241487
"/quiet",
4148341488
`/l*v`,
4148441489
path.join(process.env.RUNNER_TEMP || "", "tailscale.log"),
@@ -41491,16 +41496,16 @@ async function installTailscaleWindows(config, toolPath, fromCache = false) {
4149141496
async function installTailscaleMacOS(config, toolPath) {
4149241497
core.info("Building tailscale from src on macOS...");
4149341498
// Clone the repo
41494-
await exec.exec("git clone https://github.com/tailscale/tailscale.git tailscale");
41499+
await execSilent("glone tailscale repo", "git clone https://github.com/tailscale/tailscale.git tailscale");
4149541500
// Checkout the resolved version
41496-
await exec.exec(`git checkout v${config.resolvedVersion}`, [], {
41501+
await execSilent("checkout resolved version", `git checkout v${config.resolvedVersion}`, [], {
4149741502
cwd: cmdTailscale,
4149841503
});
4149941504
// Create tool directory and copy binaries there for caching
4150041505
fs.mkdirSync(toolPath, { recursive: true });
4150141506
// Build tailscale and tailscaled into tool directory
4150241507
for (const binary of [cmdTailscale, cmdTailscaled]) {
41503-
await exec.exec(`./build_dist.sh -o ${path.join(toolPath, binary)} ./cmd/${binary}`, [], {
41508+
await execSilent(`build ${binary}`, `./build_dist.sh -o ${path.join(toolPath, binary)} ./cmd/${binary}`, [], {
4150441509
cwd: cmdTailscale,
4150541510
env: {
4150641511
...process.env,
@@ -41509,15 +41514,23 @@ async function installTailscaleMacOS(config, toolPath) {
4150941514
});
4151041515
}
4151141516
// Install binaries to /usr/local/bin
41512-
await exec.exec("sudo", [
41517+
await execSilent("copy binaries to /usr/local/bin", "sudo", [
4151341518
"cp",
4151441519
path.join(toolPath, cmdTailscale),
4151541520
path.join(toolPath, cmdTailscaled),
4151641521
"/usr/local/bin",
4151741522
]);
4151841523
// Make sure they're executable
41519-
await exec.exec("sudo", ["chmod", "+x", cmdTailscaleFullPath]);
41520-
await exec.exec("sudo", ["chmod", "+x", cmdTailscaledFullPath]);
41524+
await execSilent("chmod tailscale", "sudo", [
41525+
"chmod",
41526+
"+x",
41527+
cmdTailscaleFullPath,
41528+
]);
41529+
await execSilent("chmod tailscaled", "sudo", [
41530+
"chmod",
41531+
"+x",
41532+
cmdTailscaledFullPath,
41533+
]);
4152141534
core.info("✅ Tailscale installed successfully on macOS from source");
4152241535
}
4152341536
async function startTailscaleDaemon(config) {
@@ -41588,7 +41601,7 @@ async function connectToTailscale(config, runnerOS) {
4158841601
hostname = `github-${process.env.COMPUTERNAME}`;
4158941602
}
4159041603
else {
41591-
const { stdout } = await exec.getExecOutput("hostname");
41604+
const { stdout } = await execSilent("hostname", "hostname");
4159241605
hostname = `github-${stdout.trim()}`;
4159341606
}
4159441607
}
@@ -41690,10 +41703,26 @@ async function installCachedBinaries(toolPath, runnerOS) {
4169041703
const tailscaleBin = path.join(toolPath, cmdTailscale);
4169141704
const tailscaledBin = path.join(toolPath, cmdTailscaled);
4169241705
if (fs.existsSync(tailscaleBin) && fs.existsSync(tailscaledBin)) {
41693-
await exec.exec("sudo", ["cp", tailscaleBin, cmdTailscaleFullPath]);
41694-
await exec.exec("sudo", ["cp", tailscaledBin, cmdTailscaledFullPath]);
41695-
await exec.exec("sudo", ["chmod", "+x", cmdTailscaleFullPath]);
41696-
await exec.exec("sudo", ["chmod", "+x", cmdTailscaledFullPath]);
41706+
await execSilent("copy tailscale from cache", "sudo", [
41707+
"cp",
41708+
tailscaleBin,
41709+
cmdTailscaleFullPath,
41710+
]);
41711+
await execSilent("copy tailscaled from cache", "sudo", [
41712+
"cp",
41713+
tailscaledBin,
41714+
cmdTailscaledFullPath,
41715+
]);
41716+
await execSilent("chmod tailscale", "sudo", [
41717+
"chmod",
41718+
"+x",
41719+
cmdTailscaleFullPath,
41720+
]);
41721+
await execSilent("chmod tailscaled", "sudo", [
41722+
"chmod",
41723+
"+x",
41724+
cmdTailscaledFullPath,
41725+
]);
4169741726
}
4169841727
else {
4169941728
throw new Error(`Cached binaries not found in ${toolPath}`);
@@ -41707,12 +41736,12 @@ async function configureDNSOnMacOS(status) {
4170741736
}
4170841737
core.info(`Setting system DNS server to 100.100.100.100 and searchdomains to ${status.CurrentTailnet.MagicDNSSuffix}`);
4170941738
try {
41710-
await exec.exec("networksetup", [
41739+
await execSilent("set dns servers", "networksetup", [
4171141740
"-setdnsservers",
4171241741
"Ethernet",
4171341742
"100.100.100.100",
4171441743
]);
41715-
await exec.exec("networksetup", [
41744+
await execSilent("set search domains", "networksetup", [
4171641745
"-setsearchdomains",
4171741746
"Ethernet",
4171841747
status.CurrentTailnet.MagicDNSSuffix,
@@ -41723,6 +41752,34 @@ async function configureDNSOnMacOS(status) {
4172341752
}
4172441753
}
4172541754
run();
41755+
/**
41756+
* Executes the given command, logging the given label as info, but suppressing
41757+
* all other output including the command line itself (unless debug logging is enabled,
41758+
* see https://docs.github.com/en/actions/how-tos/monitor-workflows/enable-debug-logging).
41759+
*
41760+
* If the command fails, stderr is written to the console.
41761+
*
41762+
* @param label a label to use for info logging what's happening
41763+
* @param cmd the command to run
41764+
* @param args arguments to the command
41765+
* @returns stdout (if command was successful)
41766+
*/
41767+
async function execSilent(label, cmd, args, opts) {
41768+
core.info(label);
41769+
const out = await exec.getExecOutput(cmd, args, {
41770+
...opts,
41771+
silent: !core.isDebug,
41772+
ignoreReturnCode: true,
41773+
});
41774+
if (out.exitCode !== 0) {
41775+
if (!core.isDebug) {
41776+
// When debug logging is off, stderr won't have been written to console, write it now.
41777+
process.stderr.write(out.stderr);
41778+
}
41779+
throw new Error(`${cmd} failed with exit code ${out.exitCode}`);
41780+
}
41781+
return out;
41782+
}
4172641783

4172741784

4172841785
/***/ }),

0 commit comments

Comments
 (0)