mirror of
1
Fork 0
Commit Graph

84 Commits

Author SHA1 Message Date
Gusted 5509ce5557 [gitea] week 2025-07 cherry pick (gitea/main -> forgejo) (#6865)
Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/6865
Reviewed-by: Earl Warren <earl-warren@noreply.codeberg.org>
2025-02-11 16:22:58 +00:00
Mirco 179f85cf49 Transient model for federated unstar (#6740)
This is the first step to https://codeberg.org/forgejo-contrib/federation/src/branch/main/FederationRoadmap.md#federated-unstar-wip

Co-authored-by: Michael Jerger <michael.jerger@meissa-gmbh.de>
Co-authored-by: ansgarz <ansgar.zwick@meissa.de>
Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/6740
Reviewed-by: Otto <otto@codeberg.org>
Co-authored-by: Mirco <mirco.zachmann@meissa.de>
Co-committed-by: Mirco <mirco.zachmann@meissa.de>
2025-02-11 12:49:32 +00:00
Gusted 3d708aeee6
chore: update deadcode 2025-02-09 10:34:12 +01:00
Gusted 1ee9e88809
chore: Remove `GetFileResponseFromCommit`
- Introduced in 2262811e40 and removed in
275d4b7e3f.
2025-01-31 16:22:29 +01:00
Gusted 039a679ccb
chore: Remove `IsCommitStatusContextSuccess`
- Introduced in 04ca7f0047 and removed in 81daf26878.
2025-01-31 16:22:29 +01:00
Gusted 5d52f88c9c
chore: Remove `WithXXXParser`
- Introduced in 88c2e24360 and removed in
the same commit. No usage.
2025-01-31 16:22:29 +01:00
Gusted 4cdfe27c8f
chore: Remove `IsXXX`
- Introduced in 812cfd0ad9 and removed in the same commit. No usage.
2025-01-31 16:22:29 +01:00
Gusted 9a406757f5
chore: Remove `UpdateTeamUnits`
- Introduced in 0b3ea42847 and removed in
b7221bec34.
2025-01-31 16:22:29 +01:00
Gusted 66d252bc2b
chore: Remove `GetTeamNamesByID`
- Introduced in 9ff4e1d2d9 and removed in
b3a6596b54.
2025-01-31 16:22:29 +01:00
Gusted e2dfdcdabd
chore: Remove `UsersInTeamsCount`
- Introduced in 9681c83734 and removed in
bac4b78e09.
2025-01-31 16:22:29 +01:00
Gusted d2701877c0
chore: Remove `IsTagExist`
- Introduced in 1ebb35b988 and removed in 2af67f6044.
2025-01-31 16:22:29 +01:00
Gusted 6fd9c065dc
chore: Remove `BreakWriter`
- Introduced in 99efa02edf and removed in 6e22605793.
2025-01-31 16:22:29 +01:00
Gusted 61f01f35ae
chore: Remove `ErrUpdateTaskNotExist`
- Introduced in f255b1e86d and removed in cd1821a7e2.
2025-01-31 16:22:29 +01:00
Gusted 581a2ca341
chore: Remove `ScheduleList`
- Introduced in 0d55f64e6c and removed in df1e7d0067.
2025-01-31 16:22:26 +01:00
Gusted 5423e22aeb
chore: Remove `GetSourceByName`
- Introduced in 5455605342 and removed in
the same commit. Usage was purely testing code.
2025-01-31 14:40:27 +01:00
Gusted 1b10046e1a
chore: Remove `ParsePushHook`
- Introduced in e378648c79 and removed in
the same commit. No usage.
2025-01-31 14:40:27 +01:00
Gusted 0ae59b7de7
chore: Remove `ParseCreateHook`
- Introduced in e378648c79 and removed in
the same commit. No usage.
2025-01-31 14:40:27 +01:00
Gusted 5cc5c877a5
chore: Remove `ToSecret`
- Introduced in 23addde28e and removed in
8cd46024fd.
2025-01-31 14:40:27 +01:00
Gusted 2d81bdbeb6
chore: Remove `DeleteLocaleCookie`
- Introduced in 9b261f52f0 and removed in
5b9557aef5.
2025-01-31 14:40:27 +01:00
Gusted 4d8f1e3e4b
chore: Remove `DeadlineForm`
- Introduced in 1a97030017 and removed in
ef6813abc9.
2025-01-31 14:40:27 +01:00
Gusted 552cfe75f5
chore: Remove `TemporaryUploadRepository.GetLastCommit`
- Introduced in 2262811e40 and removed in
the same commit. Never used.
2025-01-31 14:40:22 +01:00
Gusted 6062ba36f2
chore: Remove `ActionsRunnerRegister`
- Introduced in e90db3f5cc and it was
never used and it would've never worked.
2025-01-31 11:11:33 +01:00
Gusted 56c757561f
chore: Remove `ErrInvalidConfiguration`
- Introduced in 6b1266b6b3 and removed in
6f9c278559.
2025-01-31 11:07:21 +01:00
Gusted c4b2352c6c
chore: Remove `LimitedReaderCloser`
- Introduced in 511f6138d4 and removed in
270aab429e.
2025-01-31 10:43:29 +01:00
Gusted b7b52fd04d
chore: Remove `ChangeProjectStatus`
- Introduced in 4027c5dd7c and removed in
the same commit (only used for testing code).
2025-01-30 12:19:59 +01:00
Gusted 8c3bfcac3b
chore: Remove `UpdateColumnSorting`
- Introduced in c69c01d2b6 and removed in
the same commit, no usage at all.
2025-01-30 12:19:59 +01:00
Gusted 901b32ce16
chore: Remove `DeleteAttachmentsByIssue`
- Introduced in 4617bef895 and removed in ab2d0b3b44.
2025-01-30 12:19:59 +01:00
Gusted 7481624273
chore: Remove `FindReposMapByIDs`
- Introduced in 8ce1b539b1 and removed in beb71f5ef6.
2025-01-30 12:19:59 +01:00
Gusted a52b610eff
chore: Remove `GetTopicByName`
- Introduced in bec69f702b and removed in
the same commit (only usage was in testing code).
2025-01-30 12:19:59 +01:00
Gusted 5813244ff8 chore: Remove `ChangeMilestoneStatus` (#6741)
- Introduced in 5ed5aa5228 and removed in
4027c5dd7c.

Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/6741
Reviewed-by: Earl Warren <earl-warren@noreply.codeberg.org>
Co-authored-by: Gusted <postmaster@gusted.xyz>
Co-committed-by: Gusted <postmaster@gusted.xyz>
2025-01-30 11:09:53 +00:00
Gusted 801c392e0c
chore: remove deadcode in `models/user`
- Remove `ErrUserInactive` introduced in
f5fa22a499 and removed in
ef2a343e27
- Remove `GetUserEmailsByNames` introduced in
a4cbe79567 and removed in
08ae6bb7ed
- Remove `GetUserNamesByIDs` introduced in
9ff4e1d2d9 and removed in
b3a6596b54
2025-01-29 18:37:14 +01:00
Benedikt Straub a2787bb09e
Initial support for localization and pluralization with go-i18n-JSON-v2 format 2025-01-17 11:21:28 +01:00
Earl Warren 9a608a034d feat: add a buffer writer to the logger, for internal use (#6551)
Identical to console, file or conn but writes to a buffer instead.

It is useful in two contexts:

- tests that need to assert the logs in a way that is simpler than
  LogChecker.
- capturing the logs of a given task to display in the web UI,
  return from the API, etc.

Since all logged events at a given level are written to the buffer by default, it is best used with WriterMode.Expression to only keep the log lines of interest.

## Checklist

The [contributor guide](https://forgejo.org/docs/next/contributor/) 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...
  - [x] in their respective `*_test.go` for unit tests.
  - [ ] in the `tests/integration` directory if it involves interactions with a live Forgejo server.
- I added test coverage for JavaScript changes...
  - [ ] in `web_src/js/*.test.js` if it can be unit tested.
  - [ ] in `tests/e2e/*.test.e2e.js` if it requires interactions with a live Forgejo server (see also the [developer guide for JavaScript testing](https://codeberg.org/forgejo/forgejo/src/branch/forgejo/tests/e2e/README.md#end-to-end-tests)).

### Documentation

- [ ] I created a pull request [to the documentation](https://codeberg.org/forgejo/docs) to explain to Forgejo users how to use this change.
- [x] I did not document these changes and I do not expect someone else to do it.

### Release notes

- [x] 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/6551
Reviewed-by: Antonin Delpeuch <wetneb@noreply.codeberg.org>
Co-authored-by: Earl Warren <contact@earl-warren.org>
Co-committed-by: Earl Warren <contact@earl-warren.org>
2025-01-13 13:40:24 +00:00
Lunny Xiao 6ac88eab0f
Remove outdated code about fixture generation (#32708)
(cherry picked from commit e45ffc530f482a46de25d28f18b039f296750414)

Conflicts:
	models/fixture_test.go
  trivial context conflict and remove one line in deadcode
2024-12-08 07:31:32 +01:00
Lunny Xiao a8f2002a9b
Remove transaction for archive download (#32186)
Since there is a status column in the database, the transaction is
unnecessary when downloading an archive. The transaction is blocking
database operations, especially with SQLite.

Replace #27563

(cherry picked from commit e1b269e956e955dd1dfb012f40270d73f8329092)
2024-11-17 12:18:57 +01:00
wxiaoguang 3c4153b195
[PORT] Refactor tests to prevent from unnecessary preparations (gitea#32398)
Some preparations are only used by a few tests, so to make the tests fast, they should only be prepared when they are used.

By the way, this PR splits PrepareTestEnv into small functions to make it simple.

---

Conflict resolution: Mostly magical and just re-pasting the code into
the right places.
Done differently: use `require.NoError` instead of `assert.NoError`.

(cherry picked from commit ec2d1593c269e06655525deb96f74b8094221b6f)
2024-11-07 23:02:10 +01:00
wxiaoguang 171de4d107
[PORT] Fix git error handling (gitea#32401)
---
Conflict resolution: Trivial, for `repo_attributes.go` move where the
`IsErrCanceledOrKilled` needs to happen because of other changes that
happened in this file.

To add some words to this change: It seems to be mostly simplifying the
error handling of git operations.

(cherry picked from commit e524f63d58900557d7d57fc3bcd19d9facc8b8ee)
2024-11-03 16:47:44 +01:00
Gergely Nagy cd87c4fee6
[DEADCODE] update
Signed-off-by: Gergely Nagy <forgejo@gergo.csillger.hu>
2024-09-14 18:58:51 +02:00
Philip Peterson 03508b33a8
[FEAT] Allow pushmirror to use publickey authentication
- Continuation of https://github.com/go-gitea/gitea/pull/18835 (by
@Gusted, so it's fine to change copyright holder to Forgejo).
- Add the option to use SSH for push mirrors, this would allow for the
deploy keys feature to be used and not require tokens to be used which
cannot be limited to a specific repository. The private key is stored
encrypted (via the `keying` module) on the database and NEVER given to
the user, to avoid accidental exposure and misuse.
- CAVEAT: This does require the `ssh` binary to be present, which may
not be available in containerized environments, this could be solved by
adding a SSH client into forgejo itself and use the forgejo binary as
SSH command, but should be done in another PR.
- CAVEAT: Mirroring of LFS content is not supported, this would require
the previous stated problem to be solved due to LFS authentication (an
attempt was made at forgejo/forgejo#2544).
- Integration test added.
- Resolves #4416
2024-08-22 17:05:07 +02:00
Gusted 12f97ef51f
[SEC] Add `keying` module
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/
2024-08-21 16:06:17 +02:00
Earl Warren d42f28de4e
chore: update .deadcode.out 2024-08-13 09:05:50 +02:00
Aravinth Manivannan f9cbea3d6b feat: access ActivityPub client through interfaces to facilitate mocking in 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>
2024-08-07 05:45:24 +00:00
Earl Warren 5f1017f27d
chore: update .deadcode.out 2024-08-04 18:24:10 +02:00
Earl Warren c55f3bf3c3
chore: update .deadcode.out 2024-07-28 09:00:29 +02:00
Gusted 4383da91bd
[SECURITY] Notify users about account security changes
- Currently if the password, primary mail, TOTP or security keys are
changed, no notification is made of that and makes compromising an
account a bit easier as it's essentially undetectable until the original
person tries to log in. Although other changes should be made as
well (re-authing before allowing a password change), this should go a
long way of improving the account security in Forgejo.
- Adds a mail notification for password and primary mail changes. For
the primary mail change, a mail notification is sent to the old primary
mail.
- Add a mail notification when TOTP or a security keys is removed, if no
other 2FA method is configured the mail will also contain that 2FA is
no longer needed to log into their account.
- `MakeEmailAddressPrimary` is refactored to the user service package,
as it now involves calling the mailer service.
- Unit tests added.
- Integration tests added.
2024-07-23 18:31:47 +02:00
Gusted 138942c09e
[CHORE] Move test related function to own package
- Go's deadcode eliminator is quite simple, if you put a public function
in a package `aa/bb` that is used only by tests, it would still be built
if package `aa/bb` was imported. This means that if such functions use
libraries relevant only to tests that those libraries would still be
be built and increase the binary size of a Go binary.
- This is also the case with Forgejo, `models/migrations/base/tests.go`
contained functions exclusively used by tests which (skipping some steps
here) imports https://github.com/ClickHouse/clickhouse-go, which is
2MiB. The `code.gitea.io/gitea/models/migrations/base` package is
imported by `cmd/doctor` and thus the code of the clickhouse library is
also built and included in the Forgejo binary, although entirely unused
and not reachable.
- This patch moves the test-related functions to their own package, so
Go's deadcode eliminator knows not to build the test-related functions
and thus reduces the size of the Forgejo binary.
- It is not possible to move this to a `_test.go` file because Go does
not allow importing functions from such files, so any test helper
function must be in a non-test package and file.
- Reduction of size (built with `TAGS="sqlite sqlite_unlock_notify" make
build`):
  - Before: 95912040 bytes (92M)
  - After: 92306888 bytes (89M)
2024-07-14 17:00:49 +02:00
wxiaoguang 75bbca68ce
Refactor markup code (#31399)
1. use clearer names
2. remove deadcode
3. avoid name shadowing
4. eliminate some lint warnings

(cherry picked from commit 5a7376c0605415e63cb5b3b8f89ead01e567229b)

Conflicts:
	modules/markup/html.go
	simple code divergence, trivial logic
2024-06-23 11:53:36 +02:00
Earl Warren 41bea7c23a
chore: update deadcode-out 2024-06-16 13:42:59 +02:00
Earl Warren 9464d51b2b
chore(deadcode): restore the previous format
While the newer default format is machine parsable, it also contains
line numbers which makes it sensitive to any change unrelated to deadcode.
2024-06-08 22:04:04 +02:00
0ko bd4ee91a19 Upgrade deadcode package to a new name (#4048)
We're stuck on an old version of golang deadcode. Renovate is confused by it's rename in https://codeberg.org/forgejo/forgejo/pulls/4043.

I don't remember how to use this tool to test it, let's see how the CI reacts to this PR.

Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/4048
Reviewed-by: Victoria <efertone@noreply.codeberg.org>
Reviewed-by: Earl Warren <earl-warren@noreply.codeberg.org>
Co-authored-by: 0ko <0ko@noreply.codeberg.org>
Co-committed-by: 0ko <0ko@noreply.codeberg.org>
2024-06-07 05:42:59 +00:00