Exception: Gitlab::Git::PreReceiveError
- Inherits:
-
StandardError
- Object
- StandardError
- Gitlab::Git::PreReceiveError
- Defined in:
- lib/gitlab/git/pre_receive_error.rb
Overview
PreReceiveError is special because its message gets displayed to users in the web UI. Because of this, we:
-
Only display errors that have been marked as safe with a prefix. This is to prevent leaking of stacktraces, or other sensitive info.
-
Sanitize the string of any XSS
Constant Summary collapse
- SAFE_MESSAGE_PREFIXES =
[ 'GitLab:', # Messages from gitlab-shell 'GL-HOOK-ERR:' # Messages marked as safe by user ].freeze
- SAFE_MESSAGE_REGEX =
/^(#{SAFE_MESSAGE_PREFIXES.join('|')})\s*(?<safe_message>.+)/
Instance Attribute Summary collapse
-
#raw_message ⇒ Object
readonly
Returns the value of attribute raw_message.
Instance Method Summary collapse
-
#initialize(message = '', fallback_message: '') ⇒ PreReceiveError
constructor
A new instance of PreReceiveError.
Constructor Details
#initialize(message = '', fallback_message: '') ⇒ PreReceiveError
Returns a new instance of PreReceiveError.
21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/gitlab/git/pre_receive_error.rb', line 21 def initialize( = '', fallback_message: '') @raw_message = sanitized_msg = sanitize() if sanitized_msg.present? super(sanitized_msg) else super() end end |
Instance Attribute Details
#raw_message ⇒ Object (readonly)
Returns the value of attribute raw_message.
19 20 21 |
# File 'lib/gitlab/git/pre_receive_error.rb', line 19 def @raw_message end |