Skip to content

Commit d1241ba

Browse files
committed
fix(ncu-config): do not override encrypted values silently
1 parent 7342aff commit d1241ba

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

lib/config.js

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,12 @@ function addEncryptedPropertyGetter(target, key, input) {
7070
return value;
7171
},
7272
set(newValue) {
73-
addEncryptedPropertyGetter(target, key, newValue) ||
74-
setOwnProperty(target, key, newValue);
73+
if (!addEncryptedPropertyGetter(target, key, newValue)) {
74+
throw new Error(
75+
'Refusing to override an encrypted value with a non-encrypted one. ' +
76+
'Please use an encrypted one, or delete the config key first.'
77+
);
78+
}
7579
}
7680
});
7781
}
@@ -99,7 +103,7 @@ export function getConfig(configType, dir) {
99103
}
100104
};
101105

102-
export function getConfigPath(configType, dir) {
106+
function getConfigPath(configType, dir) {
103107
switch (configType) {
104108
case GLOBAL_CONFIG:
105109
return getNcurcPath();
@@ -117,7 +121,7 @@ export function getConfigPath(configType, dir) {
117121
}
118122
};
119123

120-
export function writeConfig(configType, obj, dir) {
124+
function writeConfig(configType, obj, dir) {
121125
const configPath = getConfigPath(configType, dir);
122126
const encryptedConfigPath = configPath + '.gpg';
123127
if (existsSync(encryptedConfigPath)) {

0 commit comments

Comments
 (0)