Skip to content

Commit

Permalink
Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
sscottgvit committed Jun 2, 2021
1 parent a786670 commit bd3993d
Show file tree
Hide file tree
Showing 9 changed files with 134 additions and 54 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -125,4 +125,5 @@ docker/runLocal.sh
docker/cleanupUntagged.sh
docker/cleanupExited.sh

log/*.log
log/*.log
fixname.sh
4 changes: 2 additions & 2 deletions app/ApplicationInfo.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@
applicationInfo = {
"name": "LEGION",
"version": "0.3.7",
"build": '1596220187',
"build": '1622655840',
"author": "GoVanguard",
"copyright": "2020",
"links": ["http://github.com/GoVanguard/legion/issues", "https://GoVanguard.com/legion"],
"emails": [],
"update": '07/31/2020',
"update": '06/02/2021',
"license": "GPL v3",
"desc": "Legion is a fork of SECFORCE's Sparta, Legion is an open source, easy-to-use, \n" +
"super-extensible and semi-automated network penetration testing tool that aids in " +
Expand Down
17 changes: 0 additions & 17 deletions app/importers/__init__.py
Original file line number Diff line number Diff line change
@@ -1,17 +0,0 @@
"""
LEGION (https://govanguard.com)
Copyright (c) 2020 GoVanguard
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public
License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later
version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied
warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
details.
You should have received a copy of the GNU General Public License along with this program.
If not, see <http://www.gnu.org/licenses/>.
Author(s): Dmitriy Dubson (d.dubson@gmail.com)
"""
91 changes: 91 additions & 0 deletions db/postgresDbAdapter.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
"""
LEGION (https://govanguard.io)
Copyright (c) 2019 GoVanguard
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public
License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later
version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied
warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
details.
You should have received a copy of the GNU General Public License along with this program.
If not, see <http://www.gnu.org/licenses/>.
Author(s): Dmitriy Dubson (d.dubson@gmail.com)
"""

from PyQt5.QtCore import QSemaphore
import time
from random import randint

from sqlalchemy import create_engine
from sqlalchemy.orm import sessionmaker
from sqlalchemy.orm.scoping import scoped_session

from app.logging.legionLog import getDbLogger


class Database:
def __init__(self, user: str, passw: str, db: str, host='localhost', port=5432):
from db.database import Base
self.log = getDbLogger()
self.base = Base
try:
self.establishSqliteConnection(user, passw. db. host, port)
except Exception as e:
self.log.error('Could not create SQLite database. Please try again.')
self.log.info(e)

def openDB(self, dbfilename):
try:
self.log.error('Not implemented for Postgres yet.')
except:
self.log.error('Could not open SQLite database file. Is the file corrupted?')

def establishSqliteConnection(self, user: str, passw: str, db: str, host='localhost', port=5432):
self.name = db
self.port = port
self.host = host
self.user = user
self.passw = passw
self.dbsemaphore = QSemaphore(1) # to control concurrent write access to db
url = 'postgresql://{}:{}@{}:{}/{}'
url = url.format(user, password, host, port, db)
# The return value of create_engine() is our connection object
self.engine = sqlalchemy.create_engine(
url, client_encoding='utf8')
# We then bind the connection to MetaData()
#meta = sqlalchemy.MetaData(bind=con, reflect=True)
self.session = scoped_session(sessionmaker())
self.session.configure(bind=self.engine, autoflush=False)
self.metadata = self.base.metadata
self.metadata.create_all(self.engine)
self.metadata.echo = True
self.metadata.bind = self.engine
self.log.info(f"Established SQLite connection on file '{dbFileName}'")

def commit(self):
self.dbsemaphore.acquire()
self.log.debug("DB lock acquired")
try:
session = self.session()
rnd = float(randint(1, 99)) / 100.00
self.log.debug("Waiting {0}s before commit...".format(str(rnd)))
time.sleep(rnd)
session.commit()
except Exception as e:
self.log.error("DB Commit issue")
self.log.error(str(e))
try:
rnd = float(randint(1, 99)) / 100.00
time.sleep(rnd)
self.log.debug("Waiting {0}s before commit...".format(str(rnd)))
session.commit()
except Exception as e:
self.log.error("DB Commit issue on retry")
self.log.error(str(e))
pass
self.dbsemaphore.release()
self.log.debug("DB lock released")
37 changes: 37 additions & 0 deletions fixname.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#!/bin/sh

git filter-branch -f --env-filter '
OLD_NAME="sscottgvit"
OLD_EMAIL="sscottgvit@govanguard.com"
CORRECT_NAME="sscottgvit"
CORRECT_EMAIL="sscott@govanguard.com"
if [ "$GIT_COMMITTER_EMAIL" = "$OLD_EMAIL" ]
then
export GIT_COMMITTER_NAME="$CORRECT_NAME"
export GIT_COMMITTER_EMAIL="$CORRECT_EMAIL"
fi
if [ "$GIT_AUTHOR_EMAIL" = "$OLD_EMAIL" ]
then
export GIT_AUTHOR_NAME="$CORRECT_NAME"
export GIT_AUTHOR_EMAIL="$CORRECT_EMAIL"
fi
if [ "$GIT_AUTHOR_NAME" = "$OLD_NAME" ]
then
export GIT_AUTHOR_NAME="$CORRECT_NAME"
export GIT_AUTHOR_EMAIL="$CORRECT_EMAIL"
fi
if [ "$GIT_COMMITTER_NAME" = "$OLD_NAME" ]
then
export GIT_COMMITTER_NAME="$CORRECT_NAME"
export GIT_COMMITTER_EMAIL="$CORRECT_EMAIL"
fi
#if [ "$GIT_COMMITTER_NAME" != "$GIT_AUTHOR_NAME" ]
#then
# export GIT_AUTHOR_NAME="$GIT_COMMITTER_NAME"
# export GIT_AUTHOR_EMAIL="$GIT_COMMITTER_EMAIL"
#fi
' --tag-name-filter cat -- --branches --tags

git push --force --tags origin 'refs/heads/*'
2 changes: 1 addition & 1 deletion legion.conf
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ store-cleartext-passwords-on-exit=True
username-wordlist-path=/usr/share/wordlists/

[GUISettings]
process-tab-column-widths="125,0,100,150,100,0,100,100,0,0,0,0,0,0,0,481,100"
process-tab-column-widths="125,0,100,150,100,0,100,100,0,0,0,0,0,0,0,483,100"
process-tab-detail=false

[GeneralSettings]
Expand Down
16 changes: 0 additions & 16 deletions parsers/examples/__init__.py
Original file line number Diff line number Diff line change
@@ -1,17 +1 @@
"""
LEGION (https://govanguard.com)
Copyright (c) 2020 GoVanguard

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public
License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later
version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied
warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
details.
You should have received a copy of the GNU General Public License along with this program.
If not, see <http://www.gnu.org/licenses/>.
Author(s): Dmitriy Dubson (d.dubson@gmail.com)
"""
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ aioredis
six>=1.11.0
Quamash>=0.6.1
SQLAlchemy==1.3.0b1
psycopg2
aiomonitor>=0.3.1
APScheduler>=3.5.3
PyQt5==5.11.3
Expand Down
17 changes: 0 additions & 17 deletions ui/models/__init__.py
Original file line number Diff line number Diff line change
@@ -1,17 +0,0 @@
"""
LEGION (https://govanguard.io)
Copyright (c) 2019 GoVanguard
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public
License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later
version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied
warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
details.
You should have received a copy of the GNU General Public License along with this program.
If not, see <http://www.gnu.org/licenses/>.
Author(s): Dmitriy Dubson (d.dubson@gmail.com)
"""

0 comments on commit bd3993d

Please sign in to comment.