Scanning the Internet for External Cloud Exposures via SSL Certs
Tricking Bundler
1. Tricking Bundler
aka developing app & gem w/o roundtrips
aka no more
gem.git (at master) is not checked out. Please run `bundle install`
Rome Ruby Social Club - March 23, 2012
Saturday, March 24, 2012
2. Bundler + Git
Gem dependencies manager (that gets
caching right ;-)
Allows to install gems from Git
repositories
This trick is for Git gems only
Rome Ruby Social Club - March 23, 2012
Saturday, March 24, 2012
3. How does it work
Parses Gemfile & Gemfile.lock
git fetch && git checkout in
`gem environment gemdir`/bundler/
gems/$NAME-$REF12
Add the checked out directory to
Ruby’s $LOAD_PATH
Rome Ruby Social Club - March 23, 2012
Saturday, March 24, 2012
4. Problem
Your project is in ~/code/app
Your gem is in ~/code/gem
You run the app and need to change
the gem code
cd ~/code/gem; <code>; git commit;
git push; cd ~/code/app; bundle up
gem # DOESN’T fit the job
Rome Ruby Social Club - March 23, 2012
Saturday, March 24, 2012
5. Symlinks to the
rescue!
Bundler directory contains all git-
fetched gems with this format:
$GEM_NAME-$REF12 (first 12 chars of
the HEAD SHA1 commit id)
Bash script gets ~/code/gems HEAD
ref && ln -s ~/code/gem to the
directory bundler expects the gem in
Profit!
Rome Ruby Social Club - March 23, 2012
Saturday, March 24, 2012
6. Solution
You edit the gem code directly in
your ~/code/gem - app picks it up
Once done, git commit && git show to
get HEAD SHA1 id
Update SHA1 in Gemfile.lock directly
symlink-gem ../gem
Rome Ruby Social Club - March 23, 2012
Saturday, March 24, 2012
7. Switching branches?
master branch needs commit c4feb4be
develop branch needs commit de4db3ef
(develop) git co master; for gem in
a b c d; do symlink-gem ../$gem;
done
# DOESN’T cut the job either ;-)
Rome Ruby Social Club - March 23, 2012
Saturday, March 24, 2012
8. Bundle::LockFileParser
is your friend
Ruby script gets all dependencies in
a nicely wrapped Array of Sources
For each Git-fetched $gem, check out
the commit required by Gemfile.lock
in your ~/code/$gem
%x{ symlink-gem #{gem} }
Why not git post-checkout-hook? :)
Rome Ruby Social Club - March 23, 2012
Saturday, March 24, 2012
9. Switch branches
w/post-checkout-hook
18:04:02 [vjt@debian ~/code/app] (develop) $ git co master
Switched to branch 'master'
[git://github.com/vjt/rtf.git] Already on 'master'
[git://github.com/vjt/dep1.git] HEAD is now at df61eac...
Fixed stuff
[git://github.com/vjt/dep2.git] Previous HEAD position was
45509fa... Experimental stuff
Switched to branch 'master'
[git://github.com/ifad/activerecord-sybase-adapter.git]
Already on 'master'
Rome Ruby Social Club - March 23, 2012
Saturday, March 24, 2012
10. Thanks!
@vjt
vjt@openssl.it
http://sindro.me/
http://github.com/vjt
Rome Ruby Social Club - March 23, 2012
Saturday, March 24, 2012