Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
csnardi committed Jan 14, 2015
2 parents 1dc8d4e + 3352fbc commit d15beac
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 13 deletions.
27 changes: 18 additions & 9 deletions continuousintegration.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import socket
import requests
import sys
import re
from globalvars import GlobalVars
import datetime
import json

def watchCi():
HOST = ''
Expand All @@ -21,16 +23,23 @@ def watchCi():

while 1:
conn, addr = s.accept()
print 'Received request from ' + addr[0]
r=requests.get('https://api.github.com/repos/Charcoal-SE/SmokeDetector/git/refs/heads/master')
addr_host = socket.gethostbyaddr(addr[0])[0]
is_circleci = True if re.compile(r"ec2-\d{1,3}-\d{1,3}-\d{1,3}-\d{1,3}.compute-1.amazonaws.com").search(addr_host) else False
print 'Received request from ' + addr[0] + " ; " + "verified as CircleCI" if is_circleci else "NOT verified as CircleCI!"
if not is_circleci:
continue
r = requests.get('https://api.github.com/repos/Charcoal-SE/SmokeDetector/git/refs/heads/master')
latest_sha = r.json()["object"]["sha"]
r = requests.get('https://api.github.com/repos/Charcoal-SE/SmokeDetector/commits/' + latest_sha + '/statuses')
states = []
for status in r.json():
state = status["state"]
states.append(state)
if "success" in states:
GlobalVars.charcoal_hq.send_message("CI build passed. Ready to pull!")
elif "error" in states or "failure" in states:
GlobarVars.charcoal_hq.send_message("CI build failed, *someone* (prolly Undo) borked something!")
target_url = status["target_url"]
if state == "success":
if datetime.datetime.strptime(status["updated_at"], '%Y-%m-%dT%H:%M:%SZ') > datetime.datetime.now()-datetime.timedelta(seconds=10):
GlobalVars.charcoal_hq.send_message("[CI build passed](%s). Ready to pull!" % target_url)
continue
elif state == "error" or state == "failure":
if datetime.datetime.strptime(status["updated_at"], '%Y-%m-%dT%H:%M:%SZ') > datetime.datetime.now()-datetime.timedelta(seconds=10):
GlobalVars.charcoal_hq.send_message("[CI build failed](%s), *someone* (prolly Undo) borked something!" % target_url)
continue
s.close()
7 changes: 4 additions & 3 deletions findspam.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@

