Skip to content

Commit

Permalink
Merge pull request #43 from Ostorlab/fix/update-python
Browse files Browse the repository at this point in the history
Update python version to python3.11
  • Loading branch information
3asm authored Feb 29, 2024
2 parents c212162 + e03fb66 commit 8a7b01e
Show file tree
Hide file tree
Showing 9 changed files with 23 additions and 12 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/pytest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: ["3.10"]
python-version: ["3.11"]

steps:
- uses: actions/checkout@v2
Expand Down
20 changes: 12 additions & 8 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ FROM owasp/zap2docker-stable AS builder
FROM ubuntu:22.04 AS final

ARG DEBIAN_FRONTEND=noninteractive
RUN apt-get update && apt-get install -y software-properties-common \
&& add-apt-repository ppa:deadsnakes/ppa \
&& apt-get remove -y python*

# Install necessary packages
RUN apt-get update && apt-get install -q -y --fix-missing \
Expand All @@ -19,22 +22,23 @@ RUN apt-get update && apt-get install -q -y --fix-missing \
openbox \
xterm \
net-tools \
python3-pip \
python-is-python3 \
curl \
python3.10 \
python3.10-dev \
python3.11 \
python3.11-dev \
python3-pip \
wireguard-tools \
openresolv \
iproute2 \
xvfb \
x11vnc && \
x11vnc \
virtualenv && \
rm -rf /var/lib/apt/lists/*

COPY requirement.txt .
RUN python3 -m pip install --upgrade pip
RUN python3 -m pip install -r requirement.txt
RUN python3.11 -m virtualenv -p python3.11 /venv
RUN /venv/bin/python3.11 -m pip install --upgrade pip
RUN /venv/bin/python3.11 -m pip install -r requirement.txt

RUN useradd -u 1000 -d /home/zap -m -s /bin/bash zap
RUN echo zap:zap | chpasswd
Expand All @@ -53,7 +57,7 @@ COPY --from=builder --chown=1000:1000 /zap/webswing /zap/webswing

ARG TARGETARCH
ENV JAVA_HOME /usr/lib/jvm/java-11-openjdk-$TARGETARCH
ENV PATH $JAVA_HOME/bin:/zap/:$PATH
ENV PATH /venv/bin:$JAVA_HOME/bin:/zap/:$PATH
ENV ZAP_PATH /zap/zap.sh

# Default port for use with health check
Expand Down Expand Up @@ -81,4 +85,4 @@ COPY agent /app/agent
COPY ostorlab.yaml /app/agent/ostorlab.yaml
WORKDIR /app
RUN mkdir -p /zap/wrk
CMD ["python3", "/app/agent/zap_agent.py"]
CMD ["/venv/bin/python3.11", "/app/agent/zap_agent.py"]
7 changes: 4 additions & 3 deletions agent/result_parser.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Module to parse zap json results."""

import dataclasses
from typing import Dict

Expand Down Expand Up @@ -96,9 +97,9 @@ def parse_results(results: Dict):
if r != ""
}
cweid = alert.get("cweid")
references[
f"cwe-{cweid}"
] = f"https://nvd.nist.gov/vuln/detail/{cweid}.html"
references[f"cwe-{cweid}"] = (
f"https://nvd.nist.gov/vuln/detail/{cweid}.html"
)
for instance in alert.get("instances"):
uri = instance.get("uri")
method = instance.get("method")
Expand Down
1 change: 1 addition & 0 deletions agent/zap_agent.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Zap agent implementation"""

import datetime
import logging
import re
Expand Down
1 change: 1 addition & 0 deletions agent/zap_wrapper.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Zap wrapper implementation"""

import datetime
import json
import logging
Expand Down
1 change: 1 addition & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Pytest fixture for the Zap agent."""

import json
import pathlib
import random
Expand Down
1 change: 1 addition & 0 deletions tests/result_parser_test.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Unit tests for result parser."""

import json
import pathlib

Expand Down
1 change: 1 addition & 0 deletions tests/zap_agent_test.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Unittests for Zap agent."""

import io
import json
import pathlib
Expand Down
1 change: 1 addition & 0 deletions tests/zap_wrapper_test.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Unit test for the Zap wrapper class."""

import pytest
import subprocess

Expand Down

0 comments on commit 8a7b01e

Please sign in to comment.