Skip to content

Commit

Permalink
Rename global_write_check to global_access_check
Browse files Browse the repository at this point in the history
Summary: Currently HAGVAH does check both global writes and global reads, so this diff updates the corresponding TAST checker's name from "global_write_check" to "global_access_check".

Reviewed By: yuxuanchen1997

Differential Revision: D39970956

fbshipit-source-id: a536f5f043e2e4be5df02f15a3ec50d4d776096a
  • Loading branch information
Chaoqiang Deng authored and facebook-github-bot committed Oct 7, 2022
1 parent 3087f9e commit 6730973
Show file tree
Hide file tree
Showing 44 changed files with 111 additions and 110 deletions.
3 changes: 2 additions & 1 deletion hphp/hack/src/errors/error_codes.ml
Original file line number Diff line number Diff line change
Expand Up @@ -765,11 +765,12 @@ end
(* 9xxx: reserved for FB ai *)
(* 10xxx: reserved for FB ai *)

(* 11xxx: reserved for global write check (fbcode/hphp/hack/src/typing/tast_check/global_write_check.ml),
(* 11xxx: reserved for global write check (fbcode/hphp/hack/src/typing/tast_check/global_access_check.ml),
* which is used to detect data leaks through global variable access.
* 11001 represents the error when a static variable is directly written.
* 11002 represents the error when a global variable is written via reference.
* 11003 represents the error when a global variable is passed to (or returned from) a function call.
* 11004 represents the error when a global variable is directly used.
*)
module GlobalWriteCheck = struct
type t =
Expand Down
4 changes: 2 additions & 2 deletions hphp/hack/src/hackrs/compare_folded_decls_file.ml
Original file line number Diff line number Diff line change
Expand Up @@ -242,8 +242,8 @@ let () =
(* The following options do not affect the direct decl parser and can be ignored
(they are used by hh_single_type_check, and we run hh_single_decl over all of
the typecheck test cases). *)
ignored_arg "--enable-global-write-check";
ignored_arg "--enable-global-write-check-functions";
ignored_arg "--enable-global-access-check";
ignored_arg "--enable-global-access-check-functions";
ignored_flag "--abstract-static-props";
ignored_arg "--allowed-decl-fixme-codes";
ignored_arg "--allowed-fixme-codes-strict";
Expand Down
4 changes: 2 additions & 2 deletions hphp/hack/src/hh_oxidize/convert_toplevel_phrase.ml
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,8 @@ let enum_modules =
("error_codes", "NastCheck");
("error_codes", "Typing");
("error_codes", "Init");
(* An optional error set that runs only for arg --enable-global-write-check
or --enable-global-write-check-function. *)
(* An optional error set that runs only for arg --enable-global-access-check
or --enable-global-access-check-function. *)
("error_codes", "GlobalWriteCheck");
]

