# 代码git clone https://github.com/gogs/gogs/# 切换到 v0.12.5版本。打了几个断点,后续可见。# 配置数据库mysqld
create database gogs;
sshCommand
即可。(就不写这一行了。)[core]
repositoryformatversion = 0
filemode = true
bare = false
logallrefupdates = true
ignorecase = true
precomposeunicode = true
[remote "origin"]
url = [email protected]:torvalds/linux.git
fetch = +refs/heads/*:refs/remotes/origin/*
[branch "master"]
remote = origin
merge = refs/heads/master
POST /admin1/repo1/upload-file HTTP/1.1
Host: localhost:3002
Content-Length: 572
sec-ch-ua: "(Not(A:Brand";v="8", "Chromium";v="100"
X-CSRF-Token: YdUSVCYfWjcmMJa-_L8-zwaB7zQ6MTY0OTIzNzA0NTcxMzI2ODAwMA
sec-ch-ua-mobile: ?0
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.60 Safari/537.36
Content-Type: multipart/form-data; boundary=----WebKitFormBoundaryofjLZyKNqVjTSLhL
Accept: application/json
Cache-Control: no-cache
X-Requested-With: XMLHttpRequest
sec-ch-ua-platform: "macOS"
Origin: http://localhost:3002
Sec-Fetch-Site: same-origin
Sec-Fetch-Mode: cors
Sec-Fetch-Dest: empty
Accept-Encoding: gzip, deflate
Accept-Language: zh-CN,zh;q=0.9
Cookie: lang=zh-CN; i_like_gogs=ea69248b2edcefa9; _csrf=YdUSVCYfWjcmMJa-_L8-zwaB7zQ6MTY0OTIzNzA0NTcxMzI2ODAwMA
Connection: close------WebKitFormBoundaryofjLZyKNqVjTSLhL
Content-Disposition: form-data; name="file"; filename="config"
Content-Type: application/octet-stream[core]
(上述配置文件的内容)
------WebKitFormBoundaryofjLZyKNqVjTSLhL--
HTTP/1.1 200 OK
Content-Type: application/json; charset=UTF-8
X-Content-Type-Options: nosniff
X-Frame-Options: DENY
Date: Thu, 07 Apr 2022 06:43:54 GMT
Content-Length: 52
Connection: close{
"uuid": "85cdd4d7-41b4-45cc-9149-0c7364471286"
}
/private/var/folders/r4/x0h2gfcj6rg3z4cv7r2rlgb00000gn/T/GoLand/data/tmp/uploads/8/5/85cdd4d7-41b4-45cc-9149-0c7364471286
func UploadLocalPath(uuid string) string {
config
/private/var/folders/r4/x0h2gfcj6rg3z4cv7r2rlgb00000gn/T/GoLand/data/tmp/uploads/8/5/85cdd4d7-41b4-45cc-9149-0c7364471286
db.NewUpload (repo_editor.go:341) gogs.io/gogs/internal/db
repo.UploadFileToServer (editor.go:545) gogs.io/gogs/internal/route/repo
runtime.call16 (asm_arm64.s:507) runtime
<autogenerated>:2
reflect.Value.call (value.go:556) reflect
reflect.Value.Call (value.go:339) reflect
inject.(*injector).callInvoke (inject.go:177) github.com/go-macaron/inject
inject.(*injector).Invoke (inject.go:137) github.com/go-macaron/inject
macaron.(*Context).run (context.go:121) gopkg.in/macaron.v1
macaron.(*Context).Next (context.go:112) gopkg.in/macaron.v1
session.Sessioner.func1 (session.go:192) github.com/go-macaron/session
macaron.ContextInvoker.Invoke (context.go:79) gopkg.in/macaron.v1
inject.(*injector).fastInvoke (inject.go:157) github.com/go-macaron/inject
inject.(*injector).Invoke (inject.go:135) github.com/go-macaron/inject
macaron.(*Context).run (context.go:121) gopkg.in/macaron.v1
macaron.(*Context).Next (context.go:112) gopkg.in/macaron.v1
macaron.Recovery.func1 (recovery.go:161) gopkg.in/macaron.v1
macaron.LoggerInvoker.Invoke (logger.go:40) gopkg.in/macaron.v1
inject.(*injector).fastInvoke (inject.go:157) github.com/go-macaron/inject
inject.(*injector).Invoke (inject.go:135) github.com/go-macaron/inject
macaron.(*Context).run (context.go:121) gopkg.in/macaron.v1
macaron.(*Router).Handle.func1 (router.go:187) gopkg.in/macaron.v1
macaron.(*Router).ServeHTTP (router.go:303) gopkg.in/macaron.v1
macaron.(*Macaron).ServeHTTP (macaron.go:220) gopkg.in/macaron.v1
http.serverHandler.ServeHTTP (server.go:2916) net/http
http.(*conn).serve (server.go:1966) net/http
http.(*Server).Serve.func3 (server.go:3071) net/http
runtime.goexit (asm_arm64.s:1259) runtime
- Async Stack Trace
http.(*Server).Serve (server.go:3071) net/http
POST /admin1/repo1/_upload/master/ HTTP/1.1
Host: localhost:3002
Content-Length: 195
Cache-Control: max-age=0
sec-ch-ua: "(Not(A:Brand";v="8", "Chromium";v="100"
sec-ch-ua-mobile: ?0
sec-ch-ua-platform: "macOS"
Upgrade-Insecure-Requests: 1
Origin: null
Content-Type: application/x-www-form-urlencoded
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.60 Safari/537.36
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9
Sec-Fetch-Site: same-origin
Sec-Fetch-Mode: navigate
Sec-Fetch-User: ?1
Sec-Fetch-Dest: document
Accept-Encoding: gzip, deflate
Accept-Language: zh-CN,zh;q=0.9
Cookie: lang=zh-CN; i_like_gogs=1e6fcd3311b0b672; _csrf=E_P0IOSWdRSGfzood1cFb1pxwJI6MTY0OTMxNTI2MjU3NjQ2NzAwMA
Connection: close_csrf=E_P0IOSWdRSGfzood1cFb1pxwJI6MTY0OTMxNTI2MjU3NjQ2NzAwMA&tree_path=.git&files=0e25760b-f51a-46bb-9511-32b5047aab43&commit_summary=sum&commit_message=desc&commit_choice=direct&new_branch_name=
.git
func (repo *Repository) UploadRepoFiles(doer *User, opts UploadRepoFileOptions) (err error) {
targetPath := path.Join(dirPath, upload.Name)
// isRepositoryGitPath returns true if given path is or resides inside ".git" path of the repository.
func isRepositoryGitPath(path string) bool {
return strings.HasSuffix(path, ".git") || strings.Contains(path, ".git"+string(os.PathSeparator))
}
db.(*Repository).UploadRepoFiles (repo_editor.go:515) gogs.io/gogs/internal/db
repo.UploadFilePost (editor.go:493) gogs.io/gogs/internal/route/repo
runtime.call128 (asm_arm64.s:510) runtime
<autogenerated>:2
reflect.Value.call (value.go:556) reflect
reflect.Value.Call (value.go:339) reflect
inject.(*injector).callInvoke (inject.go:177) github.com/go-macaron/inject
inject.(*injector).Invoke (inject.go:137) github.com/go-macaron/inject
macaron.(*Context).run (context.go:121) gopkg.in/macaron.v1
macaron.(*Context).Next (context.go:112) gopkg.in/macaron.v1
session.Sessioner.func1 (session.go:192) github.com/go-macaron/session
macaron.ContextInvoker.Invoke (context.go:79) gopkg.in/macaron.v1
inject.(*injector).fastInvoke (inject.go:157) github.com/go-macaron/inject
inject.(*injector).Invoke (inject.go:135) github.com/go-macaron/inject
macaron.(*Context).run (context.go:121) gopkg.in/macaron.v1
macaron.(*Context).Next (context.go:112) gopkg.in/macaron.v1
macaron.Recovery.func1 (recovery.go:161) gopkg.in/macaron.v1
macaron.LoggerInvoker.Invoke (logger.go:40) gopkg.in/macaron.v1
inject.(*injector).fastInvoke (inject.go:157) github.com/go-macaron/inject
inject.(*injector).Invoke (inject.go:135) github.com/go-macaron/inject
macaron.(*Context).run (context.go:121) gopkg.in/macaron.v1
macaron.(*Router).Handle.func1 (router.go:187) gopkg.in/macaron.v1
macaron.(*Router).ServeHTTP (router.go:303) gopkg.in/macaron.v1
macaron.(*Macaron).ServeHTTP (macaron.go:220) gopkg.in/macaron.v1
http.serverHandler.ServeHTTP (server.go:2916) net/http
http.(*conn).serve (server.go:1966) net/http
http.(*Server).Serve.func3 (server.go:3071) net/http
runtime.goexit (asm_arm64.s:1259) runtime
- Async Stack Trace
http.(*Server).Serve (server.go:3071) net/http
// Prevent uploading files into the ".git" directory
if isRepositoryGitPath(opts.TreePath) {
return errors.Errorf("bad tree path %q", opts.TreePath)
}
// isRepositoryGitPath returns true if given path is or resides inside ".git" path of the repository.
func isRepositoryGitPath(path string) bool {
return strings.HasSuffix(path, ".git") || strings.Contains(path, ".git"+string(os.PathSeparator))
}
注:如有侵权请联系删除
学习更多技术,关注我: