Skip to content

Commit

Permalink
Merge branch 'master' into figure.it.out
Browse files Browse the repository at this point in the history
  • Loading branch information
RaidAndFade authored Oct 15, 2018
2 parents 1f4ff07 + 551a0d4 commit 21c5c16
Show file tree
Hide file tree
Showing 23 changed files with 1,378 additions and 46 deletions.
108 changes: 87 additions & 21 deletions AutoAudit/Audit.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,12 @@
REPO_URL = "https://api.github.com/repos/RaidAndFade/Hacktoberfest2018/pulls"
RAIDANDFADE_ID = 5139165
HAZARDOUS_TAGS = ("script","style","meta","iframe","img","video","audio","link","svg")
BAD_WORDS = ("anal","anus","ballsack","blowjob","blow job","boner","clit","cock","cunt","dick","fag","dildo","fuck","jizz",
"labia","urethra","nigg","penis","porn","pussy","scrotum","sex","slut","smegma","spunk","twat","vagina","wank","whore")
BAD_WORDS = ("anal", "anus", "ballsack", "blowjob", "blow job", "boner", "clit", "cock", "cunt", "dick", "fag", "dildo",
"fuck", "jizz", "labia", "urethra", "nigg", "penis", "porn", "pussy", "scrotum", "sex", "slut", "smegma",
"spunk", "twat", "vagina", "wank", "whore")
TOPIC_LABELS = ("week1","week2")

ISDEBUG = False

class PRChecker:
def __init__(self, pr_info: dict):
Expand All @@ -30,6 +34,7 @@ def __init__(self, pr_info: dict):
self.title = None
self.url = None
self.author = None
self.topic = ""
self.invalid_reasons = []
self.attention_reasons = []

Expand All @@ -51,10 +56,55 @@ def add_invalid(self, reason: str):
self.invalid = True

def check_game_submission(self,uname,new_file,fcount):
pass
self.topic = "week2"
if fcount != 3:
self.add_invalid(f'You added/changed/deleted {fcount} files. You can only add three (3) files `index.html` `main.js` `main.css`.')

indexfile = None
jsfile = None
cssfile = None

allowedNames = ("main.js","main.css","index.html")
for f in new_file['diff']:
p = os.path.split(f.path)
if not p[1] in allowedNames:
self.add_invalid("You have a file called "+p[1]+", this is not one of the three allowed names.")
else:
if p[0].lower()!=f"games/{uname}".lower():
self.add_invalid("You have a file at "+p[0]+", this is not allowed.")
else:
if p[1] == "main.js":
jsfile = f
elif p[1] == "main.css":
cssfile = f
elif p[1] == "index.html":
indexfile = f

if jsfile is None:
self.add_invalid("Your `main.js` file was not found, it is a requirement (even if empty)")
else:
if any(w in new_file['lines'][jsfile.path] for w in BAD_WORDS):
self.add_attention('Your JS file potentially has references to foul language.')
if cssfile is None:
self.add_invalid("Your `main.css` file was not found, it is a requirement (even if empty)")
else:
if any(w in new_file['lines'][cssfile.path] for w in BAD_WORDS):
self.add_attention('Your CSS file potentially has references to foul language.')
if indexfile is None:
self.add_invalid("Your `index.html` file was not found, this one should exist and be nonempty")
else:
if any(w in new_file['lines'][indexfile.path] for w in BAD_WORDS):
self.add_attention('Your HTML file potentially has references to foul language.')

self.add_attention("These submissions must be checked manually because of the potential complexity of submissions, " +
"if you've reached this point in the process you're most likely a valid submission.")



def check_friends_submission(self,uname,new_file,fcount):
path = os.path.split(new_file['diff'][0].path)
self.topic = "week1"
fpath = new_file['diff'][0].path
path = os.path.split(fpath)

if fcount > 1:
self.add_invalid('More than one file has been added/removed/modified.')
Expand All @@ -73,12 +123,14 @@ def check_friends_submission(self,uname,new_file,fcount):

#todo if shit gets rowdy, have a list of alternate chars {"a":["4"]} and if any of those variations are included
# just straight up lock the pr for spam (and possibly auto-close future prs by the same person)
if any(w in new_file['lines'] for w in BAD_WORDS):
file_lines = new_file['lines'][fpath]

if any(w in file_lines for w in BAD_WORDS):
self.add_attention('Your file potentially has references to foul language.')

for l in valid_urls:
if l.lower() in new_file['lines']:
p = new_file['lines'][new_file['lines'].index(l.lower())+len(l):]
if l.lower() in file_lines:
p = file_lines[file_lines.index(l.lower())+len(l):]

if forbidden_next_chars.count(p[0]) > 0:
has_bad_url = True
Expand All @@ -98,7 +150,7 @@ def check_friends_submission(self,uname,new_file,fcount):
needs_review = False

for h in HAZARDOUS_TAGS:
if ("<"+h.lower()) in new_file['lines']:
if ("<"+h.lower()) in file_lines:
needs_review = True
break

Expand All @@ -118,24 +170,20 @@ def interpret_pr(self):
if fcount < 1:
self.add_invalid('Less than one file has been added/removed/modified.')
return


uname = self.pr_info['user']['login']

# get the first file (this should be fine)
path = os.path.split(new_file['diff'][0].path)


if path[0].split("/")[0] == "Game":

if path[0].split("/")[0] == "Games":
self.check_game_submission(uname,new_file,fcount)

elif path[0] == "Friends":

self.check_friends_submission(uname,new_file,fcount)

else:
self.add_attention('Your file is not in a project folder ("Friends"). This may be intentional, but most likely not.')
self.add_attention('Your file is not in a project folder ("Friends", "Games"). This may be intentional, but most likely not.')

result = {
'number': self.pr_info['number'],
Expand Down Expand Up @@ -166,19 +214,25 @@ def check_diff(self):
self.add_invalid('Less than one file has been added/removed/modified.')
return

if diff[0].is_modified_file:
self.add_attention('This file modifies a pre-existing file.')
if any(d.is_modified_file for d in diff):
self.add_attention('This PR modifies one or more pre-existing files.')
return

new_file = self.parse_diff(str(diff[0]).split('\n'))
new_file = self.parse_diff(diff_file.split("\n"))

return {'lines': new_file, 'diff': diff, 'diff_file': diff_file}

def parse_diff(self, diff: list):
new_file_lines = ""
new_file_lines = {}
current_file = ""
for line in diff:
if line.startswith('+') and not line.startswith('+++'):
new_file_lines += f"{line[1:]}\n".lower()
new_file_lines[current_file] += f"{line[1:]}\n".lower()
elif line.startswith('+++'):
current_file = line[6:]
new_file_lines[current_file] = ""

# print(new_file_lines)

return new_file_lines

Expand All @@ -188,27 +242,32 @@ def has_label(pr,lblname):
return True
return False
def do_merge(pr):
if ISDEBUG: return
#sha = sha that head must match... i did this manually, but it would have been cool to use the built-in api
#PUT /repos/:owner/:repo/pulls/:number/merge
merge_r = requests.put(pr['url']+"/merge",auth=API_AUTH,json={"commit_title":"Auto-Merging PR#"+str(pr['number']),"commit_message":"Automatically merged PR#"+str(pr['number'])+" as it seemed safe."})
if 'message' in merge_r:
print(merge_r)
def close(pr):
if ISDEBUG: return
#PATCH /repos/:owner/:repo/pulls/:number state=closed
close_r = requests.patch(pr['url'],auth=API_AUTH,json={"state":"closed"})
if 'message' in close_r:
print(close_r)
def add_label(pr,lblname):
if ISDEBUG: return
#return
addl_r = requests.post(pr['issue_url']+"/labels",auth=API_AUTH,json=[lblname]).json()
if 'message' in addl_r:
print(addl_r)
def remove_label(pr,lblname):
if ISDEBUG: return
#return
rml_r = requests.delete(pr['issue_url']+"/labels/"+lblname,auth=API_AUTH).json()
if 'message' in rml_r:
print(rml_r)
def send_comment(pr,msg):
if ISDEBUG: return
msg += "\n\n***This is an automated response, beep boop.\nif you think there is a mistake, contact a maintainer***"
msg += "\n> "+pr['head']['sha']
#print(msg)
Expand Down Expand Up @@ -259,7 +318,7 @@ def check_prs():
for i in r.json():
if i['state'] == 'open':
comment = ""

print(f"[{get_cur_time()}] "+str(i['number'])+": ",end="")

if len(i['labels']) > 0:
Expand Down Expand Up @@ -306,6 +365,13 @@ def check_prs():
continue

pr = PRChecker(i)

for label in TOPIC_LABELS:
if pr.topic != label and has_label(i,label):
remove_label(i,label)

if pr.topic is not None:
add_label(i,pr.topic)

if pr.invalid: # the pr contains a mistake, and is invalid
reasons = ""
Expand Down Expand Up @@ -364,7 +430,7 @@ def check_prs():

if __name__ == '__main__':
check_prs()
while True:
while not ISDEBUG:
t = Timer(900, check_prs) # check every 900s (15m)
t.start()
t.join()
1 change: 1 addition & 0 deletions BSoD/raidandfade.html
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
This is an empty file that does not follow the rules, this exists because the folder needed to be created manually.<br>Do not copy this file.
31 changes: 31 additions & 0 deletions Friends/SayuriRavihari.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<!DOCTYPE html>
<html>
<head>
<title>Welcome all</title>

<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css" integrity="sha384-MCw98/SFnGE8fJT3GXwEOngsV7Zt27NXFoaoApmYm81iuXoPkFOJwJ8ERdknLPMO" crossorigin="anonymous">
</head>

<body>

<section id="bio">

<div class="row">

<div class="col-xl-12">

<h1 class="text-center">Hello my dear friends......</h1>

<p class="text-center">I am Sayuri.I want to be your friend.My github bio is <a href="https://github.com/SayuriRavihari">SayuriRavihari</a></p>
</div>
</div>

</section>

<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.3/umd/popper.min.js" integrity="sha384-ZMP7rVo3mIykV+2+9J3UJ46jBk0WLaUAdn689aCwoqbBJiSnjAK/l8WvCWPIPm49" crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.min.js" integrity="sha384-ChfqqxuZUCnJSK3+MXmPNIyE6ZbWh2IMqE241rYiqJxyMiZ6OW/JmZQ5stwEULTy" crossorigin="anonymous"></script>

</body>

</html>
18 changes: 18 additions & 0 deletions Friends/Sogastar.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<!doctype <!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>New "Friend"</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
</head>

<body style="font-family: 'Lucida Sans', 'Lucida Sans Regular', 'Lucida Grande', 'Lucida Sans Unicode', Geneva, Verdana, sans-serif">
<center>
<h1> Hy</br>Friend...</h1>
<p>My name is Danijel</p>
This is my Github account <a href="https://github.com/Sogastar">
<p>url: https://github.com/Sogastar</p></a>
</center>
</body>

</html>
37 changes: 37 additions & 0 deletions Friends/parthpandyappp.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<html>
<head>
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>INTRODUCTORY FILE</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
</head>
<style>
body
{
background-color: dodgerblue;
font-family: 'Times New Roman', Times, serif;
color: wheat;

}

</style>
<body>
<center><p><font size=6>Hello there.!</font></p></center>
<center><p><font size=6>Here's the new contributor from Surat, Gujarat. Myself Parth Pandya a pre-university computer-aided student. </font></p></center>
<p >
<center><font size=5>I always use to write blogs regarding my interaction with the world. Please do f0ll0w'em, You may please refer to them. These are just below-:</font></center><br>
<a href="https://bloggingwithparth.wordpress.com/"><font size=5>* WORDPRESS.</font></a><br>
<a href="https://medium.com/@parthpandyappp"><font size=5>* MEDIUM.</font></a><br>
<center><h3>HAPPY READING..!</h3></center>
</p>
<p ><font size=6>
I have also designed my personal portfolio website. Just have a look. It's just a click more-:<br>
<a href="parthpandyappp.github.io">PORTFOLIO WEBSITE.</a>
</font></p>
<p><font size=6>
NOW, A FINAL CLICK TO MY GITHUB ACCOUNT-:<br>
<a href="https://github.com/parthpandyappp">
<center><h2>THANKYOU !</center></font>
</p>
</body>
</html>
21 changes: 21 additions & 0 deletions Friends/tbanov.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<style>
body{
text-align: center;
font-size: 50px;
font-family: 'Gill Sans', 'Gill Sans MT', Calibri, 'Trebuchet MS', sans-serif
}
p{
font-size: 30px;
}
</style>
<title>tbanov</title>
</head>
<body>
<h2>Hello Guys!</h2>
<p>This is my GitHub Profile <a href="https://github.com/tbanov">Click Here</a></p>
</body>
</html>
30 changes: 30 additions & 0 deletions Friends/virajGalappaththi.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<!DOCTYPE html>
<html>
<head>
<title>Viraj Galappaththi</title>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css" integrity="sha384-MCw98/SFnGE8fJT3GXwEOngsV7Zt27NXFoaoApmYm81iuXoPkFOJwJ8ERdknLPMO" crossorigin="anonymous">
</head>
<body>

<section id="bio">

<div class="row">

<div class="col-xl-12">

<h1 class="text-center">Hi there! This is Viraj</h1>

<p class="text-center">My github bio is <a href="https://github.com/VirajGalappaththi">@Viraj</a></p>
</div>

</div>


</section>


<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.3/umd/popper.min.js" integrity="sha384-ZMP7rVo3mIykV+2+9J3UJ46jBk0WLaUAdn689aCwoqbBJiSnjAK/l8WvCWPIPm49" crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.min.js" integrity="sha384-ChfqqxuZUCnJSK3+MXmPNIyE6ZbWh2IMqE241rYiqJxyMiZ6OW/JmZQ5stwEULTy" crossorigin="anonymous"></script>
</body>
</html>
Loading

0 comments on commit 21c5c16

Please sign in to comment.