summaryrefslogtreecommitdiffstats
path: root/modules (follow)
Commit message (Collapse)AuthorAgeFilesLines
...
* | [SEC] Add `keying` moduleGusted2024-08-213-0/+209
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The keying modules tries to solve two problems, the lack of key separation and the lack of AEAD being used for encryption. The currently used `secrets` doesn't provide this and is hard to adjust to provide this functionality. For encryption, the additional data is now a parameter that can be used, as the underlying primitive is an AEAD constructions. This allows for context binding to happen and can be seen as defense-in-depth; it ensures that if a value X is encrypted for context Y (e.g. ID=3, Column="private_key") it will only decrypt if that context Y is also given in the Decrypt function. This makes confused deputy attack harder to exploit.[^1] For key separation, HKDF is used to derives subkeys from some IKM, which is the value of the `[service].SECRET_KEY` config setting. The context for subkeys are hardcoded, any variable should be shuffled into the the additional data parameter when encrypting. [^1]: This is still possible, because the used AEAD construction is not key-comitting. For Forgejo's current use-case this risk is negligible, because the subkeys aren't known to a malicious user (which is required for such attack), unless they also have access to the IKM (at which point you can assume the whole system is compromised). See https://scottarc.blog/2022/10/17/lucid-multi-key-deputies-require-commitment/
* | Merge pull request 'git-grep: refactor defaults' (#4964) from ↵Earl Warren2024-08-191-3/+9
|\ \ | | | | | | | | | | | | | | | | | | yoctozepto/git-grep-refactor-defaults into forgejo Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/4964 Reviewed-by: Shiny Nematoda <snematoda@noreply.codeberg.org>
| * | git-grep: refactor defaultsRadosław Piliszek2024-08-191-3/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | One method to set them all... or something like that. The defaults for git-grep options were scattered over the run function body. This change refactors them into a separate method. The application of defaults is checked implicitly by existing tests and linters, and the new approach makes it very easy to inspect the desired defaults are set.
* | | Merge pull request 'Update module ↵Earl Warren2024-08-196-14/+16
|\ \ \ | | | | | | | | | | | | | | | | | | | | | | | | github.com/golangci/golangci-lint/cmd/golangci-lint to v1.60.1 (forgejo)' (#4953) from renovate/forgejo-github.com-golangci-golangci-lint-cmd-golangci-lint-1.x into forgejo Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/4953 Reviewed-by: Gusted <gusted@noreply.codeberg.org>
| * | | Fix linting issuesGusted2024-08-186-14/+16
| | | |
* | | | revert: accidental changeTheFox0x72024-08-181-0/+1
| | | |
* | | | test: add more workflow event coverageTheFox0x72024-08-181-79/+96
| | | |
* | | | style: reenable switch checkTheFox0x72024-08-187-17/+14
|/ / /
* | | Merge pull request 'git-grep: fix for initial dashes in expressions' (#4967) ↵Earl Warren2024-08-174-1/+45
|\ \ \ | | | | | | | | | | | | | | | | | | | | | | | | from yoctozepto/git-grep-fix-words into forgejo Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/4967 Reviewed-by: Shiny Nematoda <snematoda@noreply.codeberg.org>
| * | | git-grep: fix for initial dashes in expressionsRadosław Piliszek2024-08-124-1/+45
| | | | | | | | | | | | | | | | | | | | | | | | There is no reason to reject initial dashes in git-grep expressions... other than the code not supporting it previously. A new method is introduced to relax the security checks.
* | | | Merge pull request '[BUG] Make logout event non-blocking' (#4938) from ↵Otto2024-08-162-19/+0
|\ \ \ \ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | gusted/forgejo-non-blocking-logout into forgejo Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/4938 Reviewed-by: Otto <otto@codeberg.org>
| * | | | [BUG] Make logout event non-blockingGusted2024-08-122-19/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | - When people click on the logout button, a event is sent to all browser tabs (actually to a shared worker) to notify them of this logout. This is done in a blocking fashion, to ensure every registered channel (which realistically should be one for every user because of the shared worker) for a user receives this message. While doing this, it locks the mutex for the eventsource module. - Codeberg is currently observing a deadlock that's caused by this blocking behavior, a channel isn't receiving the logout event. We currently don't have a good theory of why this is being caused. This in turn is causing that the logout functionality is no longer working and people no longer receive notifications, unless they refresh the page. - This patchs makes this message non-blocking and thus making it consistent with the other messages. We don't see a good reason why this specific event needs to be blocking and the commit introducing it doesn't offer a rationale either.
* | | | | Merge pull request 'Enhancing Gitea OAuth2 Provider with Granular Scopes for ↵Earl Warren2024-08-161-16/+18
|\ \ \ \ \ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Resource Access' (#4449) from marcellmars/forgejo:forgejo into forgejo Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/4449 Reviewed-by: Earl Warren <earl-warren@noreply.codeberg.org>
| * | | | | OAuth2 provider: support for granular scopesMarcell Mars2024-08-091-16/+18
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | - `CheckOAuthAccessToken` returns both user ID and additional scopes - `grantAdditionalScopes` returns AccessTokenScope ready string (grantScopes) compiled from requested additional scopes by the client - `userIDFromToken` sets returned grantScopes (if any) instead of default `all`
* | | | | | Merge pull request 'git-grep: set timeout to 2s by default and allow ↵Otto2024-08-152-0/+6
|\ \ \ \ \ \ | |_|_|_|/ / |/| | | | | | | | | | | | | | | | | | | | | | | | | | | | | configuring it' (#4966) from yoctozepto/git-grep-timeout into forgejo Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/4966 Reviewed-by: Otto <otto@codeberg.org>
| * | | | | git-grep: set timeout to 2s by default and allow configuring itRadosław Piliszek2024-08-142-0/+6
| | |_|_|/ | |/| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | We need to shorten the timeout to bound effectively for computation size. This protects against "too big" repos. This also protects to some extent against too long lines if kept to very low values (basically so that grep cannot run out of memory beforehand). Docs-PR: forgejo/docs#812
* | | | | fix: enable LOG_COMPRESSION by defaultEarl Warren2024-08-131-2/+2
| | | | | | | | | | | | | | | | | | | | Refs: https://codeberg.org/forgejo/forgejo/pulls/4924#issuecomment-2165839
* | | | | Fix `IsObjectExist` with gogit (#31790) (tests only)Jason Song2024-08-132-1/+101
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Fix #31271. When gogit is enabled, `IsObjectExist` calls `repo.gogitRepo.ResolveRevision`, which is not correct. It's for checking references not objects, it could work with commit hash since it's both a valid reference and a commit object, but it doesn't work with blob objects. So it causes #31271 because it reports that all blob objects do not exist. (cherry picked from commit f4d3120f9d1de6a260a5e625b3ffa6b35a069e9b) Conflicts: trivial resolution because go-git support was dropped https://codeberg.org/forgejo/forgejo/pulls/4941
* | | | | Support compression for Actions logs (#31761)Jason Song2024-08-139-7/+585
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Support compression for Actions logs to save storage space and bandwidth. Inspired by https://github.com/go-gitea/gitea/issues/24256#issuecomment-1521153015 The biggest challenge is that the compression format should support [seekable](https://github.com/facebook/zstd/blob/dev/contrib/seekable_format/zstd_seekable_compression_format.md). So when users are viewing a part of the log lines, Gitea doesn't need to download the whole compressed file and decompress it. That means gzip cannot help here. And I did research, there aren't too many choices, like bgzip and xz, but I think zstd is the most popular one. It has an implementation in Golang with [zstd](https://github.com/klauspost/compress/tree/master/zstd) and [zstd-seekable-format-go](https://github.com/SaveTheRbtz/zstd-seekable-format-go), and what is better is that it has good compatibility: a seekable format zstd file can be read by a regular zstd reader. This PR introduces a new package `zstd` to combine and wrap the two packages, to provide a unified and easy-to-use API. And a new setting `LOG_COMPRESSION` is added to the config, although I don't see any reason why not to use compression, I think's it's a good idea to keep the default with `none` to be consistent with old versions. `LOG_COMPRESSION` takes effect for only new log files, it adds `.zst` as an extension to the file name, so Gitea can determine if it needs decompression according to the file name when reading. Old files will keep the format since it's not worth converting them, as they will be cleared after #31735. <img width="541" alt="image" src="https://github.com/user-attachments/assets/e9598764-a4e0-4b68-8c2b-f769265183c9"> (cherry picked from commit 33cc5837a655ad544b936d4d040ca36d74092588) Conflicts: assets/go-licenses.json go.mod go.sum resolved with make tidy
* | | | | Fix null requested_reviewer from API (#31773)Edip Emre Bodur2024-08-131-15/+16
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | If the assign the pull request review to a team, it did not show the members of the team in the "requested_reviewers" field, so the field was null. As a solution, I added the team members to the array. fix #31764 (cherry picked from commit 94cca8846e7d62c8a295d70c8199d706dfa60e5c)
* | | | | [CHORE] Drop `go-git` supportGusted2024-08-1267-4064/+1629
| |_|/ / |/| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | See https://codeberg.org/forgejo/discussions/issues/164 for the rationale and discussion of this change. Everything related to the `go-git` dependency is dropped (Only a single instance is left in a test file to test for an XSS, it requires crafting an commit that Git itself refuses to craft). `_gogit` files have been removed entirely, `go:build: !gogit` is removed, `XXX_nogogit.go` files either have been renamed or had their code being merged into the `XXX.go` file.
* | | | Merge pull request 'git-grep: ensure bounded default for MatchesPerFile' ↵Otto2024-08-121-3/+2
|\ \ \ \ | |_|_|/ |/| | | | | | | | | | | | | | | | | | | | | | | (#4928) from yoctozepto/forgejo:git-grep-limit-matches-per-file into forgejo Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/4928 Reviewed-by: Shiny Nematoda <snematoda@noreply.codeberg.org> Reviewed-by: Otto <otto@codeberg.org>
| * | | git-grep: ensure bounded default for MatchesPerFileRadosław Piliszek2024-08-111-3/+2
| |/ / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Analogously to how it happens for MaxResultLimit. The default of 20 is inspired by a well-known, commercial code hosting platform. Unbounded limits are risky because they expose Forgejo to a class of DoS attacks where queries are crafted to take advantage of missing bounds.
* / / git-grep: skip binary filesRadosław Piliszek2024-08-112-1/+27
|/ / | | | | | | | | | | | | | | | | It is a waste of resources to scan them looking for matches because they are never returned back - they appear as empty lines in the current format. Notably, even if they were returned, it is unlikely that matching in binary files makes sense when the goal is "code search".
* | feat: support grouping by any path for arch package (#4903)Exploding Dragon2024-08-112-13/+41
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Previous arch package grouping was not well-suited for complex or multi-architecture environments. It now supports the following content: - Support grouping by any path. - New support for packages in `xz` format. - Fix clean up rules <!--start release-notes-assistant--> ## Draft release notes <!--URL:https://codeberg.org/forgejo/forgejo--> - Features - [PR](https://codeberg.org/forgejo/forgejo/pulls/4903): <!--number 4903 --><!--line 0 --><!--description c3VwcG9ydCBncm91cGluZyBieSBhbnkgcGF0aCBmb3IgYXJjaCBwYWNrYWdl-->support grouping by any path for arch package<!--description--> <!--end release-notes-assistant--> Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/4903 Reviewed-by: Earl Warren <earl-warren@noreply.codeberg.org> Co-authored-by: Exploding Dragon <explodingfkl@gmail.com> Co-committed-by: Exploding Dragon <explodingfkl@gmail.com>
* | git-grep: update commentRadosław Piliszek2024-08-101-3/+4
| | | | | | | | It was outdated and missing detail.
* | [CHORE] Fix swagger deprecation messageGusted2024-08-1010-16/+16
| | | | | | | | | | | | - Fix "WARNING: item list for enum is not a valid JSON array, using the old deprecated format" messages from https://github.com/go-swagger/go-swagger in the CI.
* | [CHORE] Fix darwin compatibilityGusted2024-08-091-1/+3
|/ | | | | - Always convert (syscall.Stat_t).Dev to uint64. - Resolves #4905
* log: journald integration (#2869)Ivan Shapovalov2024-08-098-17/+168
| | | | | | | | | | | | | | | | | | | | | Provide a bit more journald integration. Specifically: - support emission of printk-style log level prefixes, documented in [`sd-daemon`(3)](https://man7.org/linux/man-pages/man3/sd-daemon.3.html#DESCRIPTION), that allow journald to automatically annotate stderr log lines with their level; - add a new "journaldflags" item that is supposed to be used in place of "stdflags" when under journald to reduce log clutter (i. e. strip date/time info to avoid duplication, and use log level prefixes instead of textual log levels); - detect whether stderr and/or stdout are attached to journald by parsing `$JOURNAL_STREAM` environment variable and adjust console logger defaults accordingly. <!--start release-notes-assistant--> ## Draft release notes <!--URL:https://codeberg.org/forgejo/forgejo--> - Features - [PR](https://codeberg.org/forgejo/forgejo/pulls/2869): <!--number 2869 --><!--line 0 --><!--description bG9nOiBqb3VybmFsZCBpbnRlZ3JhdGlvbg==-->log: journald integration<!--description--> <!--end release-notes-assistant--> Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/2869 Reviewed-by: Earl Warren <earl-warren@noreply.codeberg.org> Co-authored-by: Ivan Shapovalov <intelfx@intelfx.name> Co-committed-by: Ivan Shapovalov <intelfx@intelfx.name>
* disallow javascript: URI in the repository descriptionGusted2024-08-092-1/+5
| | | | | | | | | | | | | | | - Fixes an XSS that was introduced in https://codeberg.org/forgejo/forgejo/pulls/1433 - This XSS allows for `href`s in anchor elements to be set to a `javascript:` uri in the repository description, which would upon clicking (and not upon loading) the anchor element execute the specified javascript in that uri. - [`AllowStandardURLs`](https://pkg.go.dev/github.com/microcosm-cc/bluemonday#Policy.AllowStandardURLs) is now called for the repository description policy, which ensures that URIs in anchor elements are `mailto:`, `http://` or `https://` and thereby disallowing the `javascript:` URI. It also now allows non-relative links and sets `rel="nofollow"` on anchor elements. - Unit test added.
* Adjust codespell config + make it fix few typos which sneaked in since ↵Yaroslav Halchenko2024-08-086-8/+8
| | | | | | | | | | | | | | | | | addition of codespell support (#4857) Now that my colleague just posted a wonderful blog post https://blog.datalad.org/posts/forgejo-runner-podman-deployment/ on forgejo runner, some time I will try to add that damn codespell action to work on CI here ;) meanwhile some typos managed to sneak in and this PR should address them (one change might be functional in a test -- not sure if would cause a fail or not) ### Release notes - [ ] I do not want this change to show in the release notes. - [ ] I want the title to show in the release notes with a link to this pull request. - [ ] I want the content of the `release-notes/<pull request number>.md` to be be used for the release notes instead of the title. Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/4857 Reviewed-by: Earl Warren <earl-warren@noreply.codeberg.org> Co-authored-by: Yaroslav Halchenko <debian@onerussian.com> Co-committed-by: Yaroslav Halchenko <debian@onerussian.com>
* cherry-pick OIDC changes from gitea (#4724)Shivaram Lingamneni2024-08-082-6/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | These are the three conflicted changes from #4716: * https://github.com/go-gitea/gitea/pull/31632 * https://github.com/go-gitea/gitea/pull/31688 * https://github.com/go-gitea/gitea/pull/31706 cc @earl-warren; as per discussion on https://github.com/go-gitea/gitea/pull/31632 this involves a small compatibility break (OIDC introspection requests now require a valid client ID and secret, instead of a valid OIDC token) ## Checklist The [developer guide](https://forgejo.org/docs/next/developer/) contains information that will be helpful to first time contributors. There also are a few [conditions for merging Pull Requests in Forgejo repositories](https://codeberg.org/forgejo/governance/src/branch/main/PullRequestsAgreement.md). You are also welcome to join the [Forgejo development chatroom](https://matrix.to/#/#forgejo-development:matrix.org). ### Tests - I added test coverage for Go changes... - [ ] in their respective `*_test.go` for unit tests. - [x] in the `tests/integration` directory if it involves interactions with a live Forgejo server. ### Documentation - [ ] I created a pull request [to the documentation](https://codeberg.org/forgejo/docs) to explain to Forgejo users how to use this change. - [ ] I did not document these changes and I do not expect someone else to do it. ### Release notes - [ ] I do not want this change to show in the release notes. - [ ] I want the title to show in the release notes with a link to this pull request. - [ ] I want the content of the `release-notes/<pull request number>.md` to be be used for the release notes instead of the title. <!--start release-notes-assistant--> ## Draft release notes <!--URL:https://codeberg.org/forgejo/forgejo--> - Breaking features - [PR](https://codeberg.org/forgejo/forgejo/pulls/4724): <!--number 4724 --><!--line 0 --><!--description T0lEQyBpbnRlZ3JhdGlvbnMgdGhhdCBQT1NUIHRvIGAvbG9naW4vb2F1dGgvaW50cm9zcGVjdGAgd2l0aG91dCBzZW5kaW5nIEhUVFAgYmFzaWMgYXV0aGVudGljYXRpb24gd2lsbCBub3cgZmFpbCB3aXRoIGEgNDAxIEhUVFAgVW5hdXRob3JpemVkIGVycm9yLiBUbyBmaXggdGhlIGVycm9yLCB0aGUgY2xpZW50IG11c3QgYmVnaW4gc2VuZGluZyBIVFRQIGJhc2ljIGF1dGhlbnRpY2F0aW9uIHdpdGggYSB2YWxpZCBjbGllbnQgSUQgYW5kIHNlY3JldC4gVGhpcyBlbmRwb2ludCB3YXMgcHJldmlvdXNseSBhdXRoZW50aWNhdGVkIHZpYSB0aGUgaW50cm9zcGVjdGlvbiB0b2tlbiBpdHNlbGYsIHdoaWNoIGlzIGxlc3Mgc2VjdXJlLg==-->OIDC integrations that POST to `/login/oauth/introspect` without sending HTTP basic authentication will now fail with a 401 HTTP Unauthorized error. To fix the error, the client must begin sending HTTP basic authentication with a valid client ID and secret. This endpoint was previously authenticated via the introspection token itself, which is less secure.<!--description--> <!--end release-notes-assistant--> Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/4724 Reviewed-by: Earl Warren <earl-warren@noreply.codeberg.org> Co-authored-by: Shivaram Lingamneni <slingamn@cs.stanford.edu> Co-committed-by: Shivaram Lingamneni <slingamn@cs.stanford.edu>
* Revert "Open telemetry integration (#3972)"TheFox0x72024-08-079-1031/+0
| | | | This reverts commit c738542201d4d6f960184cb913055322138c1b46.
* feat: access ActivityPub client through interfaces to facilitate mocking in ↵Aravinth Manivannan2024-08-072-19/+112
| | | | | | | | | | | | | | | | | | | unit tests (#4853) Was facing issues while writing unit tests for federation code. Mocks weren't catching all network calls, because was being out of scope of the mocking infra. Plus, I think we can have more granular tests. This PR puts the client behind an interface, that can be retrieved from `ctx`. Context doesn't require initialization, as it defaults to the implementation available in-tree. It may be overridden when required (like testing). ## Mechanism 1. Get client factory from `ctx` (factory contains network and crypto parameters that are needed) 2. Initialize client with sender's keys and the receiver's public key 3. Use client as before. Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/4853 Reviewed-by: Earl Warren <earl-warren@noreply.codeberg.org> Co-authored-by: Aravinth Manivannan <realaravinth@batsense.net> Co-committed-by: Aravinth Manivannan <realaravinth@batsense.net>
* [BUG] Render references to cross-repo issues with external issuesGusted2024-08-072-1/+17
| | | | | | | - If you have the external issue setting enabled, any reference would have been rendered as an external issue, however this shouldn't be happening to references that refer to issues in other repositories. - Unit test added.
* feat: highlighted code search results (#4749)Shiny Nematoda2024-08-063-33/+157
| | | | | | | | | | | | | | | closes #4534 <details> <summary>Screenshots</summary> ![](https://codeberg.org/attachments/0ab8a7b0-6485-46dc-a730-c016abb1f287) </details> Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/4749 Reviewed-by: 0ko <0ko@noreply.codeberg.org> Co-authored-by: Shiny Nematoda <snematoda.751k2@aleeas.com> Co-committed-by: Shiny Nematoda <snematoda.751k2@aleeas.com>
* Merge pull request '[gitea] week 2024-32 cherry pick (gitea/main -> ↵Earl Warren2024-08-065-8/+58
|\ | | | | | | | | | | | | forgejo)' (#4801) from earl-warren/wcp/2024-32 into forgejo Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/4801 Reviewed-by: Gusted <gusted@noreply.codeberg.org>
| * Clear up old Actions logs (#31735)Jason Song2024-08-041-4/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Part of #24256. Clear up old action logs to free up storage space. Users will see a message indicating that the log has been cleared if they view old tasks. <img width="1361" alt="image" src="https://github.com/user-attachments/assets/9f0f3a3a-bc5a-402f-90ca-49282d196c22"> Docs: https://gitea.com/gitea/docs/pulls/40 --------- Co-authored-by: silverwind <me@silverwind.io> (cherry picked from commit 687c1182482ad9443a5911c068b317a91c91d586) Conflicts: custom/conf/app.example.ini routers/web/repo/actions/view.go trivial context conflict
| * Add permission description for API to add repo collaborator (#31744)Jason Song2024-08-041-0/+1
| | | | | | | | | | | | Fix #31552. (cherry picked from commit 333c9ed8cab961b6dd58b04edc47a57dc4d6dbab)
| * Distinguish LFS object errors to ignore missing objects during migration ↵Jason Song2024-08-043-4/+45
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | (#31702) Fix #31137. Replace #31623 #31697. When migrating LFS objects, if there's any object that failed (like some objects are losted, which is not really critical), Gitea will stop migrating LFS immediately but treat the migration as successful. This PR checks the error according to the [LFS api doc](https://github.com/git-lfs/git-lfs/blob/main/docs/api/batch.md#successful-responses). > LFS object error codes should match HTTP status codes where possible: > > - 404 - The object does not exist on the server. > - 409 - The specified hash algorithm disagrees with the server's acceptable options. > - 410 - The object was removed by the owner. > - 422 - Validation error. If the error is `404`, it's safe to ignore it and continue migration. Otherwise, stop the migration and mark it as failed to ensure data integrity of LFS objects. And maybe we should also ignore others errors (maybe `410`? I'm not sure what's the difference between "does not exist" and "removed by the owner".), we can add it later when some users report that they have failed to migrate LFS because of an error which should be ignored. (cherry picked from commit 09b56fc0690317891829906d45c1d645794c63d5)
* | Merge pull request 'Implement an instance-wide activitypub actor' (#4811) ↵Earl Warren2024-08-052-13/+30
|\ \ | | | | | | | | | | | | | | | | | | | | | from algernon/forgejo:to-be-or-not-to-be into forgejo Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/4811 Reviewed-by: Gusted <gusted@noreply.codeberg.org> Reviewed-by: Earl Warren <earl-warren@noreply.codeberg.org>
| * | activitypub: Sign the Host header tooGergely Nagy2024-08-042-13/+30
| |/ | | | | | | | | | | | | | | | | | | | | | | | | Mastodon with `AUTHORIZED_FETCH` enabled requires the `Host` header to be signed too, add it to the default for `setting.Federation.GetHeaders` and `setting.Federation.PostHeaders`. For this to work, we need to sign the request later: not immediately after `NewRequest`, but just before sending them out with `client.Do`. Doing so also lets us use `setting.Federation.GetHeaders` (we were using `.PostHeaders` even for GET requests before). Signed-off-by: Gergely Nagy <forgejo@gergo.csillger.hu>
* / Open telemetry integration (#3972)TheFox0x72024-08-059-0/+1031
|/ | | | | | | | | | | | | | | | | This PR adds opentelemetry and chi wrapper to have basic instrumentation <!--start release-notes-assistant--> ## Draft release notes <!--URL:https://codeberg.org/forgejo/forgejo--> - Features - [PR](https://codeberg.org/forgejo/forgejo/pulls/3972): <!--number 3972 --><!--line 0 --><!--description YWRkIHN1cHBvcnQgZm9yIGJhc2ljIHJlcXVlc3QgdHJhY2luZyB3aXRoIG9wZW50ZWxlbWV0cnk=-->add support for basic request tracing with opentelemetry<!--description--> <!--end release-notes-assistant--> Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/3972 Reviewed-by: Earl Warren <earl-warren@noreply.codeberg.org> Co-authored-by: TheFox0x7 <thefox0x7@gmail.com> Co-committed-by: TheFox0x7 <thefox0x7@gmail.com>
* Arch packages implementation (#4785)Exploding Dragon2024-08-043-0/+763
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This PR is from https://github.com/go-gitea/gitea/pull/31037 This PR was originally created by @d1nch8g , and the original source code comes from https://ion.lc/core/gitea. This PR adds a package registry for [Arch Linux](https://archlinux.org/) packages with support for package files, [signatures](https://wiki.archlinux.org/title/Pacman/Package_signing), and automatic [pacman-database](https://archlinux.org/pacman/repo-add.8.html) management. Features: 1. Push any ` tar.zst ` package and Gitea sign it. 2. Delete endpoint for specific package version and all related files 3. Supports trust levels with `SigLevel = Required`. 4. Package UI with instructions to connect to the new pacman database and visualised package metadata ![](/attachments/810ca6df-bd20-44c2-bdf7-95e94886d750) You can follow [this tutorial](https://wiki.archlinux.org/title/Creating_packages) to build a *.pkg.tar.zst package for testing docs pr: https://codeberg.org/forgejo/docs/pulls/791 Co-authored-by: d1nch8g@ion.lc Co-authored-by: @KN4CK3R Co-authored-by: @mahlzahn Co-authored-by: @silverwind Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/4785 Reviewed-by: Earl Warren <earl-warren@noreply.codeberg.org> Co-authored-by: Exploding Dragon <explodingfkl@gmail.com> Co-committed-by: Exploding Dragon <explodingfkl@gmail.com>
* feat(quota): Humble beginnings of a quota engineGergely Nagy2024-08-023-0/+181
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is an implementation of a quota engine, and the API routes to manage its settings. This does *not* contain any enforcement code: this is just the bedrock, the engine itself. The goal of the engine is to be flexible and future proof: to be nimble enough to build on it further, without having to rewrite large parts of it. It might feel a little more complicated than necessary, because the goal was to be able to support scenarios only very few Forgejo instances need, scenarios the vast majority of mostly smaller instances simply do not care about. The goal is to support both big and small, and for that, we need a solid, flexible foundation. There are thee big parts to the engine: counting quota use, setting limits, and evaluating whether the usage is within the limits. Sounds simple on paper, less so in practice! Quota counting ============== Quota is counted based on repo ownership, whenever possible, because repo owners are in ultimate control over the resources they use: they can delete repos, attachments, everything, even if they don't *own* those themselves. They can clean up, and will always have the permission and access required to do so. Would we count quota based on the owning user, that could lead to situations where a user is unable to free up space, because they uploaded a big attachment to a repo that has been taken private since. It's both more fair, and much safer to count quota against repo owners. This means that if user A uploads an attachment to an issue opened against organization O, that will count towards the quota of organization O, rather than user A. One's quota usage stats can be queried using the `/user/quota` API endpoint. To figure out what's eating into it, the `/user/repos?order_by=size`, `/user/quota/attachments`, `/user/quota/artifacts`, and `/user/quota/packages` endpoints should be consulted. There's also `/user/quota/check?subject=<...>` to check whether the signed-in user is within a particular quota limit. Quotas are counted based on sizes stored in the database. Setting quota limits ==================== There are different "subjects" one can limit usage for. At this time, only size-based limits are implemented, which are: - `size:all`: As the name would imply, the total size of everything Forgejo tracks. - `size:repos:all`: The total size of all repositories (not including LFS). - `size:repos:public`: The total size of all public repositories (not including LFS). - `size:repos:private`: The total size of all private repositories (not including LFS). - `size:git:all`: The total size of all git data (including all repositories, and LFS). - `size:git:lfs`: The size of all git LFS data (either in private or public repos). - `size:assets:all`: The size of all assets tracked by Forgejo. - `size:assets:attachments:all`: The size of all kinds of attachments tracked by Forgejo. - `size:assets:attachments:issues`: Size of all attachments attached to issues, including issue comments. - `size:assets:attachments:releases`: Size of all attachments attached to releases. This does *not* include automatically generated archives. - `size:assets:artifacts`: Size of all Action artifacts. - `size:assets:packages:all`: Size of all Packages. - `size:wiki`: Wiki size Wiki size is currently not tracked, and the engine will always deem it within quota. These subjects are built into Rules, which set a limit on *all* subjects within a rule. Thus, we can create a rule that says: "1Gb limit on all release assets, all packages, and git LFS, combined". For a rule to stand, the total sum of all subjects must be below the rule's limit. Rules are in turn collected into groups. A group is just a name, and a list of rules. For a group to stand, all of its rules must stand. Thus, if we have a group with two rules, one that sets a combined 1Gb limit on release assets, all packages, and git LFS, and another rule that sets a 256Mb limit on packages, if the user has 512Mb of packages, the group will not stand, because the second rule deems it over quota. Similarly, if the user has only 128Mb of packages, but 900Mb of release assets, the group will not stand, because the combined size of packages and release assets is over the 1Gb limit of the first rule. Groups themselves are collected into Group Lists. A group list stands when *any* of the groups within stand. This allows an administrator to set conservative defaults, but then place select users into additional groups that increase some aspect of their limits. To top it off, it is possible to set the default quota groups a user belongs to in `app.ini`. If there's no explicit assignment, the engine will use the default groups. This makes it possible to avoid having to assign each and every user a list of quota groups, and only those need to be explicitly assigned who need a different set of groups than the defaults. If a user has any quota groups assigned to them, the default list will not be considered for them. The management APIs =================== This commit contains the engine itself, its unit tests, and the quota management APIs. It does not contain any enforcement. The APIs are documented in-code, and in the swagger docs, and the integration tests can serve as an example on how to use them. Signed-off-by: Gergely Nagy <forgejo@gergo.csillger.hu>
* Add signature support for the RPM module (#4780)Exploding Dragon2024-08-021-23/+25
| | | | | | | | | | | | | | | | | | | | | This pull request comes from https://github.com/go-gitea/gitea/pull/27069. If the rpm package does not contain a matching gpg signature, the installation will fail. See ([gitea/gitea#27031](https://github.com/go-gitea/gitea/issues/27031)) , now auto-signing all new rpm uploads. This option is turned off by default for compatibility. <!--start release-notes-assistant--> ## Draft release notes <!--URL:https://codeberg.org/forgejo/forgejo--> - Features - [PR](https://codeberg.org/forgejo/forgejo/pulls/4780): <!--number 4780 --><!--line 0 --><!--description QWRkIHNpZ25hdHVyZSBzdXBwb3J0IGZvciB0aGUgUlBNIG1vZHVsZQ==-->Add signature support for the RPM module<!--description--> <!--end release-notes-assistant--> Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/4780 Reviewed-by: Earl Warren <earl-warren@noreply.codeberg.org> Co-authored-by: Exploding Dragon <explodingfkl@gmail.com> Co-committed-by: Exploding Dragon <explodingfkl@gmail.com>
* feat: allow color and background-color style properties for table cells (#4766)0ko2024-07-312-3/+5
| | | | | | | | | | | * Allow adding text color and background color to HTML table headers and cells in markdown. * Added a few test cases. Preview and example: https://codeberg.org/attachments/98634f30-4fa2-4a76-adb3-6086af73744f Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/4766 Reviewed-by: Gusted <gusted@noreply.codeberg.org> Reviewed-by: Earl Warren <earl-warren@noreply.codeberg.org>
* Add testifylint to lint checks (#4535)TheFox0x72024-07-30150-1130/+1236
| | | | | | | | | go-require lint is ignored for now Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/4535 Reviewed-by: Gusted <gusted@noreply.codeberg.org> Co-authored-by: TheFox0x7 <thefox0x7@gmail.com> Co-committed-by: TheFox0x7 <thefox0x7@gmail.com>
* Merge pull request 'Implement external release assets' (#1445) from ↵Earl Warren2024-07-301-0/+4
|\ | | | | | | | | | | | | maltejur/forgejo:forgejo-external-attachments into forgejo Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/1445 Reviewed-by: Earl Warren <earl-warren@noreply.codeberg.org>
| * Implement external assetsMalte Jürgens2024-07-291-0/+4
| |