Skip to content

Commit

Permalink
Revert "Complete dev environment to debug/code easily (#1196)"
Browse files Browse the repository at this point in the history
This reverts commit 2c9e250.
  • Loading branch information
yogeshojha authored Apr 1, 2024
1 parent 2c9e250 commit bc92e99
Show file tree
Hide file tree
Showing 16 changed files with 32 additions and 322 deletions.
35 changes: 0 additions & 35 deletions .vscode/launch.json

This file was deleted.

11 changes: 0 additions & 11 deletions .vscode/tasks-and-contexts.json

This file was deleted.

14 changes: 0 additions & 14 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@
COMPOSE_PREFIX_CMD := COMPOSE_DOCKER_CLI_BUILD=1

COMPOSE_ALL_FILES := -f docker-compose.yml
COMPOSE_DEV_ALL_FILES := -f docker-compose.dev.yml
SERVICES := db web proxy redis celery celery-beat
SERVICES_DEV := db web proxy redis celery celery-beat

# --------------------------

Expand Down Expand Up @@ -60,15 +58,3 @@ prune: ## Remove containers and delete volume data.
help: ## Show this help.
@echo "Make application docker images and manage containers using docker-compose files."
@awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n make \033[36m<target>\033[0m (default: help)\n\nTargets:\n"} /^[a-zA-Z_-]+:.*?##/ { printf " \033[36m%-12s\033[0m %s\n", $$1, $$2 }' $(MAKEFILE_LIST)

dev_build: ## Build all services.
${COMPOSE_PREFIX_CMD} docker-compose ${COMPOSE_DEV_ALL_FILES} build ${SERVICES_DEV}

dev_up: ## Build and start all services.
${COMPOSE_PREFIX_CMD} docker-compose ${COMPOSE_DEV_ALL_FILES} up -d --build ${SERVICES_DEV}

dev_down: ## Down all services.
${COMPOSE_PREFIX_CMD} docker-compose ${COMPOSE_DEV_ALL_FILES} down

dev_logs: ## Tail all logs with -n 1000.
${COMPOSE_PREFIX_CMD} docker-compose $(COMPOSE_DEV_ALL_FILES) logs --follow --tail=1000 ${SERVICES_DEV}
33 changes: 0 additions & 33 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -412,39 +412,6 @@ See the [Contributing Guide](.github/CONTRIBUTING.md) to get started.

You can also [join our Discord channel #development](https://discord.gg/JuhHdHTtwd) for any development related questions.

### Submitting issues

You can submit issues related to this project, but you should do it in a way that helps developers to resolve it as quickly as possible.

For that, you need to add as much valuable information as possible.

You can have this valuable information by following these steps:

- Go to the root of the git cloned project
- Shutdown you current production instance by launching `make down`
- Launch the dev environment by launching `make dev_up`
- Then you can start `make logs` and run into your issue, you should have more detailed log (stack trace ...)
- To deactivate the dev environment, run `make dev_down`, then restart the prod with `make up`

Example with the tool arsenal version check API bug.

```
web_1 | File "/usr/local/lib/python3.10/dist-packages/celery/app/task.py", line 411, in __call__
web_1 | return self.run(*args, **kwargs)
web_1 | TypeError: run_command() got an unexpected keyword argument 'echo'
```
Now you know the real error is `TypeError: run_command() got an unexpected keyword argument 'echo'`
And you can post the full stack trace to your newly created issue to help developers to track the root cause of the bug and correct the bug easily
**Activating debug like this also give you the Django Debug Toolbar on the left side & full stack trace in the browser** instead of an error 500 without any details.
So don't forget to open the developer console and check for any XHR request with error 500.
If there's any, check the response of this request to get your detailed error.
<img src="https://user-images.githubusercontent.com/1230954/276260955-ed1e1168-7c8f-43a3-b54d-b6285d52b771.png">
Happy issuing ;)
![-----------------------------------------------------](https://raw.githubusercontent.com/andreasbm/readme/master/assets/lines/aqua.png)

### First-time Open Source contributors
Expand Down
59 changes: 7 additions & 52 deletions docker-compose.dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ services:
networks:
- rengine_network
ports:
- "127.0.0.1:5432:5432"
- "5432:5432"

redis:
image: "redis:alpine"
Expand All @@ -26,7 +26,8 @@ services:
build:
context: ./web
restart: always
entrypoint: /usr/src/app/celery-entrypoint-dev.sh
entrypoint: /usr/src/app/celery-entrypoint.sh
# command: watchmedo auto-restart --recursive --pattern="*.py" --directory="/usr/src/app/reNgine/" -- celery -A reNgine.tasks worker --autoscale=10,0 -l INFO
volumes:
- ./web:/usr/src/app
- github_repos:/usr/src/github
Expand All @@ -35,11 +36,8 @@ services:
- gf_patterns:/root/.gf
- nuclei_templates:/root/nuclei-templates
- tool_config:/root/.config
- static_volume:/usr/src/app/staticfiles/
environment:
- DEBUG=1
- REMOTE_DEBUG=0
- REMOTE_DEBUG_PORT=5679
- CELERY_BROKER=redis://redis:6379/0
- CELERY_BACKEND=redis://redis:6379/0
- DOMAIN_NAME=${DOMAIN_NAME}
Expand All @@ -50,8 +48,6 @@ services:
- POSTGRES_HOST=${POSTGRES_HOST}
- MAX_CONCURRENCY=${MAX_CONCURRENCY}
- MIN_CONCURRENCY=${MIN_CONCURRENCY}
ports:
- "127.0.0.1:5679:5679"
depends_on:
- db
- redis
Expand All @@ -60,8 +56,10 @@ services:

celery-beat:
build: ./web
entrypoint: /usr/src/app/beat-entrypoint-dev.sh
entrypoint: /usr/src/app/beat-entrypoint.sh
command: celery -A reNgine beat -l INFO --scheduler django_celery_beat.schedulers:DatabaseScheduler
depends_on:
- celery
environment:
- DEBUG=1
- CELERY_BROKER=redis://redis:6379/0
Expand All @@ -71,8 +69,6 @@ services:
- POSTGRES_PASSWORD=${POSTGRES_PASSWORD}
- POSTGRES_PORT=${POSTGRES_PORT}
- POSTGRES_HOST=${POSTGRES_HOST}
depends_on:
- celery
volumes:
- ./web:/usr/src/app
- github_repos:/usr/src/github
Expand All @@ -87,13 +83,11 @@ services:
web:
build:
context: ./web
entrypoint: /usr/src/app/entrypoint-dev.sh
entrypoint: /usr/src/app/entrypoint.sh
restart: always
image: docker.pkg.github.com/yogeshojha/rengine/rengine:latest
environment:
- DEBUG=1
- REMOTE_DEBUG=0
- REMOTE_DEBUG_PORT=5678
- CELERY_BROKER=redis://redis:6379/0
- CELERY_BACKEND=redis://redis:6379/0
- DOMAIN_NAME=${DOMAIN_NAME}
Expand All @@ -113,47 +107,17 @@ services:
- gf_patterns:/root/.gf
- nuclei_templates:/root/nuclei-templates
- tool_config:/root/.config
- static_volume:/usr/src/app/staticfiles
ports:
- "8000:8000"
- "127.0.0.1:5678:5678"
depends_on:
- db
- celery
- celery-beat
networks:
rengine_network:
aliases:
- rengine

proxy:
restart: always
image: nginx:alpine
ports:
- 8082:8082/tcp
- 443:443/tcp
depends_on:
- web
- db
- redis
secrets:
- source: proxy.ca
target: /etc/nginx/certs/rengine_chain.pem
- source: proxy.cert
target: /etc/nginx/certs/rengine.pem
- source: proxy.key
target: /etc/nginx/certs/rengine_rsa.key
volumes:
- ./config/nginx/rengine.conf:/etc/nginx/conf.d/rengine.conf:ro
- static_volume:/usr/src/app/staticfiles
- scan_results:/usr/src/scan_results
networks:
- rengine_network


networks:
rengine_network:

volumes:
tool_config:
postgres_data:
Expand All @@ -162,12 +126,3 @@ volumes:
github_repos:
wordlist:
scan_results:
static_volume:

secrets:
proxy.ca:
file: ./secrets/certs/rengine_chain.pem
proxy.key:
file: ./secrets/certs/rengine_rsa.key
proxy.cert:
file: ./secrets/certs/rengine.pem
2 changes: 2 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ services:
- tool_config:/root/.config
- static_volume:/usr/src/app/staticfiles/
environment:
- DEBUG=0
- CELERY_BROKER=redis://redis:6379/0
- CELERY_BACKEND=redis://redis:6379/0
- DOMAIN_NAME=${DOMAIN_NAME}
Expand Down Expand Up @@ -84,6 +85,7 @@ services:
restart: always
image: docker.pkg.github.com/yogeshojha/rengine/rengine:latest
environment:
- DEBUG=0
- CELERY_BROKER=redis://redis:6379/0
- CELERY_BACKEND=redis://redis:6379/0
- DOMAIN_NAME=${DOMAIN_NAME}
Expand Down
17 changes: 0 additions & 17 deletions web/beat-entrypoint-dev.sh

This file was deleted.

22 changes: 0 additions & 22 deletions web/celery-entrypoint-dev.sh

This file was deleted.

45 changes: 21 additions & 24 deletions web/celery-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -162,32 +162,29 @@ exec "$@"
# httpx seems to have issue, use alias instead!!!
echo 'alias httpx="/go/bin/httpx"' >> ~/.bashrc

if [ ! "$CELERY_LOGLEVEL" ]; then
export CELERY_LOGLEVEL='info'
fi

# watchmedo auto-restart --recursive --pattern="*.py" --directory="/usr/src/app/reNgine/" -- celery -A reNgine.tasks worker --autoscale=10,0 -l INFO -Q scan_queue &
echo "Starting Workers..."
echo "Starting Main Scan Worker with Concurrency: $MAX_CONCURRENCY,$MIN_CONCURRENCY"
watchmedo auto-restart --recursive --pattern="*.py" --directory="/usr/src/app/reNgine/" -- celery -A reNgine.tasks worker --loglevel=$CELERY_LOGLEVEL --autoscale=$MAX_CONCURRENCY,$MIN_CONCURRENCY -Q main_scan_queue &
watchmedo auto-restart --recursive --pattern="*.py" --directory="/usr/src/app/reNgine/" -- celery -A reNgine.tasks worker --pool=gevent --concurrency=30 --loglevel=$CELERY_LOGLEVEL -Q initiate_scan_queue -n initiate_scan_worker &
watchmedo auto-restart --recursive --pattern="*.py" --directory="/usr/src/app/reNgine/" -- celery -A reNgine.tasks worker --pool=gevent --concurrency=30 --loglevel=$CELERY_LOGLEVEL -Q subscan_queue -n subscan_worker &
watchmedo auto-restart --recursive --pattern="*.py" --directory="/usr/src/app/reNgine/" -- celery -A reNgine.tasks worker --pool=gevent --concurrency=20 --loglevel=$CELERY_LOGLEVEL -Q report_queue -n report_worker &
watchmedo auto-restart --recursive --pattern="*.py" --directory="/usr/src/app/reNgine/" -- celery -A reNgine.tasks worker --pool=gevent --concurrency=10 --loglevel=$CELERY_LOGLEVEL -Q send_notif_queue -n send_notif_worker &
watchmedo auto-restart --recursive --pattern="*.py" --directory="/usr/src/app/reNgine/" -- celery -A reNgine.tasks worker --pool=gevent --concurrency=10 --loglevel=$CELERY_LOGLEVEL -Q send_scan_notif_queue -n send_scan_notif_worker &
watchmedo auto-restart --recursive --pattern="*.py" --directory="/usr/src/app/reNgine/" -- celery -A reNgine.tasks worker --pool=gevent --concurrency=10 --loglevel=$CELERY_LOGLEVEL -Q send_task_notif_queue -n send_task_notif_worker &
watchmedo auto-restart --recursive --pattern="*.py" --directory="/usr/src/app/reNgine/" -- celery -A reNgine.tasks worker --pool=gevent --concurrency=5 --loglevel=$CELERY_LOGLEVEL -Q send_file_to_discord_queue -n send_file_to_discord_worker &
watchmedo auto-restart --recursive --pattern="*.py" --directory="/usr/src/app/reNgine/" -- celery -A reNgine.tasks worker --pool=gevent --concurrency=5 --loglevel=$CELERY_LOGLEVEL -Q send_hackerone_report_queue -n send_hackerone_report_worker &
watchmedo auto-restart --recursive --pattern="*.py" --directory="/usr/src/app/reNgine/" -- celery -A reNgine.tasks worker --pool=gevent --concurrency=10 --loglevel=$CELERY_LOGLEVEL -Q parse_nmap_results_queue -n parse_nmap_results_worker &
watchmedo auto-restart --recursive --pattern="*.py" --directory="/usr/src/app/reNgine/" -- celery -A reNgine.tasks worker --pool=gevent --concurrency=20 --loglevel=$CELERY_LOGLEVEL -Q geo_localize_queue -n geo_localize_worker &
watchmedo auto-restart --recursive --pattern="*.py" --directory="/usr/src/app/reNgine/" -- celery -A reNgine.tasks worker --pool=gevent --concurrency=10 --loglevel=$CELERY_LOGLEVEL -Q query_whois_queue -n query_whois_worker &
watchmedo auto-restart --recursive --pattern="*.py" --directory="/usr/src/app/reNgine/" -- celery -A reNgine.tasks worker --pool=gevent --concurrency=30 --loglevel=$CELERY_LOGLEVEL -Q remove_duplicate_endpoints_queue -n remove_duplicate_endpoints_worker &
watchmedo auto-restart --recursive --pattern="*.py" --directory="/usr/src/app/reNgine/" -- celery -A reNgine.tasks worker --pool=gevent --concurrency=50 --loglevel=$CELERY_LOGLEVEL -Q run_command_queue -n run_command_worker &
watchmedo auto-restart --recursive --pattern="*.py" --directory="/usr/src/app/reNgine/" -- celery -A reNgine.tasks worker --pool=gevent --concurrency=10 --loglevel=$CELERY_LOGLEVEL -Q query_reverse_whois_queue -n query_reverse_whois_worker &
watchmedo auto-restart --recursive --pattern="*.py" --directory="/usr/src/app/reNgine/" -- celery -A reNgine.tasks worker --pool=gevent --concurrency=10 --loglevel=$CELERY_LOGLEVEL -Q query_ip_history_queue -n query_ip_history_worker &
watchmedo auto-restart --recursive --pattern="*.py" --directory="/usr/src/app/reNgine/" -- celery -A reNgine.tasks worker --pool=gevent --concurrency=30 --loglevel=$CELERY_LOGLEVEL -Q gpt_queue -n gpt_worker &
watchmedo auto-restart --recursive --pattern="*.py" --directory="/usr/src/app/reNgine/" -- celery -A reNgine.tasks worker --pool=gevent --concurrency=10 --loglevel=$CELERY_LOGLEVEL -Q dorking_queue -n dorking_worker &
watchmedo auto-restart --recursive --pattern="*.py" --directory="/usr/src/app/reNgine/" -- celery -A reNgine.tasks worker --pool=gevent --concurrency=10 --loglevel=$CELERY_LOGLEVEL -Q osint_discovery_queue -n osint_discovery_worker &
watchmedo auto-restart --recursive --pattern="*.py" --directory="/usr/src/app/reNgine/" -- celery -A reNgine.tasks worker --pool=gevent --concurrency=10 --loglevel=$CELERY_LOGLEVEL -Q h8mail_queue -n h8mail_worker &
watchmedo auto-restart --recursive --pattern="*.py" --directory="/usr/src/app/reNgine/" -- celery -A reNgine.tasks worker --pool=gevent --concurrency=10 --loglevel=$CELERY_LOGLEVEL -Q theHarvester_queue -n theHarvester_worker
watchmedo auto-restart --recursive --pattern="*.py" --directory="/usr/src/app/reNgine/" -- celery -A reNgine.tasks worker --loglevel=info --autoscale=$MAX_CONCURRENCY,$MIN_CONCURRENCY -Q main_scan_queue &
watchmedo auto-restart --recursive --pattern="*.py" --directory="/usr/src/app/reNgine/" -- celery -A reNgine.tasks worker --pool=gevent --concurrency=30 --loglevel=info -Q initiate_scan_queue -n initiate_scan_worker &
watchmedo auto-restart --recursive --pattern="*.py" --directory="/usr/src/app/reNgine/" -- celery -A reNgine.tasks worker --pool=gevent --concurrency=30 --loglevel=info -Q subscan_queue -n subscan_worker &
watchmedo auto-restart --recursive --pattern="*.py" --directory="/usr/src/app/reNgine/" -- celery -A reNgine.tasks worker --pool=gevent --concurrency=20 --loglevel=info -Q report_queue -n report_worker &
watchmedo auto-restart --recursive --pattern="*.py" --directory="/usr/src/app/reNgine/" -- celery -A reNgine.tasks worker --pool=gevent --concurrency=10 --loglevel=info -Q send_notif_queue -n send_notif_worker &
watchmedo auto-restart --recursive --pattern="*.py" --directory="/usr/src/app/reNgine/" -- celery -A reNgine.tasks worker --pool=gevent --concurrency=10 --loglevel=info -Q send_scan_notif_queue -n send_scan_notif_worker &
watchmedo auto-restart --recursive --pattern="*.py" --directory="/usr/src/app/reNgine/" -- celery -A reNgine.tasks worker --pool=gevent --concurrency=10 --loglevel=info -Q send_task_notif_queue -n send_task_notif_worker &
watchmedo auto-restart --recursive --pattern="*.py" --directory="/usr/src/app/reNgine/" -- celery -A reNgine.tasks worker --pool=gevent --concurrency=5 --loglevel=info -Q send_file_to_discord_queue -n send_file_to_discord_worker &
watchmedo auto-restart --recursive --pattern="*.py" --directory="/usr/src/app/reNgine/" -- celery -A reNgine.tasks worker --pool=gevent --concurrency=5 --loglevel=info -Q send_hackerone_report_queue -n send_hackerone_report_worker &
watchmedo auto-restart --recursive --pattern="*.py" --directory="/usr/src/app/reNgine/" -- celery -A reNgine.tasks worker --pool=gevent --concurrency=10 --loglevel=info -Q parse_nmap_results_queue -n parse_nmap_results_worker &
watchmedo auto-restart --recursive --pattern="*.py" --directory="/usr/src/app/reNgine/" -- celery -A reNgine.tasks worker --pool=gevent --concurrency=20 --loglevel=info -Q geo_localize_queue -n geo_localize_worker &
watchmedo auto-restart --recursive --pattern="*.py" --directory="/usr/src/app/reNgine/" -- celery -A reNgine.tasks worker --pool=gevent --concurrency=10 --loglevel=info -Q query_whois_queue -n query_whois_worker &
watchmedo auto-restart --recursive --pattern="*.py" --directory="/usr/src/app/reNgine/" -- celery -A reNgine.tasks worker --pool=gevent --concurrency=30 --loglevel=info -Q remove_duplicate_endpoints_queue -n remove_duplicate_endpoints_worker &
watchmedo auto-restart --recursive --pattern="*.py" --directory="/usr/src/app/reNgine/" -- celery -A reNgine.tasks worker --pool=gevent --concurrency=50 --loglevel=info -Q run_command_queue -n run_command_worker &
watchmedo auto-restart --recursive --pattern="*.py" --directory="/usr/src/app/reNgine/" -- celery -A reNgine.tasks worker --pool=gevent --concurrency=10 --loglevel=info -Q query_reverse_whois_queue -n query_reverse_whois_worker &
watchmedo auto-restart --recursive --pattern="*.py" --directory="/usr/src/app/reNgine/" -- celery -A reNgine.tasks worker --pool=gevent --concurrency=10 --loglevel=info -Q query_ip_history_queue -n query_ip_history_worker &
watchmedo auto-restart --recursive --pattern="*.py" --directory="/usr/src/app/reNgine/" -- celery -A reNgine.tasks worker --pool=gevent --concurrency=30 --loglevel=info -Q gpt_queue -n gpt_worker &
watchmedo auto-restart --recursive --pattern="*.py" --directory="/usr/src/app/reNgine/" -- celery -A reNgine.tasks worker --pool=gevent --concurrency=10 --loglevel=info -Q dorking_queue -n dorking_worker &
watchmedo auto-restart --recursive --pattern="*.py" --directory="/usr/src/app/reNgine/" -- celery -A reNgine.tasks worker --pool=gevent --concurrency=10 --loglevel=info -Q osint_discovery_queue -n osint_discovery_worker &
watchmedo auto-restart --recursive --pattern="*.py" --directory="/usr/src/app/reNgine/" -- celery -A reNgine.tasks worker --pool=gevent --concurrency=10 --loglevel=info -Q h8mail_queue -n h8mail_worker &
watchmedo auto-restart --recursive --pattern="*.py" --directory="/usr/src/app/reNgine/" -- celery -A reNgine.tasks worker --pool=gevent --concurrency=10 --loglevel=info -Q theHarvester_queue -n theHarvester_worker
exec "$@"
4 changes: 0 additions & 4 deletions web/dashboard/urls.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from django.contrib import admin
from django.urls import include, path
from reNgine.settings import DEBUG

from . import views

Expand Down Expand Up @@ -42,6 +41,3 @@
views.delete_project,
name='delete_project'),
]

if DEBUG:
urlpatterns.append(path("__debug__/", include("debug_toolbar.urls")))
Loading

0 comments on commit bc92e99

Please sign in to comment.