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

Initial autoupdate feature #50

Closed
wants to merge 2 commits into from
Closed

Initial autoupdate feature #50

wants to merge 2 commits into from

Conversation

denny241
Copy link
Contributor

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.

@denny241 denny241 added the WIP Work in progress label Oct 26, 2020
@denny241
Copy link
Contributor Author

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 {
Copy link
Contributor

@Morishiri Morishiri Oct 26, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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") {
Copy link
Contributor

@Morishiri Morishiri Oct 26, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You usually do it the other way around, y/Y means continue, everything else means abort

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@Morishiri
Copy link
Contributor

Opened #110 instead

@Morishiri Morishiri closed this Mar 2, 2021
@Morishiri Morishiri deleted the feature/autoupdate branch March 2, 2021 10:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
WIP Work in progress
Projects
None yet
Development

Successfully merging this pull request may close these issues.

New release updates
2 participants