Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
56b837de
Commit
56b837de
authored
May 13, 2021
by
Alex Kalderimis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Prevent smallint overflow in webhook.recent_failures
Changelog: fixed
parent
0e31fbc2
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
21 additions
and
1 deletion
+21
-1
app/services/web_hook_service.rb
app/services/web_hook_service.rb
+2
-1
spec/services/web_hook_service_spec.rb
spec/services/web_hook_service_spec.rb
+19
-0
No files found.
app/services/web_hook_service.rb
View file @
56b837de
...
...
@@ -27,6 +27,7 @@ class WebHookService
REQUEST_BODY_SIZE_LIMIT
=
25
.
megabytes
GITLAB_EVENT_HEADER
=
'X-Gitlab-Event'
MAX_FAILURES
=
100
attr_accessor
:hook
,
:data
,
:hook_name
,
:request_options
...
...
@@ -141,7 +142,7 @@ class WebHookService
next_backoff
=
hook
.
next_backoff
hook
.
update!
(
disabled_until:
next_backoff
.
from_now
,
backoff_count:
hook
.
backoff_count
+
1
)
else
hook
.
update!
(
recent_failures:
hook
.
recent_failures
+
1
)
hook
.
update!
(
recent_failures:
hook
.
recent_failures
+
1
)
if
hook
.
recent_failures
<
MAX_FAILURES
end
end
...
...
spec/services/web_hook_service_spec.rb
View file @
56b837de
...
...
@@ -240,6 +240,25 @@ RSpec.describe WebHookService do
it
'does not change the disabled_until attribute'
do
expect
{
service_instance
.
execute
}.
not_to
change
(
project_hook
,
:disabled_until
)
end
it
'does not allow the failure count to overflow'
do
project_hook
.
update!
(
recent_failures:
32767
)
expect
{
service_instance
.
execute
}.
not_to
change
(
project_hook
,
:recent_failures
)
end
context
'when the web_hooks_disable_failed FF is disabled'
do
before
do
# Hook will only be executed if the flag is disabled.
stub_feature_flags
(
web_hooks_disable_failed:
false
)
end
it
'does not allow the failure count to overflow'
do
project_hook
.
update!
(
recent_failures:
32767
)
expect
{
service_instance
.
execute
}.
not_to
change
(
project_hook
,
:recent_failures
)
end
end
end
context
'with exception'
do
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment