Skip to content

Commit

Permalink
fix(falcoctl): no-verify
Browse files Browse the repository at this point in the history
Signed-off-by: Luca Guerra <[email protected]>
  • Loading branch information
LucaGuerra committed Feb 24, 2025
1 parent 9f5c3ec commit c56eb19
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 20 deletions.
2 changes: 1 addition & 1 deletion cmd/driver/install/install.go
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ func (o *driverInstallOptions) RunDriverInstall(ctx context.Context) (string, er
o.Printer.Spinner, _ = o.Printer.Spinner.Start("Trying to download the driver")
}
dest, err = driverdistro.Download(ctx, o.Distro, o.Printer.WithWriter(&buf), o.Kr, o.Driver.Name,
o.Driver.Type, o.Driver.Version, o.Driver.Repos, o.HTTPHeaders)
o.Driver.Type, o.Driver.Version, o.Driver.Repos, o.HTTPHeaders, !o.NoVerify)
if o.Printer.Spinner != nil {
_ = o.Printer.Spinner.Stop()
}
Expand Down
41 changes: 22 additions & 19 deletions pkg/driver/distro/distro.go
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,7 @@ func Download(ctx context.Context,
driverType drivertype.DriverType,
driverVer string, repos []string,
httpHeaders string,
downloadSignature bool,
) (string, error) {
driverFileName := toFilename(d, &kr, driverName, driverType)
// Skip if existent
Expand Down Expand Up @@ -289,27 +290,29 @@ func Download(ctx context.Context,
return destination, err
}

// Download the signature, if any, and write it next to the downloaded driver.
signatureURL := driverURL + ".asc"
req, err = http.NewRequestWithContext(ctx, http.MethodGet, signatureURL, nil)
if err != nil {
printer.Logger.Warn("Error creating http request for signature.", printer.Logger.Args("err", err), printer.Logger.Args("signatureURL", signatureURL))
// Signature not found is not an error
return destination, nil
}
req.Header = header
resp, err = http.DefaultClient.Do(req)
if err != nil || resp.StatusCode != 200 {
if err == nil {
_ = resp.Body.Close()
printer.Logger.Warn("Non-200 response from url for signature.", printer.Logger.Args("code", resp.StatusCode))
} else {
printer.Logger.Warn("Error GETting url for signature.", printer.Logger.Args("err", err))
if downloadSignature {
// Download the signature, if any, and write it next to the downloaded driver.
signatureURL := driverURL + ".asc"
req, err = http.NewRequestWithContext(ctx, http.MethodGet, signatureURL, nil)
if err != nil {
printer.Logger.Warn("Error creating http request for signature.", printer.Logger.Args("err", err), printer.Logger.Args("signatureURL", signatureURL))
// Signature not found is not an error
return destination, nil
}
req.Header = header
resp, err = http.DefaultClient.Do(req)
if err != nil || resp.StatusCode != 200 {
if err == nil {
_ = resp.Body.Close()
printer.Logger.Warn("Non-200 response from url for signature.", printer.Logger.Args("code", resp.StatusCode), printer.Logger.Args("signatureURL", signatureURL))
} else {
printer.Logger.Warn("Error GETting url for signature.", printer.Logger.Args("err", err))
}
// Signature not found is not an error
return destination, nil
}
// Signature not found is not an error
return destination, nil
copyDataToLocalPath(destination+".asc", resp.Body)
}
copyDataToLocalPath(destination+".asc", resp.Body)
return destination, nil
}
return destination, fmt.Errorf("unable to find a prebuilt driver")
Expand Down

0 comments on commit c56eb19

Please sign in to comment.