A static file server is told to serve files whose names start with a dot

tx0/ts:dotfiles-servedrecommendedwarningsecurity, cwe-538

What it finds

Files whose names start with a dot, such as .env, .git/config or .npmrc, often hold credentials and configuration. A static file server that serves them hands those to anyone who asks for the path.

Reported is the option dotfiles: "allow" in a call of static or serveStatic, as Express and serve-static take it.

From the rule's source, dotfiles_served.rs.

Example from the rule's tests
import express from "express";export const a = express.static("public", { dotfiles: "allow" });tx0 reports: .env and .git can be downloadedexport const b = express.static("public", { dotfiles: "ignore" });
Highlighted lines are the ones tx0 reports, with its message under each; the other lines are left alone.

Turn it on, off or suppress it

The rule runs from the recommended tier up. To turn it on in a lower tier, give it a level in tx0.toml:

tx0.toml
[rules]
"tx0/ts:dotfiles-served" = "warning"

To keep one finding, suppress it with a reason. tx0 suppress ID --reason "..." writes the comment on the line before the code:

// tx0: ignore[tx0/ts:dotfiles-served] reason="..."

tx0 explain tx0/ts:dotfiles-served shows the same in the terminal. Found a false positive? Report it.