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
1c9105e2
Commit
1c9105e2
authored
May 05, 2020
by
charlieablett
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add allowlisted method to SpamActionService
parent
2114a94f
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
22 additions
and
0 deletions
+22
-0
app/services/spam/spam_action_service.rb
app/services/spam/spam_action_service.rb
+5
-0
changelogs/unreleased/212213-cablett-allowlist-gitlab-team-member.yml
...nreleased/212213-cablett-allowlist-gitlab-team-member.yml
+5
-0
spec/services/spam/spam_action_service_spec.rb
spec/services/spam/spam_action_service_spec.rb
+12
-0
No files found.
app/services/spam/spam_action_service.rb
View file @
1c9105e2
...
...
@@ -28,6 +28,7 @@ module Spam
# update the spam log accordingly.
SpamLog
.
verify_recaptcha!
(
user_id:
user
.
id
,
id:
spam_log_id
)
else
return
if
allowlisted?
(
user
)
return
unless
request
return
unless
check_for_spam?
...
...
@@ -39,6 +40,10 @@ module Spam
private
def
allowlisted?
(
user
)
user
.
respond_to?
(
:gitlab_employee
)
&&
user
.
gitlab_employee?
end
def
perform_spam_service_check
(
api
)
# since we can check for spam, and recaptcha is not verified,
# ask the SpamVerdictService what to do with the target.
...
...
changelogs/unreleased/212213-cablett-allowlist-gitlab-team-member.yml
0 → 100644
View file @
1c9105e2
---
title
:
Skip spam check for GitLab team members on gitlab.com
merge_request
:
31052
author
:
type
:
added
spec/services/spam/spam_action_service_spec.rb
View file @
1c9105e2
...
...
@@ -73,11 +73,13 @@ describe Spam::SpamActionService do
describe
'#execute'
do
let
(
:request
)
{
double
(
:request
,
env:
env
)
}
let
(
:fake_verdict_service
)
{
double
(
:spam_verdict_service
)
}
let
(
:allowlisted
)
{
false
}
let_it_be
(
:existing_spam_log
)
{
create
(
:spam_log
,
user:
user
,
recaptcha_verified:
false
)
}
subject
do
described_service
=
described_class
.
new
(
spammable:
issue
,
request:
request
)
allow
(
described_service
).
to
receive
(
:allowlisted?
).
and_return
(
allowlisted
)
described_service
.
execute
(
user:
user
,
api:
nil
,
recaptcha_verified:
recaptcha_verified
,
spam_log_id:
existing_spam_log
.
id
)
end
...
...
@@ -121,6 +123,16 @@ describe Spam::SpamActionService do
issue
.
description
=
'SPAM!'
end
context
'if allowlisted'
do
let
(
:allowlisted
)
{
true
}
it
'does not perform spam check'
do
expect
(
Spam
::
SpamVerdictService
).
not_to
receive
(
:new
)
subject
end
end
context
'when disallowed by the spam verdict service'
do
before
do
allow
(
fake_verdict_service
).
to
receive
(
:execute
).
and_return
(
DISALLOW
)
...
...
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