Commit Graph

3771 Commits

Author SHA1 Message Date
88e813d1ca Revert "Add simple master key provider for secret encryption"
This reverts commit d4e84c0433.
2022-12-22 11:45:06 +08:00
ab98c3ff43 Merge branch 'main' into feature/bots 2022-12-19 18:26:28 +08:00
a89b399faa Local storage should not store files as executable (#22162)
The PR #21198 introduced a probable security vulnerability which
resulted in making all storage files be marked as executable.

This PR ensures that these are forcibly marked as non-executable.

Fix #22161

Signed-off-by: Andrew Thornton <art27@cantab.net>
2022-12-19 08:50:36 +08:00
6e22605793 Ensure that plain files are rendered correctly even when containing ambiguous characters (#22017)
As recognised in #21841 the rendering of plain text files is somewhat
incorrect when there are ambiguous characters as the html code is double
escaped. In fact there are several more problems here.

We have a residual isRenderedHTML which is actually simply escaping the
file - not rendering it. This is badly named and gives the wrong
impression.

There is also unusual behaviour whether the file is called a Readme or
not and there is no way to get to the source code if the file is called
README.

In reality what should happen is different depending on whether the file
is being rendered a README at the bottom of the directory view or not.

1. If it is rendered as a README on a directory - it should simply be
escaped and rendered as `<pre>` text.
2. If it is rendered as a file then it should be rendered as source
code.

This PR therefore does:
1. Rename IsRenderedHTML to IsPlainText
2. Readme files rendered at the bottom of the directory are rendered
without line numbers
3. Otherwise plain text files are rendered as source code.

Replace #21841

Signed-off-by: Andrew Thornton <art27@cantab.net>

Signed-off-by: Andrew Thornton <art27@cantab.net>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2022-12-17 22:22:25 +02:00
651fe4bb7d Add doctor command for full GC of LFS (#21978)
The recent PR adding orphaned checks to the LFS storage is not
sufficient to completely GC LFS, as it is possible for LFSMetaObjects to
remain associated with repos but still need to be garbage collected.

Imagine a situation where a branch is uploaded containing LFS files but
that branch is later completely deleted. The LFSMetaObjects will remain
associated with the Repository but the Repository will no longer contain
any pointers to the object.

This PR adds a second doctor command to perform a full GC.

Signed-off-by: Andrew Thornton <art27@cantab.net>
2022-12-15 20:44:16 +00:00
4fb2006ca1 Make gitea work using cmd.exe again (#22073)
Gitea will attempt to lookup its location using LookPath however, this
fails on cmd.exe if gitea is in the current working directory.

exec.LookPath will return an exec.ErrDot error which we can test for and
then simply using filepath.Abs(os.Args[0]) to absolute gitea against the
current working directory.

Fix #22063

Signed-off-by: Andrew Thornton <art27@cantab.net>

Signed-off-by: Andrew Thornton <art27@cantab.net>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2022-12-14 01:15:11 -05:00
cc19ab5ced Merge branch 'main' into feature/bots 2022-12-12 17:29:51 +08:00
6398ca745a refactor bind functions based on generics (#22055) 2022-12-12 16:09:26 +08:00
705fbb46d5 Fix permission check on http push 2022-12-12 14:52:00 +08:00
a6e39ca180 Merge branch 'main' into feature/bots 2022-12-12 13:12:58 +08:00
dbdfd2647c chore: rename to workflows.go 2022-12-12 13:09:17 +08:00
7a34d37aad fix: use ctx 2022-12-12 11:05:22 +08:00
3e8285b824 Use multi reader instead to concat strings (#22099)
extract from #20326
2022-12-12 11:03:54 +08:00
dbef504584 fix: truncated title 2022-12-12 10:54:28 +08:00
22203eeb38 Update modules/notification/actions/helper.go
Co-authored-by: a1012112796 <1012112796@qq.com>
2022-12-12 10:48:32 +08:00
dfa1b6168d Merge branch 'main' into feature/bots 2022-12-12 10:46:13 +08:00
68704532c2 Rename almost all Ctx functions (#22071) 2022-12-10 10:46:31 +08:00
d378a78c79 Merge branch 'main' into feature/bots 2022-12-09 16:20:28 +08:00
3c59d31bc6 Add API management for issue/pull and comment attachments (#21783)
Close #14601
Fix #3690

Revive of #14601.
Updated to current code, cleanup and added more read/write checks.

Signed-off-by: Andrew Thornton <art27@cantab.net>
Signed-off-by: Andre Bruch <ab@andrebruch.com>
Co-authored-by: zeripath <art27@cantab.net>
Co-authored-by: 6543 <6543@obermui.de>
Co-authored-by: Norwin <git@nroo.de>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2022-12-09 14:35:56 +08:00
266a122ba2 Merge branch 'main' into feature/bots 2022-12-08 18:11:18 +08:00
0585ac3ac6 Update go dev dependencies (#22064)
`golangci-lint`
[deprecated](https://github.com/golangci/golangci-lint/issues/1841) a
bunch of linters, removed them.
2022-12-08 16:21:37 +08:00
0a85537c79 Support disabling database auto migration (#22053)
Gitea will migrate the database model version automatically, but it
should be able to be disabled and keep Gitea shutdown if the version is
not matched.
2022-12-07 09:58:31 -06:00
4142218088 chore: rename dbfs prefix 2022-12-06 16:13:29 +08:00
223782ca4c refactor: rename to actions 2022-12-06 15:16:25 +08:00
56368f3963 refactor: use ctx in models 2022-12-06 14:15:48 +08:00
c07d0c1768 refactor: rename model 2022-12-06 13:48:09 +08:00
f2c7bbb0bc refactor: rename to actions-proto-go 2022-12-06 13:44:23 +08:00
67c5c8868b refactor: rename import alias 2022-12-05 15:57:45 +08:00
5f74b35377 refactor: rename files 2022-12-05 15:52:32 +08:00
704f72017d refactor: rename packages 2022-12-05 15:45:38 +08:00
fdd3444c52 fix: add missing ctx 2022-12-05 14:46:34 +08:00
bd1af5b7f8 Merge branch 'main' into feature/bots 2022-12-05 14:31:00 +08:00
a08584ee36 Ensure that Chinese punctuation is not ambiguous when locale is Chinese (#22019)
Although there are per-locale fallbacks for ambiguity the locale names
for Chinese do not quite match our locales. This PR simply maps zh-CN on
to zh-hans and other zh variants on to zh-hant.

Ref #20999

Signed-off-by: Andrew Thornton <art27@cantab.net>
2022-12-04 17:57:30 +00:00
ea86c2b56a Use GhostUser if needed for TrackedTimes (#22021)
When getting tracked times out of the db and loading their attributes
handle not exist errors in a nicer way. (Also prevent an NPE.)

Fix #22006

Signed-off-by: Andrew Thornton <art27@cantab.net>
2022-12-04 17:48:18 +00:00
46485848fa On tag/branch-exist check, dont panic if repo is nil (#21787)
fix a panic found in gitea logs
2022-12-04 10:28:57 +00:00
0a7d3ff786 refactor some functions to support ctx as first parameter (#21878)
Co-authored-by: KN4CK3R <admin@oldschoolhack.me>
Co-authored-by: Lauris BH <lauris@nix.lv>
2022-12-03 10:48:26 +08:00
8698458f48 Remove deprecated packages & staticcheck fixes (#22012)
`ioutil` is deprecated and should use `io` instead
2022-12-02 17:06:23 -05:00
b0d6c7b86e chore: use SPDX-License-Identifier 2022-12-02 22:25:31 +08:00
76869e4b76 Merge branch 'main' into feature/bots 2022-12-02 22:17:49 +08:00
f59a74852b Update gitea-vet to check FSFE REUSE (#22004)
Related to:
- #21840
- https://gitea.com/gitea/gitea-vet/pulls/21

What it looks like when it's working:
https://drone.gitea.io/go-gitea/gitea/64040/1/5

All available SPDX license identifiers: [SPDX License
List](https://spdx.org/licenses/).

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2022-12-02 22:14:57 +08:00
f869c988a5 chore: resolve conflict 2022-12-02 11:17:41 +08:00
9bd773eb85 Merge branch 'main' into feature/bots 2022-12-02 09:42:42 +08:00
64973cf18f Use path not filepath in template filenames (#21993)
Paths in git are always separated by `/` not `\` - therefore we should
`path` and not `filepath`

Fix #21987

Signed-off-by: Andrew Thornton <art27@cantab.net>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: Lauris BH <lauris@nix.lv>
2022-12-02 07:56:51 +08:00
f9cbf5a1bc Util type to parse ref name (#21969)
Provide a new type to make it easier to parse a ref name.

Actually, it's picked up from #21937, to make the origin PR lighter.

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2022-12-01 19:56:04 +08:00
4e5d4d0073 Skip initing LFS storage if disabled (#21996)
A complement to #21985.

I overlooked it because the name of the switch is `StartServer`, not
`Enabled`. I believe the weird name is a legacy, but renaming is out of
scope.
2022-12-01 11:02:04 +02:00
b2745bff43 feat: support disable bots completely 2022-12-01 15:27:28 +08:00
ab69fdc6fe feat: more notifications 2022-12-01 14:13:22 +08:00
a29babebd0 fix: skip initing bots storage if disabled 2022-12-01 13:42:48 +08:00
c5c9b4ae57 Merge branch 'main' into feature/bots 2022-12-01 13:39:47 +08:00
67881ae99a Skip initing disabled storages (#21985)
If `Attachment` or `Packages` are disabled, we don't have to init the
storages for them.
2022-11-30 21:39:02 +08:00