Compare commits
No commits in common. "0c0125b40c925e1451ed32fe4f4f8a04f98dd405" and "a0989ccceff19618d970f55165e65dd0b4b45f78" have entirely different histories.
0c0125b40c
...
a0989cccef
4
.gitignore
vendored
4
.gitignore
vendored
@ -4,7 +4,3 @@
|
|||||||
__pycache__/
|
__pycache__/
|
||||||
|
|
||||||
templates/assets/css/styles.min.css
|
templates/assets/css/styles.min.css
|
||||||
|
|
||||||
ignore/
|
|
||||||
|
|
||||||
plugins/signatures.json
|
|
||||||
|
26
main.py
26
main.py
@ -96,7 +96,7 @@ def index():
|
|||||||
plugins = ""
|
plugins = ""
|
||||||
dashFunctions = plugins_module.getDashboardFunctions()
|
dashFunctions = plugins_module.getDashboardFunctions()
|
||||||
for function in dashFunctions:
|
for function in dashFunctions:
|
||||||
functionOutput = plugins_module.runPluginFunction(function["plugin"],function["function"],{},request.cookies.get("account"))
|
functionOutput = plugins_module.runPluginFunction(function["plugin"],function["function"],{},account_module.check_account(request.cookies.get("account")))
|
||||||
plugins += render.plugin_output_dash(functionOutput,plugins_module.getPluginFunctionReturns(function["plugin"],function["function"]))
|
plugins += render.plugin_output_dash(functionOutput,plugins_module.getPluginFunctionReturns(function["plugin"],function["function"]))
|
||||||
|
|
||||||
|
|
||||||
@ -1152,10 +1152,6 @@ def plugin(plugin):
|
|||||||
functions = plugins_module.getPluginFunctions(plugin)
|
functions = plugins_module.getPluginFunctions(plugin)
|
||||||
functions = render.plugin_functions(functions,plugin)
|
functions = render.plugin_functions(functions,plugin)
|
||||||
|
|
||||||
if data['verified'] == False:
|
|
||||||
functions = "<div class='container-fluid'><div class='alert alert-warning' role='alert'>This plugin is not verified and is disabled for your protection. Please check the code before marking the plugin as verified <a href='/plugin/" + plugin + "/verify' class='btn btn-danger'>Verify</a></div></div>" + functions
|
|
||||||
|
|
||||||
|
|
||||||
error = request.args.get("error")
|
error = request.args.get("error")
|
||||||
if error == None:
|
if error == None:
|
||||||
error = ""
|
error = ""
|
||||||
@ -1165,26 +1161,6 @@ def plugin(plugin):
|
|||||||
author=data['author'],version=data['version'],
|
author=data['author'],version=data['version'],
|
||||||
functions=functions,error=error)
|
functions=functions,error=error)
|
||||||
|
|
||||||
@app.route('/plugin/<plugin>/verify')
|
|
||||||
def plugin_verify(plugin):
|
|
||||||
# Check if the user is logged in
|
|
||||||
if request.cookies.get("account") is None:
|
|
||||||
return redirect("/login")
|
|
||||||
|
|
||||||
account = account_module.check_account(request.cookies.get("account"))
|
|
||||||
if not account:
|
|
||||||
return redirect("/logout")
|
|
||||||
|
|
||||||
if not plugins_module.pluginExists(plugin):
|
|
||||||
return redirect("/plugins")
|
|
||||||
|
|
||||||
data = plugins_module.getPluginData(plugin)
|
|
||||||
|
|
||||||
if data['verified'] == False:
|
|
||||||
plugins_module.verifyPlugin(plugin)
|
|
||||||
|
|
||||||
return redirect("/plugin/" + plugin)
|
|
||||||
|
|
||||||
@app.route('/plugin/<plugin>/<function>', methods=["POST"])
|
@app.route('/plugin/<plugin>/<function>', methods=["POST"])
|
||||||
def plugin_function(plugin,function):
|
def plugin_function(plugin,function):
|
||||||
# Check if the user is logged in
|
# Check if the user is logged in
|
||||||
|
85
plugin.py
85
plugin.py
@ -13,27 +13,6 @@ def listPlugins():
|
|||||||
details = plugin.info
|
details = plugin.info
|
||||||
details["link"] = file[:-3]
|
details["link"] = file[:-3]
|
||||||
plugins.append(details)
|
plugins.append(details)
|
||||||
|
|
||||||
# Verify plugin signature
|
|
||||||
signatures = []
|
|
||||||
try:
|
|
||||||
with open("plugins/signatures.json", "r") as f:
|
|
||||||
signatures = json.load(f)
|
|
||||||
except:
|
|
||||||
# Write a new signatures file
|
|
||||||
with open("plugins/signatures.json", "w") as f:
|
|
||||||
json.dump(signatures, f)
|
|
||||||
|
|
||||||
for plugin in plugins:
|
|
||||||
# Hash the plugin file
|
|
||||||
with open(f"plugins/{plugin['link']}.py", "r") as f:
|
|
||||||
file = f.read()
|
|
||||||
plugin_hash = hash(file)
|
|
||||||
if plugin_hash not in signatures:
|
|
||||||
plugin["verified"] = False
|
|
||||||
else:
|
|
||||||
plugin["verified"] = True
|
|
||||||
|
|
||||||
return plugins
|
return plugins
|
||||||
|
|
||||||
|
|
||||||
@ -43,49 +22,9 @@ def pluginExists(plugin: str):
|
|||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def verifyPlugin(plugin: str):
|
def getPluginData(plugin: str):
|
||||||
signatures = []
|
plugin = importlib.import_module("plugins."+plugin)
|
||||||
try:
|
return plugin.info
|
||||||
with open("plugins/signatures.json", "r") as f:
|
|
||||||
signatures = json.load(f)
|
|
||||||
except:
|
|
||||||
# Write a new signatures file
|
|
||||||
with open("plugins/signatures.json", "w") as f:
|
|
||||||
json.dump(signatures, f)
|
|
||||||
|
|
||||||
# Hash the plugin file
|
|
||||||
with open(f"plugins/{plugin}.py", "r") as f:
|
|
||||||
file = f.read()
|
|
||||||
plugin_hash = hash(file)
|
|
||||||
if plugin_hash not in signatures:
|
|
||||||
signatures.append(plugin_hash)
|
|
||||||
with open("plugins/signatures.json", "w") as f:
|
|
||||||
json.dump(signatures, f)
|
|
||||||
|
|
||||||
def getPluginData(pluginStr: str):
|
|
||||||
plugin = importlib.import_module("plugins."+pluginStr)
|
|
||||||
|
|
||||||
# Check if the plugin is verified
|
|
||||||
signatures = []
|
|
||||||
try:
|
|
||||||
with open("plugins/signatures.json", "r") as f:
|
|
||||||
signatures = json.load(f)
|
|
||||||
except:
|
|
||||||
# Write a new signatures file
|
|
||||||
with open("plugins/signatures.json", "w") as f:
|
|
||||||
json.dump(signatures, f)
|
|
||||||
|
|
||||||
info = plugin.info
|
|
||||||
# Hash the plugin file
|
|
||||||
with open(f"plugins/{pluginStr}.py", "r") as f:
|
|
||||||
file = f.read()
|
|
||||||
plugin_hash = hash(file)
|
|
||||||
if plugin_hash not in signatures:
|
|
||||||
info["verified"] = False
|
|
||||||
else:
|
|
||||||
info["verified"] = True
|
|
||||||
|
|
||||||
return info
|
|
||||||
|
|
||||||
def getPluginFunctions(plugin: str):
|
def getPluginFunctions(plugin: str):
|
||||||
plugin = importlib.import_module("plugins."+plugin)
|
plugin = importlib.import_module("plugins."+plugin)
|
||||||
@ -102,24 +41,6 @@ def runPluginFunction(plugin: str, function: str, params: dict, authentication:
|
|||||||
# Get the function object from the plugin module
|
# Get the function object from the plugin module
|
||||||
plugin_function = getattr(plugin_module, function)
|
plugin_function = getattr(plugin_module, function)
|
||||||
|
|
||||||
# Check if the function is in the signature list
|
|
||||||
signatures = []
|
|
||||||
try:
|
|
||||||
with open("plugins/signatures.json", "r") as f:
|
|
||||||
signatures = json.load(f)
|
|
||||||
except:
|
|
||||||
# Write a new signatures file
|
|
||||||
with open("plugins/signatures.json", "w") as f:
|
|
||||||
json.dump(signatures, f)
|
|
||||||
|
|
||||||
# Hash the plugin file
|
|
||||||
with open(f"plugins/{plugin}.py", "r") as f:
|
|
||||||
file = f.read()
|
|
||||||
plugin_hash = hash(file)
|
|
||||||
if plugin_hash not in signatures:
|
|
||||||
return {"error": "Plugin not verified"}
|
|
||||||
|
|
||||||
|
|
||||||
# Call the function with provided parameters
|
# Call the function with provided parameters
|
||||||
try:
|
try:
|
||||||
result = plugin_function(params, authentication)
|
result = plugin_function(params, authentication)
|
||||||
|
10
render.py
10
render.py
@ -189,10 +189,7 @@ def plugins(plugins):
|
|||||||
name = plugin['name']
|
name = plugin['name']
|
||||||
link = plugin['link']
|
link = plugin['link']
|
||||||
|
|
||||||
if plugin['verified']:
|
|
||||||
html += f'<li class="list-group-item"><a class="btn btn-secondary" style="width:100%;height:100%;margin:0px;font-size: x-large;" role="button" href="/plugin/{link}">{name}</a></li>'
|
html += f'<li class="list-group-item"><a class="btn btn-secondary" style="width:100%;height:100%;margin:0px;font-size: x-large;" role="button" href="/plugin/{link}">{name}</a></li>'
|
||||||
else:
|
|
||||||
html += f'<li class="list-group-item"><a class="btn btn-danger" style="width:100%;height:100%;margin:0px;font-size: x-large;" role="button" href="/plugin/{link}">{name} (Not verified)</a></li>'
|
|
||||||
return html
|
return html
|
||||||
|
|
||||||
def plugin_functions(functions, pluginName):
|
def plugin_functions(functions, pluginName):
|
||||||
@ -304,8 +301,9 @@ def plugin_output_dash(outputs, returns):
|
|||||||
html = ''
|
html = ''
|
||||||
|
|
||||||
for returnOutput in returns:
|
for returnOutput in returns:
|
||||||
if returnOutput not in outputs:
|
|
||||||
html += render_template('components/dashboard-plugin.html', name=returns[returnOutput]["name"], output="No output")
|
|
||||||
continue
|
|
||||||
html += render_template('components/dashboard-plugin.html', name=returns[returnOutput]["name"], output=outputs[returnOutput])
|
html += render_template('components/dashboard-plugin.html', name=returns[returnOutput]["name"], output=outputs[returnOutput])
|
||||||
|
|
||||||
|
|
||||||
|
html += f'</div>'
|
||||||
|
html += f'</div>'
|
||||||
return html
|
return html
|
Loading…
Reference in New Issue
Block a user