Skip to content

Commit

Permalink
Added ignore MAC option
Browse files Browse the repository at this point in the history
  • Loading branch information
Sergey Kvartnikov committed Jul 21, 2023
1 parent f18721b commit 47258a1
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
6 changes: 6 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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)"
}
}
},
Expand Down
8 changes: 7 additions & 1 deletion src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ enum ConfigName {
defaultGcpCredentialsPath = 'defaults.gcpCredentialsPath',
defaultAgeKeyFile = 'defaults.ageKeyFile',
configPath = 'configPath', // Run Control path
ignoreMac = "ignoreMac",
}
interface IRunControl {
awsProfile?: string;
Expand Down Expand Up @@ -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;
Expand All @@ -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) {
Expand Down Expand Up @@ -809,4 +815,4 @@ export function activate(context: vscode.ExtensionContext) {
updateSubscriptions();
}

export function deactivate() {}
export function deactivate() { }

0 comments on commit 47258a1

Please sign in to comment.