Skip to content

testPathForContractDistinctNamesDistinctPaths states a distinct-files guarantee its string-inequality assertion does not prove #71

Description

@thedavidmeister

Audit scope: whole-repo, commit 7aa85a4

Dimension 2 (test coverage) · low

test/lib/LibFs.t.sol:68-78 (test/src/lib/ after #56) —
testPathForContractDistinctNamesDistinctPaths

Problem

The comment states the guarantee as "Two contracts must never be handed the same
file: generation would silently overwrite one with the other," but the assertion
is string inequality of two paths. On a case-insensitive filesystem — macOS's
default, and foundry is routinely run there — Foo and foo are distinct
identifiers producing distinct path strings that resolve to the same file, so
the stated guarantee does not follow from what is proven.

Proposed fix

The library cannot fix this (it sees one name at a time), so the claim is what
has to move:

    /// Distinct names give distinct paths. Both names are built from the
    /// alphabet, so the pair is drawn from the domain the function accepts
    /// rather than from strings it refuses to produce a path for at all.
    /// Distinct paths are not distinct files on a case insensitive filesystem;
    /// that is a property of the filesystem and `pathForContract` documents it.

and in LibFs.pathForContract's NatSpec: "Names that differ only in case give
different paths, which a case insensitive filesystem resolves to the same file."

Metadata

Metadata

Labels

auditAudit findinglowAudit findingpass2Audit finding

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions