Skip to content

Commit

Permalink
Ran formatter
Browse files Browse the repository at this point in the history
  • Loading branch information
phreppo committed Oct 8, 2023
1 parent 21c0f40 commit 93d219e
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 36 deletions.
24 changes: 12 additions & 12 deletions src/bin/RatMain.ml
Original file line number Diff line number Diff line change
Expand Up @@ -106,18 +106,18 @@ and analyze_with_runtime regex =
and print runtime attack =
let exp_vulnerable = not (Analysis.AttackFamilySet.is_empty attack) in
(if not exp_vulnerable then print_endline "Exponential ReDoS: false"
else
match get_exploit_string attack with
(* We cannot infer a printable exploit string. *)
| None -> print_endline "Exponential ReDoS: false"
(* We have a printable exploit string. *)
| Some exploit ->
print_endline "Exponential ReDoS: true";
(if !Options.show_lang then
(* Print the whole language. *)
let exp_vuln_string = Analysis.AttackFamilySet.to_string attack in
print_endline ("Exponential Vulnerabilities: " ^ exp_vuln_string));
print_exploit exploit);
else
match get_exploit_string attack with
(* We cannot infer a printable exploit string. *)
| None -> print_endline "Exponential ReDoS: false"
(* We have a printable exploit string. *)
| Some exploit ->
print_endline "Exponential ReDoS: true";
(if !Options.show_lang then
(* Print the whole language. *)
let exp_vuln_string = Analysis.AttackFamilySet.to_string attack in
print_endline ("Exponential Vulnerabilities: " ^ exp_vuln_string));
print_exploit exploit);
print_runtime runtime

(** [get_exploit_string attack] is an exploit string for [attack] such that
Expand Down
47 changes: 23 additions & 24 deletions src/lib/regular_automata/abstractRegularAutomaton.ml
Original file line number Diff line number Diff line change
Expand Up @@ -326,25 +326,25 @@ module Make (S : SIG.STATE) (A : SIG.COMPARABLE) = struct
nd_algebra = u.algebra;
nd_trans =
(if not will_hole_be_coreachable then
fold_trans_nh
(fun (q, a, q') acc ->
let qq' = map q' in
if is_hole qq' then acc
else
let qq = map q in
nd_add_trans (qq, a, qq') acc)
u DetTrans.empty
else
StatesSet.fold
(fun q acc ->
Algebra.fold
(fun a acc ->
let q' = delta q a u in
let qq' = map q' in
let qq = map q in
nd_add_trans (qq, a, qq') acc)
u.algebra acc)
(get_states u) DetTrans.empty);
fold_trans_nh
(fun (q, a, q') acc ->
let qq' = map q' in
if is_hole qq' then acc
else
let qq = map q in
nd_add_trans (qq, a, qq') acc)
u DetTrans.empty
else
StatesSet.fold
(fun q acc ->
Algebra.fold
(fun a acc ->
let q' = delta q a u in
let qq' = map q' in
let qq = map q in
nd_add_trans (qq, a, qq') acc)
u.algebra acc)
(get_states u) DetTrans.empty);
}

let mini (u : dfa) max_split =
Expand Down Expand Up @@ -748,8 +748,8 @@ module Make (S : SIG.STATE) (A : SIG.COMPARABLE) = struct
nd_states = StatesSet.union u.nd_states u'.nd_states;
nd_init =
(if StatesSet.is_empty (StatesSet.inter u.nd_init u.nd_finals) then
u.nd_init
else StatesSet.union u.nd_init u'.nd_init);
u.nd_init
else StatesSet.union u.nd_init u'.nd_init);
nd_algebra = u.nd_algebra;
nd_trans = t';
nd_finals = u'.nd_finals;
Expand Down Expand Up @@ -1372,8 +1372,7 @@ module Make (S : SIG.STATE) (A : SIG.COMPARABLE) = struct
| (p, id) :: q ->
let trans, assoc, todo, finals =
Algebra.fold
(fun l
(trans, (assoc : (regexp list * state) list), todos, finals) ->
(fun l (trans, (assoc : (regexp list * state) list), todos, finals) ->
let x = derivate l p in
try
let xid = RWEQMap.find x assoc in
Expand Down Expand Up @@ -1404,7 +1403,7 @@ module Make (S : SIG.STATE) (A : SIG.COMPARABLE) = struct
[ (r, init) ]
DetTrans.empty assoc
(if unit_function r = E then StatesSet.singleton init
else StatesSet.empty)
else StatesSet.empty)
in
{
states =
Expand Down

0 comments on commit 93d219e

Please sign in to comment.