Skip to content

Commit

Permalink
Merge branch 'main' into feature/mula/api-filtering-docs
Browse files Browse the repository at this point in the history
  • Loading branch information
jpbruinsslot authored Nov 13, 2023
2 parents 93eef8a + c59fee1 commit ef175fe
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 22 deletions.
3 changes: 1 addition & 2 deletions boefjes/boefjes/job_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
from octopoes.models.types import OOIType

logger = logging.getLogger(__name__)

bytes_api_client = BytesAPIClient(
settings.bytes_api,
username=settings.bytes_username,
Expand Down Expand Up @@ -153,7 +154,6 @@ def handle(self, boefje_meta: BoefjeMeta) -> None:
boefje_meta.ended_at = datetime.now(timezone.utc)
logger.info("Saving to Bytes for boefje %s[%s]", boefje_meta.boefje.id, str(boefje_meta.id))

bytes_api_client.login()
bytes_api_client.save_boefje_meta(boefje_meta)

if boefje_results:
Expand All @@ -175,7 +175,6 @@ def __init__(self, job_runner):
def handle(self, normalizer_meta: NormalizerMeta) -> None:
logger.info("Handling normalizer %s[%s]", normalizer_meta.normalizer.id, normalizer_meta.id)

bytes_api_client.login()
raw = bytes_api_client.get_raw(normalizer_meta.raw_data.id)

normalizer_meta.started_at = datetime.now(timezone.utc)
Expand Down
2 changes: 1 addition & 1 deletion docs/source/developer_documentation/boefjes.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
This module has several entry points discussed below, but let us first consider the prerequisites and scope.
If you already have running setup and want to learn where each bit of functionality goes, read the following page:

[Developing Openkat Plugins](README.md#your-first-boefje)
[Developing Openkat Plugins]([https://docs.openkat.nl/introduction/makeyourown.html])

## Prerequisites

Expand Down
4 changes: 4 additions & 0 deletions docs/source/modules/api.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
API
The API is used to query the status of tasks within OpenKAT. By querying a task identifier you can see if the task has completed or failed. In the future the API can be used to create your own boefjes.

Boefjes receive their task input and save their output using REST APIs.
2 changes: 1 addition & 1 deletion rocky/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -69,4 +69,4 @@ RUN export SECRET_KEY="secret" BYTES_API="http://bytes:8000" BYTES_PASSWORD="pas

USER rocky

CMD ["uwsgi", "--ini", "uwsgi.ini", "--wsgi-file", "rocky/wsgi.py"]
CMD ["granian", "--interface", "wsgi", "rocky.wsgi:application", "--host", "0.0.0.0"]
3 changes: 1 addition & 2 deletions rocky/debian/kat-rocky.service
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,11 @@ SyslogIdentifier=kat-rocky
WorkingDirectory=/opt/venvs/kat-rocky/
EnvironmentFile=/usr/lib/kat/rocky.defaults
EnvironmentFile=/etc/kat/rocky.conf
ExecStart=/opt/venvs/kat-rocky/bin/uwsgi --ini /etc/kat/rocky.uwsgi.ini
ExecStart=/opt/venvs/kat-rocky/bin/granian --interface wsgi rocky.wsgi:application
Restart=on-failure
RestartSec=3s
KillSignal=SIGQUIT
KillMode=mixed
Type=notify
NotifyAccess=all

[Install]
Expand Down
17 changes: 6 additions & 11 deletions rocky/debian/postinst
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,14 @@ if [ "$1" = "configure" ]; then
# Set SECRET_KEY if empty
key=$(tr -dc A-Za-z0-9 < /dev/urandom | head -c 64)
sed -i "s/SECRET_KEY= *\$/SECRET_KEY=${key}/" /etc/kat/rocky.conf

# Only configure granian for new installs. Existing installations will
# switch in the next release.
mkdir -p /etc/systemd/system/kat-rocky.service.d
cat > /etc/systemd/system/kat-rocky.service.d/use-granian.conf << EOF
# Do not customize this file because it will be automatically removed in the next release
[Service]
ExecStart=
ExecStart=/opt/venvs/kat-rocky/bin/granian --interface wsgi rocky.wsgi:application
Type=simple
EOF
fi

# Delete file and directory that was added in 1.13 to use granian only on
# new installs.
if [ -d /etc/systemd/system/kat-rocky.service.d ]; then
rm -f /etc/systemd/system/kat-rocky.service.d/use-granian.conf
rmdir --ignore-fail-on-non-empty /etc/systemd/system/kat-rocky.service.d
fi
fi

#DEBHELPER#
Expand Down
6 changes: 1 addition & 5 deletions rocky/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,4 @@ if [ "$DATABASE_MIGRATION" = "1" ] || [[ $DATABASE_MIGRATION == "true" ]]; then
python manage.py migrate --noinput
fi

if [ "$1" == "uwsgi" ] && { [ "$USE_GRANIAN" = "1" ] || [[ $USE_GRANIAN == "true" ]]; }; then
exec granian --interface wsgi rocky.wsgi:application --host 0.0.0.0
else
exec "$@"
fi
exec "$@"

0 comments on commit ef175fe

Please sign in to comment.