Skip to content

Forward slashes in the cwd option cause "safe directory" check to fail erroneously. #1286

Closed

Description

@the-t-in-rtf

If you specify a value for the cwd option that contains forward slashes, such as c:/path/to/fixtures and then run Testem from a directory higher than that path, the tests will fail with 403 errors, because of this "safe dirs" check

The check will fail for a cwd value that contains forward slashes because one half of the comparison is run through path.resolve (which standardises the slashes), and one half (config.cwd()) isn't:

var filePath = path.resolve(config.resolvePath(uri));
    var ext = path.extname(filePath);
    var isPathPermitted = filePath.indexOf(config.cwd()) !== -1;

I will submit a pull that wraps the call to config.cwd() in a similar call to path.resolve, I have verified that this resolves the problem in local testing.

Activity

  1. added 2 commits that reference this issue on Aug 15, 2018
  2. added a commit that references this issue on Aug 16, 2018
  3. johanneswuerbach commented on Oct 26, 2026

    @johanneswuerbach
    Member

    Sorry for the very long wait on this one, and thanks for reporting it! The served-file containment check now normalizes the configured cwd with path.resolve and compares with path.relative (#2104), so a cwd with forward slashes like c:/path/to/fixtures no longer causes false 403s. Closing as outdated. If you still see this on a current testem version, please open a new issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions