Skip to content
Projects
Groups
Snippets
Help
Sign in / Register
Toggle navigation
Minds Backend - Engine
Project overview
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Locked Files
Issues
281
Merge Requests
38
CI / CD
Security & Compliance
Packages
Wiki
Snippets
Members
Collapse sidebar
Close sidebar
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Minds
Minds Backend - Engine
Commits
cf1ddd5e
Commit
cf1ddd5e
authored
35 minutes ago
by
Mark Harding
Browse files
Options
Download
(chore): use a const instead of var
parent
ae68fa35
fix/spam-detection-return-1104
1 merge request
!391
[Sprint/RollingRabbit](fix): Updated returned exception of offending spam link. #1104
Pipeline
#98602648
failed with stages
in 2 minutes and 36 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
16 additions
and
38 deletions
+16
-38
Core/Security/ProhibitedDomains.php
View file @
cf1ddd5e
...
...
@@ -3,29 +3,13 @@
namespace
Minds\Core\Security
;
/**
*
@author Ben
*
@desc holds the list of prohibited domain
s.
*
Domains listed here has been blacklisted due to spam.
*
Short urls are also not allowed due to security issue
s.
*/
class
ProhibitedDomains
{
public
function
__construct
()
{
}
/**
* getter for prohibitedDomains
*
* @return array an array of prohibited domains.
*/
public
function
get
()
:
array
{
return
$this
->
prohibitedDomains
;
}
private
$prohibitedDomains
=
[
//shorts
// 't.co', 'goo.gl', 'ow.ly', 'bitly.com', 'bit.ly','tinyurl.com','bit.do','go2.do',
// 'adf.ly', 'adcrun.ch', 'zpag.es','ity.im', 'q.gs', 'lnk.co', 'is.gd',
//full
/** @var array */
const
DOMAINS
=
[
'movieblog.tumblr.com'
,
'moviehdstream.wordpress.com'
,
'moviehq.tumblr.com'
,
...
...
@@ -263,7 +247,6 @@ class ProhibitedDomains
'samuelsconstruction.build'
,
'pmwares.com'
,
'watchesofwales.co.uk'
,
//'.ru',
'zotero.org'
,
'speakerdeck.com'
,
'freesiteslike.com'
,
...
...
This diff is collapsed.
Core/Security/Spam.php
View file @
cf1ddd5e
...
...
@@ -8,39 +8,34 @@ use Minds\Core\Security\ProhibitedDomains;
class
Spam
{
/** @var ProhibitedDomains $prohibitedDomains */
protected
$prohibitedDomains
;
public
function
__construct
(
$prohibitedDomains
=
null
)
{
$this
->
prohibitedDomains
=
$prohibitedDomains
??
new
ProhibitedDomains
();
}
public
function
check
(
$entity
)
/**
* Check for spam
* @param mixed $entity
* @return bool
*/
public
function
check
(
$entity
)
:
bool
{
$prohibitedDomains
=
$this
->
prohibitedDomains
->
get
();
$foundSpam
=
false
;
switch
(
$entity
->
getType
())
{
case
'comment'
:
$foundSpam
=
Text
::
strposa
(
$entity
->
getBody
(),
$prohibitedDomains
);
$foundSpam
=
Text
::
strposa
(
$entity
->
getBody
(),
ProhibitedDomains
::
DOMAINS
);
break
;
case
'activity'
:
$foundSpam
=
Text
::
strposa
(
$entity
->
getMessage
(),
$prohibitedDomains
);
$foundSpam
=
Text
::
strposa
(
$entity
->
getMessage
(),
ProhibitedDomains
::
DOMAINS
);
break
;
case
'object'
:
if
(
$entity
->
getSubtype
()
===
'blog'
)
{
$foundSpam
=
Text
::
strposa
(
$entity
->
getBody
(),
$prohibitedDomains
);
$foundSpam
=
Text
::
strposa
(
$entity
->
getBody
(),
ProhibitedDomains
::
DOMAINS
);
break
;
}
$foundSpam
=
Text
::
strposa
(
$entity
->
getDescription
(),
$prohibitedDomains
);
$foundSpam
=
Text
::
strposa
(
$entity
->
getDescription
(),
ProhibitedDomains
::
DOMAINS
);
break
;
case
'user'
:
$foundSpam
=
Text
::
strposa
(
$entity
->
briefdescription
,
$prohibitedDomains
);
$foundSpam
=
Text
::
strposa
(
$entity
->
briefdescription
,
ProhibitedDomains
::
DOMAINS
);
break
;
case
'group'
:
$foundSpam
=
Text
::
strposa
(
$entity
->
getBriefDescription
(),
$prohibitedDomains
);
$foundSpam
=
Text
::
strposa
(
$entity
->
getBriefDescription
(),
ProhibitedDomains
::
DOMAINS
);
break
;
default
:
error_log
(
"[spam-check]:
$entity->type
:
$entity->subtype
not supported"
);
...
...
This diff is collapsed.
Please
register
or
sign in
to comment