Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix and clean Requirements & Add Docker Compose support #149

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
10 changes: 5 additions & 5 deletions API/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ def start_scan():
# Success
msg = {"status" : scanid}
try:
db.scanids.insert({"scanid" : scanid, "name" : name, "url" : url})
db.scanids.insert_one({"scanid" : scanid, "name" : name, "url" : url})
except:
print("Failed to update DB")
else:
Expand Down Expand Up @@ -329,7 +329,7 @@ def get_postman():
return jsonify(msg)
try:
scan_id = generate_hash()
db.scanids.insert({"scanid" : scan_id, "name" : appname, "url" : url})
db.scanids.insert_one({"scanid" : scan_id, "name" : appname, "url" : url})
scan_result = scan_postman_collection(filename,scan_id,auth_token,url)
print(scan_result)
except Exception as e:
Expand All @@ -340,7 +340,7 @@ def get_postman():
return jsonify(msg)
if scan_result == True:
# Update the email notification collection
# db.email.insert({"email" : email, "scanid" : scan_id, "to_email" : email, "email_notification" : 'N'})
# db.email.insert_one({"email" : email, "scanid" : scan_id, "to_email" : email, "email_notification" : 'N'})
msg = {"status" : "Success", "scanid" : scan_id}
else:

Expand Down Expand Up @@ -391,7 +391,7 @@ def scan_postman():
else:
try:
scan_id = generate_hash()
db.scanids.insert({"scanid" : scan_id, "name" : appname, "url" : postman_url,"env_type": env_type, "url" : url,"email" : email})
db.scanids.insert_one({"scanid" : scan_id, "name" : appname, "url" : postman_url,"env_type": env_type, "url" : url,"email" : email})
if ip_result == 1:
scan_result = scan_postman_collection(result,scan_id,url)
else:
Expand All @@ -402,7 +402,7 @@ def scan_postman():

if scan_result == True:
# Update the email notification collection
db.email.insert({"email" : email, "scanid" : scan_id, "to_email" : email, "email_notification" : 'N'})
db.email.insert_one({"email" : email, "scanid" : scan_id, "to_email" : email, "email_notification" : 'N'})
msg = {"status" : "Success", "scanid" : scan_id}
else:
msg = {"status" : "Failed!"}
Expand Down
7 changes: 3 additions & 4 deletions API/dbconnection.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,8 @@
def db_connect():
maxSevSelDelay = 1
try:
mongo_host = 'localhost'
mongo_port = 27017

mongo_host = os.environ.get('MONGO_HOST', 'localhost')
mongo_port = os.environ.get('MONGO_PORT', 27017)
if 'MONGO_PORT_27017_TCP_ADDR' in os.environ :
mongo_host = os.environ['MONGO_PORT_27017_TCP_ADDR']

Expand All @@ -22,4 +21,4 @@ def db_connect():
return client

except ServerSelectionTimeoutError as err:
exit("Failed to connect to MongoDB.")
exit("Failed to connect to MongoDB.")
7 changes: 5 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
FROM python:2-alpine
FROM python:3.8

ENV app /app

RUN mkdir $app
WORKDIR $app
COPY . $app

COPY requirements.txt $app

RUN pip install -r requirements.txt

COPY . $app

WORKDIR API/

EXPOSE 8094
Expand Down
16 changes: 5 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,25 +49,19 @@ $ python3 api.py

## Docker Installation

### Run Mongo Container:

```
$ docker pull mongo
$ docker run --name astra-mongo -d mongo
```

### Installing GUI Docker:
### Installing Mongo & GUI Docker:

```
$ git clone https://github.com/flipkart-incubator/Astra.git
$ cd Astra
$ docker build -t astra .
$ docker run --rm -it --link astra-mongo:mongo -p 8094:8094 astra
$ docker-compose up -d --build
```

### Installing CLI Docker :
### Installing CLI-only Docker :

```
$ docker pull mongo
$ docker run --name astra-mongo -d mongo
$ git clone -b docker-cli https://github.com/flipkart-incubator/Astra.git
$ cd Astra
$ docker build -t astra-cli .
Expand Down
19 changes: 19 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
version: '3'

services:
astra-mongo:
image: "mongo"
container_name: "astra-mongo"
restart: unless-stopped

astra-gui:
build: .
image: "astra"
container_name: "astra-gui"
ports:
- "8094:8094"
environment:
MONGO_HOST: astra-mongo
depends_on:
- astra-mongo
restart: unless-stopped
79 changes: 5 additions & 74 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,79 +1,10 @@
amqp==5.1.1
APScheduler==3.9.1.post1
billiard==3.6.4.0
celery==5.2.7
certifi
chardet==3.0.4
charset-normalizer==2.1.1
click==8.1.3
click-didyoumean==0.3.0
click-plugins==1.1.1
click-repl==0.2.0
Flask==2.2.2
idna==2.8
importlib-metadata==5.0.0
itsdangerous==2.1.2
Jinja2==3.0.3
kombu==5.2.4
MarkupSafe==2.1.1
prompt-toolkit==3.0.33
PyJWT==2.6.0
pymongo==3.13.0
pytz==2022.6
pytz-deprecation-shim==0.1.0.post0
requests==2.28.1
six==1.16.0
sqlmap==1.6.10
tzdata==2022.7
tzlocal==4.2
urllib3==1.24.3
vine==5.0.0
wcwidth==0.2.5
Werkzeug==2.2.2
zipp==3.10.0
requests
logger
pymongo
pymongo==3.13.0
ConfigParser
pyjwt
flask
sqlmapamqp==5.1.1
APScheduler==3.9.1.post1
billiard==3.6.4.0
celery==5.2.7
certifi
chardet==3.0.4
charset-normalizer==2.1.1
click==8.1.3
click-didyoumean==0.3.0
click-plugins==1.1.1
click-repl==0.2.0
Flask==2.2.2
idna==2.8
importlib-metadata==5.0.0
itsdangerous==2.1.2
Jinja2==3.0.3
kombu==5.2.4
MarkupSafe==2.1.1
prompt-toolkit==3.0.33
PyJWT==2.6.0
pymongo==3.13.0
pytz==2022.6
pytz-deprecation-shim==0.1.0.post0
requests==2.28.1
six==1.16.0
sqlmap==1.6.10
tzdata==2022.7
tzlocal==4.2
urllib3==1.24.3
vine==5.0.0
wcwidth==0.2.5
Werkzeug==2.2.2
zipp==3.10.0
Flask==2.2.2
Jinja2==3.0.3
PyJWT==2.6.0
pymongo==3.13.0
requests==2.28.1
sqlmap==1.7
apscheduler
sqlmap
celery
reportlab
APScheduler
10 changes: 5 additions & 5 deletions utils/db.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
class Database_update:
def __init__(self):
# Mongo DB connection
mongo_host = 'localhost'
mongo_port = 27017
mongo_host = os.environ.get('MONGO_HOST', 'localhost')
mongo_port = os.environ.get('MONGO_PORT', 27017)

maxSevSelDelay = 1

if 'MONGO_PORT_27017_TCP_ADDR' in os.environ :
Expand All @@ -28,7 +28,7 @@ def fetch_records(self):

def insert_record(self,data):
try:
self.db.vulnerabilities.insert(data)
self.db.vulnerabilities.insert_one(data)
except Exception as e:
raise e

Expand All @@ -42,4 +42,4 @@ def update_scan_record(self,find,update):
try:
self.db.scanids.update(find,update)
except Exception as e:
raise e
raise e