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

Add dev containers. #136

Closed
wants to merge 3 commits into from
Closed
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
14 changes: 14 additions & 0 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
FROM mcr.microsoft.com/devcontainers/python:0-3.11

ENV app /app

RUN mkdir $app
WORKDIR $app
COPY requirements.txt $app

RUN pip install -r requirements.txt && rm requirements.txt
WORKDIR $app/API/

EXPOSE 8094
CMD ["tail -f /app/logs/scan.log"]

26 changes: 26 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// For format details, see https://aka.ms/devcontainer.json. For config options, see the
// README at: https://github.com/devcontainers/templates/tree/main/src/python
{
"name": "Python 3",
// Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile
"dockerComposeFile": "docker-compose.yml",
"service": "devcontainer",

// "workspaceMount": "source=${localWorkspaceFolder},target=/app,type=bind",
"workspaceFolder": "/app"

// Features to add to the dev container. More info: https://containers.dev/features.
// "features": {},

// Use 'forwardPorts' to make a list of ports inside the container available locally.
// "forwardPorts": [],

// Use 'postCreateCommand' to run commands after the container is created.
// "postCreateCommand": "pip3 install --user -r requirements.txt",

// Configure tool-specific properties.
// "customizations": {},

// Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root.
// "remoteUser": "root"
}
24 changes: 24 additions & 0 deletions .devcontainer/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
version: '3.8'

services:
devcontainer:
build:
context: "../"
dockerfile: "./.devcontainer/Dockerfile"
volumes:
- ../:/app
command: sleep infinity
depends_on: [ "mongo" ]

mongo:
image: mongo
restart: unless-stopped
healthcheck:
test: [ "CMD", "bash", "-c", "echo 'db.runCommand(\"ping\").ok' | mongosh --quiet" ]
interval: 10s
timeout: 5s
retries: 4
start_period: 1s

rabbit:
image: rabbitmq:3
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@

.idea/
venv/
/logs/scan.log
23 changes: 23 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"command": "celery -A celery_app worker --loglevel=INFO",
"name": "Start worker",
"request": "launch",
"type": "node-terminal"
},
{
"name": "Start python api",
"type": "python",
"request": "launch",
"cwd": "${workspaceFolder}/API/",
"program": "${workspaceFolder}/API/api.py",
"console": "integratedTerminal",
"justMyCode": true
}
]
}
2 changes: 1 addition & 1 deletion 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
2 changes: 1 addition & 1 deletion API/dbconnection.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
def db_connect():
maxSevSelDelay = 1
try:
mongo_host = 'localhost'
mongo_host = 'mongo'
mongo_port = 27017

if 'MONGO_PORT_27017_TCP_ADDR' in os.environ :
Expand Down
16 changes: 0 additions & 16 deletions Dockerfile

This file was deleted.

11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,17 @@ $ docker build -t astra-cli .
$ docker run --rm -it --link astra-mongo:mongo astra-cli
```

## Vscode

> Enable docker-compose v2 for --wait support on the docker compose up command, allowing waiting for health checks.

Open the repository directory root in Visual Studio Code, click the prompt to open the container or issue the following command:

```
> Dev Containers: Rebuild container
```


## Dependencies

```
Expand Down
2 changes: 1 addition & 1 deletion celery_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import os

sys.path.append(os.getcwd())
app = Celery('celery_app', broker='amqp://guest@localhost//')
app = Celery('celery_app', broker='amqp://guest@rabbit//')
# app.conf.task_serializer = 'pickle'
# app.conf.result_serializer = 'pickle'
# app.conf.accept_content = ['application/json', 'application/x-python-serialize']
Expand Down
4,101 changes: 0 additions & 4,101 deletions logs/scan.log

This file was deleted.

89 changes: 10 additions & 79 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
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
requests
logger
pymongo==3.13.0
ConfigParser
pyjwt
flask
sqlmap
celery
reportlab
APScheduler
4 changes: 2 additions & 2 deletions utils/db.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
class Database_update:
def __init__(self):
# Mongo DB connection
mongo_host = 'localhost'
mongo_host = 'mongo'
mongo_port = 27017

maxSevSelDelay = 1
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 Down