Security
This commit is contained in:
parent
49cea62407
commit
3008659ce0
2 changed files with 31 additions and 11 deletions
|
@ -81,6 +81,14 @@ def head(title="", description="", image="", config={}, author=""):
|
||||||
<meta property="og:description" content=\""""+Safe(description)+"""">
|
<meta property="og:description" content=\""""+Safe(description)+"""">
|
||||||
<meta property="og:image" content=\""""+image+"""">
|
<meta property="og:image" content=\""""+image+"""">
|
||||||
|
|
||||||
|
<!-- RSS Link -->
|
||||||
|
|
||||||
|
<link rel="alternate" title='"""+config.get("title", "My Website")+"""' type="application/rss+xml" href="/rss" />
|
||||||
|
"""
|
||||||
|
if author:
|
||||||
|
html = html + """
|
||||||
|
<link rel="alternate" title='Just @"""+author+"""' type="application/rss+xml" href="/rss?author="""+author+"""" />
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
# Author tags.
|
# Author tags.
|
||||||
|
@ -173,8 +181,17 @@ def validate(cookie):
|
||||||
return Accounts[account]
|
return Accounts[account]
|
||||||
return {}
|
return {}
|
||||||
|
|
||||||
def isHuman(cookie):
|
def isHuman(server):
|
||||||
|
|
||||||
|
cookie = server.cookie
|
||||||
|
|
||||||
|
# Identifying probable browsers
|
||||||
|
useragent = False
|
||||||
|
for i in ["Chrome", "Firefox", "Safari", "Mozilla"]:
|
||||||
|
if i in server.headers.get("User-Agent"):
|
||||||
|
useragent = True
|
||||||
|
break
|
||||||
|
if not useragent: return False
|
||||||
return ( cookie in ProbablyHumanCookies and cookie in KnownCookies ) or validate(cookie)
|
return ( cookie in ProbablyHumanCookies and cookie in KnownCookies ) or validate(cookie)
|
||||||
|
|
||||||
def moderates(moderator, user):
|
def moderates(moderator, user):
|
||||||
|
@ -849,7 +866,7 @@ def AccountPage(server, account):
|
||||||
html = html + '</center>'
|
html = html + '</center>'
|
||||||
|
|
||||||
# Protecting emails and stuff from scrubbers
|
# Protecting emails and stuff from scrubbers
|
||||||
if isHuman(server.cookie):
|
if isHuman(server):
|
||||||
|
|
||||||
# Website
|
# Website
|
||||||
|
|
||||||
|
@ -885,15 +902,15 @@ def AccountPage(server, account):
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
|
||||||
mastodon = mastohead(mastodon)
|
Mastodon = mastohead(mastodon)
|
||||||
mastolink = mastolink(mastodon)
|
Mastolink = mastolink(mastodon)
|
||||||
|
|
||||||
html = html + '<center>'
|
html = html + '<center>'
|
||||||
html = html + '<img style="vertical-align: middle" src="/icon/mastodon">'
|
html = html + '<img style="vertical-align: middle" src="/icon/mastodon">'
|
||||||
html = html + '<a href="'+mastolink+'"> '+mastodon+'</a>'
|
html = html + '<a href="'+Mastolink+'"> '+Mastodon+'</a>'
|
||||||
html = html + '</center>'
|
html = html + '</center>'
|
||||||
except:
|
except Exception as e:
|
||||||
pass
|
print(e)
|
||||||
|
|
||||||
# Matrix
|
# Matrix
|
||||||
|
|
||||||
|
@ -1642,7 +1659,7 @@ def Footer(server):
|
||||||
Accounts = accounts()
|
Accounts = accounts()
|
||||||
if account in Accounts:
|
if account in Accounts:
|
||||||
|
|
||||||
if isHuman(server.cookie):
|
if isHuman(server):
|
||||||
email = Accounts[account].get("email")
|
email = Accounts[account].get("email")
|
||||||
if email:
|
if email:
|
||||||
html = html + Button("Contact Admin", "mailto:"+email, "frase")
|
html = html + Button("Contact Admin", "mailto:"+email, "frase")
|
||||||
|
@ -2073,7 +2090,7 @@ def Error(server, text="Some Error Happened."):
|
||||||
send(server, html, 501)
|
send(server, html, 501)
|
||||||
|
|
||||||
|
|
||||||
def FreeCompetitor(free, nonfree):
|
def FreeCompetitor(free, nonfree, score):
|
||||||
|
|
||||||
html = """
|
html = """
|
||||||
|
|
||||||
|
@ -2084,6 +2101,7 @@ def FreeCompetitor(free, nonfree):
|
||||||
html = html + '<h1><img alt="[icon fc]" src="/icon/fc" style="vertical-align: middle">'
|
html = html + '<h1><img alt="[icon fc]" src="/icon/fc" style="vertical-align: middle">'
|
||||||
html = html + free.get("names", ["Software"])[0]+'</h1>'
|
html = html + free.get("names", ["Software"])[0]+'</h1>'
|
||||||
|
|
||||||
|
|
||||||
icon = free.get("links", {}).get("icon", "")
|
icon = free.get("links", {}).get("icon", "")
|
||||||
if icon:
|
if icon:
|
||||||
html = html + '<center><img alt="[thumbnail]" style="min-width:80%;" src="'+icon+'"></center>'
|
html = html + '<center><img alt="[thumbnail]" style="min-width:80%;" src="'+icon+'"></center>'
|
||||||
|
@ -2584,7 +2602,7 @@ def UpdatePublicationRights(server):
|
||||||
def DoComment(server):
|
def DoComment(server):
|
||||||
|
|
||||||
# Limiting bots from commenting
|
# Limiting bots from commenting
|
||||||
if not isHuman(server.cookie):
|
if not isHuman(server):
|
||||||
AccessDenied(server)
|
AccessDenied(server)
|
||||||
return
|
return
|
||||||
|
|
||||||
|
@ -3347,7 +3365,7 @@ def Search(server):
|
||||||
if soft[1].get("names", [""])[0] in fcdata.get("found", {}).get("data", {}).get("names", []):
|
if soft[1].get("names", [""])[0] in fcdata.get("found", {}).get("data", {}).get("names", []):
|
||||||
continue
|
continue
|
||||||
|
|
||||||
html = html + FreeCompetitor(soft[1], fcdata.get("found", {}).get("data",{}))
|
html = html + FreeCompetitor(soft[1], fcdata.get("found", {}).get("data",{}), soft[0])
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -132,6 +132,8 @@ class handler(BaseHTTPRequestHandler):
|
||||||
self.cookie = self.headers.get("Cookie")
|
self.cookie = self.headers.get("Cookie")
|
||||||
if self.cookie: self.cookie = self.cookie[-200:]
|
if self.cookie: self.cookie = self.cookie[-200:]
|
||||||
|
|
||||||
|
#print(self.headers)
|
||||||
|
|
||||||
# ignore = ["/rss"]
|
# ignore = ["/rss"]
|
||||||
|
|
||||||
# if not self.cookie and not self.path.startswith(tuple(ignore)):
|
# if not self.cookie and not self.path.startswith(tuple(ignore)):
|
||||||
|
|
Loading…
Add table
Reference in a new issue