背景
见github运维给12306_ticket_helper(一款用于辅助在12306.CN上购票的Chrome&Firefox脚本)的issue:https://github.com/iccfish/12306_ticket_helper/issues/16
jnewland opened this issue 6 hours ago
raw.github.com embeds disabled
No milestone
No one is assigned
Hi, I’m @jnewland, a member of GitHub’s Ops Team.
We’ve detected that https://dynamic.12306.cn/otsweb/ is embedding several javascript files from this repo, causing a negative impact on our service. We’ve disabled hotlinking to resources from this repo via the raw.github.com domain for the time being.
I’ve contacted abuse@12306.cn about this, but figured I’d file an issue here too. If you’re a developer on 12306.cn, please remove this embed and host this file from your own servers as soon as possible. Thanks!
大意是,github的运维发现来自https://dynamic.12306.cn/otsweb/的页面,内嵌了几个来自12306_ticket_helper项目库的脚本文件,导致github的服务出现负面影响。当前解决方法是暂时屏蔽从raw.github.com访问这几个脚本。
有意思的是,运维以为这个库是12306.cn的开发者,请求尽快删掉内嵌的内容。
iccfish commented 5 hours ago
Sorry for this inconvenience, I will remove this script reference immediatly. This script used for check new version from repositiory, from now on this script will be removed, and will never do this agagin after they all update they client scrips.
Very sorry for this.
该脚本作者回应是说,这个脚本本意是用于提醒升级的,现在已经移除。
后面还有数个运维请求和应急调整情况,以及作者对这个问题的解释:在设计上,若脚本载入失败(http 40x)后,会5秒重试一次,结果惹祸。
具体见issue。
微博的@quakewang评论道“看来以后要ddos什么网站,做个12306的插件就行了。”(http://weibo.com/1686211971/zeAYQhQTn)
代码回溯(仅分析指向github的时机)
出现问题的代码主要集中在12306_ticket_helper.user.js。
此插件作者,最早是将升级版本文件放在自己的服务器上。
“2012年5月26日:第一次完整发布”
https://github.com/iccfish/12306_ticket_helper/commit/f06d22cb10064abe9368f10772ab86a5e4fa7162
//#region 检查更新
function checkUpdate() {
if (isFirefox) {
if (typeof (GM_xmlhttpRequest) == “undefined”) return;
var request = GM_xmlhttpRequest({
url:”http://em.tiande.com/fish/44.txt”,
……(略)
}
function updateScriptContentForChrome() {
var updateScipt = document.createElement(‘script’);
updateScipt.src = ‘http://em.tiande.com/fish/44.js?’ + Math.random();
……(略)
}
到了2012年8月份,作者为了避免浏览器的安全限制,开始将repo当作静态服务器使用。
“8月23日,3.0.6”
“修改检查更新所使用的地址,避免出现不安全脚本不让更新的问题”
https://github.com/iccfish/12306_ticket_helper/commit/3906ed2301e94b93dc795d84eff96dd1670a967a
function updateScriptContentForChrome() {
var updateScipt = document.createElement(‘script’);
– updateScipt.src = ‘http://www.fishlee.net/file/44/version.js?’ + Math.random();
+ updateScipt.src = ‘https://github.com/iccfish/12306_ticket_helper/raw/master/version.js?’ + Math.random();
……(略)
}
“2012年9月13日,3.2.9, 彻底修正登录人多时自动重试过快的问题;修改默认音乐地址,避免浏览器安全设置导致没有音乐;”
https://github.com/iccfish/12306_ticket_helper/commit/c6c4e566d5818987a647ce45b575414e3727ab7e
getAudioUrl: function () {
/// <summary>获得音乐地址</summary>
– return window.localStorage[“audioUrl”] || “http://www.w3school.com.cn/i/song.ogg”;
+ return window.localStorage[“audioUrl”] || “https://github.com/iccfish/12306_ticket_helper/raw/master/res/song.ogg”;
},
2012年9月,开始直接将repo当作静态服务器使用。
“2012-9-18,允许禁用自动登录改用手动登录”
https://github.com/iccfish/12306_ticket_helper/commit/83ca4de0d542b317a4adf91b36931ea0dfd7bdb4
function updateScriptContentForChrome() {
var updateScipt = document.createElement(‘script’);
– updateScipt.src = ‘https://github.com/iccfish/12306_ticket_helper/raw/master/version.js?’ + Math.random();
+ updateScipt.src = ‘https://github.com/iccfish/12306_ticket_helper/raw/master/version.js’;
……(略)
}
“2012年9月19日:3.4.0 released.”
https://github.com/iccfish/12306_ticket_helper/commit/b707e6d3dec5f370e42c94eef885faf4d0fef895
getAudioUrl: function () {
/// <summary>获得音乐地址</summary>
– return window.localStorage[“audioUrl”] || “https://github.com/iccfish/12306_ticket_helper/raw/master/res/song.ogg”;
+ return window.localStorage[“audioUrl”] || (navigator.userAgent.indexOf(“Firefox”) != -1 ? “https://github.com/iccfish/12306_ticket_helper/raw/master/res/song.ogg” : “http://www.w3school.com.cn/i/song.ogg”);
},
“2012年9月20日:添加音乐资源”
https://github.com/iccfish/12306_ticket_helper/commit/9b89ea54540498c137a21bda3cbc1f2537062580
(这个……有点凶残啊……)
“2012年9月20日:项目重新组织结构”
https://github.com/iccfish/12306_ticket_helper/commit/c307219a897269a66d082183add6d40ea581017c
getFailAudioUrl: function () {
return (utility.isWebKit() ? “http://resbak.fishlee.net/res/” : “https://github.com/iccfish/12306_ticket_helper/raw/master/res/”) + “music3.ogg”;
},
……
function updateScriptContentForChrome() {
var updateScipt = document.createElement(‘script’);
updateScipt.src = ‘https://github.com/iccfish/12306_ticket_helper/raw/master/version.js’;
……(略)
}
与此同时,作者还与数个国产浏览器(淘宝浏览器、猎豹浏览器)合作,进行特别版本制作。相关的文件仍然放在repo下面。
而这些浏览器针对节日,对捆绑此插件的浏览器进行特别主推,比如2013年1月14日前后,猎豹浏览器以春运为时机进行主推(http://12306.liebao.cn/ ),从而客观上助长了悲剧的发生。
悲剧发生后,作者紧急进行了更新,具体见“2013-1-15:4.1.0 released.”,此处不再贴代码:https://github.com/iccfish/12306_ticket_helper/commit/eaa4e00c6845972f141d98a8a599f88fb25edbda
建议
在这里,呼吁前端开发者,不要把版本库(repo)当作静态文件服务器来使用,这就是一个很好的反例。
另引用@xslidian 在zone.wooyun.org上的评论:“github 尽可能为用户提供便利,所有高开销操作均不作限制不设缓存。可这次不但付费用户受影响造成损失,还要被不明事理的人辱骂单方面违背服务条款。免费基础服务来之不易,大家要好好珍惜!”(来源:http://zone.wooyun.org/content/2360 )
其它
2013-1-15 21:00最新消息,猎豹浏览器在配合作者修复中。
2013-1-15 21:00 @johnhax 称,原脚本作者将相关文件转移到sae中(http://weibo.com/1960954893/zeCb13Eix ;https://github.com/iccfish/12306_ticket_helper/issues/16#issuecomment-12264481 )
==
这就是所谓的小问题乘以十三亿都是大问题的典范
Leave a Reply