Skip to content

[Question] Why are dot-prefixed files considered "Sensitive"? #54712

Closed
@YuKitsune

Description

@YuKitsune

I spent a good amount of time trying to figure out why a Configuration Provider using the PhysicalFileProvider refused to read a dot-prefixed file (E.g. .env).
It turns out, dot-prefixed files are considered sensitive:

/// <summary>
/// Equivalent to <c>DotPrefixed | Hidden | System</c>. Exclude files and directories when the name begins with a period, or has either <see cref="FileAttributes.Hidden"/> or <see cref="FileAttributes.System"/> is set on <see cref="FileSystemInfo.Attributes"/>.
/// </summary>
Sensitive = DotPrefixed | Hidden | System,
/// <summary>
/// Exclude files and directories when the name begins with period.
/// </summary>
DotPrefixed = 0x0001,

It was introduced as part of this PR in the previous repository: aspnet/FileSystem#280

After finding this, I had two questions:

  1. Why are dot-prefixed files considered sensitive?
  2. Why are sensitive files excluded from PhysicalFileProvider by default.

For further context, I'm working on an app where I need to read the configuration from a file called .env. I kept getting FileNotFoundExceptions and had to dig into the source code to find out why.
I've attempted to address the confusing error in this PR: #54717

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-Extensions-FileSystemquestionAnswer questions and provide assistance, not an issue with source code or documentation.

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions