Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Catch an edge case in expand._assert_local() #3595

Merged
merged 2 commits into from Oct 14, 2022
Merged

Catch an edge case in expand._assert_local() #3595

merged 2 commits into from Oct 14, 2022

Commits on Sep 18, 2022

  1. Catch an edge case in expand._assert_local()

    Using str.startswith() has an edge case where someone can access files
    outside the root directory. For example, consider the case where the
    root directory is "/home/user/my-package" but some secrets are stored in
    "/home/user/my-package-secrets". Evaluating a check that
    "/home/user/my-package-secrets".startswith("/home/user/my-package") will
    return True, but the statement's intention is that no file outside of
    "/home/user/my-package" can be accessed.
    
    Using pathlib.Path.resolve() and pathlib.Path.parents eliminates this
    edge case.
    mssalvatore committed Sep 18, 2022
    Configuration menu
    Copy the full SHA
    4249da1 View commit details
    Browse the repository at this point in the history

Commits on Sep 23, 2022

  1. Use abspath() instead of resolve() in expand._assert_local()

    4249da1 uses `pathlib.Path.resolve()` instead of `os.path.abspath()`
    to canonicalize path names. `resolve()` resolves symlinks, whereas
    `abspath()` does not. `resolve()` can also raise a `RuntimeError` if
    infinite loops are discovered while resolving the path. There is some
    concern that using `resolve()` would not be backwards compatible. This
    commit switches back to `abspath()` but still uses `Path.parents` to
    avoid the edge case. See PR #3595 for more details.
    mssalvatore committed Sep 23, 2022
    Configuration menu
    Copy the full SHA
    063aecd View commit details
    Browse the repository at this point in the history