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

Version 5.0.0 #524

Merged
merged 34 commits into from
Dec 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
2f64957
add layout to config, export config with orjson
stitch Jun 24, 2024
ec2e90c
remove internet.nl references in the backend templates
stitch Jul 1, 2024
c2dc5e5
optimize some installation steps
stitch Jul 5, 2024
4fb6ea1
add default policy and scan configuration
stitch Jul 5, 2024
e0052b9
add missing scan config
stitch Jul 5, 2024
ac228c5
update update installation steps
stitch Jul 8, 2024
1951933
Remove old compose file
aequitas Jul 3, 2024
5d10af1
Generate encryption keys
aequitas Jul 3, 2024
df5f596
Add Compose file
aequitas Jul 3, 2024
62f5b04
support old docker compose workflow in intermediate builds
stitch Jul 8, 2024
4187600
fix lint, cannot use custom dockerfile
stitch Jul 8, 2024
642397a
fix binary mode doesnt take an encoding argument
stitch Jul 8, 2024
1e9f3ba
latest fixes to docs
stitch Jul 8, 2024
3a1feb0
fix missing chapter
stitch Jul 8, 2024
f7d7f04
use development defaults for internetnl docker instance, add default …
stitch Jul 17, 2024
b8035dd
remove unused field name
stitch Jul 17, 2024
121ce54
split account creation
stitch Jul 17, 2024
7fa3c30
suppress false positive warning
stitch Jul 18, 2024
7fd11e8
allow scanning on servfail, fix duplicate endpoints
stitch Jul 18, 2024
acbe547
fix inconsistency in requirements
stitch Aug 12, 2024
f8c43d7
add movie and installation instructions in readme
stitch Aug 12, 2024
8586588
add translation option
stitch Nov 11, 2024
beac9c6
ignore github codeql warning
stitch Nov 11, 2024
af95d95
fix fixtures and add test to verify
stitch Nov 12, 2024
c3786c3
fix deprecation warnings in migrations
stitch Nov 12, 2024
1c111b1
move towards indexes with fixed names, solving a deprecation warning
stitch Nov 12, 2024
de834c1
Add UWSGI_CHEAPER 0 to Dockerfile
stitch Nov 12, 2024
e0b9d83
Updated requirements.
stitch Nov 12, 2024
9c9032c
re-lint and add black linter for more linting
stitch Nov 12, 2024
fedd4e9
add #540, prevent starting scans when credentials are not correct, pe…
stitch Nov 12, 2024
ec77713
add vite server default port for development, remove old development …
stitch Dec 11, 2024
0011f9a
incorporate new linting, restore jet sidemenu
stitch Dec 11, 2024
3173909
make timing test easier to pass
stitch Dec 11, 2024
66c0730
disable testcase due to not enough people looking west at the same time
stitch Dec 11, 2024
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
2 changes: 2 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ USER root
ENV UWSGI_GID root
ENV UWSGI_UID root
ENV UWSGI_MODULE dashboard.wsgi
# Fix uwsgi "invalid cheaper value: must be lower than processes", see #495.
ENV UWSGI_CHEAPER 0
# serve static files (to caching proxy) from collected/generated static files
ENV UWSGI_STATIC_MAP /static=/srv/dashboard/static
# set proxy and browser caching for static files to 1 month
Expand Down
2 changes: 2 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ pylama: ${pysrc} ${app}
# check code quality
${env} pylama ${pysrcdirs} --skip "**/migrations/*"


shellcheck: ${shsrc}
# shell script checks (if installed)
if command -v shellcheck &>/dev/null && ! test -z "${shsrc}";then ${env} shellcheck ${shsrc}; fi
Expand All @@ -143,6 +144,7 @@ autofix fix: ${pysrc} ${app} ## automatic fix of trivial code quality issues
${env} autoflake -ri --remove-all-unused-imports ${pysrcdirs}
# sort imports
${env} isort -rc ${pysrcdirs}
black .
# do a check after autofixing to show remaining problems
${MAKE} check

