Unverified Commit ea744957 authored by Luke Sandberg's avatar Luke Sandberg Committed by GitHub

disallow reads from .next-profiles (#94570)

`next` already disallows reading out of `.next` during a build, this
extends that to the new `.next-profiles` directory

This is currently hardcoded (not end user configurable), so we just
hardcode the path in the next entrypoints.
parent 554a1e3c
...@@ -16,7 +16,8 @@ use next_core::{ ...@@ -16,7 +16,8 @@ use next_core::{
ClientChunkingContextOptions, get_client_chunking_context, get_client_compile_time_info, ClientChunkingContextOptions, get_client_chunking_context, get_client_compile_time_info,
}, },
next_config::{ next_config::{
ModuleIds as ModuleIdStrategyConfig, NextConfig, TurbopackPluginRuntimeStrategy, DIST_PROFILES_DIR_NAME, ModuleIds as ModuleIdStrategyConfig, NextConfig,
TurbopackPluginRuntimeStrategy,
}, },
next_edge::context::EdgeChunkingContextOptions, next_edge::context::EdgeChunkingContextOptions,
next_server::{ next_server::{
...@@ -1066,10 +1067,16 @@ impl Project { ...@@ -1066,10 +1067,16 @@ impl Project {
} }
}; };
// CPU profiles are written to `.next-profiles/` at the project root (see `--cpu-prof`).
// Deny access to it so the bundler doesn't traverse into the profiling output directory.
let denied_profiles_path = join_path(&self.project_path, DIST_PROFILES_DIR_NAME)
.unwrap()
.into();
Ok(DiskFileSystem::new_with_denied_paths( Ok(DiskFileSystem::new_with_denied_paths(
PROJECT_FILESYSTEM_NAME, PROJECT_FILESYSTEM_NAME,
*self.root_path, *self.root_path,
vec![denied_path], vec![denied_path, denied_profiles_path],
)) ))
} }
......
...@@ -46,6 +46,11 @@ use crate::{ ...@@ -46,6 +46,11 @@ use crate::{
util::relativize_glob, util::relativize_glob,
}; };
/// Name of the directory at the project root where CPU profiles are written when profiling is
/// enabled (see the `--cpu-prof` CLI flag). It is a fixed-name sibling of `distDir`, not
/// configurable. Kept here so the bundler and the napi bindings agree on the path.
pub const DIST_PROFILES_DIR_NAME: &str = ".next-profiles";
#[turbo_tasks::value(transparent)] #[turbo_tasks::value(transparent)]
pub struct ModularizeImports( pub struct ModularizeImports(
#[bincode(with = "turbo_bincode::indexmap")] FxIndexMap<String, ModularizeImportPackageConfig>, #[bincode(with = "turbo_bincode::indexmap")] FxIndexMap<String, ModularizeImportPackageConfig>,
......
...@@ -34,6 +34,7 @@ use next_api::{ ...@@ -34,6 +34,7 @@ use next_api::{
}; };
use next_core::{ use next_core::{
app_structure::find_app_dir, app_structure::find_app_dir,
next_config::DIST_PROFILES_DIR_NAME,
next_telemetry::ProjectFeatureUsageSummary, next_telemetry::ProjectFeatureUsageSummary,
tracing_presets::{ tracing_presets::{
TRACING_NEXT_OVERVIEW_TARGETS, TRACING_NEXT_TARGETS, TRACING_NEXT_TURBO_TASKS_TARGETS, TRACING_NEXT_OVERVIEW_TARGETS, TRACING_NEXT_TARGETS, TRACING_NEXT_TURBO_TASKS_TARGETS,
...@@ -463,7 +464,7 @@ pub fn project_new( ...@@ -463,7 +464,7 @@ pub fn project_new(
} else { } else {
PathBuf::from(&options.root_path) PathBuf::from(&options.root_path)
.join(&options.project_path) .join(&options.project_path)
.join(".next-profiles") .join(DIST_PROFILES_DIR_NAME)
.join("trace-turbopack") .join("trace-turbopack")
}; };
let trace_dir = trace_file let trace_dir = trace_file
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment