From 8024971437adff6d57b7f05984a85e2a78f3ce84 Mon Sep 17 00:00:00 2001 From: Alex Vulaj Date: Fri, 19 Jul 2024 14:43:06 -0400 Subject: [PATCH] Add fallback if we fail to convert github list to a curl string (#257) --- pkg/verifier/aws/entry_point.go | 32 +++++++++++++++----------------- 1 file changed, 15 insertions(+), 17 deletions(-) diff --git a/pkg/verifier/aws/entry_point.go b/pkg/verifier/aws/entry_point.go index 284a581a..c3a71ab8 100644 --- a/pkg/verifier/aws/entry_point.go +++ b/pkg/verifier/aws/entry_point.go @@ -131,32 +131,30 @@ func (a *AwsVerifier) ValidateEgress(vei verifier.ValidateEgressInput) *output.O // Note that this is TOTALLY IGNORED by LegacyProbe, // as that probe only knows how to use the egress URL lists baked into its // AMIs/container images - var egressListYaml string - if vei.EgressListYaml != "" { - egressListYaml = vei.EgressListYaml - } else { - githubEgressList, err := egress_lists.GetGithubEgressList(vei.PlatformType) - if err != nil { - a.Logger.Error(vei.Ctx, "Failed to get egress list from GitHub, falling back to local list: %v", err) - } else { - egressListYaml, err = githubEgressList.GetContent() - if err != nil { - a.Logger.Error(vei.Ctx, "Failed to get egress list from GitHub, falling back to local list: %v", err) + egressListYaml := vei.EgressListYaml + var egressListStr, tlsDisabledEgressListStr string + if egressListYaml == "" { + githubEgressList, githubListErr := egress_lists.GetGithubEgressList(vei.PlatformType) + if githubListErr == nil { + egressListYaml, githubListErr = githubEgressList.GetContent() + if githubListErr == nil { + a.Logger.Info(vei.Ctx, "Using egress URL list from %s at SHA %s", githubEgressList.GetURL(), githubEgressList.GetSHA()) + egressListStr, tlsDisabledEgressListStr, githubListErr = egress_lists.EgressListToString(egressListYaml, map[string]string{"AWS_REGION": a.AwsClient.Region}) } - a.Logger.Info(vei.Ctx, "Using egress URL list from %s at SHA %s", githubEgressList.GetURL(), githubEgressList.GetSHA()) } - if egressListYaml == "" { + if githubListErr != nil { + a.Logger.Error(vei.Ctx, "Failed to get egress list from GitHub, falling back to local list: %v", githubListErr) egressListYaml, err = egress_lists.GetLocalEgressList(vei.PlatformType) if err != nil { return a.Output.AddError(err) } + egressListStr, tlsDisabledEgressListStr, err = egress_lists.EgressListToString(egressListYaml, map[string]string{"AWS_REGION": a.AwsClient.Region}) + if err != nil { + return a.Output.AddError(err) + } } } - egressListStr, tlsDisabledEgressListStr, err := egress_lists.EgressListToString(egressListYaml, map[string]string{"AWS_REGION": a.AwsClient.Region}) - if err != nil { - return a.Output.AddError(err) - } // Generate the userData file // As expand replaces all ${var} (using empty string for unknown ones), adding the env variables used in userdata.yaml