Add blocking joining open group based on blocklist.

pull/2174/head
warrickct 3 years ago
parent 606c03f518
commit 75191ae757

@ -57,9 +57,6 @@ jobs:
repository: oxen-io/blocklist
path: blocklist
- name: Find blocklist
run: find / -name "blocklist" 2>/dev/null
- name: Generate and concat files
run: yarn generate

@ -81,6 +81,7 @@
"jquery": "3.3.1",
"jsbn": "1.1.0",
"libsodium-wrappers": "^0.7.8",
"libsodium-wrappers-sumo": "^0.7.9",
"linkify-it": "3.0.2",
"lodash": "4.17.11",
"long": "^4.0.0",
@ -139,6 +140,7 @@
"@types/fs-extra": "5.0.5",
"@types/jquery": "3.3.29",
"@types/libsodium-wrappers": "^0.7.8",
"@types/libsodium-wrappers-sumo": "^0.7.5",
"@types/linkify-it": "2.0.3",
"@types/lodash": "4.14.106",
"@types/mocha": "5.0.0",
@ -250,7 +252,11 @@
"StartupWMClass": "Session"
},
"asarUnpack": "node_modules/spellchecker/vendor/hunspell_dictionaries",
"target": ["deb", "rpm", "freebsd"],
"target": [
"deb",
"rpm",
"freebsd"
],
"icon": "build/icon-linux.icns"
},
"asarUnpack": [

@ -5,8 +5,10 @@ const path = require('path');
const { webFrame, remote, clipboard, ipcRenderer } = require('electron');
const { app } = remote;
const url = require('url');
const fs = require('fs');
const config = require('url').parse(window.location.toString(), true).query;
const config = url.parse(window.location.toString(), true).query;
let title = config.name;
if (config.environment !== 'production') {
@ -212,6 +214,23 @@ window.clipboard = clipboard;
window.getSeedNodeList = () => JSON.parse(config.seedNodeList);
window.getOpenGroupBlockList = () => {
// const blocklist = url.parse(window.location.toString(), true).query;
if (!window.groupBlockList) {
try {
const blockList = fs
.readFileSync(path.resolve(__dirname, 'blocklist', 'blocklist.txt'), 'utf8')
.toString()
.split('\n');
// TODO: trim whitespace
window.groupBlockList = blockList;
} catch (e) {
return [];
}
}
return window.groupBlockList;
};
const { locale: localFromEnv } = config;
window.i18n = i18n.setup(localFromEnv, localeMessages);

@ -1,5 +1,6 @@
import { getV2OpenGroupRoomByRoomId, OpenGroupV2Room } from '../../../../data/opengroups';
import { getConversationController } from '../../../conversations';
import { getSodium } from '../../../crypto';
import { PromiseUtils, ToastUtils } from '../../../utils';
import { forceSyncConfigurationNowIfNeeded } from '../../../utils/syncUtils';
import {
@ -44,6 +45,22 @@ export function parseOpenGroupV2(urlWithPubkey: string): OpenGroupV2Room | undef
return undefined;
}
/**
* Checks if the group pubkey (hashed as blake2b) is in the list of blocked groups (also hashed)
* @param serverPubKey PubKey of the open group being evaluated
* @returns true - group is in the blocklist, false - the group is not in the blocklist
*/
export const isGroupInBlockList = async (serverPubKey: string): Promise<boolean> => {
const blockList = window?.getOpenGroupBlockList();
if (!blockList || !blockList.length) {
return false;
}
const sodium = await getSodium();
// generic hash is blake2b
const serverPubKeyBlake2bHash = sodium.crypto_generichash(32, serverPubKey, null, 'hex');
return blockList.includes(serverPubKeyBlake2bHash);
};
/**
* Join an open group using the v2 logic.
*
@ -58,6 +75,10 @@ async function joinOpenGroupV2(room: OpenGroupV2Room, fromConfigMessage: boolean
return;
}
if (await isGroupInBlockList(room.serverPublicKey)) {
return;
}
const serverUrl = room.serverUrl.toLowerCase();
const roomId = room.roomId.toLowerCase();
const publicKey = room.serverPublicKey.toLowerCase();

@ -6,7 +6,7 @@ import crypto from 'crypto';
// libsodium-wrappers requires the `require` call to work
// tslint:disable-next-line: no-require-imports
import libsodiumwrappers from 'libsodium-wrappers';
import libsodiumwrappers from 'libsodium-wrappers-sumo';
import { toHex } from '../utils/String';
import { ECKeyPair } from '../../receiver/keypairs';

1
ts/window.d.ts vendored

@ -74,5 +74,6 @@ declare global {
setStartInTray: (val: boolean) => Promise<void>;
getStartInTray: () => Promise<boolean>;
libsession: any;
getOpenGroupBlockList: () => Array<string>;
}
}

@ -1056,6 +1056,18 @@
resolved "https://registry.yarnpkg.com/@types/json-schema/-/json-schema-7.0.8.tgz#edf1bf1dbf4e04413ca8e5b17b3b7d7d54b59818"
integrity sha512-YSBPTLTVm2e2OoQIDYx8HaeWJ5tTToLH67kXR7zYNGupXMEHa2++G8k+DczX2cFVgalypqtyZIcU19AFcmOpmg==
"@types/libsodium-wrappers-sumo@^0.7.5":
version "0.7.5"
resolved "https://registry.yarnpkg.com/@types/libsodium-wrappers-sumo/-/libsodium-wrappers-sumo-0.7.5.tgz#c5191fc28d44edd39583552bd1855f6b7b77ca88"
integrity sha512-CL7rmLxw28H/FpFUnMu5BzzRsE+ICxHBpRoaY8ks+3HMsCJdA/Vp809sj+qNhw64Ht0OEnfoN3BC1sHwagoVaw==
dependencies:
"@types/libsodium-wrappers" "*"
"@types/libsodium-wrappers@*":
version "0.7.9"
resolved "https://registry.yarnpkg.com/@types/libsodium-wrappers/-/libsodium-wrappers-0.7.9.tgz#89c3ad2156d5143e64bce86cfeb0045a983aeccc"
integrity sha512-LisgKLlYQk19baQwjkBZZXdJL0KbeTpdEnrAfz5hQACbklCY0gVFnsKUyjfNWF1UQsCSjw93Sj5jSbiO8RPfdw==
"@types/libsodium-wrappers@^0.7.8":
version "0.7.8"
resolved "https://registry.yarnpkg.com/@types/libsodium-wrappers/-/libsodium-wrappers-0.7.8.tgz#34575d7692fdbb7a7fdb63afcde381db86ec0de2"
@ -5867,6 +5879,18 @@ levn@^0.3.0, levn@~0.3.0:
prelude-ls "~1.1.2"
type-check "~0.3.2"
libsodium-sumo@^0.7.0:
version "0.7.9"
resolved "https://registry.yarnpkg.com/libsodium-sumo/-/libsodium-sumo-0.7.9.tgz#dff3d6144849e30d9b9a7bf628d28243f1c49102"
integrity sha512-DcfJ57zlSlcmQU4s8KOX78pT0zKx5S9RLi0oyDuoIgm4K95+VNSaOidK/y9lUK4lxft14PtTPjoBy8tmLk1TDQ==
libsodium-wrappers-sumo@^0.7.9:
version "0.7.9"
resolved "https://registry.yarnpkg.com/libsodium-wrappers-sumo/-/libsodium-wrappers-sumo-0.7.9.tgz#d15a346870c8e339baf1518f06b0ddccfa1e1046"
integrity sha512-XLgLkqY973PngrRElbjOH0y7bJKYEfMWVpWPmW5iuhBjO6zXvHYQWtN52MVEeie/h98ZXN1Aw9BE+GzxQVAfLg==
dependencies:
libsodium-sumo "^0.7.0"
libsodium-wrappers@^0.7.8:
version "0.7.8"
resolved "https://registry.yarnpkg.com/libsodium-wrappers/-/libsodium-wrappers-0.7.8.tgz#d95cdf3e7236c2aef76844bf8e1929ba9eef3e9e"

Loading…
Cancel
Save