sameersbn / sameersbn/docker-gitlab

gitlab not working after setting GITLAB_CONTENT_SECURITY_POLICY_DIRECTIVES_CONNECT_SRC

Open
#2,401 1 comment 4 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Shell
Stars
8.1k
Forks
2.1k
Avg merge
17h 47m
Merged PRs (30d)
7

Description

After setting GITLAB_CONTENT_SECURITY_POLICY_DIRECTIVES_CONNECT_SRC, gitlab cannot start.

- GITLAB_CONTENT_SECURITY_POLICY_ENABLED=true
- GITLAB_CONTENT_SECURITY_POLICY_DIRECTIVES_CONNECT_SRC="'self'"
# tried with default value
# - GITLAB_CONTENT_SECURITY_POLICY_DIRECTIVES_CONNECT_SRC="'self' http://localhost:* ws://localhost:* wss://localhost:*"
# tried with custom domain
# - GITLAB_CONTENT_SECURITY_POLICY_DIRECTIVES_CONNECT_SRC="'self' http://example.com"

There's some log in Puma output:

==> supervisor/puma.log <==
{"timestamp":"2021-08-18T10:08:39.740Z","pid":985,"message":"! Unable to load application: Psych::SyntaxError: (\u003cunknown\u003e): did not find expected key while parsing a block mapping at line 59 column 9"}
/usr/lib/ruby/2.7.0/psych.rb:456:in `parse': (<unknown>): did not find expected key while parsing a block mapping at line 59 column 9 (Psych::SyntaxError)
        from /usr/lib/ruby/2.7.0/psych.rb:456:in `parse_stream'
        from /usr/lib/ruby/2.7.0/psych.rb:390:in `parse'
        from /usr/lib/ruby/2.7.0/psych.rb:277:in `load'
        from /home/git/gitlab/vendor/bundle/ruby/2.7.0/gems/settingslogic-2.0.9/lib/settingslogic.rb:103:in `initialize'
        from /home/git/gitlab/vendor/bundle/ruby/2.7.0/gems/settingslogic-2.0.9/lib/settingslogic.rb:60:in `new'
        from /home/git/gitlab/vendor/bundle/ruby/2.7.0/gems/settingslogic-2.0.9/lib/settingslogic.rb:60:in `instance'
        from /home/git/gitlab/vendor/bundle/ruby/2.7.0/gems/settingslogic-2.0.9/lib/settingslogic.rb:37:in `[]'
        from /home/git/gitlab/config/initializers/1_settings.rb:8:in `<top (required)>'
        from /home/git/gitlab/vendor/bundle/ruby/2.7.0/gems/activesupport-6.1.3.2/lib/active_support/dependencies.rb:326:in `load'
        from /home/git/gitlab/vendor/bundle/ruby/2.7.0/gems/activesupport-6.1.3.2/lib/active_support/dependencies.rb:326:in `block in load'
        from /home/git/gitlab/vendor/bundle/ruby/2.7.0/gems/activesupport-6.1.3.2/lib/active_support/dependencies.rb:299:in `load_dependency'
        from /home/git/gitlab/vendor/bundle/ruby/2.7.0/gems/activesupport-6.1.3.2/lib/active_support/dependencies.rb:326:in `load'
        from /home/git/gitlab/vendor/bundle/ruby/2.7.0/gems/railties-6.1.3.2/lib/rails/engine.rb:681:in `block in load_config_initializer'
        from /home/git/gitlab/vendor/bundle/ruby/2.7.0/gems/activesupport-6.1.3.2/lib/active_support/notifications.rb:205:in `instrument'
        from /home/git/gitlab/vendor/bundle/ruby/2.7.0/gems/railties-6.1.3.2/lib/rails/engine.rb:680:in `load_config_initializer'
        from /home/git/gitlab/vendor/bundle/ruby/2.7.0/gems/railties-6.1.3.2/lib/rails/engine.rb:634:in `block (2 levels) in <class:Engine>'
        from /home/git/gitlab/vendor/bundle/ruby/2.7.0/gems/railties-6.1.3.2/lib/rails/engine.rb:633:in `each'
        from /home/git/gitlab/vendor/bundle/ruby/2.7.0/gems/railties-6.1.3.2/lib/rails/engine.rb:633:in `block in <class:Engine>'
        from /home/git/gitlab/vendor/bundle/ruby/2.7.0/gems/railties-6.1.3.2/lib/rails/initializable.rb:32:in `instance_exec'
        from /home/git/gitlab/vendor/bundle/ruby/2.7.0/gems/railties-6.1.3.2/lib/rails/initializable.rb:32:in `run'
        from /home/git/gitlab/vendor/bundle/ruby/2.7.0/gems/railties-6.1.3.2/lib/rails/initializable.rb:61:in `block in run_initializers'
        from /usr/lib/ruby/2.7.0/tsort.rb:228:in `block in tsort_each'
        from /usr/lib/ruby/2.7.0/tsort.rb:350:in `block (2 levels) in each_strongly_connected_component'
        from /usr/lib/ruby/2.7.0/tsort.rb:422:in `block (2 levels) in each_strongly_connected_component_from'
        from /usr/lib/ruby/2.7.0/tsort.rb:431:in `each_strongly_connected_component_from'
        from /usr/lib/ruby/2.7.0/tsort.rb:421:in `block in each_strongly_connected_component_from'
        from /home/git/gitlab/vendor/bundle/ruby/2.7.0/gems/railties-6.1.3.2/lib/rails/initializable.rb:50:in `each'
        from /home/git/gitlab/vendor/bundle/ruby/2.7.0/gems/railties-6.1.3.2/lib/rails/initializable.rb:50:in `tsort_each_child'
        from /usr/lib/ruby/2.7.0/tsort.rb:415:in `call'
        from /usr/lib/ruby/2.7.0/tsort.rb:415:in `each_strongly_connected_component_from'
        from /usr/lib/ruby/2.7.0/tsort.rb:349:in `block in each_strongly_connected_component'
        from /usr/lib/ruby/2.7.0/tsort.rb:347:in `each'
        from /usr/lib/ruby/2.7.0/tsort.rb:347:in `call'
        from /usr/lib/ruby/2.7.0/tsort.rb:347:in `each_strongly_connected_component'
        from /usr/lib/ruby/2.7.0/tsort.rb:226:in `tsort_each'
        from /usr/lib/ruby/2.7.0/tsort.rb:205:in `tsort_each'
        from /home/git/gitlab/vendor/bundle/ruby/2.7.0/gems/railties-6.1.3.2/lib/rails/initializable.rb:60:in `run_initializers'
        from /home/git/gitlab/vendor/bundle/ruby/2.7.0/gems/railties-6.1.3.2/lib/rails/application.rb:384:in `initialize!'
        from /home/git/gitlab/config/environment.rb:7:in `<top (required)>'
        from config.ru:5:in `require'
        from config.ru:5:in `block in <main>'
        from /home/git/gitlab/vendor/bundle/ruby/2.7.0/gems/rack-2.2.3/lib/rack/builder.rb:116:in `eval'
        from /home/git/gitlab/vendor/bundle/ruby/2.7.0/gems/rack-2.2.3/lib/rack/builder.rb:116:in `new_from_string'
        from /home/git/gitlab/vendor/bundle/ruby/2.7.0/gems/rack-2.2.3/lib/rack/builder.rb:105:in `load_file'
        from /home/git/gitlab/vendor/bundle/ruby/2.7.0/gems/rack-2.2.3/lib/rack/builder.rb:66:in `parse_file'
        from /home/git/gitlab/vendor/bundle/ruby/2.7.0/gems/puma-5.3.2/lib/puma/configuration.rb:345:in `load_rackup'
        from /home/git/gitlab/vendor/bundle/ruby/2.7.0/gems/puma-5.3.2/lib/puma/configuration.rb:267:in `app'
        from /home/git/gitlab/vendor/bundle/ruby/2.7.0/gems/puma-5.3.2/lib/puma/runner.rb:143:in `load_and_bind'
        from /home/git/gitlab/vendor/bundle/ruby/2.7.0/gems/puma-5.3.2/lib/puma/cluster.rb:349:in `run'
        from /home/git/gitlab/vendor/bundle/ruby/2.7.0/gems/puma-5.3.2/lib/puma/launcher.rb:181:in `run'
        from /home/git/gitlab/vendor/bundle/ruby/2.7.0/gems/puma-5.3.2/lib/puma/cli.rb:80:in `run'
        from /home/git/gitlab/vendor/bundle/ruby/2.7.0/gems/puma-5.3.2/bin/puma:10:in `<top (required)>'
        from /home/git/gitlab/vendor/bundle/ruby/2.7.0/bin/puma:23:in `load'
        from /home/git/gitlab/vendor/bundle/ruby/2.7.0/bin/puma:23:in `<main>'

It seems there's some parsing error after GITLAB_CONTENT_SECURITY_POLICY_DIRECTIVES_CONNECT_SRC is set, anyway how to fix it or did I set GITLAB_CONTENT_SECURITY_POLICY_DIRECTIVES_CONNECT_SRC the wrong format?

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at config/initializers/1_settings.rb and the supervisor/puma.log Psych::SyntaxError, then trace startup through config.ru and the SettingsLogic load shown in the stack trace. Reproduce the failure with GITLAB_CONTENT_SECURITY_POLICY_DIRECTIVES_CONNECT_SRC set to the documented examples; done means GitLab starts successfully with the variable configured.

Written by the indexing model from the issue text.

Assessment

Tech stack
docker, gitlab, ruby
Domain
devops, infrastructure
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.