summaryrefslogtreecommitdiff
path: root/packages/backend/src/core/DownloadService.ts
diff options
context:
space:
mode:
authorJulia <julia@insertdomain.name>2024-11-21 00:20:48 +0000
committerJulia <julia@insertdomain.name>2024-11-21 00:20:48 +0000
commit0fcb23c4c1e4cb3d2ed175ab9af2e72f81b8e7d1 (patch)
tree6400b81a06e9d5a83dd4718089beac69dc3c3136 /packages/backend/src/core/DownloadService.ts
parentmerge: Bump version (!756) (diff)
parentfix(backend): allow fetchSummaryFromProxy, trueMail to access local addresses (diff)
downloadsharkey-0fcb23c4c1e4cb3d2ed175ab9af2e72f81b8e7d1.tar.gz
sharkey-0fcb23c4c1e4cb3d2ed175ab9af2e72f81b8e7d1.tar.bz2
sharkey-0fcb23c4c1e4cb3d2ed175ab9af2e72f81b8e7d1.zip
merge: Coordinated Security Release (!761)
View MR for information: https://activitypub.software/TransFem-org/Sharkey/-/merge_requests/761
Diffstat (limited to 'packages/backend/src/core/DownloadService.ts')
-rw-r--r--packages/backend/src/core/DownloadService.ts22
1 files changed, 0 insertions, 22 deletions
diff --git a/packages/backend/src/core/DownloadService.ts b/packages/backend/src/core/DownloadService.ts
index 0e992f05de..05b9e64a37 100644
--- a/packages/backend/src/core/DownloadService.ts
+++ b/packages/backend/src/core/DownloadService.ts
@@ -6,7 +6,6 @@
import * as fs from 'node:fs';
import * as stream from 'node:stream/promises';
import { Inject, Injectable } from '@nestjs/common';
-import ipaddr from 'ipaddr.js';
import chalk from 'chalk';
import got, * as Got from 'got';
import { parse } from 'content-disposition';
@@ -70,13 +69,6 @@ export class DownloadService {
},
enableUnixSockets: false,
}).on('response', (res: Got.Response) => {
- if ((process.env.NODE_ENV === 'production' || process.env.NODE_ENV === 'test') && !this.config.proxy && res.ip) {
- if (this.isPrivateIp(res.ip)) {
- this.logger.warn(`Blocked address: ${res.ip}`);
- req.destroy();
- }
- }
-
const contentLength = res.headers['content-length'];
if (contentLength != null) {
const size = Number(contentLength);
@@ -139,18 +131,4 @@ export class DownloadService {
cleanup();
}
}
-
- @bindThis
- private isPrivateIp(ip: string): boolean {
- const parsedIp = ipaddr.parse(ip);
-
- for (const net of this.config.allowedPrivateNetworks ?? []) {
- const cidr = ipaddr.parseCIDR(net);
- if (cidr[0].kind() === parsedIp.kind() && parsedIp.match(ipaddr.parseCIDR(net))) {
- return false;
- }
- }
-
- return parsedIp.range() !== 'unicast';
- }
}