class FindSpam:
rules = [
{'regex': u"(?i)\\b(baba(ji)?|fifa.*coin|nike|bajotz|vashi?k[ae]r[ae]n|sumer|kolcak|porn|molvi|judi bola|ituBola.com|lost lover|11s|acai|skin care|LifeForce|swtor2credits|me2.do|black magic|bam2u|Neuro(3X|flexyn)|Nutra|TesteroneXL|Bowtrol|Slim ?Genix|Cleanse EFX|Babyliss ?Pro|Forskolin|Blackline Elite|TestCore Pro|Xtreme Antler|Maxx Test 3000|Cheap Wigs?|(Improve )?Brain Power|aging skin|acne( prone)? skin|(skin )?eye serum|skin (serum|eye)|fake (passports?|driver'?s? licen[cs]e|ID cards?)|bagprada)\\b|ಌ|(support|service|helpline)( phone)? number|1[ -]?866[ -]?978[ -]?6819", 'all': True,
{'regex': u"(?i)\\b(baba(ji)?|fifa.*coin|nike|bajotz|vashi?k[ae]r[ae]n|sumer|kolcak|porn|molvi|judi bola|ituBola.com|lost lover|11s|acai|skin care|rejuvenated skin|LifeForce|swtor2credits|me2.do|black magic|bam2u|Neuro(3X|flexyn)|Nutra|TesteroneXL|Bowtrol|Slim ?Genix|Cleanse EFX|Babyliss ?Pro|Forskolin|Blackline Elite|TestCore Pro|Xtreme Antler|Maxx Test 3000|Cheap Wigs?|jivam|(Improve )?Brain Power|aging skin|acne( prone)? skin|(skin )?eye serum|skin (serum|eye)|fake (passports?|driver'?s? licen[cs]e|ID cards?)|bagprada)\\b|ಌ|(support|service|helpline)( phone)? number|1[ -]?866[ -]?978[ -]?6819", 'all': True,
'sites': [], 'reason': "Bad keyword in {}", 'title': True, 'body': True, 'username': True},
{'regex': u"(?i)\\b(fifabay)\\b", 'all': True, 'reason': "Bad keyword in {}", 'sites': [], 'title': True, 'body': True, 'username': True},
{'regex': u"(?i)\\b(weight (loo?s[es]|reduction)|muscles? build(ing)?|muscles?( (grow(th)?|diets?))?|anti aging|SkinCentric|loo?s[es] weight|wrinkles?)\\b", 'all': True,
{'regex': u"(?i)\\b(weight (body ?builder|loo?s[es]|reduction)|muscles? build(ing)?|muscles?( (grow(th)?|diets?))?|anti aging|SkinCentric|loo?s[es] weight|wrinkles?)\\b", 'all': True,
'sites': ["fitness.stackexchange.com"], 'reason': "Bad keyword in {}", 'title': True, 'body': False, 'username': True},
{'regex': u"(?i)^(?:(?=.*?\\b(?:online|hd)\\b)(?=.*?(?:free|full|unlimited)).*?movies?\\b|(?=.*?\\b(?:acai|kisn)\\b)(?=.*?care).*products?\\b|(?=.*?packer).*mover)", 'all': True,
'sites': [], 'reason': "Bad keywords in {}", 'title': True, 'body': False, 'username': True},
Expand All @@ -20,7 +20,8 @@ class FindSpam:
{'regex': u"^(?=.*[0-9])[^a-zA-Z]*$", 'all': True, 'sites': [], 'reason': "Numbers-only title", 'title': True, 'body': False, 'username': False},
{'regex': u"https?://[a-zA-Z0-9_.-]+\\.[a-zA-Z]{2,4}(/[a-zA-Z0-9_/?=.-])?", 'all': True,
'sites': ["stackoverflow.com", "superuser.com", "askubuntu.com"], 'reason': "URL in title", 'title': True, 'body': False, 'username': False},
{'regex': u"(?i)\\b(cfpchampionship2015playofflive|optimalstackfacts\.org|maletestosteronebooster\.org|x4facts\.com|tripleeffectseyeserum\.org|healthcaresup\.com|garciniacambogiaprofacts\.com|filerepairforum\.com)\\b", 'sites': [], 'all': True, 'reason': "Blacklisted website", 'title': True, 'body': True, 'username': True}
{'regex': u"(?i)(orabank|cfpchampionship2015playofflive|optimalstackfacts\.org|maletestosteronebooster\.org|x4facts\.com|tripleeffectseyeserum\.org|healthcaresup\.com|garciniacambogiaprofacts\.com|filerepairforum\.com)", 'sites': [], 'all': True, 'reason': "Blacklisted website", 'title': True, 'body': True, 'username': True},
{'regex': u"([a-zA-Z])\\1{10,}", 'all': True, 'sites': [], 'reason': "Repeating characters in {}", 'title': True, 'body': True, 'username': False}
]

@staticmethod
Expand Down
3 changes: 2 additions & 1 deletion test/test_regexes.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@
('How to avoid objects when traveling at greater than .75 light speed. or How Not to Go SPLAT?', '', 'bowlturner', '', False),
('Is it unfair to regrade prior work after detecting cheating?', '', 'Village', '', False),
('Inner workings of muscles', '', '', 'fitness.stackexchange.com', False),
('Cannot access http://stackoverflow.com/ with proxy enabled', '', '', 'superuser.com', False)
('Cannot access http://stackoverflow.com/ with proxy enabled', '', '', 'superuser.com', False),
('kkkkkkkkkkkkkkkkkkkkkkkkkkkk', '<p>bbbbbbbbbbbbbbbbbbbbbb</p>', '', 'stackoverflow.com', True)
])

def test_regexes(title, body, username, site, match):
Expand Down

0 comments on commit d15beac

Please sign in to comment.