Unverified Commit b61ca538 by Thomas Barabosch Committed by GitHub

Merge pull request #3 from fkie-cad/refactoring

Merging refactoring of Docker container and cwe_checker_to_ida
parents 1176088a 87b088ed
...@@ -209,3 +209,6 @@ test/real_world_samples ...@@ -209,3 +209,6 @@ test/real_world_samples
test/run_real_world_samples.sh test/run_real_world_samples.sh
# End of https://www.gitignore.io/api/c,ocaml,python # End of https://www.gitignore.io/api/c,ocaml,python
.project
.pydevproject
# based on https://github.com/BinaryAnalysisPlatform/bap/blob/master/docker/Dockerfile # based on https://github.com/BinaryAnalysisPlatform/bap/blob/master/docker/Dockerfile
FROM ubuntu:bionic FROM phusion/baseimage:0.11
MAINTAINER Thomas Barabosch <thomas.barabosch@fkie.fraunhofer.de>
RUN apt-get -y update && apt-get -y install \ RUN apt-get -y update && apt-get -y install \
build-essential \ build-essential \
curl \ curl \
...@@ -12,14 +11,15 @@ RUN apt-get -y update && apt-get -y install \ ...@@ -12,14 +11,15 @@ RUN apt-get -y update && apt-get -y install \
software-properties-common \ software-properties-common \
sudo \ sudo \
unzip \ unzip \
wget wget \
RUN apt-get -y install \
binutils-multiarch \ binutils-multiarch \
clang \ clang \
libgmp-dev \ libgmp-dev \
libzip-dev \ libzip-dev \
llvm-6.0-dev \ llvm-6.0-dev \
zlib1g-dev zlib1g-dev \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
RUN wget https://raw.githubusercontent.com/ocaml/opam/master/shell/install.sh RUN wget https://raw.githubusercontent.com/ocaml/opam/master/shell/install.sh
RUN yes /usr/local/bin | sh install.sh RUN yes /usr/local/bin | sh install.sh
RUN useradd -m bap && echo "bap:bap" | chpasswd && adduser bap sudo RUN useradd -m bap && echo "bap:bap" | chpasswd && adduser bap sudo
...@@ -35,14 +35,13 @@ RUN opam repo add bap opam-repository ...@@ -35,14 +35,13 @@ RUN opam repo add bap opam-repository
RUN opam update RUN opam update
RUN opam install depext --yes RUN opam install depext --yes
RUN OPAMJOBS=1 opam depext --install bap --yes RUN OPAMJOBS=1 opam depext --install bap --yes
RUN sudo -EH pip install bap RUN pip install bap
# install CWE_Checker and dependencies # install CWE_Checker and dependencies
RUN OPAMJOBS=1 opam install yojson alcotest --yes RUN OPAMJOBS=1 opam install yojson alcotest --yes
COPY . /home/bap/cwe_checker/ COPY . /home/bap/cwe_checker/
RUN sudo chown -R bap:bap /home/bap/cwe_checker RUN sudo chown -R bap:bap /home/bap/cwe_checker
ENV PATH="/home/bap/.opam/4.05.0/bin/:${PATH}" ENV PATH="/home/bap/.opam/4.05.0/bin/:${PATH}"
RUN cd /home/bap/cwe_checker/src;\ WORKDIR /home/bap/cwe_checker/src
bapbuild -r -Is checkers,utils -pkgs yojson,unix cwe_checker.plugin; \ RUN bapbuild -r -Is checkers,utils -pkgs yojson,unix cwe_checker.plugin; \
bapbundle install cwe_checker.plugin; \ bapbundle install cwe_checker.plugin;
cd -
ENTRYPOINT ["opam", "config", "exec", "--"] ENTRYPOINT ["opam", "config", "exec", "--"]
...@@ -85,42 +85,51 @@ class Parser(object): ...@@ -85,42 +85,51 @@ class Parser(object):
raise Exception() raise Exception()
return lines return lines
def _not_highlighted(self, warning): @staticmethod
def _not_highlighted(warning):
warning.highlight = False warning.highlight = False
return warning return warning
def _parse_at(self, warning): @staticmethod
def _parse_at(warning):
warning.address = warning.warning.split("at ")[-1].split()[0].strip() warning.address = warning.warning.split("at ")[-1].split()[0].strip()
return warning return warning
def _parse_cwe190(self, warning): @staticmethod
def _parse_cwe190(warning):
if "multiplication" in warning.warning: if "multiplication" in warning.warning:
warning.address = warning.warning.split("multiplication ")[1].split()[0] warning.address = warning.warning.split("multiplication ")[1].split()[0]
else: else:
warning.address = warning.warning.split("addition ")[1].split()[0] warning.address = warning.warning.split("addition ")[1].split()[0]
return warning return warning
def _parse_cwe457(self, warning): @staticmethod
def _parse_cwe457(warning):
warning.address = warning.warning.split("at ")[-1].split(":")[0].strip() warning.address = warning.warning.split("at ")[-1].split(":")[0].strip()
return warning return warning
def _parse_cwe467(self, warning): @staticmethod
def _parse_cwe467(warning):
warning.address = warning.warning.split("at ")[1].split()[0] warning.address = warning.warning.split("at ")[1].split()[0]
return warning return warning
def _parse_cwe476(self, warning): @staticmethod
def _parse_cwe476(warning):
warning.address = warning.warning.split("at ")[1].split()[0] warning.address = warning.warning.split("at ")[1].split()[0]
return warning return warning
def _parse_cwe676(self, warning): @staticmethod
def _parse_cwe676(warning):
warning.address = warning.warning.split("(")[1].split(")")[0].split(":")[0] warning.address = warning.warning.split("(")[1].split(")")[0].split(":")[0]
return warning return warning
def _parse_cwe782(self, warning): @staticmethod
def _parse_cwe782(warning):
warning.address = warning.warning.spit("(")[1].split(")")[0].strip() warning.address = warning.warning.spit("(")[1].split(")")[0].strip()
return warning return warning
def _extract_cwe_number(self, name): @staticmethod
def _extract_cwe_number(name):
tmp = name.split("]")[0] tmp = name.split("]")[0]
return tmp[1:] return tmp[1:]
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment