From 47258a1053961937264c05f7d323780cc2b921e9 Mon Sep 17 00:00:00 2001 From: Sergey Kvartnikov Date: Fri, 21 Jul 2023 12:34:07 +0300 Subject: [PATCH] Added ignore MAC option --- README.md | 1 + package.json | 6 ++++++ src/extension.ts | 8 +++++++- 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 5dc1045..119b5a3 100644 --- a/README.md +++ b/README.md @@ -30,6 +30,7 @@ VSCode extension with underlying [SOPS](https://github.com/mozilla/sops) support * `sops.defaults.gcpCredentialsPath`: Default path used to find GCP credentials. Overrides the `$GOOGLE_APPLICATION_CREDENTIALS` environment variable (empty: defaults to environment variable `$GOOGLE_APPLICATION_CREDENTIALS`) * `sops.defaults.ageKeyFile`: Default path used to find AGE key file. Overwrites the `$SOPS_AGE_KEY_FILE` environment variable (default: uses from environment variable `$SOPS_AGE_KEY_FILE`) * `sops.creationEnabled`: enable/disable this extension to try encrypt files included in .sops.yaml path_regex when is not encrypted yet (default: false) +* `sops.ignoreMac`: enable/disable MAC verification ## Config file > Named `.sopsrc` in project root by default and is in YAML format. diff --git a/package.json b/package.json index 6dedf96..5c4af18 100644 --- a/package.json +++ b/package.json @@ -81,6 +81,12 @@ "type": "string", "scope": "resource", "description": "Default path used to find AGE key file. Overwrites the `$SOPS_AGE_KEY_FILE` environment variable (default: uses from environment variable `$SOPS_AGE_KEY_FILE`)" + }, + "sops.defaults.ignoreMac": { + "type": "boolean", + "scope": "resource", + "default": false, + "description": "enable/disable MAC verification (default: false)" } } }, diff --git a/src/extension.ts b/src/extension.ts index cd65acf..2289c9b 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -41,6 +41,7 @@ enum ConfigName { defaultGcpCredentialsPath = 'defaults.gcpCredentialsPath', defaultAgeKeyFile = 'defaults.ageKeyFile', configPath = 'configPath', // Run Control path + ignoreMac = "ignoreMac", } interface IRunControl { awsProfile?: string; @@ -516,6 +517,7 @@ async function getSopsGeneralOptions() { const defaultAwsProfile: string | undefined = vscode.workspace.getConfiguration(CONFIG_BASE_SECTION).get(ConfigName.defaultAwsProfile); const defaultGcpCredentialsPath: string | undefined = vscode.workspace.getConfiguration(CONFIG_BASE_SECTION).get(ConfigName.defaultGcpCredentialsPath); const defaultAgeKeyFile: string | undefined = vscode.workspace.getConfiguration(CONFIG_BASE_SECTION).get(ConfigName.defaultAgeKeyFile); + const defaultIgnoreMac: boolean | undefined = vscode.workspace.getConfiguration(CONFIG_BASE_SECTION).get(ConfigName.ignoreMac); debug('config', { defaultAwsProfile, defaultGcpCredentialsPath, defaultAgeKeyFile }); const rc = await getRunControl(); const awsProfile = rc.awsProfile ?? defaultAwsProfile; @@ -530,6 +532,10 @@ async function getSopsGeneralOptions() { sopsGeneralEnvVars[AWS_PROFILE_ENV_VAR_NAME] = awsProfile; // --aws-profile argument doesn't work well } + if (defaultIgnoreMac) { + sopsGeneralArgs.push('--ignore-mac'); + } + if (gcpCredentialsPath) { if (!path.isAbsolute(gcpCredentialsPath) && vscode.workspace.workspaceFolders) { for (const workspaceFolder of vscode.workspace.workspaceFolders) { @@ -809,4 +815,4 @@ export function activate(context: vscode.ExtensionContext) { updateSubscriptions(); } -export function deactivate() {} +export function deactivate() { }