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

Fixes to git commands hardening. #720

Open
wants to merge 2 commits into
base: 0.10.3
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 37 additions & 2 deletions autoload/vundle/installer.vim
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,38 @@ func! s:process(bang, cmd)
endf


" ---------------------------------------------------------------------------
" Parse the output from git log after an update to create a change log for the
" user.
" ---------------------------------------------------------------------------
func! vundle#installer#create_changelog() abort
let changelog = ['Updated Plugins:']
for bundle_data in g:vundle#updated_bundles
let initial_sha = bundle_data[0]
let updated_sha = bundle_data[1]
let bundle = bundle_data[2]

let cmd = s:make_git_command(bundle, ['log', '--pretty=format:%s %an, %ar',
\ '--graph', initial_sha.'..'.updated_sha ])

let updates = system(cmd)

call add(changelog, '')
call add(changelog, 'Updated Plugin: '.bundle.name)

if bundle.uri =~ "https://github.com"
call add(changelog, 'Compare at: '.bundle.uri[0:-5].'/compare/'.initial_sha.'...'.updated_sha)
endif

for update in split(updates, '\n')
let update = substitute(update, '\s\+$', '', '')
call add(changelog, ' '.update)
endfor
endfor
return changelog
endf


" ---------------------------------------------------------------------------
" Call another function in the different Vundle windows.
"
Expand Down Expand Up @@ -372,9 +404,12 @@ func! s:make_git_command(bundle, args) abort
let workdir = a:bundle.path()
let gitdir = workdir.'/.git/'

let git = [g:vundle#git_executable, '--git-dir='.gitdir, '--work-tree='.workdir]
let git_cmd = [g:vundle#git_executable, '--git-dir', gitdir]
if a:args[0] != 'clone'
let git_cmd = git_cmd + ['-C', workdir, '--work-tree', workdir]
endif

return join(map(git + a:args, 'vundle#installer#shellesc(v:val)'))
return join(map(git_cmd + a:args, 'vundle#installer#shellesc(v:val)'))
endf

" ---------------------------------------------------------------------------
Expand Down
34 changes: 1 addition & 33 deletions autoload/vundle/scripts.vim
Original file line number Diff line number Diff line change
Expand Up @@ -73,38 +73,6 @@ func! s:view_log()
endf


" ---------------------------------------------------------------------------
" Parse the output from git log after an update to create a change log for the
" user.
" ---------------------------------------------------------------------------
func! s:create_changelog() abort
let changelog = ['Updated Plugins:']
for bundle_data in g:vundle#updated_bundles
let initial_sha = bundle_data[0]
let updated_sha = bundle_data[1]
let bundle = bundle_data[2]

let cmd = s:make_git_command(bundle, ['log', '--pretty=format:"%s %an, %ar"',
\ '--graph', initial_sha.'..'.updated_sha ])

let updates = system(cmd)

call add(changelog, '')
call add(changelog, 'Updated Plugin: '.bundle.name)

if bundle.uri =~ "https://github.com"
call add(changelog, 'Compare at: '.bundle.uri[0:-5].'/compare/'.initial_sha.'...'.updated_sha)
endif

for update in split(updates, '\n')
let update = substitute(update, '\s\+$', '', '')
call add(changelog, ' '.update)
endfor
endfor
return changelog
endf


" ---------------------------------------------------------------------------
" View the change log after an update or installation.
" ---------------------------------------------------------------------------
Expand All @@ -116,7 +84,7 @@ func! s:view_changelog()
if bufloaded(s:changelog_file)
execute 'silent bdelete' s:changelog_file
endif
call writefile(s:create_changelog(), s:changelog_file)
call writefile(vundle#installer#create_changelog(), s:changelog_file)
execute 'silent pedit' s:changelog_file
set bufhidden=wipe
setl buftype=nofile
Expand Down