Expand Down
4 changes: 2 additions & 2 deletions hphp/hack/src/hh_single_decl.ml
Original file line number Diff line number Diff line change
Expand Up @@ -241,8 +241,8 @@ let () =
(* The following options do not affect the direct decl parser and can be ignored
(they are used by hh_single_type_check, and we run hh_single_decl over all of
the typecheck test cases). *)
ignored_arg "--enable-global-write-check";
ignored_arg "--enable-global-write-check-functions";
ignored_arg "--enable-global-access-check";
ignored_arg "--enable-global-access-check-functions";
ignored_flag "--abstract-static-props";
ignored_arg "--allowed-decl-fixme-codes";
ignored_arg "--allowed-fixme-codes-strict";
Expand Down
26 changes: 13 additions & 13 deletions hphp/hack/src/hh_single_type_check.ml
Original file line number Diff line number Diff line change
Expand Up @@ -328,22 +328,22 @@ let parse_options () =
ref (TypecheckerOptions.profile_top_level_definitions GlobalOptions.default)
in
let memtrace = ref None in
let enable_global_write_check = ref [] in
let enable_global_write_check_functions = ref SSet.empty in
let enable_global_access_check = ref [] in
let enable_global_access_check_functions = ref SSet.empty in
let refactor_mode = ref "" in
let refactor_analysis_mode = ref "" in
let set_enable_global_write_check_functions s =
let set_enable_global_access_check_functions s =
let json_obj = Hh_json.json_of_file s in
let add_function f =
match f with
| Hh_json.JSON_String str ->
enable_global_write_check_functions :=
SSet.add str !enable_global_write_check_functions
enable_global_access_check_functions :=
SSet.add str !enable_global_access_check_functions
| _ -> ()
in
match json_obj with
| Hh_json.JSON_Array lst -> List.iter lst ~f:add_function
| _ -> enable_global_write_check_functions := SSet.empty
| _ -> enable_global_access_check_functions := SSet.empty
in
let allow_all_files_for_module_declarations = ref true in
let loop_iteration_upper_bound = ref None in
Expand Down Expand Up @@ -814,13 +814,13 @@ let parse_options () =
" Sets the amount of fuel that the type printer can use to display an individual type. Default: "
^ string_of_int
(TypecheckerOptions.type_printer_fuel GlobalOptions.default) );
( "--enable-global-write-check",
( "--enable-global-access-check",
Arg.String
(fun s -> enable_global_write_check := String_utils.split ',' s),
(fun s -> enable_global_access_check := String_utils.split ',' s),
" Run global write checker on any file whose path is prefixed by the argument (use \"\\\" for hh_single_type_check)"
);
( "--enable-global-write-check-functions",
Arg.String set_enable_global_write_check_functions,
( "--enable-global-access-check-functions",
Arg.String set_enable_global_access_check_functions,
" Run global write checker on functions listed in the given JSON file"
);
( "--overwrite-loop-iteration-upper-bound",
Expand Down Expand Up @@ -965,9 +965,9 @@ let parse_options () =
["/"]
else
[])
~tco_global_write_check_enabled:!enable_global_write_check
~tco_global_write_check_functions_enabled:
!enable_global_write_check_functions
~tco_global_access_check_enabled:!enable_global_access_check
~tco_global_access_check_functions_enabled:
!enable_global_access_check_functions
~tco_use_direct_decl_parser:!use_direct_decl_parser
~po_enable_enum_classes:(not !disable_enum_classes)
~po_interpret_soft_types_as_like_types:!interpret_soft_types_as_like_types
Expand Down
4 changes: 2 additions & 2 deletions hphp/hack/src/naming/naming_special_names.ml
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,7 @@ module UserAttributes = struct
let uaNoFlatten = "__NoFlatten"

(* <<__SafeForGlobalWriteCheck>> marks global variables as safe from mutations.
This attribute merely ensures that the global_write_check does NOT raise
This attribute merely ensures that the global_access_check does NOT raise
errors/warnings from writing to the annotated global variable, and it
has NO runtime/semantic implication. *)
let uaSafeGlobalVariable = "__SafeForGlobalWriteCheck"
Expand Down Expand Up @@ -698,7 +698,7 @@ module UserAttributes = struct
autocomplete = false;
doc =
"Marks this global variable as safe from mutation."
^ " This ensures the global_write_check does NOT raise errors/warnings from writing to this global variable.";
^ " This ensures the global_access_check does NOT raise errors/warnings from writing to this global variable.";
} );
])

