Skip to content

Commit 36a214d

Browse files
committed
docs: improve security documentation
Minor wording fixes. Increases visibility of `Builder::permissions`, the `NamedTempFile` Security documentation and `env::override_temp_dir`. Partially addresses Stebalien#303.
1 parent 16209da commit 36a214d

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

src/lib.rs

+9-6
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,12 @@
2626
//! In the presence of pathological temporary file cleaner, relying on file paths is unsafe because
2727
//! a temporary file cleaner could delete the temporary file which an attacker could then replace.
2828
//!
29-
//! `tempfile` doesn't rely on file paths so this isn't an issue. However, `NamedTempFile` does
30-
//! rely on file paths for _some_ operations. See the security documentation on
31-
//! the `NamedTempFile` type for more information.
29+
//! `tempfile` doesn't rely on file paths, so this should not be an issue. However,
30+
//! `NamedTempFile` does rely on file paths for _some_ operations. On Unix-like
31+
//! operating systems and depending on your use case, it may be possible to
32+
//! mitigate this issue by overriding the crate's default options. For more information,
33+
//! consult the Security documentation of the [`NamedTempFile`] type,
34+
//! [`Builder::permissions`] and [`env::override_temp_dir`].
3235
//!
3336
//! The OWASP Foundation provides a resource on vulnerabilities concerning insecure
3437
//! temporary files: https://owasp.org/www-community/vulnerabilities/Insecure_Temporary_File
@@ -172,7 +175,7 @@ pub use crate::file::{
172175
};
173176
pub use crate::spooled::{spooled_tempfile, SpooledData, SpooledTempFile};
174177

175-
/// Create a new temporary file or directory with custom parameters.
178+
/// Create a new temporary file or directory with custom parameters and permissions.
176179
#[derive(Debug, Clone, Eq, PartialEq)]
177180
pub struct Builder<'a, 'b> {
178181
random_len: usize,
@@ -349,7 +352,7 @@ impl<'a, 'b> Builder<'a, 'b> {
349352
///
350353
/// # Security
351354
///
352-
/// By default, the permissions of tempfiles on unix are set for it to be
355+
/// By default, the permissions of tempfiles on Unix are set for it to be
353356
/// readable and writable by the owner only, yielding the greatest amount
354357
/// of security.
355358
/// As this method allows to widen the permissions, security would be
@@ -369,7 +372,7 @@ impl<'a, 'b> Builder<'a, 'b> {
369372
/// ## Windows and others
370373
///
371374
/// This setting is unsupported and trying to set a file or directory read-only
372-
/// will cause an error to be returned..
375+
/// will return an error.
373376
///
374377
/// # Examples
375378
///

0 commit comments

Comments
 (0)