
Security News
Follow-up and Clarification on Recent Malicious Ruby Gems Campaign
A clarification on our recent research investigating 60 malicious Ruby gems.
A drop-in replacement for the current Pathname class.
gem install pathname2
require 'pathname2'
# Unix
path1 = Pathname.new("/foo/bar/baz")
path2 = Pathname.new("../zap")
path1 + path2 # "/foo/bar/zap"
path1 / path2 # "/foo/bar/zap" (same as +)
path1.exists? # Does this path exist?
path1.dirname # "/foo/bar"
path1.to_a # ['foo','bar','baz']
# Windows
path1 = Pathname.new("C:/foo/bar/baz")
path2 = Pathname.new("../zap")
path1 + path2 # "C:\\foo\\bar\\zap"
path1.root # "C:\\"
path1.to_a # ['C:','foo','bar','baz']
All forward slashes are converted to backslashes for Pathname objects.
If your pathname consists solely of ".", or "..", the return value for Pathname#clean will be different. On Win32, "\" is returned, while on Unix "." is returned. I consider this an extreme edge case and will not worry myself with it.
to_a
and root
instance methods.Pathname#cleanpath
method works differently - it always returns
a canonical pathname. In addition, there is no special consideration
for symlinks (yet), though I'm not sure it warrants it.Pathname#+
method auto cleans.Pathname#clean
works slightly differently. In the stdlib version,
Pathname#clean("../a")
returns "../a". In this version, it returns "a".
This affects other methods, such as Pathname#relative_path_from
.pn
method as a shortcut.Because there is some overlap in method names between File, Dir, and FileUtils, the priority is as follows:
In other words, whichever of these defines a given method first is the method that is used by the pathname2 library.
On MS Windows, some methods may not work on pathnames greater than 260 characters because of internal function limitations.
Any issues you find should be reported on the project page at https://github.com/djberg96/pathname2
None at this time. Suggestions welcome.
Apache-2.0
(C) 2003-2021 Daniel J. Berger All rights reserved.
This library is provided "as is" and without any express or implied warranties, including, without limitation, the implied warranties of merchantability and fitness for a particular purpose.
Daniel J. Berger
FAQs
Unknown package
We found that pathname2 demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
A clarification on our recent research investigating 60 malicious Ruby gems.
Security News
ESLint now supports parallel linting with a new --concurrency flag, delivering major speed gains and closing a 10-year-old feature request.
Research
/Security News
A malicious Go module posing as an SSH brute forcer exfiltrates stolen credentials to a Telegram bot controlled by a Russian-speaking threat actor.