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

Remove backup api at /database/backup; change method from GET to POST #33

Merged
merged 3 commits into from
Apr 18, 2021

Conversation

c0llab0rat0r
Copy link
Contributor

… on /api/v3/plugins/database/backup

@c0llab0rat0r
Copy link
Contributor Author

Resolves #24.

Would appreciate someone else testing out the changes locally.

@c0llab0rat0r c0llab0rat0r changed the title Remove backup api at /database/backup; change method from GET to POST [wip] Remove backup api at /database/backup; change method from GET to POST Apr 17, 2021
…response in scripts; add tests around authorized and unauthorized requests and using a non-default file name
@c0llab0rat0r c0llab0rat0r changed the title [wip] Remove backup api at /database/backup; change method from GET to POST Remove backup api at /database/backup; change method from GET to POST Apr 17, 2021
@@ -27,7 +42,7 @@ class H2BackupController extends ControllerBase with AdminAuthenticator {
// private val defaultBackupFile:String = new File(GitBucketHome, "gitbucket-database-backup.zip").toString;

def exportDatabase(exportFile: File): Unit = {
Copy link
Contributor

@takezoe takezoe Apr 18, 2021

Choose a reason for hiding this comment

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

With the design in this pull request (moving functional methods to the companion object), this method also can be moved to the companion object. Connection can be taken as an argument.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I hadn't made any changes to exportDatabase and was trying to minimize the scope of the code changes while still having good hygiene (like writing tests) - so I did the minimum refactor to have tests.

Testing exportDatabase is a bit more involved since it would require calling a live database. I didn't want to change that area of the code and thus become responsible for it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Separately, I feel like there's some design or constraint issues with how backup file names are dealt with.

It seems problematic that an external service can pass a dest with an absolute (from root /) folder or an upwardly-mobile relative folder ( ../../somewhere-else) to a path on the GitBucket server. I think the path should be, at minimum, constrained to a subfolder that's determined by the GitBucket server configuration.

Copy link
Contributor

@takezoe takezoe Apr 18, 2021

Choose a reason for hiding this comment

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

Yeah, that is true. Also, I found that actions provided by this plugin don't have permission checking although usage of these actions should be limited to admin only. Anyway, they are out of the scope of this pull request.

@takezoe
Copy link
Contributor

takezoe commented Apr 18, 2021

@c0llab0rat0r This looks good to me, though some security issues pointed in comments need to be dealt with in another pull request. Is this ready to merge?

@c0llab0rat0r
Copy link
Contributor Author

@c0llab0rat0r This looks good to me, though some security issues pointed in comments need to be dealt with in another pull request. Is this ready to merge?

Yes. I found a second security issue and I'm working on a change for it right now.

You can merge this one and I'll put up a separate pr for it. It will be up within 30 minutes.

@takezoe
Copy link
Contributor

takezoe commented Apr 18, 2021

Great. Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants