Skip to content

Commit

Permalink
Merge commit '1647e6ae0ec6fbcfa1247eea6c6e1aa3a08eb7ed'
Browse files Browse the repository at this point in the history
  • Loading branch information
shejinxin committed Apr 29, 2024
2 parents 39836c7 + 1647e6a commit 202bb9c
Show file tree
Hide file tree
Showing 128 changed files with 5,141 additions and 1,553 deletions.
1 change: 1 addition & 0 deletions vendor/whistle/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -64,3 +64,4 @@ coverage
_book
dist
/.history
/test/temp_files
78 changes: 78 additions & 0 deletions vendor/whistle/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,81 @@
# v2.9.70
1. feat: 插件列表添加自定义右键菜单
2. feat: 支持通过 `pattern jsAppend://[value|file|url] linePropslineProps://nomodule lineProps://module lineProps://defer lineProps://async lineProps://crossorigin` 设置标签属性

# v2.9.69
1. fix: https://github.com/avwo/whistle/issues/1064
2. feat: 支持通过 `http://local.whistlejs.com/?dataUrl=encodeURIComponent(dataUrl)` 导入 `dataUrl` 返回的数据

# v2.9.68
1. feat: 新增 `enable://abortRes` 在响应阶段中断请求
2. feat: 优化界面展示

# v2.9.67
1. feat: 新增 `enable://requestWithMatchedRules``enable://responseWithMatchedRules` 支持在请求头或响应头带上当前匹配的规则
2. feat: 调整 Tools/Console 日志的缓存大小
3. feat: Values 的编辑器添加快捷键 `Shift + Ctrl[Command] + F``Shift + Ctrl[Command] + I` 分别用来格式化和通过 JSONView 查看 JSON 数据
4. feat: Whistle 默认会对 WebSocket 压缩包进行解压,有[用户反馈存在解压bug][https://github.com/avwo/whistle/issues/1048],故新增 `wss://xxx disable://wsDecompress` 禁止解压数据包
5. feat: WebSocket Frames 列表添加右键功能

# v2.9.66
1. feat: 支持通过正则表达式搜索日志
2. feat: 支持通过 `disable://captureHttp disable://captureHttps` 关闭 http 或 https 的 TUNNEL 请求

# v2.9.65
1. feat: 支持 Rules 里面的 Values 和临时文件通过 Ctrl[Command] + 鼠标点击快速修改
2. feat: 新增默认临时空白文件 `temp/blank`(支持自定义后缀 `temp/blank.xxx`
> 可以通过在 Rules 新建文件 `protocol://temp/blank.xxx` 再通过Ctrl[Command] + 鼠标点击快速修改生成新的临时文件
3. feat: Values 右键菜单新增 JSON / Inspect 查看 JSON 数据对象

# v2.9.64
1. feat: Mock 功能支持对临时文件添加注释
2. feat: 优化 Rules & Values 的拖拽功能
3. fix: https://github.com/avwo/whistle/issues/1040

# v2.9.63
1. feat: 支持 Cookie 的 `Partitioned` 属性(该属性需要跟 `Secure``SameSite=None` 一起使用)
2. feat: Composer 添加 `CopyAsCURL` 按钮
3. feat: Composer 添加 `ProxyRules` 选项,去选后可以禁用 Proxy (Whistle) 设置的所有规则(Proxy 里面的规则优先级高于 Composer Rules)

# v2.9.62
1. chore: 更新 CodeMirror 版本
2. feat: Network Settings 支持导入导出
3. feat: Rules & Values 支持通过 `b:keyword` 搜索内容
4. feat: Composer 支持导入导出
5. feat: 插件 Option 支持设置 `openInModal` 以对话框形式打开
6. feat: Network 列表新增 `Back to the bottom` 按钮

# v2.9.61
1. fix: 在新版本 Node 可能存在 [pipe](https://wproxy.org/whistle/rules/pipe.html) 功能失效问题
2. fix: https://github.com/avwo/whistle/issues/1017

# v2.9.60
1. fix: https://github.com/avwo/whistle/issues/1012

# v2.9.59
1. feat: 支持 https://github.com/avwo/whistle/issues/978
2. feat: 客户端支持直接使用 WebView 预览抓包内容


# v2.9.58
1. feat: Network 右键菜单 Mock > Export,通过插件或拖拽导入 Mock 数据
2. feat: 插件支持 `window.whistleBridge.download({name, value[, base64]})` 下载指定数据
3. feat: 新增特殊路径 `/_WHISTLE_5b6af7b9884e1165_/`,Whistle 会自动将url 里面第一个此路径片段替换成 `/`

# v2.9.57
1. feat: Composer 添加修改请求参数按钮 `Params`
2. feat: Composer 面板优化
3. feat: Composer 添加 Cookies 按钮方便获取当前抓包记录里面对应域名的 Cookie
4. feat: 支持通过启动参数 `uiExt` 往页面注入 js 或 html (把 Whistle 作为第三方 npm 包使用时可用)
``` js
uiExt?: {
required?: boolean;
htmlPrepend?: string;
htmlAppend?: string;
jsPrepend?: string;
jsAppend?: string;
};
```

# v2.9.56
1. feat: 支持通过 `Online / IPv6-only network` 强制 dns 获取 ipv6(命令行版本还可以通过 `-M ipv6Only` 开启)
Expand Down
5 changes: 4 additions & 1 deletion vendor/whistle/assets/js/log.js
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,9 @@
}

function stringifyObj(obj) {
if (typeof obj === 'string') {
return obj;
}
try {
return JSON.stringify(obj);
} catch(e) {}
Expand Down Expand Up @@ -392,7 +395,7 @@
window.addEventListener('unhandledrejection', function(e) {
var reason = 'UnhandledRejection';
if (e) {
e = e.reason || stringifyObj(e) || String(e);
e = stringifyObj(e.reason || e) || String(e);
reason += (/^[\w.-]*:/.test(e) ? ' ' : ': ') + e;
}
wConsole.error(reason);
Expand Down
40 changes: 39 additions & 1 deletion vendor/whistle/assets/menu.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
var networkListeners = [];
var rulesListeners = [];
var valuesListeners = [];
var pluginsListeners = [];
var handleOnLoad = function() {
timer = null;
list.forEach(emit);
Expand All @@ -30,6 +31,9 @@
case 'values':
execListeners(valuesListeners, options);
break;
case 'plugins':
execListeners(pluginsListeners, options);
break;
default:
execListeners(networkListeners, options);
}
Expand Down Expand Up @@ -95,6 +99,20 @@
var removeAllValuesListeners = function() {
valuesListeners = [];
};
var addPluginsListener = function(l) {
if (typeof l === 'function' && pluginsListeners.indexOf(l) === -1) {
pluginsListeners.push(l);
}
};
var removePluginsListener = function(l) {
l = pluginsListeners.indexOf(l);
if (l !== -1) {
pluginsListeners.splice(l, 1);
}
};
var removeAllPluginsListeners = function(l) {
pluginsListeners = [];
};

function on(type, l) {
if (typeof l !== 'function') {
Expand All @@ -107,6 +125,8 @@
return addRulesListener(l);
case 'values':
return addValuesListener(l);
case 'plugins':
return addPluginsListener(l);
}
}

Expand All @@ -133,6 +153,13 @@
removeAllValuesListeners();
}
return;
case 'plugins':
if (l) {
removePluginsListener(l);
} else {
removeAllPluginsListeners();
}
return;
}
}

Expand All @@ -149,21 +176,32 @@
removeAllRulesListeners: removeAllRulesListeners,
addValuesListener: addValuesListener,
removeValuesListener: removeValuesListener,
removeAllValuesListeners: removeAllValuesListeners
removeAllValuesListeners: removeAllValuesListeners,
addPluginsListener: addPluginsListener,
removePluginsListener: removePluginsListener,
removeAllPluginsListeners: removeAllPluginsListeners
};
try {
window.initWhistleBridge = function(options) {
window.initWhistleBridge = function() {};
Object.keys(options.msgBox).forEach(function(name) {
toast[name] = options.msgBox[name];
});
whistleBridge.getSelectedSessionList = options.getSelectedSessionList;
whistleBridge.getActiveSession = whistleBridge.getSession = whistleBridge.getSelectedSession = options.getActiveSession;
whistleBridge.showOption = options.showOption;
whistleBridge.hideOption = options.hideOption;
whistleBridge.updateUI = options.updateUI;
whistleBridge.copyText = options.copyText;
whistleBridge.pageId = options.pageId;
whistleBridge.compose = options.compose;
whistleBridge.decodeBase64 = options.decodeBase64;
whistleBridge.importSessions = options.importSessions;
whistleBridge.exportSessions = options.exportSessions;
whistleBridge.importMockData = options.importMockData;
whistleBridge.download = options.download;
whistleBridge.setNetworkSettings = options.setNetworkSettings;
whistleBridge.setComposerData = options.setComposerData;
whistleBridge.request = options.request;
whistleBridge.createRequest = options.createRequest;
whistleBridge.showModal = options.showModal;
Expand Down
43 changes: 43 additions & 0 deletions vendor/whistle/assets/modal.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<!DOCTYPE html>
<script>
;(function() {
var toast = {};
var whistleBridge = {
toast: toast
};
try {
window.parent.onWhistlePluginOptionModalReady(function(options) {
Object.keys(options.msgBox).forEach(function(name) {
toast[name] = options.msgBox[name];
});
whistleBridge.getSelectedSessionList = options.getSelectedSessionList;
whistleBridge.getActiveSession = whistleBridge.getSession = whistleBridge.getSelectedSession = options.getActiveSession;
whistleBridge.showOption = options.showOption;
whistleBridge.hideOption = options.hideOption;
whistleBridge.updateUI = options.updateUI;
whistleBridge.copyText = options.copyText;
whistleBridge.pageId = options.pageId;
whistleBridge.compose = options.compose;
whistleBridge.decodeBase64 = options.decodeBase64;
whistleBridge.importSessions = options.importSessions;
whistleBridge.exportSessions = options.exportSessions;
whistleBridge.importMockData = options.importMockData;
whistleBridge.download = options.download;
whistleBridge.setNetworkSettings = options.setNetworkSettings;
whistleBridge.setComposerData = options.setComposerData;
whistleBridge.request = options.request;
whistleBridge.createRequest = options.createRequest;
whistleBridge.showModal = options.showModal;
whistleBridge.importRules = options.importRules;
whistleBridge.importValues = options.importValues;
whistleBridge.getServerInfo = options.getServerInfo;
whistleBridge.alert = options.alert;
whistleBridge.confirm = options.confirm;
whistleBridge.syncData = options.syncData;
whistleBridge.syncRules = options.syncRules;
whistleBridge.syncValues = options.syncValues;
}, window);
} catch (e) {}
window.whistleBridge = whistleBridge;
})();
</script>
6 changes: 6 additions & 0 deletions vendor/whistle/assets/tab.html
Original file line number Diff line number Diff line change
Expand Up @@ -282,13 +282,19 @@
});
getActiveSession = options.getActiveSession;
getSelectedSessionList = options.getSelectedSessionList;
whistleBridge.showOption = options.showOption;
whistleBridge.hideOption = options.hideOption;
whistleBridge.updateUI = options.updateUI;
whistleBridge.copyText = options.copyText;
whistleBridge.pageId = options.pageId;
whistleBridge.compose = options.compose;
whistleBridge.decodeBase64 = options.decodeBase64;
whistleBridge.importSessions = options.importSessions;
whistleBridge.exportSessions = options.exportSessions;
whistleBridge.importMockData = options.importMockData;
whistleBridge.download = options.download;
whistleBridge.setNetworkSettings = options.setNetworkSettings;
whistleBridge.setComposerData = options.setComposerData;
whistleBridge.request = options.request;
whistleBridge.createRequest = options.createRequest;
whistleBridge.showModal = options.showModal;
Expand Down
3 changes: 1 addition & 2 deletions vendor/whistle/bin/ca/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ var config = require('../../lib/config');
var NUM_RE = /^\d+$/;
var HOST_SUFFIX_RE = /\:(\d+|auto)?$/;
var HOST_RE = /^[a-z\d_-]+(?:\.[a-z\d_-]+)*$/i;
var URL_RE = /^https?:\/\/./i;
var MAX_LEN = 1024 * 1024;

function installCert(certFile, url) {
Expand Down Expand Up @@ -79,7 +78,7 @@ module.exports = function(argv) {
} else {
delete options.port;
delete options.host;
if (URL_RE.test(arg)) {
if (commonUtil.isUrl(arg)) {
options.addr = { url: arg };
} else {
options.addr = { file: arg };
Expand Down
2 changes: 1 addition & 1 deletion vendor/whistle/bin/plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ var commonUtil = require('../lib/util/common');
var getWhistlePath = commonUtil.getWhistlePath;
var REMOTE_URL_RE = commonUtil.REMOTE_URL_RE;
var WHISTLE_PLUGIN_RE = commonUtil.WHISTLE_PLUGIN_RE;
const getPlugins = commonUtil.getPlugins;
var getPlugins = commonUtil.getPlugins;
var CMD_SUFFIX = process.platform === 'win32' ? '.cmd' : '';
var CUSTOM_PLUGIN_PATH = path.join(getWhistlePath(), 'custom_plugins');
var DEFAULT_PATH = commonUtil.getDefaultWhistlePath();
Expand Down
2 changes: 1 addition & 1 deletion vendor/whistle/bin/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ function readConfigList() {
exports.readConfig = readConfig;
exports.readConfigList = readConfigList;
exports.getHash = function(str) {
var hmac = createHmac('sha256', 'a secret');
var hmac = createHmac('sha256', '5b6af7b9884e1165');
return hmac.update(str).digest('hex');
};

Expand Down
3 changes: 2 additions & 1 deletion vendor/whistle/biz/webui/cgi-bin/add-rules-values.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,11 @@ module.exports = function(req, res) {
if (rulesData) {
if (rulesData.name === 'Default') {
rules.setDefault(rulesData.value, clientId);
rules.enableDefault();
} else {
rules.add(rulesData.name, rulesData.value, clientId);
rules.select(rulesData.name);
}
rules.select(rulesData.name);
}
if (valuesData) {
values.add(valuesData.name, valuesData.value, clientId);
Expand Down
6 changes: 5 additions & 1 deletion vendor/whistle/biz/webui/cgi-bin/composer.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ var zlib = require('../../../lib/util/zlib');
var properties = require('../../../lib/rules/util').properties;
var getSender = require('ws-parser').getSender;
var hparser = require('hparser');
var sendGzip = require('./util').sendGzip;

var formatHeaders = hparser.formatHeaders;
var getRawHeaders = hparser.getRawHeaders;
Expand Down Expand Up @@ -250,6 +251,9 @@ module.exports = function(req, res) {
var isWebSocket = method === 'WEBSOCKET';
delete headers[config.WEBUI_HEAD];
headers[config.REQ_FROM_HEADER] = 'W2COMPOSER';
if (req.body.enableProxyRules === false) {
headers[config.DISABLE_RULES_HEADER] = '1';
}
headers.host = options.host;
options.clientId = clientId;
var clientIp = util.getClientIp(req);
Expand Down Expand Up @@ -337,7 +341,7 @@ module.exports = function(req, res) {
}});
return;
}
res.json({ec: 0, em: 'success', res: data || ''});
sendGzip(req, res, {ec: 0, em: 'success', res: data || ''});
} : null;
if (err) {
return handleResponse && handleResponse(err);
Expand Down
4 changes: 3 additions & 1 deletion vendor/whistle/biz/webui/cgi-bin/download.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,15 @@ module.exports = function(req, res) {
var suffix = '.txt';
if (type === 'log') {
suffix = '.log';
} else if (type === 'mock') {
suffix = '.json';
} else if (type === 'rawBase64') {
type = 'base64';
suffix = '';
}

if (!filename || typeof filename !== 'string') {
filename = 'text_' + util.formatDate() + suffix;
filename = (type === 'mock' ? 'mock_' : 'text_') + util.formatDate() + suffix;
} else if (!/\.\w+$/.test(filename)) {
filename += suffix;
}
Expand Down
1 change: 1 addition & 0 deletions vendor/whistle/biz/webui/cgi-bin/get-data.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ module.exports = function(req, res) {
log: stopRecordConsole ? [] : proxy.getLogs(data.startLogTime, data.count, data.logId),
svrLog: stopRecordSvrLog ? [] : logger.getLogs(data.startSvrLogTime, data.count),
plugins: pluginMgr.getPlugins(),
pluginsRoot: config.PLUGIN_INSTALL_ROOT,
disabledPlugins: !config.notAllowedDisablePlugins && properties.get('disabledPlugins') || {},
allowMultipleChoice: properties.get('allowMultipleChoice'),
backRulesFirst: properties.get('backRulesFirst'),
Expand Down
2 changes: 1 addition & 1 deletion vendor/whistle/biz/webui/cgi-bin/import-remote.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
var util = require('../../../lib/util');

var MAX_LEN = 1024 * 1024 * 6;
var HTTP_RE = /https?:\/\//i;
var HTTP_RE = /https?:\/\/\S/i;

module.exports = function(req, res) {
var url = req.query.url;
Expand Down
1 change: 1 addition & 0 deletions vendor/whistle/biz/webui/cgi-bin/init.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ module.exports = function(req, res) {
interceptHttpsConnects: properties.isEnableCapture(),
enableHttp2: properties.isEnableHttp2(),
plugins: pluginMgr.getPlugins(),
pluginsRoot: config.PLUGIN_INSTALL_ROOT,
disabledPlugins: !config.notAllowedDisablePlugins && properties.get('disabledPlugins') || {},
disabledAllPlugins: !config.notAllowedDisablePlugins && properties.get('disabledAllPlugins'),
disabledAllRules: !config.notAllowedDisableRules && properties.get('disabledAllRules'),
Expand Down
Loading

0 comments on commit 202bb9c

Please sign in to comment.