Skip to content

Commit

Permalink
Only allow a --filename that resolves to file in pwd
Browse files Browse the repository at this point in the history
An arbitrary filename can be a "security" issue. Also, check the
--package parameter, because otherwise we could "modify" an arbitrary
*.changes file (less critical, though).
  • Loading branch information
marcus-h committed Sep 4, 2018
1 parent b5ca8d6 commit 4f80307
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions git_tarballs
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,14 @@ def update_changes_file(package, changes):
f.close()


def _check_filenames(*filenames):
for filename in filenames:
basename = os.path.basename(filename)
if os.path.abspath(filename) != os.path.abspath(basename):
# no arbitrary filename, please
sys.exit("%s: illegal filename" % filename)


if __name__ == '__main__':
parser = argparse.ArgumentParser(description='Git Tarballs')
parser.add_argument('--url', required=True,
Expand All @@ -281,6 +289,7 @@ if __name__ == '__main__':
if not args.package:
args.package = os.getcwd().rsplit("/", 1)[1]

_check_filenames(args.filename, args.package)
download_tarball(args.url, args.filename)

changelog = get_changelog_from_tarball(args.filename)
Expand Down

0 comments on commit 4f80307

Please sign in to comment.