Merge commit from fork

Fix `GHSA-jqx4-9gpq-rppm`
This commit is contained in:
おさむのひと 2025-04-28 07:52:03 +09:00 committed by GitHub
commit 9e3f23691c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 14 additions and 12 deletions

View File

@ -59,17 +59,6 @@ export async function scpaping(
) {
const args = getGotOptions(url, opts);
const headResponse = await getResponse({
...args,
method: 'HEAD',
});
// SUMMALY_ALLOW_PRIVATE_IPはテスト用
const allowPrivateIp = process.env.SUMMALY_ALLOW_PRIVATE_IP === 'true' || Object.keys(agent).length > 0;
if (!allowPrivateIp && headResponse.ip && PrivateIp(headResponse.ip)) {
throw new StatusError(`Private IP rejected ${headResponse.ip}`, 400, 'Private IP Rejected');
}
const response = await getResponse({
...args,
method: 'GET',
@ -134,6 +123,14 @@ export async function getResponse(args: GotOptions) {
const res = await receiveResponse({ req, opts: args });
// SUMMALY_ALLOW_PRIVATE_IPはテスト用
// TODO: Try moving this to receiveResponse- ATM `got` doesn't provide a means
// to check the IP/response header data while streaming the response...
const allowPrivateIp = process.env.SUMMALY_ALLOW_PRIVATE_IP === 'true' || Object.keys(agent).length > 0;
if (!allowPrivateIp && res.ip && PrivateIp(res.ip)) {
throw new StatusError(`Private IP rejected ${res.ip}`, 400, 'Private IP Rejected');
}
// Check html
const contentType = res.headers['content-type'];
if (args.typeFilter && !contentType?.match(args.typeFilter)) {

View File

@ -45,6 +45,11 @@ function skippableTest(name: string, fn: () => void) {
}
}
beforeEach(() => {
// Allow private IPs by default, since a lot of the tests rely on old behvior
process.env.SUMMALY_ALLOW_PRIVATE_IP = 'true';
});
afterEach(async () => {
if (app) {
await app.close();
@ -93,7 +98,7 @@ skippableTest('Stage Bye Stage', async () => {
expect(summary).toEqual(
{
'title': '【アイドルマスター】「Stage Bye Stage」(歌:島村卯月、渋谷凛、本田未央)',
'icon': 'https://www.youtube.com/s/desktop/711fd789/img/logos/favicon.ico',
'icon': 'https://www.youtube.com/s/desktop/78bc1359/img/logos/favicon.ico',
'description': 'Website▶https://columbia.jp/idolmaster/Playlist▶https://www.youtube.com/playlist?list=PL83A2998CF3BBC86D2018年7月18日発売予定THE IDOLM@STER CINDERELLA GIRLS CG STAR...',
'thumbnail': 'https://i.ytimg.com/vi/NMIEAhH_fTU/maxresdefault.jpg',
'player': {