-
Notifications
You must be signed in to change notification settings - Fork 122
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
test: fix e2e tests broken in various ways #2078
Changes from all commits
ebc9290
7e05a2f
3ecc5d7
ef557b1
f60b7ca
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -128,15 +128,24 @@ func (tr *TestConfig) Initialize() { | |||||||||||||||||
// Note: if no matching version is found an empty string is returned | ||||||||||||||||||
func getIcsVersion(reference string) string { | ||||||||||||||||||
icsVersion := "" | ||||||||||||||||||
if reference == "" { | ||||||||||||||||||
|
||||||||||||||||||
if reference == "" || reference == VLatest { | ||||||||||||||||||
return icsVersion | ||||||||||||||||||
} | ||||||||||||||||||
|
||||||||||||||||||
if semver.IsValid(reference) { | ||||||||||||||||||
// remove build suffix | ||||||||||||||||||
return semver.Canonical(reference) | ||||||||||||||||||
} | ||||||||||||||||||
|
||||||||||||||||||
for _, tag := range []string{"v2.0.0", "v2.4.0", "v2.4.0-lsm", "v3.1.0", "v3.2.0", "v3.3.0", "v4.0.0", "v4.1.1", "v4.1.1-lsm"} { | ||||||||||||||||||
// List of all tags matching vX.Y.Z or vX.Y.Z-lsm in ascending order | ||||||||||||||||||
cmd := exec.Command("git", "tag", "-l", "--sort", "v:refname", "v*.?", "v*.?-lsm", "v*.??", "v*.??-lsm") | ||||||||||||||||||
out, err := cmd.CombinedOutput() | ||||||||||||||||||
if err != nil { | ||||||||||||||||||
panic(fmt.Sprintf("Error getting sorted tag list from git: %s", err.Error())) | ||||||||||||||||||
} | ||||||||||||||||||
icsVersions := strings.Split(string(out), "\n") | ||||||||||||||||||
for _, tag := range icsVersions { | ||||||||||||||||||
Comment on lines
+147
to
+148
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Improve error handling for Git command execution. The function currently panics if the Git command fails. Consider improving error handling by logging the error and returning a more descriptive error message. - if err != nil {
- panic(fmt.Sprintf("Error getting sorted tag list from git: %s", err.Error()))
+ if err != nil {
+ log.Printf("Error getting sorted tag list from git: %s", err.Error())
+ return "" Committable suggestion
Suggested change
|
||||||||||||||||||
//#nosec G204 -- Bypass linter warning for spawning subprocess with cmd arguments | ||||||||||||||||||
cmd := exec.Command("git", "merge-base", "--is-ancestor", reference, tag) | ||||||||||||||||||
out, err := cmd.CombinedOutput() | ||||||||||||||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Handle potential security risks with
exec.Command
.The use of
exec.Command
to execute Git commands introduces potential security risks. Ensure that the inputs toexec.Command
are sanitized and consider using a safer alternative if possible.