"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "interprocedural_analyses/taint/modelParser.ml" between
pyre-check-0.0.54.tar.gz and pyre-check-0.0.55.tar.gz

About: Pyre is a performant type checker for Python (ships with Pysa, a security focused static analysis tool).

modelParser.ml  (pyre-check-0.0.54):modelParser.ml  (pyre-check-0.0.55)
skipping to change at line 184 skipping to change at line 184
match expression.Node.value with match expression.Node.value with
| Expression.Name (Name.Identifier breadcrumb) -> | Expression.Name (Name.Identifier breadcrumb) ->
[Features.simple_via ~allowed:configuration.features breadcrumb] [Features.simple_via ~allowed:configuration.features breadcrumb]
| Tuple expressions -> List.concat_map ~f:extract_breadcrumbs expressions | Tuple expressions -> List.concat_map ~f:extract_breadcrumbs expressions
| _ -> | _ ->
Format.sprintf Format.sprintf
"Invalid expression for breadcrumb: %s" "Invalid expression for breadcrumb: %s"
(show_expression expression.Node.value) (show_expression expression.Node.value)
|> failwith |> failwith
in in
let base_name = function
| {
Node.value =
Expression.Name
(Name.Attribute { base = { Node.value = Name (Name.Identifier identi
fier); _ }; _ });
_;
} ->
Some identifier
| _ -> None
in
let rec extract_via_positions expression = let rec extract_via_positions expression =
match expression.Node.value with match expression.Node.value with
| Expression.Name (Name.Identifier name) -> [get_parameter_position name] | Expression.Name (Name.Identifier name) -> [get_parameter_position name]
| Tuple expressions -> List.concat_map ~f:extract_via_positions expressions | Tuple expressions -> List.concat_map ~f:extract_via_positions expressions
| Call { callee; _ } when Option.equal String.equal (base_name callee) (Some "WithTag") -> []
| _ -> | _ ->
Format.sprintf Format.sprintf
"Invalid expression for ViaValueOf or ViaTypeOf: %s" "Invalid expression for ViaValueOf or ViaTypeOf: %s"
(show_expression expression.Node.value) (show_expression expression.Node.value)
|> failwith |> failwith
in in
let rec extract_via_tag expression =
match expression.Node.value with
| Expression.Call
{
callee;
arguments =
[
{
Call.Argument.value =
{ Node.value = Expression.String { StringLiteral.value; _ }; _
};
_;
};
];
}
when Option.equal String.equal (base_name callee) (Some "WithTag") ->
Some value
| Expression.Call _ ->
Format.sprintf
"Invalid expression in ViaValueOf or ViaTypeOf declaration: %s"
(Expression.show expression)
|> failwith
| Tuple expressions -> List.find_map expressions ~f:extract_via_tag
| _ -> None
in
let rec extract_names expression = let rec extract_names expression =
match expression.Node.value with match expression.Node.value with
| Expression.Name (Name.Identifier name) -> [name] | Expression.Name (Name.Identifier name) -> [name]
| Tuple expressions -> List.concat_map ~f:extract_names expressions | Tuple expressions -> List.concat_map ~f:extract_names expressions
| _ -> | _ ->
Format.sprintf "Invalid expression name: %s" (show_expression expression .Node.value) Format.sprintf "Invalid expression name: %s" (show_expression expression .Node.value)
|> failwith |> failwith
in in
let base_name = function
| {
Node.value =
Expression.Name
(Name.Attribute { base = { Node.value = Name (Name.Identifier identi
fier); _ }; _ });
_;
} ->
Some identifier
| _ -> None
in
let rec extract_kinds expression = let rec extract_kinds expression =
match expression.Node.value with match expression.Node.value with
| Expression.Name (Name.Identifier taint_kind) -> [Leaf taint_kind] | Expression.Name (Name.Identifier taint_kind) -> [Leaf taint_kind]
| Name (Name.Attribute { base; _ }) -> extract_kinds base | Name (Name.Attribute { base; _ }) -> extract_kinds base
| Call { callee; arguments = { Call.Argument.value = expression; _ } :: _ } -> ( | Call { callee; arguments = { Call.Argument.value = expression; _ } :: _ } -> (
match base_name callee with match base_name callee with
| Some "Via" -> [Breadcrumbs (extract_breadcrumbs expression)] | Some "Via" -> [Breadcrumbs (extract_breadcrumbs expression)]
| Some "ViaValueOf" -> | Some "ViaValueOf" ->
let tag = extract_via_tag expression in
[ [
Breadcrumbs Breadcrumbs
( extract_via_positions expression ( extract_via_positions expression
|> List.map ~f:(fun position -> Features.Simple.ViaValueOf { pos ition }) ); |> List.map ~f:(fun position -> Features.Simple.ViaValueOf { pos ition; tag }) );
] ]
| Some "ViaTypeOf" -> | Some "ViaTypeOf" ->
let tag = extract_via_tag expression in
[ [
Breadcrumbs Breadcrumbs
( extract_via_positions expression ( extract_via_positions expression
|> List.map ~f:(fun position -> Features.Simple.ViaTypeOf { posi tion }) ); |> List.map ~f:(fun position -> Features.Simple.ViaTypeOf { posi tion; tag }) );
] ]
| Some "Updates" -> | Some "Updates" ->
extract_names expression extract_names expression
|> List.map ~f:(fun name -> |> List.map ~f:(fun name ->
Leaf (Format.sprintf "ParameterUpdate%d" (get_parameter_posit ion name))) Leaf (Format.sprintf "ParameterUpdate%d" (get_parameter_posit ion name)))
| _ -> extract_kinds callee ) | _ -> extract_kinds callee )
| Call { callee; _ } -> extract_kinds callee | Call { callee; _ } -> extract_kinds callee
| Tuple expressions -> List.concat_map ~f:extract_kinds expressions | Tuple expressions -> List.concat_map ~f:extract_kinds expressions
| _ -> | _ ->
Format.sprintf Format.sprintf
 End of changes. 8 change blocks. 
13 lines changed or deleted 42 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)