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

Added ignore MAC option #68

Open
wants to merge 1 commit into
base: master
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 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() { }