Expand Down
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
For quick installation: Follow [these quick instructions](https://github.com/internetstandards/Internet.nl-dashboard/blob/50/docs/render/markdown/1_installation.md)
and watch [this 6 minute video](https://github.com/internetstandards/Internet.nl-dashboard/tree/50/docs/input/internet.nl%20dashboard%20installation%20video%20small.mp4).

# Internet.nl Dashboard
The internet.nl dashboard allows you to visualize batch scans from the internet.nl API. It allows:

Expand All @@ -13,6 +16,12 @@ The internet.nl dashboard allows you to visualize batch scans from the internet.
- Second factor authentication
- Seamless internet.nl API integration

## Setup / installation

For quick installation: Follow [these quick instructions](https://github.com/internetstandards/Internet.nl-dashboard/blob/50/docs/render/markdown/1_installation.md)
and watch [this 6 minute video](https://github.com/internetstandards/Internet.nl-dashboard/tree/50/docs/input/internet.nl%20dashboard%20installation%20video%20small.mp4).


## Screenshots

Some screenshots can be found at: https://dashboard.internet.nl/#/tour
Expand Down
124 changes: 124 additions & 0 deletions compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
services:
backend:
image: ${DOCKER_IMAGE_DASHBOARD:-${DOCKER_REGISTRY:-internetstandards}/dashboard:${RELEASE:-latest}}
build: .
command: dashboard_prdserver --migrate
# TODO: check if needed: --security-opt seccomp=unconfined
environment:
SECRET_KEY_FILE: /etc/django_keys/secret_key
FIELD_ENCRYPTION_KEY_FILE: /etc/django_keys/field_encryption_key
ALLOWED_HOSTS: "*"
UWSGI_HARAKIRI: 3600
DJANGO_DATABASE: production
DB_ENGINE: postgresql_psycopg2
DB_HOST: database
WORKER_ROLE: default
BROKER: redis://broker:6379/0
SENTRY_DSN:
DASHBOARD_FRONTEND_URL:
networks:
dashboard:
volumes:
- dashboard-frontend-uploads:/source/dashboard/uploads
- django-keys:/etc/django_keys/
healthcheck:
interval: 60s

frontend:
image: ${DOCKER_IMAGE_DASHBOARD_STATIC:-${DOCKER_REGISTRY:-internetstandards}/dashboard-static:${RELEASE:-latest}}
build: https://github.com/internetstandards/Internet.nl-dashboard-frontend.git
networks:
dashboard:
healthcheck:
interval: 60s
volumes:
- dashboard-frontend-uploads:/source/dashboard/uploads

worker: &worker
image: ${DOCKER_IMAGE_DASHBOARD:-${DOCKER_REGISTRY:-internetstandards}/dashboard:${RELEASE:-latest}}
build: .
command: celery_dashboard worker --queues storage,celery,isolated,kickoff,kickoff1,kickoff2,kickoff3,kickoff4,database_deprecate,database_deprecate3,database,database3
environment: &worker-environment
SECRET_KEY_FILE: /etc/django_keys/secret_key
FIELD_ENCRYPTION_KEY_FILE: /etc/django_keys/field_encryption_key
DJANGO_DATABASE: production
DB_ENGINE: postgresql_psycopg2
DB_HOST: database
WORKER_ROLE: default_ipv4
BROKER: redis://broker:6379/0
SENTRY_DSN:
networks:
dashboard:
healthcheck:
interval: 60s
volumes:
- django-keys:/etc/django_keys/
- dashboard-frontend-uploads:/source/dashboard/uploads

worker-reporting:
<<: *worker
command: celery_dashboard worker --queues reporting
environment:
<<: *worker-environment
WORKER_ROLE: reporting

worker-scanning:
<<: *worker
command: celery_dashboard worker --queues ipv4,internet
environment:
<<: *worker-environment
WORKER_ROLE: default_ipv4

scheduler:
<<: *worker
image: ${DOCKER_IMAGE_DASHBOARD:-${DOCKER_REGISTRY:-internetstandards}/dashboard:${RELEASE:-latest}}
build: .
command: celery_dashboard beat -l info --pidfile=/var/tmp/celerybeat.pid

webserver:
image: caddy
configs:
- source: caddyfile
target: /etc/caddy/Caddyfile
ports:
- 127.0.0.1:8000:8000
networks:
dashboard:

database:
image: postgres:12
environment:
POSTGRES_DB: dashboard
POSTGRES_USER: dashboard
POSTGRES_PASSWORD: dashboard
networks:
dashboard:
volumes:
- database:/var/lib/postgresql/data
healthcheck:
interval: 60s
stop_grace_period: 60s

broker:
image: redis
healthcheck:
interval: 60s
networks:
dashboard:

configs:
caddyfile:
content: |
:8000 {
@paths path /account/* /admin/* /data/* /jet/* /logout/* /mail/* /session/* /static/* /upload/* /security.txt /.well-known/security.txt
reverse_proxy @paths backend:8000
reverse_proxy /* frontend:80
}

volumes:
dashboard-frontend-uploads:
database:
django-keys:

networks:
dashboard:
57 changes: 29 additions & 28 deletions dashboard/celery/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,9 @@
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "dashboard.settings")

# autodiscover all celery tasks in tasks.py files inside websecmap modules
app.autodiscover_tasks([app for app in settings.INSTALLED_APPS
if app.startswith('dashboard') or app.startswith('websecmap')])
app.autodiscover_tasks(
[app for app in settings.INSTALLED_APPS if app.startswith("dashboard") or app.startswith("websecmap")]
)

# http://docs.celeryproject.org/en/master/whatsnew-4.0.html?highlight=priority#redis-priorities-reversed
# http://docs.celeryproject.org/en/master/history/whatsnew-3.0.html?highlight=priority
Expand All @@ -31,9 +32,9 @@
# https://github.com/celery/celery/blob/f83b072fba7831f60106c81472e3477608baf289/docs/whatsnew-4.0.rst#redis-priorities-reversed
# contrary to 'documentation' in release notes the redis priorities do not seem aligned with rabbitmq
app.conf.broker_transport_options = {
'priority_steps': [1, 5, 9],
"priority_steps": [1, 5, 9],
}
if 'redis://' in app.conf.broker_url:
if "redis://" in app.conf.broker_url:
PRIO_HIGH = 1
PRIO_NORMAL = 5
PRIO_LOW = 9
Expand All @@ -44,8 +45,8 @@

# lookup table for routing keys for different IP versions
IP_VERSION_QUEUE = {
4: 'scanners.ipv4',
6: 'scanners.ipv6',
4: "scanners.ipv4",
6: "scanners.ipv6",
}


Expand Down Expand Up @@ -77,21 +78,24 @@ def status():
active = inspect.active()
reserved = inspect.reserved()
active_queues = inspect.active_queues()
workers = [{
'name': worker_name,
'queues': [q['name'] for q in active_queues.get(worker_name, [])],
'tasks_processed': sum(worker_stats['total'].values()),
'tasks_active': len(active.get(worker_name, [])),
'tasks_reserved': len(reserved.get(worker_name, [])),
'prefetch_count': worker_stats['prefetch_count'],
'concurrency': worker_stats['pool']['max-concurrency'],
} for worker_name, worker_stats in stats.items()]
workers = [
{
"name": worker_name,
"queues": [q["name"] for q in active_queues.get(worker_name, [])],
"tasks_processed": sum(worker_stats["total"].values()),
"tasks_active": len(active.get(worker_name, [])),
"tasks_reserved": len(reserved.get(worker_name, [])),
"prefetch_count": worker_stats["prefetch_count"],
"concurrency": worker_stats["pool"]["max-concurrency"],
}
for worker_name, worker_stats in stats.items()
]

# todo: fix Returning Any from function declared to return "SupportsLessThan"
workers = sorted(workers, key=lambda k: (k['name']), reverse=False) # type: ignore
workers = sorted(workers, key=lambda k: (k["name"]), reverse=False) # type: ignore

if 'redis://' in app.conf.broker_url:
queue_names = [q.name for q in QUEUES_MATCHING_ROLES['queuemonitor']]
if "redis://" in app.conf.broker_url:
queue_names = [q.name for q in QUEUES_MATCHING_ROLES["queuemonitor"]]

# on localhost and remote workers there is no event loop. This causes an exception.
# Inspired on https://github.com/tornadoweb/tornado/issues/2352 and
Expand All @@ -103,6 +107,7 @@ def status():
# 'solves': RuntimeError: There is no current event loop in thread 'Thread-3'.
try:
import asyncio # pylint: disable=import-outside-toplevel

asyncio.set_event_loop(asyncio.new_event_loop())
except BaseException: # pylint: disable=broad-except
# an eventloop already exists.
Expand All @@ -118,21 +123,17 @@ def status():
log.error("Could not connect to flower to retrieve queue stats.")
log.exception(runtime_error)

queues = [{'name': x['name'], 'tasks_pending': x['messages']} for x in queue_stats]
queues = [{"name": x["name"], "tasks_pending": x["messages"]} for x in queue_stats]
else:
raise NotImplementedError('Currently only Redis is supported!')
raise NotImplementedError("Currently only Redis is supported!")

# todo: fix Returning Any from function declared to return "SupportsLessThan"
queues = sorted(queues, key=lambda k: (k['name']), reverse=False) # type: ignore
queues = sorted(queues, key=lambda k: (k["name"]), reverse=False) # type: ignore

alerts = []
if not workers:
alerts.append('No active workers!')
alerts.append("No active workers!")
if len(workers) > 9000:
alerts.append('Number of workers is OVER 9000!!!!1111')
alerts.append("Number of workers is OVER 9000!!!!1111")

return {
'alerts': alerts,
'workers': workers,
'queues': queues
}
return {"alerts": alerts, "workers": workers, "queues": queues}
2 changes: 1 addition & 1 deletion dashboard/internet_nl_dashboard/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# SPDX-License-Identifier: Apache-2.0
import logging

default_app_config = 'dashboard.internet_nl_dashboard.apps.DashboardConfig' # pylint: disable=invalid-name
default_app_config = "dashboard.internet_nl_dashboard.apps.DashboardConfig" # pylint: disable=invalid-name

log = logging.getLogger(__package__)
Loading
Loading