forgejo/modules
Twenty Panda 0d09acf669 fix(hook): ignore unknown push options instead of failing
If a repository has

git config --add push.pushOption submit=".sourcehut/*.yml"

it failed when pushed because of the unknown submit push
option. It will be ignored instead.

Filtering out the push options is done in an earlier stage, when the
hook command runs, before it submits the options map to the private
endpoint.

* move all the push options logic to modules/git/pushoptions
* add 100% test coverage for modules/git/pushoptions

Test coverage for the code paths from which code was moved to the
modules/git/pushoptions package:

* cmd/hook.go:runHookPreReceive
* routers/private/hook_pre_receive.go:validatePushOptions
  tests/integration/git_push_test.go:TestOptionsGitPush runs through
  both. The test verifying the option is rejected was removed and, if
  added again, will fail because the option is now ignored instead of
  being rejected.

* cmd/hook.go:runHookProcReceive
* services/agit/agit.go:ProcReceive
  tests/integration/git_test.go: doCreateAgitFlowPull runs through
  both. It uses variations of AGit related push options.

* cmd/hook.go:runHookPostReceive
* routers/private/hook_post_receive.go:HookPostReceive
  tests/integration/git_test.go:doPushCreate called by TestGit/HTTP/sha1/PushCreate
  runs through both.
  Note that although it provides coverage for this code path it does not use push options.

