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

316 make the encryption optional #329

Merged
merged 6 commits into from
Oct 28, 2024
Merged
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
2 changes: 1 addition & 1 deletion documentation/PRIVACY.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ As mentioned above, all data is stored locally only on participant's machines. U
Should a user want to modify and/or delete their data, they can do so directly in the sqlite-file. No other copies of the data exists, unless the user made them.

## Sharing Collected Data
In case users are running PersonalAnalytics during a scientific study, the researchers might ask the users (or in this context, participants) to share their data with the reseachers. To that purpose, we recommend using the built-in data obfuscation and export feature, which allows users to understand what the data will be used for as part of the research project, review the collected data and decide which data they want to share and/or obfuscate. Afterwards, an encrypted and password-protected export-file is created which can be shared with the researchers per their instructions. The data export tool can be accessed by clicking "Export Data" in the taskbar icon (on Windows) or menubar (on macOS).
In case users are running PersonalAnalytics during a scientific study, the researchers might ask the users (or in this context, participants) to share their data with the reseachers. To that purpose, we recommend using the built-in data obfuscation and export feature, which allows users to understand what the data will be used for as part of the research project, review the collected data and decide which data they want to share and/or obfuscate. Afterwards, an encrypted and password-protected (if enabled in config) file is created which can be shared with the researchers per their instructions. The data export tool can be accessed by clicking "Export Data" in the taskbar icon (on Windows) or menubar (on macOS).

## Note on Using PersonalAnalytics
Note that the creators of PersonalAnalytics can in no way be held liable against use, misuse or problems that arise from using the app. The app was developed as a public, open-source application that can be freely used and extended (with [correct attribution](https://github.com/HASEL-UZH/PersonalAnalytics/blob/main/documentation/RESEARCH.md). The researchers are responsible for informing users (or participants) of the usage of PersonalAnalytics, collected data and usage of any data that is shared with researchers, as well as data privacy and data security.
Expand Down
6 changes: 4 additions & 2 deletions src/electron/electron/ipc/IpcHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -152,12 +152,14 @@ export class IpcHandler {
private async startDataExport(
windowActivityExportType: DataExportType,
userInputExportType: DataExportType,
obfuscationTerms: string[]
obfuscationTerms: string[],
encryptData: boolean
): Promise<string> {
return this.dataExportService.startDataExport(
windowActivityExportType,
userInputExportType,
obfuscationTerms
obfuscationTerms,
encryptData
);
}

Expand Down
13 changes: 8 additions & 5 deletions src/electron/electron/main/services/DataExportService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ export class DataExportService {
public async startDataExport(
windowActivityExportType: DataExportType,
userInputExportType: DataExportType,
obfuscationTerms: string[]
obfuscationTerms: string[],
encryptData: boolean
): Promise<string> {
LOG.info('startDataExport called');
await UsageDataService.createNewUsageDataEvent(
Expand Down Expand Up @@ -59,11 +60,13 @@ export class DataExportService {
// see https://github.com/WiseLibs/better-sqlite3/blob/master/docs/performance.md
db.pragma('journal_mode = WAL');

// see https://github.com/m4heshd/better-sqlite3-multiple-ciphers/issues/5#issuecomment-1008330548
db.pragma(`cipher='sqlcipher'`);
db.pragma(`legacy=4`);
if (encryptData) {
// see https://github.com/m4heshd/better-sqlite3-multiple-ciphers/issues/5#issuecomment-1008330548
db.pragma(`cipher='sqlcipher'`);
db.pragma(`legacy=4`);

db.pragma(`rekey='PersonalAnalytics_${settings.subjectId}'`);
db.pragma(`rekey='PersonalAnalytics_${settings.subjectId}'`);
}

if (
windowActivityExportType === DataExportType.Obfuscate ||
Expand Down
1 change: 1 addition & 0 deletions src/electron/shared/StudyConfiguration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,5 +40,6 @@ export interface StudyConfiguration {
contactEmail: string;
subjectIdLength: number;
dataExportEnabled: boolean;
dataExportEncrypted: boolean;
trackers: TrackerConfiguration;
}
1 change: 1 addition & 0 deletions src/electron/shared/study.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ const studyConfig: StudyConfiguration = {
contactEmail: '[email protected]',
subjectIdLength: 6,
dataExportEnabled: true,
dataExportEncrypted: false,
trackers: {
windowActivityTracker: {
enabled: true,
Expand Down
3 changes: 2 additions & 1 deletion src/electron/src/utils/Commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ type Commands = {
startDataExport: (
windowActivityExportType: DataExportType,
userInputExportType: DataExportType,
obfuscationTerms: string[]
obfuscationTerms: string[],
encryptData: boolean
) => Promise<string>;
revealItemInFolder: (path: string) => Promise<void>;
startAllTrackers: () => void;
Expand Down
21 changes: 13 additions & 8 deletions src/electron/src/views/DataExportView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,8 @@ async function handleNextStep() {
'startDataExport',
exportWindowActivitySelectedOption.value,
exportUserInputSelectedOption.value,
obfuscationTerms
obfuscationTerms,
studyConfig.dataExportEncrypted
);
hasExportError.value = false;
const now = new Date();
Expand Down Expand Up @@ -218,9 +219,11 @@ function revealItemInFolder(event: Event) {
</p>
<p>
Please click "Next" once you are ready to
<b class="dark:text-white">first review, and later share your data</b>. The export
that will be created with your permission in the next step will be encrypted and
password-protected.
<b class="dark:text-white">first review, and later share your data</b>.
<span v-if="studyConfig.dataExportEncrypted">
The export that will be created with your permission in the next step will be
encrypted and password-protected </span
>.
</p>
<p>
Below, you find additional information on the study and how the researchers ensure
Expand Down Expand Up @@ -273,10 +276,12 @@ function revealItemInFolder(event: Event) {
{{ studyConfig.name }}-study.
</p>
<p>
A single password-protected and encrypted
<b class="dark:text-white">file was created</b> based on your preferences on the
previous page. To share this file with the researchers, please take the following
steps:
Your data was exported and we created a
<span v-if="studyConfig.dataExportEncrypted"
>password-protected and encrypted
</span>
file based on your preferences on the previous page. To share this file with the
researchers, please take the following steps:
</p>
<ol>
<li>
Expand Down