Expand Down
18 changes: 9 additions & 9 deletions hphp/hack/src/options/globalOptions.ml
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,8 @@ type t = {
po_disallow_inst_meth: bool;
tco_use_direct_decl_parser: bool;
tco_ifc_enabled: string list;
tco_global_write_check_enabled: string list;
tco_global_write_check_functions_enabled: SSet.t;
tco_global_access_check_enabled: string list;
tco_global_access_check_functions_enabled: SSet.t;
po_enable_enum_supertyping: bool;
po_interpret_soft_types_as_like_types: bool;
tco_enable_strict_string_concat_interp: bool;
Expand Down Expand Up @@ -268,8 +268,8 @@ let default =
po_disallow_inst_meth = false;
tco_use_direct_decl_parser = true;
tco_ifc_enabled = [];
tco_global_write_check_enabled = [];
tco_global_write_check_functions_enabled = SSet.empty;
tco_global_access_check_enabled = [];
tco_global_access_check_functions_enabled = SSet.empty;
po_enable_enum_supertyping = true;
po_interpret_soft_types_as_like_types = false;
tco_enable_strict_string_concat_interp = false;
Expand Down Expand Up @@ -419,9 +419,9 @@ let make
?(po_disallow_inst_meth = default.po_disallow_inst_meth)
?(tco_use_direct_decl_parser = default.tco_use_direct_decl_parser)
?(tco_ifc_enabled = default.tco_ifc_enabled)
?(tco_global_write_check_enabled = default.tco_global_write_check_enabled)
?(tco_global_write_check_functions_enabled =
default.tco_global_write_check_functions_enabled)
?(tco_global_access_check_enabled = default.tco_global_access_check_enabled)
?(tco_global_access_check_functions_enabled =
default.tco_global_access_check_functions_enabled)
?(po_enable_enum_supertyping = default.po_enable_enum_supertyping)
?(po_interpret_soft_types_as_like_types =
default.po_interpret_soft_types_as_like_types)
Expand Down Expand Up @@ -572,8 +572,8 @@ let make
po_disallow_inst_meth;
tco_use_direct_decl_parser;
tco_ifc_enabled;
tco_global_write_check_enabled;
tco_global_write_check_functions_enabled;
tco_global_access_check_enabled;
tco_global_access_check_functions_enabled;
po_enable_enum_supertyping;
po_interpret_soft_types_as_like_types;
tco_enable_strict_string_concat_interp;
Expand Down
8 changes: 4 additions & 4 deletions hphp/hack/src/options/globalOptions.mli
Original file line number Diff line number Diff line change
Expand Up @@ -260,10 +260,10 @@ type t = {
(* Enable global write check on the specified list of path prefixes
(a list containing the empty string would denote all files,
an empty list denotes no files) *)
tco_global_write_check_enabled: string list;
tco_global_access_check_enabled: string list;
(* Enable global write check on the spcified set of functions
(Empty denotes no functions) *)
tco_global_write_check_functions_enabled: SSet.t;
tco_global_access_check_functions_enabled: SSet.t;
(* Enables the enum supertyping extension *)
po_enable_enum_supertyping: bool;
(* <<__Soft>> T -> ~T *)
Expand Down Expand Up @@ -439,8 +439,8 @@ val make :
?po_disallow_inst_meth:bool ->
?tco_use_direct_decl_parser:bool ->
?tco_ifc_enabled:string list ->
?tco_global_write_check_enabled:string list ->
?tco_global_write_check_functions_enabled:SSet.t ->
?tco_global_access_check_enabled:string list ->
?tco_global_access_check_functions_enabled:SSet.t ->
?po_enable_enum_supertyping:bool ->
?po_interpret_soft_types_as_like_types:bool ->
?tco_enable_strict_string_concat_interp:bool ->
Expand Down
12 changes: 6 additions & 6 deletions hphp/hack/src/options/typecheckerOptions.ml
Original file line number Diff line number Diff line change
Expand Up @@ -155,14 +155,14 @@ let enable_ifc t = GlobalOptions.{ t with tco_ifc_enabled = ["/"] }

let ifc_enabled t = t.GlobalOptions.tco_ifc_enabled

let enable_global_write_check t =
GlobalOptions.{ t with tco_global_write_check_enabled = ["/"] }
let enable_global_access_check t =
GlobalOptions.{ t with tco_global_access_check_enabled = ["/"] }

let global_write_check_enabled t =
t.GlobalOptions.tco_global_write_check_enabled
let global_access_check_enabled t =
t.GlobalOptions.tco_global_access_check_enabled

let global_write_check_functions_enabled t =
t.GlobalOptions.tco_global_write_check_functions_enabled
let global_access_check_functions_enabled t =
t.GlobalOptions.tco_global_access_check_functions_enabled

let like_type_hints t = t.GlobalOptions.tco_like_type_hints

Expand Down
6 changes: 3 additions & 3 deletions hphp/hack/src/oxidized/gen/global_options.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// This source code is licensed under the MIT license found in the
// LICENSE file in the "hack" directory of this source tree.
//
// @generated SignedSource<<955fb16eed4d702f3264d0e911f1cf60>>
// @generated SignedSource<<618c9c7aba2f3189646de21f775d6491>>
//
// To regenerate this file, run:
// hphp/hack/src/oxidized_regen.sh
Expand Down Expand Up @@ -133,8 +133,8 @@ pub struct GlobalOptions {
pub po_disallow_inst_meth: bool,
pub tco_use_direct_decl_parser: bool,
pub tco_ifc_enabled: Vec<String>,
pub tco_global_write_check_enabled: Vec<String>,
pub tco_global_write_check_functions_enabled: s_set::SSet,
pub tco_global_access_check_enabled: Vec<String>,
pub tco_global_access_check_functions_enabled: s_set::SSet,
pub po_enable_enum_supertyping: bool,
pub po_interpret_soft_types_as_like_types: bool,
pub tco_enable_strict_string_concat_interp: bool,
Expand Down
4 changes: 2 additions & 2 deletions hphp/hack/src/oxidized/manual/global_options_impl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,8 @@ impl Default for GlobalOptions {
po_disallow_inst_meth: false,
tco_use_direct_decl_parser: true,
tco_ifc_enabled: vec![],
tco_global_write_check_enabled: vec![],
tco_global_write_check_functions_enabled: s_set::SSet::new(),
tco_global_access_check_enabled: vec![],
tco_global_access_check_functions_enabled: s_set::SSet::new(),
po_enable_enum_supertyping: true,
po_interpret_soft_types_as_like_types: false,
tco_enable_strict_string_concat_interp: false,
Expand Down
6 changes: 3 additions & 3 deletions hphp/hack/src/oxidized_by_ref/gen/global_options.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// This source code is licensed under the MIT license found in the
// LICENSE file in the "hack" directory of this source tree.
//
// @generated SignedSource<<54540867c465e9e095690f8ca897b356>>
// @generated SignedSource<<7f2e8a77347250323dcd3eecaca58989>>
//
// To regenerate this file, run:
// hphp/hack/src/oxidized_regen.sh
Expand Down Expand Up @@ -158,9 +158,9 @@ pub struct GlobalOptions<'a> {
#[serde(deserialize_with = "arena_deserializer::arena", borrow)]
pub tco_ifc_enabled: &'a [&'a str],
#[serde(deserialize_with = "arena_deserializer::arena", borrow)]
pub tco_global_write_check_enabled: &'a [&'a str],
pub tco_global_access_check_enabled: &'a [&'a str],
#[serde(deserialize_with = "arena_deserializer::arena", borrow)]
pub tco_global_write_check_functions_enabled: s_set::SSet<'a>,
pub tco_global_access_check_functions_enabled: s_set::SSet<'a>,
pub po_enable_enum_supertyping: bool,
pub po_interpret_soft_types_as_like_types: bool,
pub tco_enable_strict_string_concat_interp: bool,
Expand Down
4 changes: 2 additions & 2 deletions hphp/hack/src/oxidized_by_ref/manual/global_options_impl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,8 @@ const DEFAULT: GlobalOptions<'_> = GlobalOptions {
po_disallow_inst_meth: false,
tco_use_direct_decl_parser: true,
tco_ifc_enabled: &[],
tco_global_write_check_enabled: &[],
tco_global_write_check_functions_enabled: s_set::SSet::empty(),
tco_global_access_check_enabled: &[],
tco_global_access_check_functions_enabled: s_set::SSet::empty(),
po_enable_enum_supertyping: true,
po_interpret_soft_types_as_like_types: false,
tco_enable_strict_string_concat_interp: false,
Expand Down
Loading

0 comments on commit 6730973

Please sign in to comment.