Documentation
¶
Overview ¶
Package wslagent keeps the Linux agent binary that the Windows agent runs inside WSL distributions next to the Windows agent.
The MSI and the PowerShell loader both install that binary (as dmg-linux). Installs that have neither, such as a binary run with `install`, an old loader, or a loader run that skipped it, otherwise never get WSL telemetry. Ensure fills that gap: it downloads the linux_<arch> asset for the running agent's version from the GitHub release and accepts it only if its checksum carries a valid release signature (see internal/releasesig).
A copy this package did not install belongs to whoever did (MSI, loader) and is used as is. A copy it did install is tracked by a marker file and replaced when the agent version changes.
Index ¶
Constants ¶
const BinaryName = "dmg-linux"
BinaryName is the file name the Windows agent looks for next to itself. The MSI and the loader install the Linux agent under the same name.
const DefaultReleaseBase = "https://github.com/step-security/dev-machine-guard/releases/download"
DefaultReleaseBase is where release assets are downloaded from.
const DefaultTimeout = 90 * time.Second
DefaultTimeout bounds one download, so a slow network cannot hold the host's scheduled run open. Under the wsl_scan phase budget, leaving time to launch the distros afterwards.
Variables ¶
var NativeArch = nativeArch
NativeArch returns the architecture the Linux agent must be built for on this host: the machine's own, not this executable's. An amd64 agent can run under x64 emulation on Windows on Arm, where WSL distros are arm64 and cannot run a linux_amd64 binary. A variable so tests can stand in for the host.
Functions ¶
Types ¶
type Fetcher ¶
type Fetcher struct {
HTTP *http.Client
ReleaseBase string
// Verify checks a release signature over a hex checksum. Replaceable in
// tests; production uses releasesig.VerifyChecksum.
Verify func(checksum string, sig []byte) error
}
Fetcher downloads and installs the Linux agent. The zero value is not usable; use New.
func (*Fetcher) Ensure ¶
func (f *Fetcher) Ensure(ctx context.Context, dir, version, arch string) (path string, downloaded bool, err error)
Ensure returns the path of a Linux agent binary in dir that is safe to run for agent version, downloading one when needed. downloaded reports whether this call installed a new copy.
When replacing an older copy of our own fails (offline, GitHub blocked), Ensure returns that older copy together with the error: a guest from a recent release still scans, and the next run tries again.