Skip to content

Commit

Permalink
feat: empty sensitive envs values in Neo Session Launcher
Browse files Browse the repository at this point in the history
  • Loading branch information
yomybaby committed Sep 10, 2024
1 parent 9d0dd72 commit ca56621
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 5 deletions.
36 changes: 36 additions & 0 deletions react/src/components/EnvVarFormList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -137,4 +137,40 @@ const EnvVarFormList: React.FC<EnvVarFormListProps> = ({
);
};

const sensitivePatterns = [
/AUTH/i,
/ACCESS/i,
/SECRET/i,
/_KEY/i,
/PASSWORD/i,
/PASSWD/i,
/PWD/i,
/TOKEN/i,
/PRIVATE/i,
/CREDENTIAL/i,
/JWT/i,
/KEYPAIR/i,
/CERTIFICATE/i,
/SSH/i,
/ENCRYPT/i,
/SIGNATURE/i,
/SALT/i,
/PIN/i,
/PASSPHRASE/i,
/OAUTH/i,
];

export function isSensitiveEnv(key: string) {
return sensitivePatterns.some((pattern) => pattern.test(key));
}

export function emptySensitiveEnv(envs: EnvVarFormListValue[]) {
return envs.map((env) => {
if (env && isSensitiveEnv(env.variable)) {
return { ...env, value: '' };
}
return env;
});
}

export default EnvVarFormList;
1 change: 1 addition & 0 deletions react/src/components/VFolderTableFormItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ interface VFolderTableFormItemProps extends Omit<FormItemProps, 'name'> {
export interface VFolderTableFormValues {
mounts: string[];
vfoldersAliasMap: AliasMap;
autoMountedFolderNames?: string[];
}

const VFolderTableFormItem: React.FC<VFolderTableFormItemProps> = ({
Expand Down
18 changes: 13 additions & 5 deletions react/src/pages/SessionLauncherPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import BAIIntervalText from '../components/BAIIntervalText';
import DatePickerISO from '../components/DatePickerISO';
import DoubleTag from '../components/DoubleTag';
import EnvVarFormList, {
emptySensitiveEnv,
EnvVarFormListValue,
} from '../components/EnvVarFormList';
import Flex from '../components/Flex';
Expand Down Expand Up @@ -229,14 +230,21 @@ const SessionLauncherPage = () => {
// console.log('syncFormToURLWithDebounce', form.getFieldsValue());
// To sync the latest form values to URL,
// 'trailing' is set to true, and get the form values here."
const currentValue = form.getFieldsValue();
setQuery(
{
// formValues: form.getFieldsValue(),
formValues: _.omit(
form.getFieldsValue(),
['environments.image'],
['environments.customizedTag'],
['autoMountedFolderNames'],
formValues: _.extend(
_.omit(
form.getFieldsValue(),
['environments.image'],
['environments.customizedTag'],
['autoMountedFolderNames'],
['envvars'],
),
{
envvars: emptySensitiveEnv(currentValue.envvars),
},
),
},
'replaceIn',
Expand Down

0 comments on commit ca56621

Please sign in to comment.