BigW Consortium Gitlab
Accept environment variables from the `pre-receive` script ## Summary 1. Starting version 2.11, git changed the way the pre-receive flow works. - Previously, the new potential objects would be added to the main repo. If the pre-receive passes, the new objects stay in the repo but are linked up. If the pre-receive fails, the new objects stay orphaned in the repo, and are cleaned up during the next `git gc`. - In 2.11, the new potential objects are added to a temporary "alternate object directory", that git creates for this purpose. If the pre-receive passes, the objects from the alternate object directory are migrated to the main repo. If the pre-receive fails the alternate object directory is simply deleted. 2. In our workflow, the pre-recieve script (in `gitlab-shell`) calls the `/allowed` endpoint, which calls out directly to git to perform various checks. These direct calls to git do _not_ have the necessary environment variables set which allow access to the "alternate object directory" (explained above). Therefore these calls to git are not able to access any of the new potential objects to be added during this push. 3. We fix this by accepting the relevant environment variables (`GIT_ALTERNATE_OBJECT_DIRECTORIES`, `GIT_OBJECT_DIRECTORY`, and `GIT_QUARANTINE_PATH`) on the `/allowed` endpoint, and then include these environment variables while calling out to git. 4. This commit includes these environment variables while making the "force push" check. ## Issue Numbers - Closes #25301 (assuming the corresponding `gitlab-shell` MR has been merged in first) - Corresponding `gitlab-shell` MR: gitlab-org/gitlab-shell!112 - Corresponding EE MR: gitlab-org/gitlab-ee!964 ## Tasks - [#25301/!7967/!112] Git version 2.11.0 - Can't push to protected branch as master or developer - [x] Investigate - [x] Implementation - [x] `force_push.rb` should use the relevant environment variables - [x] Any other instances of `/allowed` calling out to git directly? - [x] Verify that the fix works over SSH as well - [x] Can we trim the number of env variables? Do we need all 3? - [x] Whitelist variables. Server shouldn't pass through _any_ env variable passed in - [x] Any security implications? - [x] Check for force push return code - [x] Shouldn't be able to opt-out from the force push check by passing an env variable - [x] Tests - [x] CE - [x] Added - [x] Passing - [x] Shell - [x] Added - [x] Passing - [x] Meta - [x] CHANGELOG entry created - [x] Branch has no merge conflicts with `master` - [x] Squashed related commits together - [x] EE merge request - [x] Review - [x] Endboss - [ ] Follow-up - [x] Make sure EE is working as expected - [x] [CE] Gitlab changes without gitlab-shell changes shouldn't raise any exceptions - [x] [CE] Gitlab-shell changes without gitlab changes shouldn't raise any exceptions - [x] [EE] Gitlab changes without gitlab-shell changes shouldn't raise any exceptions - [x] [EE] Gitlab-shell changes without gitlab changes shouldn't raise any exceptions - [ ] Wait for merge - [ ] CE - [ ] EE - [x] Shell See merge request !7967
Name |
Last commit
|
Last update |
---|---|---|
.. | ||
auth | Loading commit data... | |
backend | Loading commit data... | |
badge | Loading commit data... | |
bitbucket_import | Loading commit data... | |
chat_commands | Loading commit data... | |
checks | Loading commit data... | |
ci | Loading commit data... | |
conflict | Loading commit data... | |
cycle_analytics | Loading commit data... | |
data_builder | Loading commit data... | |
database | Loading commit data... | |
diff | Loading commit data... | |
downtime_check | Loading commit data... | |
Loading commit data... | ||
fogbugz_import | Loading commit data... | |
gfm | Loading commit data... | |
git | Loading commit data... | |
github_import | Loading commit data... | |
gitlab_import | Loading commit data... | |
google_code_import | Loading commit data... | |
graphs | Loading commit data... | |
import_export | Loading commit data... | |
ldap | Loading commit data... | |
markdown | Loading commit data... | |
metrics | Loading commit data... | |
middleware | Loading commit data... | |
o_auth | Loading commit data... | |
request_profiler | Loading commit data... | |
saml | Loading commit data... | |
sanitizers | Loading commit data... | |
sherlock | Loading commit data... | |
sidekiq_middleware | Loading commit data... | |
slash_commands | Loading commit data... | |
sql | Loading commit data... | |
template | Loading commit data... | |
access.rb | Loading commit data... | |
allowable.rb | Loading commit data... | |
app_logger.rb | Loading commit data... | |
asciidoc.rb | Loading commit data... | |
auth.rb | Loading commit data... | |
award_emoji.rb | Loading commit data... | |
blame.rb | Loading commit data... | |
changes_list.rb | Loading commit data... | |
chat_name_token.rb | Loading commit data... | |
closing_issue_extractor.rb | Loading commit data... | |
color_schemes.rb | Loading commit data... | |
config_helper.rb | Loading commit data... | |
contributions_calendar.rb | Loading commit data... | |
contributor.rb | Loading commit data... | |
current_settings.rb | Loading commit data... | |
database.rb | Loading commit data... | |
devise_failure.rb | Loading commit data... | |
downtime_check.rb | Loading commit data... | |
ee_compat_check.rb | Loading commit data... | |
emoji.rb | Loading commit data... | |
environment_logger.rb | Loading commit data... | |
exclusive_lease.rb | Loading commit data... | |
file_detector.rb | Loading commit data... | |
git.rb | Loading commit data... | |
git_access.rb | Loading commit data... | |
git_access_status.rb | Loading commit data... | |
git_access_wiki.rb | Loading commit data... | |
git_logger.rb | Loading commit data... | |
git_post_receive.rb | Loading commit data... | |
git_ref_validator.rb | Loading commit data... | |
gl_id.rb | Loading commit data... | |
gon_helper.rb | Loading commit data... | |
highlight.rb | Loading commit data... | |
identifier.rb | Loading commit data... | |
import_export.rb | Loading commit data... | |
import_formatter.rb | Loading commit data... | |
import_sources.rb | Loading commit data... | |
incoming_email.rb | Loading commit data... | |
issues_labels.rb | Loading commit data... | |
key_fingerprint.rb | Loading commit data... | |
lazy.rb | Loading commit data... | |
lfs_token.rb | Loading commit data... | |
logger.rb | Loading commit data... | |
mail_room.rb | Loading commit data... | |
markup_helper.rb | Loading commit data... | |
metrics.rb | Loading commit data... | |
optimistic_locking.rb | Loading commit data... | |
other_markup.rb | Loading commit data... | |
popen.rb | Loading commit data... | |
project_search_results.rb | Loading commit data... | |
protocol_access.rb | Loading commit data... | |
recaptcha.rb | Loading commit data... | |
redis.rb | Loading commit data... | |
reference_extractor.rb | Loading commit data... | |
regex.rb | Loading commit data... | |
repository_check_logger.rb | Loading commit data... | |
request_profiler.rb | Loading commit data... | |
routing.rb | Loading commit data... | |
search_results.rb | Loading commit data... | |
seeder.rb | Loading commit data... | |
sentry.rb | Loading commit data... | |
sherlock.rb | Loading commit data... | |
sidekiq_logger.rb | Loading commit data... | |
sidekiq_throttler.rb | Loading commit data... | |
snippet_search_results.rb | Loading commit data... | |
themes.rb | Loading commit data... | |
timeless.rb | Loading commit data... | |
upgrader.rb | Loading commit data... | |
uploads_transfer.rb | Loading commit data... | |
url_builder.rb | Loading commit data... | |
url_sanitizer.rb | Loading commit data... | |
user_access.rb | Loading commit data... | |
utils.rb | Loading commit data... | |
version_info.rb | Loading commit data... | |
visibility_level.rb | Loading commit data... | |
workhorse.rb | Loading commit data... |