feat: report sus per monthly active user
parent
4227f163a4
commit
5f8e3e558b
|
@ -16,8 +16,8 @@ class Models:
|
||||||
'total_users': fields.Integer(description="The total amount of users registered in that instance"),
|
'total_users': fields.Integer(description="The total amount of users registered in that instance"),
|
||||||
'active_users_monthly': fields.Integer(description="The amount of active users monthly."),
|
'active_users_monthly': fields.Integer(description="The amount of active users monthly."),
|
||||||
'signup': fields.Boolean(default=False,description="True when subscriptions are open, else False"),
|
'signup': fields.Boolean(default=False,description="True when subscriptions are open, else False"),
|
||||||
'activity_suspicion': fields.Float(description="Local Comments+Posts per User. Higher is worse"),
|
'activity_suspicion': fields.Float(description="Local Comments+Posts per user. Higher is worse"),
|
||||||
'activity_suspicion': fields.Float(description="Local Comments+Posts per User. Higher is worse"),
|
'active_users_suspicion': fields.Float(description="Monthly active users per user. Higher is worse"),
|
||||||
})
|
})
|
||||||
self.response_model_model_Suspicions_get = api.model('SuspiciousInstances', {
|
self.response_model_model_Suspicions_get = api.model('SuspiciousInstances', {
|
||||||
'instances': fields.List(fields.Nested(self.response_model_suspicious_instances)),
|
'instances': fields.List(fields.Nested(self.response_model_suspicious_instances)),
|
||||||
|
@ -40,9 +40,3 @@ class Models:
|
||||||
'domains': fields.List(fields.String(description="The instance domains as a list.")),
|
'domains': fields.List(fields.String(description="The instance domains as a list.")),
|
||||||
'csv': fields.String(description="The instance domains as a csv."),
|
'csv': fields.String(description="The instance domains as a csv."),
|
||||||
})
|
})
|
||||||
self.response_model_model_Suspicions_get = api.model('SuspiciousInstances', {
|
|
||||||
'self': fields.Nested(self.response_model_instances),
|
|
||||||
'guaranteed': fields.List(fields.Nested(self.response_model_instances)),
|
|
||||||
'endorsed': fields.List(fields.String(description="The suspicious domains as a list.")),
|
|
||||||
'endorsing': fields.String(description="The suspicious domains as a csv."),
|
|
||||||
})
|
|
||||||
|
|
|
@ -34,6 +34,7 @@ class Suspicions(Resource):
|
||||||
get_parser = reqparse.RequestParser()
|
get_parser = reqparse.RequestParser()
|
||||||
get_parser.add_argument("Client-Agent", default="unknown:0:unknown", type=str, required=False, help="The client name and version.", location="headers")
|
get_parser.add_argument("Client-Agent", default="unknown:0:unknown", type=str, required=False, help="The client name and version.", location="headers")
|
||||||
get_parser.add_argument("activity_suspicion", required=False, default=20, type=int, help="How many users per local post+comment to consider suspicious", location="args")
|
get_parser.add_argument("activity_suspicion", required=False, default=20, type=int, help="How many users per local post+comment to consider suspicious", location="args")
|
||||||
|
get_parser.add_argument("active_suspicion", required=False, default=500, type=int, help="How many users per active users to consider suspicious", location="args")
|
||||||
get_parser.add_argument("csv", required=False, type=bool, help="Set to true to return just the domains as a csv. Mutually exclusive with domains", location="args")
|
get_parser.add_argument("csv", required=False, type=bool, help="Set to true to return just the domains as a csv. Mutually exclusive with domains", location="args")
|
||||||
get_parser.add_argument("domains", required=False, type=bool, help="Set to true to return just the domains as a list. Mutually exclusive with csv", location="args")
|
get_parser.add_argument("domains", required=False, type=bool, help="Set to true to return just the domains as a list. Mutually exclusive with csv", location="args")
|
||||||
|
|
||||||
|
@ -45,7 +46,7 @@ class Suspicions(Resource):
|
||||||
'''A List with the details of all suspicious instances
|
'''A List with the details of all suspicious instances
|
||||||
'''
|
'''
|
||||||
self.args = self.get_parser.parse_args()
|
self.args = self.get_parser.parse_args()
|
||||||
sus_instances = retrieve_suspicious_instances(self.args.activity_suspicion)
|
sus_instances = retrieve_suspicious_instances(self.args.activity_suspicion, self.args.active_suspicion)
|
||||||
if self.args.csv:
|
if self.args.csv:
|
||||||
return {"csv": ",".join([instance["domain"] for instance in sus_instances])},200
|
return {"csv": ",".join([instance["domain"] for instance in sus_instances])},200
|
||||||
if self.args.domains:
|
if self.args.domains:
|
||||||
|
|
|
@ -69,7 +69,11 @@ def retrieve_suspicious_instances(activity_suspicion = 20, active_suspicious = 5
|
||||||
# print(node)
|
# print(node)
|
||||||
|
|
||||||
# check active users (monthly is a lot lower than total users)
|
# check active users (monthly is a lot lower than total users)
|
||||||
if node["total_users"] / node["active_users_monthly"] > active_suspicious:
|
local_active_monthly_users = node["active_users_monthly"]
|
||||||
|
# Avoid division by 0
|
||||||
|
if local_active_monthly_users == 0:
|
||||||
|
local_active_monthly_users= 0.5
|
||||||
|
if node["total_users"] / local_active_monthly_users > active_suspicious:
|
||||||
is_bad = True
|
is_bad = True
|
||||||
# print(node)
|
# print(node)
|
||||||
|
|
||||||
|
@ -83,6 +87,7 @@ def retrieve_suspicious_instances(activity_suspicion = 20, active_suspicious = 5
|
||||||
"active_users_monthly": node["active_users_monthly"],
|
"active_users_monthly": node["active_users_monthly"],
|
||||||
"signup": node["signup"],
|
"signup": node["signup"],
|
||||||
"activity_suspicion": node["total_users"] / local_activity,
|
"activity_suspicion": node["total_users"] / local_activity,
|
||||||
|
"active_users_suspicion": node["total_users"] / local_active_monthly_users,
|
||||||
}
|
}
|
||||||
bad_nodes.append(bad_node)
|
bad_nodes.append(bad_node)
|
||||||
return bad_nodes
|
return bad_nodes
|
||||||
|
|
Loading…
Reference in New Issue