From 8e87c9fb6fc619a4bdb092555a156df65ff05b56 Mon Sep 17 00:00:00 2001 From: Amr Bashir Date: Sat, 17 Jun 2023 15:17:36 +0300 Subject: [PATCH] fix(core): fix `require_literal_leading_dot` flipped behavior (#7227) --- .changes/config.json | 1 + .changes/core-leading-dot.md | 5 +++++ core/tauri-config-schema/schema.json | 2 +- core/tauri-utils/src/config.rs | 2 +- core/tauri/src/scope/fs.rs | 8 ++++---- tooling/cli/schema.json | 2 +- 6 files changed, 13 insertions(+), 7 deletions(-) create mode 100644 .changes/core-leading-dot.md diff --git a/.changes/config.json b/.changes/config.json index 33ce3a18926..0969381b137 100644 --- a/.changes/config.json +++ b/.changes/config.json @@ -7,6 +7,7 @@ "bug": "Bug Fixes", "pref": "Performance Improvements", "changes": "What's Changed", + "sec": "Security fixes", "deps": "Dependencies" }, "defaultChangeTag": "changes", diff --git a/.changes/core-leading-dot.md b/.changes/core-leading-dot.md new file mode 100644 index 00000000000..432d94ac656 --- /dev/null +++ b/.changes/core-leading-dot.md @@ -0,0 +1,5 @@ +--- +'tauri': 'patch:sec' +--- + +Fix regression in `1.4` where the default behavior of the file system scope was changed to allow reading hidden files and directories by default. diff --git a/core/tauri-config-schema/schema.json b/core/tauri-config-schema/schema.json index 475211b8840..206ad2b5c93 100644 --- a/core/tauri-config-schema/schema.json +++ b/core/tauri-config-schema/schema.json @@ -1935,7 +1935,7 @@ } }, "requireLiteralLeadingDot": { - "description": "Whether or not paths that contain components that start with a `.` will require that `.` appears literally in the pattern; `*`, `?`, `**`, or `[...]` will not match. This is useful because such files are conventionally considered hidden on Unix systems and it might be desirable to skip them when listing files.\n\nDefaults to `false` on Unix systems and `true` on Windows", + "description": "Whether or not paths that contain components that start with a `.` will require that `.` appears literally in the pattern; `*`, `?`, `**`, or `[...]` will not match. This is useful because such files are conventionally considered hidden on Unix systems and it might be desirable to skip them when listing files.\n\nDefaults to `true` on Unix systems and `false` on Windows", "type": [ "boolean", "null" diff --git a/core/tauri-utils/src/config.rs b/core/tauri-utils/src/config.rs index b8a1792934d..e256a7d7ee7 100644 --- a/core/tauri-utils/src/config.rs +++ b/core/tauri-utils/src/config.rs @@ -1195,7 +1195,7 @@ pub enum FsScope { /// conventionally considered hidden on Unix systems and it might be /// desirable to skip them when listing files. /// - /// Defaults to `false` on Unix systems and `true` on Windows + /// Defaults to `true` on Unix systems and `false` on Windows // dotfiles are not supposed to be exposed by default on unix #[serde(alias = "require-literal-leading-dot")] require_literal_leading_dot: Option, diff --git a/core/tauri/src/scope/fs.rs b/core/tauri/src/scope/fs.rs index 754720e7d43..8a1bdc2306d 100644 --- a/core/tauri/src/scope/fs.rs +++ b/core/tauri/src/scope/fs.rs @@ -108,9 +108,9 @@ impl Scope { } => *require, // dotfiles are not supposed to be exposed by default on unix #[cfg(unix)] - _ => false, - #[cfg(windows)] _ => true, + #[cfg(windows)] + _ => false, }; Ok(Self { @@ -281,9 +281,9 @@ mod tests { require_literal_separator: true, // dotfiles are not supposed to be exposed by default on unix #[cfg(unix)] - require_literal_leading_dot: false, - #[cfg(windows)] require_literal_leading_dot: true, + #[cfg(windows)] + require_literal_leading_dot: false, ..Default::default() }, } diff --git a/tooling/cli/schema.json b/tooling/cli/schema.json index 475211b8840..206ad2b5c93 100644 --- a/tooling/cli/schema.json +++ b/tooling/cli/schema.json @@ -1935,7 +1935,7 @@ } }, "requireLiteralLeadingDot": { - "description": "Whether or not paths that contain components that start with a `.` will require that `.` appears literally in the pattern; `*`, `?`, `**`, or `[...]` will not match. This is useful because such files are conventionally considered hidden on Unix systems and it might be desirable to skip them when listing files.\n\nDefaults to `false` on Unix systems and `true` on Windows", + "description": "Whether or not paths that contain components that start with a `.` will require that `.` appears literally in the pattern; `*`, `?`, `**`, or `[...]` will not match. This is useful because such files are conventionally considered hidden on Unix systems and it might be desirable to skip them when listing files.\n\nDefaults to `true` on Unix systems and `false` on Windows", "type": [ "boolean", "null"