Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Harden remote plugin installs #12915

Merged
merged 16 commits into from
May 8, 2024
Merged
Show file tree
Hide file tree
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
16 changes: 15 additions & 1 deletion command/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ for more info.`)
Checksummers: []plugingetter.Checksummer{
{Type: "sha256", Hash: sha256.New()},
},
ReleasesOnly: true,
},
}

Expand Down Expand Up @@ -127,7 +128,20 @@ for more info.`)
}

if cla.Force && !cla.Upgrade {
pluginRequirement.VersionConstraints, _ = gversion.NewConstraint(fmt.Sprintf("=%s", installs[len(installs)-1].Version))
// Only place another constaint to the latest release
// binary, if any, otherwise this is essentially the same
// as an upgrade
var installVersion string
for _, install := range installs {
ver, _ := gversion.NewVersion(install.Version)
if ver.Prerelease() == "" {
installVersion = install.Version
}
}

if installVersion != "" {
pluginRequirement.VersionConstraints, _ = gversion.NewConstraint(fmt.Sprintf("=%s", installVersion))
}
}
}

Expand Down
1 change: 1 addition & 0 deletions command/plugins_install.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ func (c *PluginsInstallCommand) RunContext(buildCtx context.Context, args *Plugi
Checksummers: []plugingetter.Checksummer{
{Type: "sha256", Hash: sha256.New()},
},
ReleasesOnly: true,
},
}
if runtime.GOOS == "windows" {
Expand Down
Loading