Skip to content
This repository has been archived by the owner on Sep 8, 2022. It is now read-only.

Develop #33

Open
wants to merge 75 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
75 commits
Select commit Hold shift + click to select a range
7d1cbbc
CON-83 complete
Jul 4, 2022
ee6c577
-moved to redux [breaking change for auth states]
Ser0n-ath Jul 5, 2022
62d1c0a
-added ipc main to get system info
Ser0n-ath Jul 7, 2022
2142acf
-added Deviceloader used to chain startup function
Ser0n-ath Jul 8, 2022
d81a4ce
Merge branch 'develop' into CON-80
Ser0n-ath Jul 8, 2022
ac4e896
Merge pull request #10 from UTSCCSCC01/CON-80
Ser0n-ath Jul 8, 2022
a0f6fb4
[CON-26]
Ser0n-ath Jul 11, 2022
50f929e
Merge pull request #11 from UTSCCSCC01/CON-26
Ser0n-ath Jul 11, 2022
5a8e7da
-added ability to send payload
Ser0n-ath Jul 28, 2022
6c5fad0
-added auth token verification
Ser0n-ath Jul 28, 2022
0b4f800
added proxy for dispatch socket
Ser0n-ath Jul 28, 2022
8a6259e
-added socket connection between electron and
Ser0n-ath Jul 29, 2022
2371789
-added ipc rest endpoints
Ser0n-ath Jul 30, 2022
9e19aaa
-add rest api as ipc sockets
Ser0n-ath Jul 30, 2022
d513ae7
[CON-97] backend event-builder microservice
lee00286 Jul 31, 2022
479a497
[CON-97] EventBuilder UI + connect with backend
lee00286 Jul 31, 2022
e47916e
[CON-97] Updated pages for event creation
lee00286 Jul 31, 2022
40b49dc
predicate-microservice completed
Jul 31, 2022
87529da
[CON-77]
Ser0n-ath Aug 1, 2022
c063244
Merge branch 'develop' into CON-77
Ser0n-ath Aug 1, 2022
7a5078d
Merge pull request #12 from UTSCCSCC01/CON-77
Ser0n-ath Aug 1, 2022
14a21ae
docker-compose bugfix
Ser0n-ath Aug 1, 2022
4d07ba6
Merge pull request #13 from UTSCCSCC01/develop
Ser0n-ath Aug 1, 2022
bf55068
merged marketplace routes
UnsAbbasi2022 Aug 2, 2022
e6ac185
Merge pull request #14 from UTSCCSCC01/mergeupload
UnsAbbasi2022 Aug 2, 2022
a23e5ed
Added marketplace.py
UnsAbbasi2022 Aug 2, 2022
3f1a9d8
Merge pull request #15 from UTSCCSCC01/UnsAbbasi2022-patch-1
UnsAbbasi2022 Aug 2, 2022
a7ab978
eventId added
Aug 2, 2022
df6bb04
Merge branch 'CON-96' into develop
Aug 2, 2022
eef516b
-added ability to view and
Ser0n-ath Aug 2, 2022
8938f37
Merge pull request #16 from UTSCCSCC01/CON-99
Ser0n-ath Aug 2, 2022
55dbaf6
[CON-97] Fix errors of BotBuilderPage
lee00286 Aug 2, 2022
766cf71
[CON-97] Update EventBuilderPage
lee00286 Aug 4, 2022
0b1fd6c
added addToBots
UnsAbbasi2022 Aug 6, 2022
cf87fce
added header options for addbots
UnsAbbasi2022 Aug 6, 2022
dae29da
fixed bugs
UnsAbbasi2022 Aug 6, 2022
24405df
Merge branch 'CON-97' into develop
lee00286 Aug 6, 2022
56d7909
Merge pull request #17 from UTSCCSCC01/develop
lee00286 Aug 6, 2022
8956049
Merge branch 'develop' into CON-93
UnsAbbasi2022 Aug 6, 2022
804ea44
Merge pull request #18 from UTSCCSCC01/CON-93
UnsAbbasi2022 Aug 6, 2022
1d7c5db
[CON-97] Update EventBuilderPage
lee00286 Aug 6, 2022
5c58231
[CON-97] Update BotBuilderPage
lee00286 Aug 6, 2022
aafc180
[CON-97] Update EventBuilderPage
lee00286 Aug 6, 2022
6b913d9
[CON-97] Update BotDetailPage
lee00286 Aug 6, 2022
5c62527
add download & getMetadata endpoint in Marketplace
UnsAbbasi2022 Aug 7, 2022
4e50d1a
Add marketplace/buid endpoint
UnsAbbasi2022 Aug 7, 2022
9df6824
/download endpoint complete
UnsAbbasi2022 Aug 7, 2022
ad91b68
Merge pull request #19 from UTSCCSCC01/CON-103
UnsAbbasi2022 Aug 7, 2022
c02bc66
download_and_install endpoint complete
UnsAbbasi2022 Aug 7, 2022
d1b207e
Merge pull request #20 from UTSCCSCC01/CON-104
UnsAbbasi2022 Aug 7, 2022
1b47e14
bot execution finished
UnsAbbasi2022 Aug 7, 2022
50d8e8e
Merge pull request #21 from UTSCCSCC01/exec_bot
UnsAbbasi2022 Aug 7, 2022
6aca782
added get_local_bots endpoint
UnsAbbasi2022 Aug 7, 2022
2de0e96
Merge pull request #22 from UTSCCSCC01/local_bots
UnsAbbasi2022 Aug 7, 2022
fe9ddfe
Fix /api/devices/getAllDevices
UnsAbbasi2022 Aug 7, 2022
6eb57f5
Merge pull request #23 from UTSCCSCC01/CON-66
UnsAbbasi2022 Aug 7, 2022
15c2eb9
change auth object to string
UnsAbbasi2022 Aug 7, 2022
6576bed
predicatemicroservice updated
Aug 7, 2022
fcb62ce
Merge branch 'develop' of https://github.com/UTSCCSCC01/finalprojects…
Aug 7, 2022
0b410a2
using path.join now
UnsAbbasi2022 Aug 7, 2022
7fe9737
Merge pull request #24 from UTSCCSCC01/CON-66
UnsAbbasi2022 Aug 7, 2022
64ebecb
fixed searching and added pages
UnsAbbasi2022 Aug 8, 2022
9cbc142
Merge pull request #25 from UTSCCSCC01/fix-search
UnsAbbasi2022 Aug 8, 2022
d432f21
dockerised marketplace
UnsAbbasi2022 Aug 8, 2022
8d0e0d7
Merge pull request #26 from UTSCCSCC01/dockerise-marketplace
UnsAbbasi2022 Aug 8, 2022
6c1c1af
fixed from name to buid
UnsAbbasi2022 Aug 8, 2022
10f83c0
Merge pull request #27 from UTSCCSCC01/fix-search
UnsAbbasi2022 Aug 8, 2022
a543997
[CON-97] Connected events with CalendarPage
lee00286 Aug 8, 2022
1e87125
[CON-97] Connected event with calendar active jobs
lee00286 Aug 8, 2022
73df542
Merge pull request #29 from UTSCCSCC01/develop
lee00286 Aug 8, 2022
7750683
[CON-97] Update frontend based on backend changes
lee00286 Aug 8, 2022
d7a3ca4
undockerise marketplace
UnsAbbasi2022 Aug 8, 2022
ebe8941
Merge pull request #30 from UTSCCSCC01/undockerise-marketplace
UnsAbbasi2022 Aug 8, 2022
9ce23d9
[CON-97] Update details
lee00286 Aug 8, 2022
9f99294
Merge pull request #31 from UTSCCSCC01/CON-97
lee00286 Aug 8, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions Cognitavit/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,14 @@ node_modules

__pycache__
venv
.venv

# OSX
.DS_Store

build/
dist/

release/app/dist
release/build
.erb/dll
Expand Down
21,397 changes: 11,873 additions & 9,524 deletions Cognitavit/package-lock.json

Large diffs are not rendered by default.

17 changes: 15 additions & 2 deletions Cognitavit/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -78,24 +78,37 @@
}
},
"dependencies": {
"@emotion/react": "^11.10.0",
"@emotion/styled": "^11.10.0",
"@mui/material": "^5.9.3",
"@reduxjs/toolkit": "^1.8.3",
"axios": "^0.27.2",
"bootstrap": "^5.2.0",
"electron-debug": "^3.2.0",
"electron-log": "^4.4.7",
"electron-store": "^8.0.2",
"electron-updater": "^5.0.1",
"i": "^0.3.7",
"node-machine-id": "^1.1.12",
"react": "^18.1.0",
"react-bootstrap": "^2.4.0",
"react-dom": "^18.1.0",
"react-redux": "^8.0.2",
"react-router-dom": "^6.3.0",
"react-scripts": "^2.1.3",
"react-toastify": "^9.0.5"
"react-spinners": "^0.13.3",
"react-toastify": "^9.0.5",
"redux": "^4.2.0",
"socket.io": "^4.5.1",
"socket.io-client": "^4.5.1"
},
"devDependencies": {
"@pmmmwh/react-refresh-webpack-plugin": "^0.5.6",
"@teamsupercell/typings-for-css-modules-loader": "^2.5.1",
"@testing-library/jest-dom": "^5.16.4",
"@testing-library/react": "^13.2.0",
"@types/jest": "^27.5.1",
"@types/node": "17.0.33",
"@types/node": "^17.0.33",
"@types/react": "^18.0.9",
"@types/react-dom": "^18.0.4",
"@types/react-test-renderer": "^18.0.0",
Expand Down
119 changes: 77 additions & 42 deletions Cognitavit/src/executor/core.py
Original file line number Diff line number Diff line change
@@ -1,63 +1,98 @@
from time import sleep
from execFactory import FactoryExecutor
'''
python-electron executor
A tool used to read applet list and execute applications based on name or applet id.

-
This app lifecycle is managed by electron.
Upon startup the follow enviroment variables are set.

def print_list(list):
for item in list:
print(item + " " + list[item])
APPDATA = "path_to_save_data/<userid>/
ie: the path will look like this -> C:/path_to_shared_secret/cognitavit/userid/

inside the userid folder we have the following

#Create factory executor
execute_factory = FactoryExecutor()
#Return an executor object
platform_exec = execute_factory.create('win')
dev = platform_exec.read_native_app_list()
# def native_exec(self, name:str, params:str, exec_app_list:Tuple[dict,dict], app_type:int) -> AppStatus:
Folder content:
/orchestra_webapps: A folder which consists of shortcuts to the actual binaries. [Located in the download folder]
/custom_binaries: A folder which consits of shortcut to bots detail. [Located in random place in drive. (which is why its a shortcut)]
/downloads: A place where downloaded items are stored.
web_app.config: config file of what orchestra web bots are installed.

print_list(dev[0])
print("End of dev0 list")
You may assume that you are already inside the userid/ folder

print_list(dev[1])
print("End of dev1 list")
'''

from platform import platform
from flask import Flask, request, jsonify
from flask_socketio import SocketIO, emit

import json, os, signal

#test a system command
#ps = platform_exec.native_exec("terminal", r" 'shutdown', '/s' ", dev, 0)
#sleep(3)
from engineio.async_drivers import threading

#Regular App
ps = platform_exec.native_exec("chrome", r"https://www.youtube.com/watch?v=dQw4w9WgXcQ", dev, 0)
sleep(3)

#Windows Store App

ps = platform_exec.native_exec("notepad", r"C:\Users\Seron\Desktop\test.txt", dev, 0)
sleep(3)
#Windows Store App
ps = platform_exec.native_exec("player", r"C:\Users\Seron\Desktop\pro_battles.177886dc.mp3", dev, 0)
sleep(3)
import requests
import sys
#Import Routes from network
from network.readApplication import read_app as readApplication
from network.execApplication import exec_app as execApplication
from network.downloadApplication import download_app as downloadApplication
from network.downloadApplication import download_and_install
# To read the enviroment variables

#Windows Store App
ps = platform_exec.native_exec("clock", r"", dev, 0)
sleep(3)

#Installed App
ps = platform_exec.native_exec("discord", r"", dev, 0)
sleep(3)
port_start = 5000

AUTHENiCATION_OBJECT = None
USER_DATA_PATH = None
PlATFORM_START = None
DEVICE_ID = None

#Installed App
ps = platform_exec.native_exec("edge", r"", dev, 0)
sleep(3)
if sys.argv.__len__() > 1:
try:
AUTHENiCATION_OBJECT = sys.argv[1]
except:
print("failed to read json object")
USER_DATA_PATH = sys.argv[2]
PlATFORM_START = sys.argv[3]
DEVICE_ID = sys.argv[4]

#test a system command
ps = platform_exec.native_exec("terminal", r" 'shutdown', '/s' ", dev, 0)
sleep(3)

#cancel the restart
ps = platform_exec.native_exec("terminal", r" 'shutdown', '-a' ", dev, 0)
app = Flask(__name__)
socketio = SocketIO(
app,
async_mode="threading"
)


print(ps)
app.register_blueprint(readApplication)
app.register_blueprint(execApplication)
app.register_blueprint(downloadApplication)

# Import Application flags

@app.route('/is_alive', methods=['POST'])
def alive():
return {"status": True}


@app.route('/kill', methods=['POST'])
def kill():
os.kill(os.getpid(), signal.SIGINT)

@app.route('/enviroment', methods=['POST'])
def enviroment():
return str([AUTHENiCATION_OBJECT, USER_DATA_PATH, PlATFORM_START])

@socketio.event
def connect():
print("I'm connected!")

@socketio.event
def disconnect():
print("Cognitavit disconnected. Im gonna die now.")
os.kill(os.getpid(), signal.SIGINT)

if __name__ == '__main__':
download_and_install()
socketio.run(app,host="0.0.0.0", port=port_start,debug=True)
44 changes: 44 additions & 0 deletions Cognitavit/src/executor/core.spec
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# -*- mode: python ; coding: utf-8 -*-


block_cipher = None


a = Analysis(
['core.py'],
pathex=[],
binaries=[],
datas=[],
hiddenimports=['engineio.async_drivers.eventlet'],
hookspath=[],
hooksconfig={},
runtime_hooks=[],
excludes=[],
win_no_prefer_redirects=False,
win_private_assemblies=False,
cipher=block_cipher,
noarchive=False,
)
pyz = PYZ(a.pure, a.zipped_data, cipher=block_cipher)

exe = EXE(
pyz,
a.scripts,
a.binaries,
a.zipfiles,
a.datas,
[],
name='core',
debug=False,
bootloader_ignore_signals=False,
strip=False,
upx=True,
upx_exclude=[],
runtime_tmpdir=None,
console=True,
disable_windowed_traceback=False,
argv_emulation=False,
target_arch=None,
codesign_identity=None,
entitlements_file=None,
)
34 changes: 32 additions & 2 deletions Cognitavit/src/executor/device_executor/exec.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,17 @@
from abc import ABC, abstractclassmethod
import subprocess
import os, sys
from os import path
import json

AUTHENiCATION_OBJECT = sys.argv[1]
USER_DATA_PATH = sys.argv[2]
DEVICE_ID = sys.argv[4]
userId = AUTHENiCATION_OBJECT
env_userpath = USER_DATA_PATH
CONFIG_NAME = "installed.json"
config_file = path.join(env_userpath, CONFIG_NAME)


class Executor(ABC):

Expand All @@ -20,7 +33,24 @@ def native_exec(self, name:str, params:str, applist:dict) -> None:
'''Executes a native application with optional launch params'''

@abstractclassmethod
def bot_exec(self, params:str) ->None:
'''Executes a bot application from the orchestra webstore'''
def execute(self, name:str, params:str) ->None:
'''Wrapper for native_exec'''


def bot_exec(self, buid:str, args:str):
if (os.path.exists(config_file) == True):
with open(config_file) as f:
data = json.load(f)

for bot in data["installed"]:
if bot["buid"] == buid:
path = bot["path"]
args = args.split() + [path]
#return {"to_run": args}
output = subprocess.Popen(args, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, universal_newlines=True)
outdata = output.stdout.read()
print(outdata, file=sys.stderr)
return {"result": outdata}



60 changes: 51 additions & 9 deletions Cognitavit/src/executor/device_executor/exec_linux.py
Original file line number Diff line number Diff line change
@@ -1,32 +1,74 @@

from device_executor.exec import Executor
import subprocess, os, json
from typing import Tuple

from AppStatus import AppStatus

ERROR = 0
OUTPUT = 1

# Application Binary classification
APPLICATION_LIST = 0 # Regular program [Assume properly registered to start menu]
FALLBACK_LIST = 1 # Regular program + Windows Store Apps [Hidden]

class LinuxExecutor(Executor):


def read_native_app_list(self) -> dict:
''' Returns a list of apps natively installed apps on this machine, alongside the appid.

On success returns a list as {"appname1": "appid1", "appname2": "appid2", "appname3", "appid3"}
Otherwises returns a errorcode
'''
return {}

fall_back_list = {}
# echo '"""{' && find /usr/bin -type f -printf '"%P" : "%p"\n' && echo '}"""'
# echo "\"\"\"{" && find /usr/bin -type f -printf "\"%P\" : \"%p\"\n" && echo "}\"\"\""
c = 'find /usr/bin -type f -printf \"\\"%P\\" : \\"%p\\", \"'
rnc = subprocess.check_output(c, shell=True)
if (len(rnc)): return [json.loads("{" + (rnc.decode('utf-8'))[:-2] + "}"), fall_back_list]
else: return [{}, fall_back_list]

def read_orchestra_app_list(self) -> dict:
''' Returns a list of currently installed bots from the orchestra web store on this machine
along side the binary location. The directory is stored in the userapp storage as a json file.
'''
return {}

def native_exec(self, name:str, params:str, applist: dict) -> None:




def locate_binary(self, name:str, exec_app_list):
'''Returns -1 if binary name cannot be located in app_list. Otherwise return tuple of
appname, and binary location.
Works by doing a char match. name is defined from exec_app_list at earlier point in time.
'''
print("ran")
name = name.lower()
for app in sorted(exec_app_list,key=len):
application_name = app.lower()
if (name == application_name):
return [app, exec_app_list[app]]
return 0

def native_exec(self, name:str, params:str, exec_app_list:Tuple[dict,dict], app_type:int) -> AppStatus:
'''Executes a native application with optional launch params'''
return
ar = self.locate_binary(name, exec_app_list[APPLICATION_LIST]) # app rec
if (not ar):
ar = self.locate_binary(name, exec_app_list[FALLBACK_LIST])
if (not ar):
return -1
print("Binary located @: " + ar[1])
try:
c = ar[0]
if (len(params)):
c += " " + params
subprocess.run(c, shell=True)
return 1
except Exception as e:
return -2

def bot_exec(self, params) -> None:
'''Executes a bot application from the orchestra webstore'''
return {}

def execute(self, name:str, params:str) ->None:
'''Wrapper for native_exec, user does not pass in exec_app_list, but instead the fxn
will generate using one of its built in functions'''
pass
6 changes: 3 additions & 3 deletions Cognitavit/src/executor/device_executor/exec_mac.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,6 @@ def native_exec(self, name:str, params:str, applist: dict) -> None:
'''Executes a native application with optional launch params'''
return

def bot_exec(self, params) -> None:
'''Executes a bot application from the orchestra webstore'''
return {}
def execute(self, name:str, params:str) ->None:
'''Wrapper for native_exec'''
pass
Loading