diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..6b8710a --- /dev/null +++ b/.dockerignore @@ -0,0 +1 @@ +.git diff --git a/.github/workflows/semgrep.yml b/.github/workflows/semgrep.yml new file mode 100644 index 0000000..c821e5a --- /dev/null +++ b/.github/workflows/semgrep.yml @@ -0,0 +1,25 @@ + +on: + pull_request: {} + workflow_dispatch: {} + push: + branches: + - main + - master + schedule: + - cron: '0 0 * * *' +name: Semgrep config +jobs: + semgrep: + name: semgrep/ci + runs-on: ubuntu-20.04 + env: + SEMGREP_APP_TOKEN: ${{ secrets.SEMGREP_APP_TOKEN }} + SEMGREP_URL: https://cloudflare.semgrep.dev + SEMGREP_APP_URL: https://cloudflare.semgrep.dev + SEMGREP_VERSION_CHECK_URL: https://cloudflare.semgrep.dev/api/check-version + container: + image: returntocorp/semgrep + steps: + - uses: actions/checkout@v3 + - run: semgrep ci diff --git a/Dockerfile b/Dockerfile index 1823df4..9cdde85 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,16 +1,15 @@ -FROM python:3.5-alpine +FROM python:3.9-alpine -RUN apk add --no-cache nmap nmap-scripts git -COPY requirements.txt / -RUN pip install --no-cache-dir -r requirements.txt - -RUN git clone https://github.com/vulnersCom/nmap-vulners /usr/share/nmap/scripts/vulners && nmap --script-updatedb -RUN mkdir /shared - -COPY run.sh output_report.py gcp_push.py aws_push.py / +COPY aws_push.py gcp_push.py output_report.py requirements.txt run.sh / COPY contrib /contrib COPY shared /shared -RUN chmod +x /run.sh +RUN apk add --no-cache nmap nmap-scripts git && \ + pip install --no-cache-dir -r requirements.txt && \ + git clone https://github.com/vulnersCom/nmap-vulners \ + /usr/share/nmap/scripts/vulners && \ + nmap --script-updatedb && \ + apk del git && \ + chmod +x /run.sh -ENTRYPOINT ["/run.sh"] +ENTRYPOINT ["/bin/sh","-c","/run.sh"] diff --git a/Makefile b/Makefile index cfd1d30..babe21d 100644 --- a/Makefile +++ b/Makefile @@ -1,15 +1,15 @@ -build : - docker build -t flan_scan . +build : + docker build --no-cache -t flan_scan -f Dockerfile . container_name = flan_$(shell date +'%s') -start : - docker run --name $(container_name) -v "$(CURDIR)/shared:/shared:Z" flan_scan +start : + docker run --rm --cap-drop=all --cap-add=NET_RAW --name $(container_name) -v "$(CURDIR)/shared:/shared:Z" flan_scan md : - docker run --name $(container_name) -v "$(CURDIR)/shared:/shared:Z" -e format=md flan_scan + docker run --rm --cap-drop=all --cap-add=NET_RAW --name $(container_name) -v "$(CURDIR)/shared:/shared:Z" -e format=md flan_scan html : - docker run --name $(container_name) -v "$(CURDIR)/shared:/shared:Z" -e format=html flan_scan + docker run --rm --cap-drop=all --cap-add=NET_RAW --name $(container_name) -v "$(CURDIR)/shared:/shared:Z" -e format=html flan_scan json : - docker run --name $(container_name) -v "$(CURDIR)/shared:/shared:Z" -e format=json flan_scan \ No newline at end of file + docker run --rm --cap-drop=all --cap-add=NET_RAW --name $(container_name) -v "$(CURDIR)/shared:/shared:Z" -e format=json flan_scan diff --git a/README.md b/README.md index cb9eaa5..d6dd1ed 100644 --- a/README.md +++ b/README.md @@ -47,7 +47,7 @@ $ nmap -sV -oX /shared/xml_files -oN - -v1 $@ --script=vulners/vulners.nse diff --git a/contrib/parsers/flan_xml_parser.py b/contrib/parsers/flan_xml_parser.py index 5254921..e0e0b43 100644 --- a/contrib/parsers/flan_xml_parser.py +++ b/contrib/parsers/flan_xml_parser.py @@ -85,7 +85,10 @@ def parse_port(self, ip_addr: str, port: Dict[str, Any]): if port['state']['@state'] == 'closed': return - app_name = self.get_app_name(port['service']) + try: + app_name = self.get_app_name(port['service']) + except KeyError: + app_name = "unknown" port_num = port['@portid'] new_app = app_name not in self.results self.results[app_name].locations[ip_addr].append(port_num) diff --git a/contrib/report_builders/latex_report_builder.py b/contrib/report_builders/latex_report_builder.py index 6889910..f7ef197 100644 --- a/contrib/report_builders/latex_report_builder.py +++ b/contrib/report_builders/latex_report_builder.py @@ -109,6 +109,8 @@ def _append(self, text: str): \usepackage{hyperref} \usepackage{fontawesome} \usepackage{listings} +\extrafloats{600} +\maxdeadcycles 600 \lstset{ basicstyle=\small\ttfamily, columns=flexible, diff --git a/requirements.txt b/requirements.txt index aced391..1e00ad8 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,5 @@ xmltodict==0.12.0 google-cloud-storage==1.23.0 boto3==1.12.15 -Jinja2==2.10.3 \ No newline at end of file +Jinja2==2.11.3 +markupsafe==2.0.1 \ No newline at end of file