Skip to content

Commit

Permalink
Programmatically run the with-no-return pass (#364)
Browse files Browse the repository at this point in the history
* Programmatically run the with-no-return pass

* Add bap-toolkit to dockerfile
  • Loading branch information
Chloe Fortuna committed Mar 30, 2022
1 parent 1d5dac4 commit 119528b
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 6 deletions.
8 changes: 8 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
FROM binaryanalysisplatform/bap:latest

RUN sudo -E apt install -y zip

RUN git clone https://github.com/BinaryAnalysisPlatform/bap-toolkit.git

RUN cd bap-toolkit; \
opam config exec -- make; \
opam config exec -- make install

RUN git clone https://github.com/draperlaboratory/cbat_tools.git

RUN cd cbat_tools/wp; \
Expand Down
20 changes: 14 additions & 6 deletions wp/plugin/lib/wp_utils.ml
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,26 @@ module Cache = Wp_cache

let default_loader = "llvm"

(* Runs the passes set to autorun by default. (abi and api). *)
let autorun_passes (proj : Project.t) : Project.t =
Project.passes ()
|> List.filter ~f:Project.Pass.autorun
|> List.fold ~init:proj ~f:(fun proj pass -> Project.Pass.run_exn pass proj)
let find_passes () : Project.pass list =
(* Runs the passes set to autorun by default. (abi and api). *)
let autorun = List.filter ~f:Project.Pass.autorun (Project.passes ()) in
let with_no_return =
match Project.find_pass "with-no-return" with
| None -> warning "with-no-return pass is missing"; []
| Some pass -> [pass]
in
autorun @ with_no_return

let run_passes (passes : Project.pass list) (proj : Project.t) : Project.t =
List.fold passes ~init:proj ~f:(fun proj pass ->
Project.Pass.run_exn pass proj)

(* Creates a BAP project from an input file. *)
let create_proj (state : Project.state option) (loader : string)
(filename : string) : Project.t =
let input = Project.Input.file ~loader ~filename in
match Project.create ~package:filename ?state input with
| Ok proj -> autorun_passes proj
| Ok proj -> run_passes (find_passes ()) proj
| Error e ->
let msg = Error.to_string_hum e in
failwith (Printf.sprintf "Error loading project: %s\n%!" msg)
Expand Down

0 comments on commit 119528b

Please sign in to comment.