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
test/run_real_world_samples.sh
# End of https://www.gitignore.io/api/c,ocaml,python
.project
.pydevproject
# based on https://github.com/BinaryAnalysisPlatform/bap/blob/master/docker/Dockerfile
FROM ubuntu:bionic
MAINTAINER Thomas Barabosch <thomas.barabosch@fkie.fraunhofer.de>
FROM phusion/baseimage:0.11
RUN apt-get -y update && apt-get -y install \
build-essential \
curl \
......@@ -12,14 +11,15 @@ RUN apt-get -y update && apt-get -y install \
software-properties-common \
sudo \
unzip \
wget
RUN apt-get -y install \
wget \
binutils-multiarch \
clang \
libgmp-dev \
libzip-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 yes /usr/local/bin | sh install.sh
RUN useradd -m bap && echo "bap:bap" | chpasswd && adduser bap sudo
......@@ -35,14 +35,13 @@ RUN opam repo add bap opam-repository
RUN opam update
RUN opam install depext --yes
RUN OPAMJOBS=1 opam depext --install bap --yes
RUN sudo -EH pip install bap
RUN pip install bap
# install CWE_Checker and dependencies
RUN OPAMJOBS=1 opam install yojson alcotest --yes
COPY . /home/bap/cwe_checker/
RUN sudo chown -R bap:bap /home/bap/cwe_checker
ENV PATH="/home/bap/.opam/4.05.0/bin/:${PATH}"
RUN cd /home/bap/cwe_checker/src;\
bapbuild -r -Is checkers,utils -pkgs yojson,unix cwe_checker.plugin; \
bapbundle install cwe_checker.plugin; \
cd -
WORKDIR /home/bap/cwe_checker/src
RUN bapbuild -r -Is checkers,utils -pkgs yojson,unix cwe_checker.plugin; \
bapbundle install cwe_checker.plugin;
ENTRYPOINT ["opam", "config", "exec", "--"]
......@@ -85,42 +85,51 @@ class Parser(object):
raise Exception()
return lines
def _not_highlighted(self, warning):
@staticmethod
def _not_highlighted(warning):
warning.highlight = False
return warning
def _parse_at(self, warning):
@staticmethod
def _parse_at(warning):
warning.address = warning.warning.split("at ")[-1].split()[0].strip()
return warning
def _parse_cwe190(self, warning):
@staticmethod
def _parse_cwe190(warning):
if "multiplication" in warning.warning:
warning.address = warning.warning.split("multiplication ")[1].split()[0]
else:
warning.address = warning.warning.split("addition ")[1].split()[0]
return warning
def _parse_cwe457(self, warning):
@staticmethod
def _parse_cwe457(warning):
warning.address = warning.warning.split("at ")[-1].split(":")[0].strip()
return warning
def _parse_cwe467(self, warning):
@staticmethod
def _parse_cwe467(warning):
warning.address = warning.warning.split("at ")[1].split()[0]
return warning
def _parse_cwe476(self, warning):
@staticmethod
def _parse_cwe476(warning):
warning.address = warning.warning.split("at ")[1].split()[0]
return warning
def _parse_cwe676(self, warning):
@staticmethod
def _parse_cwe676(warning):
warning.address = warning.warning.split("(")[1].split(")")[0].split(":")[0]
return warning
def _parse_cwe782(self, warning):
@staticmethod
def _parse_cwe782(warning):
warning.address = warning.warning.spit("(")[1].split(")")[0].strip()
return warning
def _extract_cwe_number(self, name):
@staticmethod
def _extract_cwe_number(name):
tmp = name.split("]")[0]
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