Commit Graph

7 Commits

Author SHA1 Message Date
brian m. carlson
4505c620f1
debian/copyright: remove vendor directory
We're no longer including the `vendor` directory in our tarballs, so
delete the entries in the `debian/copyright` file.
2022-09-07 19:57:25 +00:00
brian m. carlson
a66274014c
tools: add a function to properly canonicalize paths
Git consistently uses canonicalized paths internally.  This is for many
reasons, but mostly to verify that a single path is within a repository.
In order to interoperate properly with Git, we need to canonicalize
paths and do it in the same way as Git.

On Unix systems, to canonicalize a path, it is sufficient to make the
path absolute and then resolve any symlinks.  Go provides two functions
to do these two steps, filepath.Abs and filepath.EvalSymlinks, and they
work as advertised.

Windows, however, has much more complex path handling and these
functions do not handle all cases.  The typical way to canonicalize
paths on Windows is using GetFinalPathNameByHandle, and this is the
technique Git uses.

Go, however, does not provide a general API to canonicalize paths,
unlike Rust's std::fs::canonicalize and similar functionality in myriad
other languages.  Therefore, in order to get this working on Windows,
let's add a function to canonicalize paths in the appropriate system
way, one for Unix systems and one for Windows.  The code comes from Go's
standard library, so update the copyright and license accordingly.

Update the CanonicalizePath function to use the new function.  We
duplicate the Abs call because we an absolute path in CanonicalizePath
in some cases even if the path is missing, whereas the new function
needs to do it in all cases because we will use it other situations in
the future.  This should be a simple string check, so it should not
involve an extra system call or other overhead.
2021-03-01 22:10:19 +00:00
brian m. carlson
74d5f2397f
subprocess: avoid using relative program names
When Go runs a program with os.exec, it uses the LookPath function to
look up the path name if the path does not contain a path separator.  On
Unix, this provides the standard Unix semantics by looking in PATH.
However, on Windows, it also looks in the current directory as well to
emulate the behavior of CMD.

Unfortunately, this is a well-known security flaw on Windows and similar
behavior there is the source for several whole classes of security
vulnerabilities.  This leads to an untrusted repository being able to
create a git.bat file that gets executed in preference to our trusted
path for the git binary.

Since we don't want to rely on Go fixing this behavior, let's import
some code from Go to provide the Unix semantics for LookPath, which are
secure if the user hasn't put the current directory in PATH.  That
should provide secure behavior in this case.  Fortunately, our code goes
through one particular place to run all commands, so this is a
relatively simple fix.

Update the various copyright and license files to reflect our imported
code.
2020-11-02 20:57:56 +00:00
brian m. carlson
6d92208550
debian: update copyright file
Update the Debian machine-readable copyright file to reflect all the
components used.
2020-01-15 18:24:57 +00:00
risk danger olson
8773193ca0 update other github/git-lfs references 2016-11-15 10:07:11 -07:00
Stephen Gelman
dbc190e518 Some cleanup to make debian package pass lintian checks 2015-07-08 02:24:38 +00:00
Stephen Gelman
a5acd518f0 Add debian directory and gitignore temporary build files 2015-05-15 15:27:21 +00:00