@@ -240,6 +240,12 @@ bool config_preserve_symlinks = false;
240240// that is used by lib/module.js
241241bool config_preserve_symlinks_main = false ;
242242
243+ // Set in node.cc by ParseArgs when --experimental-access-control is used.
244+ // Used in node_config.cc to set a constant on process.binding('config')
245+ // that is used by the bootstrapper.
246+ bool config_experimental_access_control = false ;
247+ AccessControl global_access_control;
248+
243249// Set in node.cc by ParseArgs when --experimental-modules is used.
244250// Used in node_config.cc to set a constant on process.binding('config')
245251// that is used by lib/module.js
@@ -2615,9 +2621,15 @@ static void PrintHelp() {
26152621 " --abort-on-uncaught-exception\n "
26162622 " aborting instead of exiting causes a\n "
26172623 " core file to be generated for analysis\n "
2624+ " --disable=featureA,featureB,...\n "
2625+ " experimental support for\n "
2626+ " disabling individual features\n "
2627+ " by listing them on the command line\n "
26182628#if HAVE_OPENSSL && NODE_FIPS_MODE
26192629 " --enable-fips enable FIPS crypto at startup\n "
26202630#endif // NODE_FIPS_MODE && NODE_FIPS_MODE
2631+ " --experimental-access-control experimental support for\n "
2632+ " disabling individual features\n "
26212633 " --experimental-modules experimental ES Module support\n "
26222634 " and caching modules\n "
26232635 " --experimental-repl-await experimental await keyword support\n "
@@ -2785,7 +2797,9 @@ static void CheckIfAllowedInEnv(const char* exe, bool is_env,
27852797 static const char * whitelist[] = {
27862798 // Node options, sorted in `node --help` order for ease of comparison.
27872799 // Please, update NODE_OPTIONS section in cli.md if changed.
2800+ " --disable" ,
27882801 " --enable-fips" ,
2802+ " --experimental-access-control" ,
27892803 " --experimental-modules" ,
27902804 " --experimental-repl-await" ,
27912805 " --experimental-vm-modules" ,
@@ -2982,6 +2996,18 @@ static void ParseArgs(int* argc,
29822996 config_preserve_symlinks = true ;
29832997 } else if (strcmp (arg, " --preserve-symlinks-main" ) == 0 ) {
29842998 config_preserve_symlinks_main = true ;
2999+ } else if (strncmp (arg, " --disable=" , 10 ) == 0 ) {
3000+ std::string unknown_item;
3001+ global_access_control.apply (
3002+ AccessControl::FromString (arg + 10 , &unknown_item));
3003+ if (!unknown_item.empty ()) {
3004+ fprintf (stderr, " %s: unknown --disable entry %s\n " ,
3005+ argv[0 ], unknown_item.c_str ());
3006+ exit (9 );
3007+ }
3008+ config_experimental_access_control = true ;
3009+ } else if (strcmp (arg, " --experimental-access-control" ) == 0 ) {
3010+ config_experimental_access_control = true ;
29853011 } else if (strcmp (arg, " --experimental-modules" ) == 0 ) {
29863012 config_experimental_modules = true ;
29873013 } else if (strcmp (arg, " --experimental-vm-modules" ) == 0 ) {
@@ -3081,6 +3107,12 @@ static void ParseArgs(int* argc,
30813107 exit (9 );
30823108 }
30833109
3110+ if (config_experimental_access_control) {
3111+ fprintf (stderr,
3112+ " Warning: Access control through disabling features is "
3113+ " experimental and may be changed at any time.\n " );
3114+ }
3115+
30843116 // Copy remaining arguments.
30853117 const unsigned int args_left = nargs - index;
30863118
0 commit comments