Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disallow unencrypted cloud backups #1244

Open
wants to merge 2 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1,034 changes: 519 additions & 515 deletions _locales/en/messages.json

Large diffs are not rendered by default.

41 changes: 13 additions & 28 deletions src/components/Popup/DrivePage.vue
Original file line number Diff line number Diff line change
@@ -1,29 +1,24 @@
<template>
<div>
<div>
<div class="text warning" v-show="!isEncrypted || !defaultEncryption">
{{ i18n.dropbox_risk }}
<div class="text warning" v-show="needEncryption">
{{ i18n.encryption_required }}
</div>
<div v-show="backupToken">
<div style="margin: 10px 0px 0px 20px; overflow-wrap: break-word">
{{ i18n.account }} - {{ email }}
</div>
</div>
<a-select-input
v-show="!!defaultEncryption && backupToken"
:label="i18n.encrypted"
v-model="isEncrypted"
>
<option value="true">{{ i18n.yes }}</option>
<option value="false">{{ i18n.no }}</option>
</a-select-input>
<a-button v-show="backupToken" @click="backupLogout()">
{{ i18n.log_out }}
</a-button>
<a-button v-show="!backupToken" @click="getBackupToken()">
<a-button
v-show="!backupToken && !needEncryption"
@click="getBackupToken()"
>
{{ i18n.sign_in }}
</a-button>
<a-button v-show="backupToken" @click="backupUpload()">
<a-button v-show="backupToken && !needEncryption" @click="backupUpload()">
{{ i18n.manual_dropbox }}
</a-button>
</div>
Expand All @@ -50,25 +45,15 @@ export default Vue.extend({
defaultEncryption: function () {
return this.$store.state.accounts.defaultEncryption;
},
isEncrypted: {
get(): boolean {
if (UserSettings.items[`${service}Encrypted`] === null) {
this.$store.commit("backup/setEnc", { service, value: true });
UserSettings.items[`${service}Encrypted`] = true;
UserSettings.commitItems();
return true;
}
return this.$store.state.backup.driveEncrypted;
},
set(newValue: string) {
UserSettings.items.driveEncrypted = newValue === "true";
UserSettings.commitItems();
this.$store.commit("backup/setEnc", { service, value: newValue });
},
allEntriesEncrypted: function (): boolean {
return this.$store.getters["accounts/allEntriesEncrypted"];
},
backupToken: function () {
backupToken: function (): string | undefined {
return this.$store.state.backup.driveToken;
},
needEncryption: function (): boolean {
return !this.defaultEncryption || !this.allEntriesEncrypted;
},
},
methods: {
getBackupToken() {
Expand Down
41 changes: 13 additions & 28 deletions src/components/Popup/DropboxPage.vue
Original file line number Diff line number Diff line change
@@ -1,29 +1,24 @@
<template>
<div>
<div>
<div class="text warning" v-show="!isEncrypted || !defaultEncryption">
{{ i18n.dropbox_risk }}
<div class="text warning" v-show="needEncryption">
{{ i18n.encryption_required }}
</div>
<div v-show="backupToken">
<div style="margin: 10px 0px 0px 20px; overflow-wrap: break-word">
{{ i18n.account }} - {{ email }}
</div>
</div>
<a-select-input
v-show="!!defaultEncryption && backupToken"
:label="i18n.encrypted"
v-model="isEncrypted"
>
<option value="true">{{ i18n.yes }}</option>
<option value="false">{{ i18n.no }}</option>
</a-select-input>
<a-button v-show="backupToken" @click="backupLogout()">
{{ i18n.log_out }}
</a-button>
<a-button v-show="!backupToken" @click="getBackupToken()">
<a-button
v-show="!backupToken && !needEncryption"
@click="getBackupToken()"
>
{{ i18n.sign_in }}
</a-button>
<a-button v-show="backupToken" @click="backupUpload()">
<a-button v-show="backupToken && !needEncryption" @click="backupUpload()">
{{ i18n.manual_dropbox }}
</a-button>
</div>
Expand All @@ -49,25 +44,15 @@ export default Vue.extend({
defaultEncryption: function () {
return this.$store.state.accounts.defaultEncryption;
},
isEncrypted: {
get(): boolean {
if (UserSettings.items[`${service}Encrypted`] === null) {
this.$store.commit("backup/setEnc", { service, value: true });
UserSettings.items[`${service}Encrypted`] = true;
UserSettings.commitItems();
return true;
}
return this.$store.state.backup.dropboxEncrypted;
},
set(newValue: string) {
UserSettings.items.dropboxEncrypted = newValue === "true";
UserSettings.commitItems();
this.$store.commit("backup/setEnc", { service, value: newValue });
},
allEntriesEncrypted: function (): boolean {
return this.$store.getters["accounts/allEntriesEncrypted"];
},
backupToken: function () {
backupToken: function (): string | undefined {
return this.$store.state.backup.dropboxToken;
},
needEncryption: function (): boolean {
return !this.defaultEncryption || !this.allEntriesEncrypted;
},
},
methods: {
getBackupToken() {
Expand Down
48 changes: 18 additions & 30 deletions src/components/Popup/OneDrivePage.vue
Original file line number Diff line number Diff line change
@@ -1,39 +1,37 @@
<template>
<div>
<div>
<div class="text warning" v-show="!isEncrypted || !defaultEncryption">
{{ i18n.dropbox_risk }}
<div class="text warning" v-show="needEncryption">
{{ i18n.encryption_required }}
</div>
<div v-show="backupToken">
<div style="margin: 10px 0px 0px 20px; overflow-wrap: break-word">
{{ i18n.account }} - {{ email }}
</div>
</div>
<a-select-input
v-show="!!defaultEncryption && backupToken"
:label="i18n.encrypted"
v-model="isEncrypted"
>
<option value="true">{{ i18n.yes }}</option>
<option value="false">{{ i18n.no }}</option>
</a-select-input>
<a-button v-show="backupToken" @click="backupLogout()">
{{ i18n.log_out }}
</a-button>
<a-button v-show="!backupToken" @click="getBackupToken()">
<a-button
v-show="!backupToken && !needEncryption"
@click="getBackupToken()"
>
{{ i18n.sign_in }}
</a-button>
<a-button v-show="!backupToken" @click="getBackupToken(true)">
<a-button
v-show="!backupToken && !needEncryption"
@click="getBackupToken(true)"
>
{{ i18n.sign_in_business }}
</a-button>
<div class="text" v-show="!backupToken">
<div class="text" v-show="!backupToken && !needEncryption">
<a
v-on:click="openLink('https://otp.ee/onedriveperms')"
href="https://otp.ee/onedriveperms"
>{{ i18n.onedrive_business_perms }}</a
>
</div>
<a-button v-show="backupToken" @click="backupUpload()">
<a-button v-show="backupToken && !needEncryption" @click="backupUpload()">
{{ i18n.manual_dropbox }}
</a-button>
</div>
Expand All @@ -59,23 +57,13 @@ export default Vue.extend({
defaultEncryption: function () {
return this.$store.state.accounts.defaultEncryption;
},
isEncrypted: {
get(): boolean {
if (UserSettings.items.oneDriveEncrypted === null) {
this.$store.commit("backup/setEnc", { service, value: true });
UserSettings.items.oneDriveEncrypted = true;
UserSettings.commitItems();
return true;
}
return this.$store.state.backup.driveEncrypted;
},
set(newValue: string) {
UserSettings.items.driveEncrypted = newValue === "true";
UserSettings.commitItems();
this.$store.commit("backup/setEnc", { service, value: newValue });
},
allEntriesEncrypted: function (): boolean {
return this.$store.getters["accounts/allEntriesEncrypted"];
},
needEncryption: function (): boolean {
return !this.defaultEncryption || !this.allEntriesEncrypted;
},
backupToken: function () {
backupToken: function (): string | undefined {
return this.$store.state.backup.oneDriveToken;
},
},
Expand Down
4 changes: 1 addition & 3 deletions src/definitions/module-interface.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ interface AccountsState {
keys: OldKey | Key[];
wrongPassword: boolean;
initComplete: boolean;
allEntriesEncrypted: boolean;
}

interface NotificationState {
Expand All @@ -86,9 +87,6 @@ interface NotificationState {
}

interface BackupState {
dropboxEncrypted: boolean;
driveEncrypted: boolean;
oneDriveEncrypted: boolean;
dropboxToken: boolean;
driveToken: boolean;
oneDriveToken: boolean;
Expand Down
29 changes: 5 additions & 24 deletions src/models/backup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,7 @@ export class Dropbox implements BackupProvider {
async upload(encryption: Encryption) {
await UserSettings.updateItems();

if (UserSettings.items.dropboxEncrypted === undefined) {
// Encrypt by default if user hasn't set yet
UserSettings.items.dropboxEncrypted = true;
UserSettings.commitItems();
}
const exportData = await EntryStorage.backupGetExport(
encryption,
UserSettings.items.dropboxEncrypted === true
);
const exportData = await EntryStorage.backupGetExport(encryption, true);
const backup = JSON.stringify(exportData, null, 2);

const url = "https://content.dropboxapi.com/2/files/upload";
Expand Down Expand Up @@ -352,14 +344,8 @@ export class Drive implements BackupProvider {

async upload(encryption: Encryption) {
await UserSettings.updateItems();
if (UserSettings.items.driveEncrypted === undefined) {
UserSettings.items.driveEncrypted = true;
UserSettings.commitItems();
}
const exportData = await EntryStorage.backupGetExport(
encryption,
UserSettings.items.driveEncrypted === true
);

const exportData = await EntryStorage.backupGetExport(encryption, true);
const backup = JSON.stringify(exportData, null, 2);

const token = await this.getToken();
Expand Down Expand Up @@ -581,13 +567,8 @@ export class OneDrive implements BackupProvider {

async upload(encryption: Encryption) {
await UserSettings.updateItems();
if (UserSettings.items.oneDriveEncrypted === undefined) {
UserSettings.items.oneDriveEncrypted = true;
}
const exportData = await EntryStorage.backupGetExport(
encryption,
UserSettings.items.oneDriveEncrypted === true
);

const exportData = await EntryStorage.backupGetExport(encryption, true);
const backup = JSON.stringify(exportData, null, 2);

const token = await this.getToken();
Expand Down
12 changes: 0 additions & 12 deletions src/models/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,15 @@ export enum StorageLocation {

interface UserSettingsData {
// local settings
driveEncrypted?: boolean;
driveFolder?: string;
driveRefreshToken?: string;
driveRevoked?: boolean;
driveToken?: string;
dropboxEncrypted?: boolean;
dropboxRevoked?: boolean;
dropboxToken?: string;
lastRemindingBackupTime?: number;
offset?: number;
oneDriveBusiness?: boolean;
oneDriveEncrypted?: boolean;
oneDriveRevoked?: boolean;
oneDriveRefreshToken?: string;
oneDriveToken?: string;
Expand All @@ -35,18 +32,15 @@ interface UserSettingsData {

// Maybe we can have a better way to define this
const LocalUserSettingsDataKeys = [
"driveEncrypted",
"driveFolder",
"driveRefreshToken",
"driveRevoked",
"driveToken",
"dropboxEncrypted",
"dropboxRevoked",
"dropboxToken",
"lastRemindingBackupTime",
"offset",
"oneDriveBusiness",
"oneDriveEncrypted",
"oneDriveRevoked",
"oneDriveRefreshToken",
"oneDriveToken",
Expand All @@ -70,13 +64,10 @@ export class UserSettings {
if (
[
"autofill",
"driveEncrypted",
"driveRevoked",
"dropboxEncrypted",
"dropboxRevoked",
"enableContextMenu",
"oneDriveBusiness",
"oneDriveEncrypted",
"oneDriveRevoked",
"smartFilter",
"enableContextMenu",
Expand All @@ -85,13 +76,10 @@ export class UserSettings {
settings[
key as
| "autofill"
| "driveEncrypted"
| "driveRevoked"
| "dropboxEncrypted"
| "dropboxRevoked"
| "enableContextMenu"
| "oneDriveBusiness"
| "oneDriveEncrypted"
| "oneDriveRevoked"
| "smartFilter"
| "enableContextMenu"
Expand Down
15 changes: 15 additions & 0 deletions src/popup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,21 @@ async function init() {
init();

async function runScheduledBackup(clientTime: number, instance: Vue) {
if (!instance.$store.getters["accounts/allEntriesEncrypted"]) {
// Don't ever upload an unencrypted secret
if (
instance.$store.state.backup.dropboxToken ||
instance.$store.state.backup.driveToken ||
instance.$store.state.backup.oneDriveToken
) {
instance.$store.commit(
"notification/alert",
instance.i18n.warn_backup_paused
);
}
return;
}

if (instance.$store.state.backup.dropboxToken) {
chrome.permissions.contains(
{ origins: ["https://*.dropboxapi.com/*"] },
Expand Down
5 changes: 5 additions & 0 deletions src/store/Accounts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,11 @@ export class Accounts implements Module {
);
return [...pinnedEntries, ...unpinnedEntries];
},
allEntriesEncrypted(state: AccountsState) {
return state.entries.every((entry) => {
return Boolean(entry.encryption?.getEncryptionStatus());
});
},
},
mutations: {
stopFilter(state: AccountsState) {
Expand Down
Loading
Loading