Prevent http git urls from including username/pword

This commit is contained in:
Nick O'Leary
2018-02-02 22:43:29 +00:00
parent fc1436a96d
commit d1f7fd8bfd
5 changed files with 54 additions and 6 deletions

View File

@@ -501,6 +501,10 @@ module.exports = {
// Add a remote
app.post("/:id/remotes", needsPermission("projects.write"), function(req,res) {
var projectName = req.params.id;
if (/^https?:\/\/[^/]+@/i.test(req.body.url)) {
res.status(400).json({error:"unexpected_error", message:"Git http url must not include username/password"});
return;
}
runtime.storage.projects.addRemote(req.user, projectName, req.body).then(function() {
res.redirect(303,req.baseUrl+"/"+projectName+"/remotes");
}).catch(function(err) {

View File

@@ -69,6 +69,8 @@ function runGitCommand(args,cwd,env) {
err.code = "git_not_a_repository";
} else if (/Repository not found/i.test(stderr)) {
err.code = "git_repository_not_found";
} else if (/repository '.*' does not exist/i.test(stderr)) {
err.code = "git_repository_not_found";
} else if (/refusing to merge unrelated histories/.test(stderr)) {
err.code = "git_pull_unrelated_history"
}