Add AD detection on desktop app #264, #304

This commit addresses issues #264 and #304, where users were not
receiving error messages when script execution failed due to
antivirus intervention, particularly with Microsoft Defender.
Now, desktop app users will see a detailed error message with
guidance on next steps if script saving or execution fails due
to antivirus removal.

Key changes:

- Implement a check to detect failure in file writing,
  including reading the written file back. This method effectively
  detects antivirus interventions, as the read operation triggers
  an antivirus scan, leading to file deletion by the antivirus.
- Introduce a specific error message for scenarios where an
  antivirus intervention is detected.
This commit is contained in:
undergroundwires
2024-01-16 22:26:28 +01:00
parent 756c736e21
commit f03fc24098
23 changed files with 841 additions and 142 deletions

View File

@@ -12,6 +12,7 @@ import { defineComponent, computed } from 'vue';
import { injectKey } from '@/presentation/injectionSymbols';
import { OperatingSystem } from '@/domain/OperatingSystem';
import { Dialog } from '@/presentation/common/Dialog';
import { CodeRunError } from '@/application/CodeRunner/CodeRunner';
import IconButton from './IconButton.vue';
export default defineComponent({
@@ -37,7 +38,7 @@ export default defineComponent({
currentContext.state.collection.scripting.fileExtension,
);
if (!success) {
showScriptRunError(dialog, `${error.type}: ${error.message}`);
showScriptRunError(dialog, error);
}
}
@@ -57,8 +58,18 @@ function getCanRunState(
return isRunningAsDesktopApplication && isRunningOnSelectedOs;
}
function showScriptRunError(dialog: Dialog, technicalDetails: string) {
function showScriptRunError(dialog: Dialog, error: CodeRunError) {
const technicalDetails = `[${error.type}] ${error.message}`;
dialog.showError(
...(
error.type === 'FileReadbackVerificationError'
? createAntivirusErrorDialog(technicalDetails)
: createGenericErrorDialog(technicalDetails)),
);
}
function createGenericErrorDialog(technicalDetails: string): Parameters<Dialog['showError']> {
return [
'Error Running Script',
[
'We encountered an issue while running the script.',
@@ -67,13 +78,44 @@ function showScriptRunError(dialog: Dialog, technicalDetails: string) {
'Here are some steps you can take:',
'- Confirm that you have the necessary permissions to execute scripts on your system.',
'- Check if there is sufficient disk space and system resources available.',
'- Antivirus or security software can sometimes mistakenly block script execution. If you suspect this, verify your security settings, or temporarily disable the security software to see if that resolves the issue.',
[
'- Antivirus or security software can sometimes mistakenly block script execution.',
'Verify your security settings, or temporarily disable the security software to see if that resolves the issue.',
'privacy.sexy is secure, transparent, and open-source, but the scripts might still be mistakenly flagged by antivirus software.',
].join(' '),
'- If possible, try running a different script to determine if the issue is specific to a particular script.',
'- Should the problem persist, reach out to the community for further assistance.',
'\n',
'For your reference, here are the technical details of the error:',
'Technical Details:',
technicalDetails,
].join('\n'),
);
];
}
function createAntivirusErrorDialog(technicalDetails: string): Parameters<Dialog['showError']> {
return [
'Potential Antivirus Intervention',
[
[
'We\'ve encountered a problem which may be due to your antivirus software intervening.',
'privacy.sexy is secure, transparent, and open-source, but the scripts might still be mistakenly flagged by antivirus software such as Defender.',
].join(' '),
'\n',
'To address this, you can:',
'1. Temporarily disable your antivirus (real-time protection) or add an exclusion for privacy.sexy scripts.',
'2. Re-try running or downloading the script.',
'3. If the issue persists, check your antivirus logs for more details and consider reporting this as a false positive to your antivirus provider.',
'\n',
'To handle false warnings in Defender: Open "Virus & threat protection" from the "Start" menu.',
'\n',
[
'Remember to re-enable your antivirus protection as soon as possible for your security.',
'For more guidance, refer to your antivirus documentation.',
].join(' '),
'\n',
'Technical Details:',
technicalDetails,
].join('\n'),
];
}
</script>

View File

@@ -20,7 +20,7 @@ import ModalDialog from '@/presentation/components/Shared/Modal/ModalDialog.vue'
import { ScriptingLanguage } from '@/domain/ScriptingLanguage';
import { IScriptingDefinition } from '@/domain/IScriptingDefinition';
import { ScriptFilename } from '@/application/CodeRunner/ScriptFilename';
import { Dialog, FileType } from '@/presentation/common/Dialog';
import { Dialog, FileType, SaveFileError } from '@/presentation/common/Dialog';
import IconButton from '../IconButton.vue';
import RunInstructions from './RunInstructions/RunInstructions.vue';
@@ -45,7 +45,7 @@ export default defineComponent({
getType(currentState.value.collection.scripting.language),
);
if (!success) {
showScriptSaveError(dialog, `${error.type}: ${error.message}`);
showScriptSaveError(dialog, error);
return;
}
areInstructionsVisible.value = true;
@@ -78,8 +78,18 @@ function buildFilename(scripting: IScriptingDefinition) {
return ScriptFilename;
}
function showScriptSaveError(dialog: Dialog, technicalDetails: string) {
function showScriptSaveError(dialog: Dialog, error: SaveFileError) {
const technicalDetails = `[${error.type}] ${error.message}`;
dialog.showError(
...(
error.type === 'FileReadbackVerificationError'
? createAntivirusErrorDialog(technicalDetails)
: createGenericErrorDialog(technicalDetails)),
);
}
function createGenericErrorDialog(technicalDetails: string): Parameters<Dialog['showError']> {
return [
'Error Saving Script',
[
'An error occurred while saving the script.',
@@ -95,6 +105,32 @@ function showScriptSaveError(dialog: Dialog, technicalDetails: string) {
'Technical Details:',
technicalDetails,
].join('\n'),
);
];
}
function createAntivirusErrorDialog(technicalDetails: string): Parameters<Dialog['showError']> {
return [
'Potential Antivirus Intervention',
[
[
'It seems your antivirus software might have blocked the saving of the script.',
'privacy.sexy is secure, transparent, and open-source, but the scripts might still be mistakenly flagged by antivirus software such as Defender.',
].join(' '),
'\n',
'To resolve this, consider:',
'1. Checking your antivirus for any blocking notifications and allowing the script.',
'2. Temporarily disabling real-time protection or adding an exclusion for privacy.sexy scripts.',
'3. Re-attempting to save the script.',
'4. If the problem continues, review your antivirus logs for more details.',
'\n',
'To handle false warnings in Defender: Open "Virus & threat protection" from the "Start" menu.',
'\n',
'Always ensure to re-enable your antivirus protection promptly.',
'For more guidance, refer to your antivirus documentation.',
'\n',
'Technical Details:',
technicalDetails,
].join('\n'),
];
}
</script>

View File

@@ -49,11 +49,15 @@
</p>
<p>
These false positives are common for scripts that modify system settings.
privacy.sexy is secure, transparent, and open-source.
</p>
<p>
To handle false warnings in Microsoft Defender:
<ol>
<li>Open <strong>Virus & threat protection</strong> from the Start menu.</li>
<li>
Open <strong>Virus & threat protection</strong> from
the <strong>Start</strong> menu.
</li>
<li>
Locate the event in <strong>Protection history</strong>
that pertains to the script.