Skip to content

Commit

Permalink
Move AccessPath into interprocedural and rename as TaintAccessPath
Browse files Browse the repository at this point in the history
Summary:
This change would allow the follow-ups to use `AccessPath.t` in `target.ml`,
which would define parameterized callables.

This diff also renames `AccessPath` to `TaintAccessPath` to indicate that this
is only used by the taint analysis.

Reviewed By: arthaud

Differential Revision: D64151987

fbshipit-source-id: 64308298322546ac9031c0ef3c0b006b6969cc9d
  • Loading branch information
Tianhan Lu authored and facebook-github-bot committed Oct 11, 2024
1 parent 04583c0 commit 4dae77a
Show file tree
Hide file tree
Showing 27 changed files with 27 additions and 10 deletions.
1 change: 1 addition & 0 deletions source/interprocedural/interprocedural.ml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

(* Taint: here we expose modules for the `pyrelib.interprocedural` library *)

module AccessPath = TaintAccessPath
module FixpointAnalysis = FixpointAnalysis
module Target = Target
module CallGraph = CallGraph
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,7 @@ let create root path = { root; path }
let extend { root; path = original_path } ~path = { root; path = original_path @ path }

let get_index expression =
match Interprocedural.CallResolution.extract_constant_name expression with
match CallResolution.extract_constant_name expression with
| Some "True" -> Abstract.TreeDomain.Label.Index "1"
| Some "False" -> Abstract.TreeDomain.Label.Index "0"
| Some name -> Abstract.TreeDomain.Label.Index name
Expand Down
File renamed without changes.
3 changes: 2 additions & 1 deletion source/interprocedural/test/dune
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
fetchCallablesTest
overrideGraphTest
changedPathsTest
globalConstantsTest)
globalConstantsTest
taintAccessPathTest)
(preprocess
(pps
ppx_deriving.eq
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@

open OUnit2
open Core
open Taint
open Test
module AccessPath = Interprocedural.AccessPath

let test_of_expression _ =
let ( !+ ) expression = Test.parse_single_expression expression in
Expand Down
1 change: 1 addition & 0 deletions source/interprocedural_analyses/taint/annotationParser.ml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

open Core
open Result
module AccessPath = Interprocedural.AccessPath

(* Represents a source or sink kind from a model (e.g, UserControlled). *)
module KindExpression = struct
Expand Down
2 changes: 1 addition & 1 deletion source/interprocedural_analyses/taint/annotationParser.mli
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ module KindExpression : sig
name: string;
subkind: string option;
}
| Updates of AccessPath.Root.t
| Updates of Interprocedural.AccessPath.Root.t
[@@deriving equal]

val from_name : string -> t
Expand Down
1 change: 1 addition & 0 deletions source/interprocedural_analyses/taint/backwardAnalysis.ml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ open Expression
open Pyre
open Domains
module CallGraph = Interprocedural.CallGraph
module AccessPath = Interprocedural.AccessPath
module PyrePysaEnvironment = Analysis.PyrePysaEnvironment
module PyrePysaLogic = Analysis.PyrePysaLogic

Expand Down
1 change: 1 addition & 0 deletions source/interprocedural_analyses/taint/features.ml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ open Core
open Ast
open Pyre
module PyrePysaEnvironment = Analysis.PyrePysaEnvironment
module AccessPath = Interprocedural.AccessPath

module MakeInterner (T : sig
type t
Expand Down
1 change: 1 addition & 0 deletions source/interprocedural_analyses/taint/forwardAnalysis.ml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ open Pyre
open Domains
module CallGraph = Interprocedural.CallGraph
module CallResolution = Interprocedural.CallResolution
module AccessPath = Interprocedural.AccessPath
module PyrePysaEnvironment = Analysis.PyrePysaEnvironment
module PyrePysaLogic = Analysis.PyrePysaLogic

Expand Down
1 change: 1 addition & 0 deletions source/interprocedural_analyses/taint/globalModel.ml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ open Expression
open Pyre
open Domains
module CallGraph = Interprocedural.CallGraph
module AccessPath = Interprocedural.AccessPath
module PyrePysaEnvironment = Analysis.PyrePysaEnvironment

type t = {
Expand Down
1 change: 1 addition & 0 deletions source/interprocedural_analyses/taint/modelParseResult.ml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ open Core
open Interprocedural
open Pyre
module PyrePysaLogic = Analysis.PyrePysaLogic
module AccessPath = Interprocedural.AccessPath

(* ModelParseResult: defines the result of parsing pysa model files (`.pysa`). *)

Expand Down
2 changes: 2 additions & 0 deletions source/interprocedural_analyses/taint/modelParseResult.mli
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@

(* ModelParseResult: defines the result of parsing pysa model files (`.pysa`). *)

module AccessPath = Interprocedural.AccessPath

module CollapseDepth : sig
type t =
| Value of int
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

open Core
open Ast
module AccessPath = Interprocedural.AccessPath

module IncompatibleModelError = struct
type reason =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ module IncompatibleModelError : sig
| InvalidNamedParameterPosition of {
name: string;
position: int;
valid_roots: AccessPath.Root.t list;
valid_roots: Interprocedural.AccessPath.Root.t list;
}
[@@deriving sexp, equal, compare]

Expand Down
1 change: 1 addition & 0 deletions source/interprocedural_analyses/taint/modelVerifier.ml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ open Ast
open Expression
module PyrePysaEnvironment = Analysis.PyrePysaEnvironment
module PyrePysaLogic = Analysis.PyrePysaLogic
module AccessPath = Interprocedural.AccessPath

type parameter_requirements = {
anonymous_parameters_positions: Int.Set.t;
Expand Down
2 changes: 1 addition & 1 deletion source/interprocedural_analyses/taint/modelVerifier.mli
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ val demangle_class_attribute : string -> string
val verify_signature
: path:PyrePath.t option ->
location:Location.t ->
normalized_model_parameters:AccessPath.NormalizedParameter.t list ->
normalized_model_parameters:Interprocedural.AccessPath.NormalizedParameter.t list ->
name:Reference.t ->
Type.Callable.t option ->
(unit, ModelVerificationError.t) result
Expand Down
1 change: 1 addition & 0 deletions source/interprocedural_analyses/taint/sanitize.ml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
* domain. *)

open Core
module AccessPath = Interprocedural.AccessPath

type sanitize = {
sources: SanitizeTransform.SourceSet.t;
Expand Down
1 change: 1 addition & 0 deletions source/interprocedural_analyses/taint/sinks.ml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
*)

open Core
module AccessPath = Interprocedural.AccessPath

let name = "sink"

Expand Down
2 changes: 2 additions & 0 deletions source/interprocedural_analyses/taint/sinks.mli
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
* LICENSE file in the root directory of this source tree.
*)

module AccessPath = Interprocedural.AccessPath

module PartialSink : sig
type t = string [@@deriving compare, hash, sexp, equal, show]

Expand Down
1 change: 0 additions & 1 deletion source/interprocedural_analyses/taint/taint.ml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

(* Taint: here we expose modules for the `pyrelib.taint` library *)

module AccessPath = AccessPath
module BackwardAnalysis = BackwardAnalysis
module Rule = Rule
module SourceSinkFilter = SourceSinkFilter
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
open OUnit2
open Core
open Taint
module AccessPath = Interprocedural.AccessPath

let named name = { AnnotationParser.KindDefinition.name; kind = Named; location = None }

Expand Down
4 changes: 2 additions & 2 deletions source/interprocedural_analyses/taint/test/domainTest.ml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ let test_partition_call_map context =
~location
~callee
~arguments:[]
~port:AccessPath.Root.LocalResult
~port:Interprocedural.AccessPath.Root.LocalResult
~path:[Abstract.TreeDomain.Label.create_name_index "a"]
~is_class_method:false
~is_static_method:false
Expand All @@ -45,7 +45,7 @@ let test_partition_call_map context =
~location
~callee
~arguments:[]
~port:AccessPath.Root.LocalResult
~port:Interprocedural.AccessPath.Root.LocalResult
~path:[Abstract.TreeDomain.Label.create_name_index "a"]
~is_class_method:false
~is_static_method:false
Expand Down
1 change: 0 additions & 1 deletion source/interprocedural_analyses/taint/test/dune
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@

(tests
(names
accessPathTest
annotationParserTest
configurationTest
domainTest
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
open Core
open OUnit2
open Taint
module AccessPath = Interprocedural.AccessPath

let test_from_source _ =
let assert_sources ~expected ~actual =
Expand Down
1 change: 1 addition & 0 deletions source/interprocedural_analyses/taint/test/modelTest.ml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ open Test
open TestHelper
open Taint
module PyrePysaEnvironment = Analysis.PyrePysaEnvironment
module AccessPath = Interprocedural.AccessPath

let get_stubs_and_definitions ~source_file_name ~project =
let pyre_api = Test.ScratchProject.pyre_pysa_read_only_api project in
Expand Down

0 comments on commit 4dae77a

Please sign in to comment.