timthumb.php の脆弱性が直されたタイミング
http://blog.vaultpress.com/2011/08/02/vulnerability-found-in-timthumb/ で見つかった脆弱性の対応
$ svn diff -c 143 (svn)-[trunk:r143][~/lang/php/timthumb-read-only] Index: timthumb.php =================================================================== --- timthumb.php (revision 142) +++ timthumb.php (revision 143)@@ -665,7 +665,7 @@ $isAllowedSite = false; foreach ($allowedSites as $site) { - if (strpos (strtolower ($url_info['host']), $site) !== false) { + if (strpos (strtolower ($url_info['host'] . '/'), $site) !== false) { $isAllowedSite = true; } }
define ('VERSION', '1.33'); // version number (to force a cache refresh)
$ svn log -r 143 (svn)-[trunk:r143][~/lang/php/timthumb-read-only] ------------------------------------------------------------------------ r143 | binarymoon@gmail.com | 2011-08-02 17:33:10 +0900 (火, 02 8 2011) | 1 line stronger website domain checks (don't allow http://wordpress.com.hacker.com/) ------------------------------------------------------------------------
ここで対策が取られている
$ svn log -r 144 (svn)-[trunk:r143][~/lang/php/timthumb-read-only] ------------------------------------------------------------------------ r144 | binarymoon@gmail.com | 2011-08-02 18:41:38 +0900 (火, 02 8 2011) | 1 line even stronger website domain name checks for clean domains ------------------------------------------------------------------------
$ svn diff -c 144 (svn)-[trunk:r191][~/lang/php/timthumb-read-only] Index: timthumb.php =================================================================== --- timthumb.php (revision 143) +++ timthumb.php (revision 144) @@ -14,7 +14,7 @@ define ('CACHE_CLEAR', 20); // maximum number of files to delete on each cache clear define ('CACHE_USE', TRUE); // use the cache files? (mostly for testing) define ('CACHE_MAX_AGE', 864000); // time to cache in the browser -define ('VERSION', '1.33'); // version number (to force a cache refresh) +define ('VERSION', '1.34'); // version number (to force a cache refresh) define ('DIRECTORY_CACHE', './cache'); // cache directory define ('MAX_WIDTH', 1500); // maximum image width define ('MAX_HEIGHT', 1500); // maximum image height @@ -656,6 +656,8 @@ } } + $isAllowedSite = false; + // check allowed sites (if required) if (ALLOW_EXTERNAL) { @@ -663,9 +665,8 @@ } else { - $isAllowedSite = false; foreach ($allowedSites as $site) { - if (strpos (strtolower ($url_info['host'] . '/'), $site) !== false) { + if (preg_match ('/(?:^|\.)' . $site . '$/i', $url_info['host'])) { $isAllowedSite = true; } }
r144 でも対応が取られているが正規表現を使ったりして、苦心が伺える。
ちなみに現在 (20111130 現在、version 2.8.3、r191) は正規表現を使ってない。
基本的には version 1.33 以降の timthumb.php であれば問題ないといえる。
参考
Nonopaste.vim を書いてみた
基本的な動機は、nonopaste-cli を書いた - @kyanny's blog で書かれている内容と同じです。
部分選択がポストできるのがちょっと便利かな、と。
Mac で OpenOffice を利用時に白黒で印刷する
毎回完全に分からなくなるので書いておく。
正確には白黒では印刷できなくて、「色をグレースケールに変換する」、
ということしかできないが、
OpenOffice > 設定 > OpenOffice.org > 印刷 > 色をグレースケールに変換する にチェックをつける
zsh で rvm-prompt を表示する
rvm 1.8.0 にあげてみたら rvm-prompt の仕様が変わっていて、引数によって表示できるようになってた。
http://beginrescueend.com/workflow/prompt/
(i)nterpreter - interpreter abreviation (default)
(v)ersion - version (default)
(p)atchlevel - patch level (default)
(g)emset - current gemset (default)
(r)evision - revison
(a)rchitecture - architecture
(u)nicode - single unicode character representation of interpreter
(s)ystem - echo "system" when using system ruby
これで、それまでの rvm-prompt では [ruby-1.9.2-p290@foo] までがでていたのが、
[1.9.2@foo] (gemset を選択してない時は [1.9.2]) みたいに
そのプロジェクトに必要な情報だけ表示できるようになっていい感じです。
下みたいな関数を .zshrc に書いて、RPROMPT にいれて使ってみます
# show rvm prompt like "1.9.2@gemset_name" function rvm_prompt { result=`rvm-prompt v g 2> /dev/null` if [ "$result" ] ; then echo "[$result]" fi }
https://github.com/banyan/config/blob/3bad3cacf836ab37de12255ad58268ecf0a82cc6/.zshrc
Webistrano + rsync のメモ
- Webistrano を使っていて、Capistrano + rsync で省エネデプロイ - 肉とビールとパンケーキ by @sotarok を参考にさせてもらって Webistrano + rsync をしてみたのでメモ
- webistrano のバージョン。割と最近のです。
commit a98ba6b161ee5aedf4b7198a0a909be32bb0b9a6 Author: Jonathan Weiss <jw@innerewut.de> Date: Fri May 20 21:18:11 2011 +0200
- 最近の Webistrano は bundler に対応したので、Gemfile に gem を追加。直接読み込めなかったので、git のソースを指定して、$ bundle
gem "capistrano_rsync_with_remote_cache", :git => "git://github.com/luisparravicini/capistrano_rsync_with_remote_cache.git", :branch => "v2.3.6"
set :scm, :git set :deploy_via, :rsync_with_remote_cache set :git_enable_submodules, true set :local_cache, "/var/cache/webistrano/[repository_name]" set :repository, "ssh://git@gitserver.local/path/to/repository.git" # repository は今まで通り set :rsync_options, '-a --delete --delete-excluded --exclude=.git'
Webistrano の Recipe で特定の変数を使う
@@ -212,6 +212,7 @@ def set_project_and_stage_names(config) config.set(:webistrano_project, deployment.stage.project.webistrano_project_name) config.set(:webistrano_stage, deployment.stage.webistrano_stage_name) + config.set(:webistrano_user, deployment.user.login) unless deployment.user.nil? end # casts a given string to the correct Ruby value
とか割り当てると、レシピで任意の情報が使えるみたい
- http://groups.google.com/group/webistrano/browse_thread/thread/52c90bd4742db1d2
- unless deployment.user.nil? で確かめないと、レシピ自体はうまくいくが、stage の task を load する処理で失敗する