Conversation
|
Just noticed I didn't add error handling for the extraction and made a mistake in the control flow for windows vs. linux extraction. Will fix that in the next commit alongside the aforementioned Windows bug and the zip slip CodeQL noticed. |
| if err != nil { | ||
| log.Fatal("GithubTag error:" + err.Error()) | ||
| } | ||
| if _, err := os.Stat("loophole_version_" + res.Current); err == nil { |
There was a problem hiding this comment.
What if someone moves the binary to his /usr/local/bin?
| fmt.Print("Y/n : ") | ||
| text, _ := reader.ReadString('\n') | ||
| // convert CRLF to LF | ||
| text = strings.Replace(text, "\n", "", -1) |
There was a problem hiding this comment.
I think you should replace /r, becuase now you do CRLF -> CR instead of CRLF -> LF
|
|
||
| fmt.Println(text) | ||
|
|
||
| if strings.Contains(text, "n") || strings.Contains(text, "N") { |
There was a problem hiding this comment.
You usually do it the other way around, y/Y means continue, everything else means abort
There was a problem hiding this comment.
Was basing it on the way apt upgrade does it, but I guess users run that expecting to upgrade something, so continue as default is to be expected, unlike this where the update prompt might show up when a user just wants to use the program itself.
Will reverse it.
|
Opened #110 instead |
Closes #19
We will need to decide if we maybe want to relocate the functionality into a new command among several other things, but this can act as a working starting point to those discussions.
For now, I made it so that main.go, before even parsing the user inputs, checks whether the current version is the latest via Github Tags. If a new version is out, the user is prompted whether or not they want to download it. If they want to download it, the binary will be put in a subfolder with the name of the downloaded version and loophole will close afterwards. If they start the old binary again, there is a notification on top that we recommend using the new version they just downloaded.
There is currently a bug in Windows where the .zip file can't be deleted automatically after extraction.