Fixes: https://codeberg.org/forgejo/forgejo/issues/3651
(cherry picked from commit 5561e80b04)
2024-07-02 20:18:33 +00:00
..
actions Add support for workflow_dispatch (#3334) 2024-06-28 05:17:11 +00:00
activitypub FIX: use proper time format (activitypub/client) (#4132) 2024-06-14 15:22:37 +00:00
analyze Rename code_langauge.go to code_language.go (#26377) 2023-08-07 15:00:53 -04:00
assetfs Use Set[Type] instead of map[Type]bool/struct{}. (#26804) 2023-08-30 06:55:25 +00:00
auth Enable unparam linter (#31277) 2024-06-16 13:42:58 +02:00
avatar Add codespell support and fix a good number of typos with its help (#3270) 2024-05-09 13:49:37 +00:00
base Refactor sha1 and time-limited code (#31023) 2024-05-26 18:43:30 +02:00
cache [PORT] Add cache test for admins (#31265) 2024-06-23 11:38:35 +02:00
charset s/Gitea/Forgejo in various log messages and comments 2024-04-21 21:26:15 +05:00
container Add container.FilterSlice function (gitea#30339) 2024-04-16 11:49:44 +02:00
csv Refactor locale&string&template related code (#29165) 2024-02-16 15:20:52 +01:00
emoji Update emoji set to Unicode 15 (#25595) 2023-06-29 16:29:48 +00:00
eventsource Final round of db.DefaultContext refactor (#27587) 2023-10-14 08:37:24 +00:00
forgefed fix review 2024-05-29 18:31:06 +02:00
generate Port "Use general token signing secret" 2024-02-19 20:49:37 +01:00
git fix(hook): ignore unknown push options instead of failing 2024-07-02 20:18:33 +00:00
gitgraph Add codespell support and fix a good number of typos with its help (#3270) 2024-05-09 13:49:37 +00:00
gitrepo Move get/set default branch from git package to gitrepo package to hide repopath (#29126) 2024-03-11 23:36:59 +07:00
graceful [FIX] make pprof labels conformant with prometheus spec 2024-03-31 17:07:14 +02:00
hcaptcha Consume hcaptcha and pwn deps (#22610) 2023-01-29 09:49:51 -06:00
highlight Fix 2024-03-30 15:23:48 +01:00
hostmatcher Support allowed hosts for webhook to work with proxy (#27655) 2023-10-18 09:44:36 +00:00
html Refactor backend SVG package and add tests (#26335) 2023-08-05 04:34:59 +00:00
httpcache [BRANDING] add X-Forgejo-* headers 2024-02-05 16:02:14 +01:00
httplib Skip gzip for some well-known compressed file types (#30796) 2024-05-05 12:15:40 +01:00
indexer Fix bug filtering issues which have no project (#31337) 2024-06-16 13:42:59 +02:00
issue/template Support setting the default attribute of the issue template dropdown field (#31045) 2024-05-26 20:13:09 +02:00
json Replace interface{} with any (#25686) 2023-07-04 18:36:08 +00:00
label Make label templates have consistent behavior and priority (#23749) 2023-04-10 16:44:02 +08:00
lfs Support legacy _links LFS batch responses (#31513) 2024-07-02 09:02:33 +00:00
log Add codespell support and fix a good number of typos with its help (#3270) 2024-05-09 13:49:37 +00:00
markup Fix markdown math brackets render problem (#31420) 2024-06-23 12:40:06 +02:00
mcaptcha Implement FSFE REUSE for golang files (#21840) 2022-11-27 18:20:29 +00:00
metrics Rename project board -> column to make the UI less confusing (#30170) 2024-06-02 09:42:39 +02:00
migration Refactor locale&string&template related code (#29165) 2024-02-16 15:20:52 +01:00
nosql s/Gitea/Forgejo in various log messages and comments 2024-04-21 21:26:15 +05:00
optional Resolve lint for unused parameter and unnecessary type arguments (#30750) 2024-05-05 08:38:16 +01:00
options Use a general approach to access custom/static/builtin assets (#24022) 2023-04-12 18:16:45 +08:00
packages Extract and display readme and comments for Composer packages (#30927) 2024-06-16 13:42:59 +02:00
paginator Use more specific test methods (#24265) 2023-04-22 17:56:27 -04:00
pprof Implement FSFE REUSE for golang files (#21840) 2022-11-27 18:20:29 +00:00
private fix(hook): ignore unknown push options instead of failing 2024-07-02 20:18:33 +00:00
process Add codespell support and fix a good number of typos with its help (#3270) 2024-05-09 13:49:37 +00:00
proxy Use proxy for pull mirror (#22771) 2023-02-11 08:39:50 +08:00
proxyprotocol Implement FSFE REUSE for golang files (#21840) 2022-11-27 18:20:29 +00:00
public Refactor CORS handler (#28587) 2023-12-25 20:13:18 +08:00
queue chore(deps): update module github.com/redis/go-redis/v9 to v9.5.2 2024-06-04 12:38:35 +02:00
recaptcha Implement FSFE REUSE for golang files (#21840) 2022-11-27 18:20:29 +00:00
references Refactor to use UnsafeStringToBytes (#31358) 2024-06-16 13:42:58 +02:00
regexplru Upgrade go dependencies (#25819) 2023-07-14 11:00:31 +08:00
repository fix(repository): git push to an adopted repository fails 2024-06-16 19:06:06 +02:00
secret [GITEA] Drop sha256-simd in favor of stdlib 2024-02-05 16:09:40 +01:00
session Avoid importing modules/web/middleware in modules/session (#30584) 2024-04-21 16:28:16 +02:00
setting Add support for workflow_dispatch (#3334) 2024-06-28 05:17:11 +00:00
sitemap Fix sitemap (#22272) 2022-12-30 23:31:00 +08:00
ssh Remove SSH workaround (#27893) 2023-11-03 15:21:05 +00:00
storage test(avatar): deleting a user avatar is idempotent 2024-06-05 09:10:42 +02:00
structs Add support for workflow_dispatch (#3334) 2024-06-28 05:17:11 +00:00
svg Refactor backend SVG package and add tests (#26335) 2023-08-05 04:34:59 +00:00
sync Implement FSFE REUSE for golang files (#21840) 2022-11-27 18:20:29 +00:00
system Refactor to use UnsafeStringToBytes (#31358) 2024-06-16 13:42:58 +02:00
templates Add slogan config (#3752) 2024-06-07 17:12:48 +00:00
test test(util): MockProtect when mocking multiple times 2024-06-02 15:24:06 +02:00
testlogger Add codespell support and fix a good number of typos with its help (#3270) 2024-05-09 13:49:37 +00:00
timeutil Remove the time-since class (#29826) 2024-03-20 08:46:30 +01:00
translation Rename ByteSize to ReadableSize 2024-03-31 20:17:12 +05:00
turnstile Add new captcha: cloudflare turnstile (#22369) 2023-02-05 15:29:03 +08:00
typesniffer Add codespell support and fix a good number of typos with its help (#3270) 2024-05-09 13:49:37 +00:00
updatechecker [PRIVACY] Add a DNS method to fetch new updates 2024-02-05 15:38:36 +01:00
uri Implement FSFE REUSE for golang files (#21840) 2022-11-27 18:20:29 +00:00
user Implement FSFE REUSE for golang files (#21840) 2022-11-27 18:20:29 +00:00
util Refactor to use UnsafeStringToBytes (#31358) 2024-06-16 13:42:58 +02:00
validation added validation fixes 2024-05-14 08:31:34 +02:00
web Delete legacy cookie before setting new cookie (#31306) 2024-06-16 08:21:32 +02:00
webhook Add support for workflow_dispatch (#3334) 2024-06-28 05:17:11 +00:00