@forgezero/agent 0.1.41 → 0.1.42
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +299 -86
- package/dist/agent-heartbeat.js +6 -3
- package/dist/agent-update-helper.js +5 -2
- package/dist/agent-update.js +5 -2
- package/dist/bootstrap.d.ts +17 -8
- package/dist/bootstrap.js +1504 -512
- package/dist/cli/agent-install.d.ts +6 -5
- package/dist/cli/cloudflare-bootstrap.d.ts +12 -1
- package/dist/cli/maintenance.d.ts +23 -0
- package/dist/cli/run.d.ts +3 -1
- package/dist/cli/session-store.d.ts +5 -0
- package/dist/cloudflare-bootstrap.d.ts +73 -35
- package/dist/cloudflare-bootstrap.js +587 -90
- package/dist/cloudflare-edge.d.ts +64 -12
- package/dist/cloudflare-edge.js +103 -8
- package/dist/community-rehearsal-host.d.ts +51 -0
- package/dist/community-rehearsal-host.js +272 -0
- package/dist/credential-schema.d.ts +54 -0
- package/dist/credential-schema.js +47 -0
- package/dist/definition.d.ts +31 -5
- package/dist/definition.js +271 -44
- package/dist/deploy-file.js +294 -68
- package/dist/deployment-runner.js +18 -5
- package/dist/deployment.d.ts +13 -1
- package/dist/fz-agent.js +3932 -582
- package/dist/fz-git-ssh.js +122 -0
- package/dist/fz.js +3634 -1266
- package/dist/git-ssh.d.ts +5 -0
- package/dist/guest-enrolment.d.ts +2 -0
- package/dist/guest-enrolment.js +1 -0
- package/dist/host-maintenance.d.ts +39 -0
- package/dist/host-maintenance.js +135 -0
- package/dist/index.d.ts +4 -2
- package/dist/mesh-connector.d.ts +16 -0
- package/dist/mesh-connector.js +46 -0
- package/dist/metal-bootstrap.js +145 -7
- package/dist/metal-helper-socket.js +61 -31
- package/dist/metal-provision.d.ts +2 -2
- package/dist/metal-provision.js +62 -32
- package/dist/operator-bootstrap.d.ts +90 -0
- package/dist/operator-bootstrap.js +5704 -0
- package/dist/otel-collector.d.ts +18 -0
- package/dist/pipeline.d.ts +3 -2
- package/dist/pipeline.js +1 -1
- package/dist/platform-bootstrap-runtime.d.ts +39 -21
- package/dist/platform-bootstrap-runtime.js +182 -59
- package/dist/platform-fleet-verification.d.ts +19 -0
- package/dist/platform-fleet-verification.js +3873 -0
- package/dist/platform-genesis-config.d.ts +7 -0
- package/dist/platform-genesis.d.ts +17 -0
- package/dist/provision.d.ts +76 -3
- package/dist/provision.js +1061 -229
- package/dist/recovery-host.d.ts +7 -0
- package/dist/recovery-host.js +124 -0
- package/dist/service-supervisor.d.ts +42 -0
- package/dist/software-helper.d.ts +4 -0
- package/dist/software-helper.js +865 -63
- package/dist/software.d.ts +14 -3
- package/dist/software.js +163 -37
- package/dist/ssh-bootstrap.d.ts +97 -0
- package/dist/supervised-app.d.ts +2 -0
- package/dist/version.d.ts +1 -1
- package/package.json +175 -164
- package/schema/{deploy-v2.json → deploy-v3.json} +53 -6
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
#!/usr/bin/env bun
|
|
2
|
+
// @bun
|
|
3
|
+
|
|
4
|
+
// src/git-ssh.ts
|
|
5
|
+
import { lstatSync } from "fs";
|
|
6
|
+
import { isAbsolute } from "path";
|
|
7
|
+
import { isIP } from "net";
|
|
8
|
+
|
|
9
|
+
class GitSshError extends Error {
|
|
10
|
+
}
|
|
11
|
+
var required = (name) => {
|
|
12
|
+
const value = process.env[name];
|
|
13
|
+
if (!value)
|
|
14
|
+
throw new GitSshError(`${name} is required`);
|
|
15
|
+
return value;
|
|
16
|
+
};
|
|
17
|
+
var regularPrivateFile = (path, name) => {
|
|
18
|
+
if (!isAbsolute(path))
|
|
19
|
+
throw new GitSshError(`${name} must be absolute`);
|
|
20
|
+
const stat = lstatSync(path);
|
|
21
|
+
if (!stat.isFile() || stat.isSymbolicLink() || stat.nlink !== 1) {
|
|
22
|
+
throw new GitSshError(`${name} must be one regular file`);
|
|
23
|
+
}
|
|
24
|
+
if ((stat.mode & 63) !== 0)
|
|
25
|
+
throw new GitSshError(`${name} must not be group/world accessible`);
|
|
26
|
+
return path;
|
|
27
|
+
};
|
|
28
|
+
function gitSshArgv(args) {
|
|
29
|
+
const identity = regularPrivateFile(required("FZ_GIT_SSH_IDENTITY"), "Git identity");
|
|
30
|
+
const knownHosts = regularPrivateFile(required("FZ_GIT_SSH_KNOWN_HOSTS"), "known_hosts");
|
|
31
|
+
const address = required("FZ_GIT_SSH_ADDRESS");
|
|
32
|
+
if (isIP(address) === 0)
|
|
33
|
+
throw new GitSshError("FZ_GIT_SSH_ADDRESS must be one verified IP address");
|
|
34
|
+
const alias = required("FZ_GIT_SSH_HOST_ALIAS").toLowerCase();
|
|
35
|
+
if (!/^[a-z0-9](?:[a-z0-9.-]{0,251}[a-z0-9])?$/.test(alias)) {
|
|
36
|
+
throw new GitSshError("FZ_GIT_SSH_HOST_ALIAS is invalid");
|
|
37
|
+
}
|
|
38
|
+
let index = 0;
|
|
39
|
+
let port;
|
|
40
|
+
while (index < args.length - 2) {
|
|
41
|
+
const option = args[index++];
|
|
42
|
+
if (option === "-p") {
|
|
43
|
+
const value = args[index++];
|
|
44
|
+
if (!value || !/^[1-9][0-9]{0,4}$/.test(value) || Number(value) > 65535 || port) {
|
|
45
|
+
throw new GitSshError("Git supplied an invalid SSH port");
|
|
46
|
+
}
|
|
47
|
+
port = value;
|
|
48
|
+
continue;
|
|
49
|
+
}
|
|
50
|
+
if (option === "-o" && args[index] === "SendEnv=GIT_PROTOCOL") {
|
|
51
|
+
index += 1;
|
|
52
|
+
continue;
|
|
53
|
+
}
|
|
54
|
+
throw new GitSshError(`Git supplied an unsupported SSH option: ${option ?? "<missing>"}`);
|
|
55
|
+
}
|
|
56
|
+
if (args.length - index !== 2)
|
|
57
|
+
throw new GitSshError("Git SSH invocation must contain a destination and command");
|
|
58
|
+
const destination = args[index];
|
|
59
|
+
const command = args[index + 1];
|
|
60
|
+
const host = destination.slice(destination.lastIndexOf("@") + 1).replace(/^\[|\]$/g, "").toLowerCase();
|
|
61
|
+
if (host !== alias)
|
|
62
|
+
throw new GitSshError("Git SSH destination does not match the pinned repository host");
|
|
63
|
+
if (command.length > 8192 || /[\r\n\0]/.test(command) || !command.startsWith("git-upload-pack ")) {
|
|
64
|
+
throw new GitSshError("Git SSH permits only repository reads");
|
|
65
|
+
}
|
|
66
|
+
return [
|
|
67
|
+
"/usr/bin/ssh",
|
|
68
|
+
"-F",
|
|
69
|
+
"/dev/null",
|
|
70
|
+
"-i",
|
|
71
|
+
identity,
|
|
72
|
+
"-o",
|
|
73
|
+
"IdentitiesOnly=yes",
|
|
74
|
+
"-o",
|
|
75
|
+
"BatchMode=yes",
|
|
76
|
+
"-o",
|
|
77
|
+
"ConnectTimeout=15",
|
|
78
|
+
"-o",
|
|
79
|
+
"StrictHostKeyChecking=yes",
|
|
80
|
+
"-o",
|
|
81
|
+
`UserKnownHostsFile=${knownHosts}`,
|
|
82
|
+
"-o",
|
|
83
|
+
`Hostname=${address}`,
|
|
84
|
+
"-o",
|
|
85
|
+
`HostKeyAlias=${alias}`,
|
|
86
|
+
"-o",
|
|
87
|
+
"CanonicalizeHostname=no",
|
|
88
|
+
"-o",
|
|
89
|
+
"ProxyCommand=none",
|
|
90
|
+
"-o",
|
|
91
|
+
"ProxyJump=none",
|
|
92
|
+
"-o",
|
|
93
|
+
"PermitLocalCommand=no",
|
|
94
|
+
"-o",
|
|
95
|
+
"ClearAllForwardings=yes",
|
|
96
|
+
...port ? ["-p", port] : [],
|
|
97
|
+
destination,
|
|
98
|
+
command
|
|
99
|
+
];
|
|
100
|
+
}
|
|
101
|
+
async function runGitSsh(args = process.argv.slice(2)) {
|
|
102
|
+
const child = Bun.spawn(gitSshArgv(args), {
|
|
103
|
+
stdin: "inherit",
|
|
104
|
+
stdout: "inherit",
|
|
105
|
+
stderr: "inherit",
|
|
106
|
+
env: { PATH: "/usr/bin:/bin", LANG: "C.UTF-8", ...process.env.GIT_PROTOCOL ? { GIT_PROTOCOL: process.env.GIT_PROTOCOL } : {} }
|
|
107
|
+
});
|
|
108
|
+
return child.exited;
|
|
109
|
+
}
|
|
110
|
+
if (import.meta.main) {
|
|
111
|
+
try {
|
|
112
|
+
process.exit(await runGitSsh());
|
|
113
|
+
} catch (cause) {
|
|
114
|
+
console.error(`fz-git-ssh: ${cause instanceof Error ? cause.message : "refused"}`);
|
|
115
|
+
process.exit(64);
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
export {
|
|
119
|
+
runGitSsh,
|
|
120
|
+
gitSshArgv,
|
|
121
|
+
GitSshError
|
|
122
|
+
};
|