Commit 77bb5e0c authored by 皮倩雯's avatar 皮倩雯

fix: '解密bug修复'

parent 5192971b
Pipeline #87437 passed with stages
...@@ -116,7 +116,7 @@ const InitDataBase = props => { ...@@ -116,7 +116,7 @@ const InitDataBase = props => {
padding: CryptoJS.pad.Pkcs7, padding: CryptoJS.pad.Pkcs7,
}); });
let decryptedStr = decrypt.toString(CryptoJS.enc.Utf8); let decryptedStr = decrypt.toString(CryptoJS.enc.Utf8);
return decryptedStr.toString(); return decryptedStr?.toString();
}; };
//加密 //加密
...@@ -167,10 +167,10 @@ const InitDataBase = props => { ...@@ -167,10 +167,10 @@ const InitDataBase = props => {
const onFinish = values => { const onFinish = values => {
setCardLoading(true); setCardLoading(true);
const obj = values; const obj = values;
let pwd = let pwd = obj.password;
Decrypt(obj.password) === '' || Decrypt(obj.password).indexOf('\u0004') !== -1 if (obj.password.length < 32 || !isAlphanumeric(obj.password)) {
? Encrypt(obj.password) pwd = Encrypt(obj.password);
: obj.password; }
saveConnectionNew({ saveConnectionNew({
ip: obj.ip, ip: obj.ip,
dbName: obj.dbName, dbName: obj.dbName,
...@@ -213,14 +213,15 @@ const InitDataBase = props => { ...@@ -213,14 +213,15 @@ const InitDataBase = props => {
}); });
}); });
}; };
// 测试连接 // 测试连接
const onCheck = e => { const onCheck = e => {
setCardLoading(true); setCardLoading(true);
const obj = form.getFieldsValue(); const obj = form.getFieldsValue();
let pwd = let pwd = obj.password;
Decrypt(obj.password) === '' || Decrypt(obj.password).indexOf('\u0004') !== -1 if (obj.password.length < 32 || !isAlphanumeric(obj.password)) {
? Encrypt(obj.password) pwd = Encrypt(obj.password);
: obj.password; }
connectionTest({ connectionTest({
ip: obj.ip, ip: obj.ip,
dbName: obj.dbName, dbName: obj.dbName,
...@@ -249,13 +250,18 @@ const InitDataBase = props => { ...@@ -249,13 +250,18 @@ const InitDataBase = props => {
console.log(err); console.log(err);
}); });
}; };
const isAlphanumeric = str => {
return /^[A-Za-z0-9]+$/.test(str);
};
// 获取数据库列表 // 获取数据库列表
const selectFocus = e => { const selectFocus = e => {
let params = form.getFieldsValue(); let params = form.getFieldsValue();
let pwd = let pwd = params.password;
Decrypt(params.password) === '' || Decrypt(params.password).indexOf('\u0004') !== -1 if (params.password.length < 32 || !isAlphanumeric(params.password)) {
? Encrypt(params.password) pwd = Encrypt(params.password);
: params.password; }
getDataBaseList({ getDataBaseList({
userName: params.userName || '', userName: params.userName || '',
password: pwd || '', password: pwd || '',
......
...@@ -36,16 +36,21 @@ const AddModal = props => { ...@@ -36,16 +36,21 @@ const AddModal = props => {
}); });
return encrypted.ciphertext.toString().toUpperCase(); return encrypted.ciphertext.toString().toUpperCase();
}; };
const isAlphanumeric = str => {
return /^[A-Za-z0-9]+$/.test(str);
};
// 提交 // 提交
const onSubmit = () => { const onSubmit = () => {
form.validateFields().then(validate => { form.validateFields().then(validate => {
if (validate) { if (validate) {
setLoading(true); setLoading(true);
let obj = form.getFieldsValue(); let obj = form.getFieldsValue();
let pwd = let pwd = obj.password;
Decrypt(obj.password) === '' || Decrypt(obj.password).indexOf('\u0004') !== -1 if (obj.password.length < 32 || !isAlphanumeric(obj.password)) {
? Encrypt(obj.password) pwd = Encrypt(obj.password);
: obj.password; }
if (type === 'add') { if (type === 'add') {
AddConnString({ AddConnString({
...obj, ...obj,
...@@ -82,10 +87,10 @@ const AddModal = props => { ...@@ -82,10 +87,10 @@ const AddModal = props => {
}; };
const handleEdit = () => { const handleEdit = () => {
let obj = form.getFieldsValue(); let obj = form.getFieldsValue();
let pwd = let pwd = obj.password;
Decrypt(obj.password) === '' || Decrypt(obj.password).indexOf('\u0004') !== -1 if (obj.password.length < 32 || !isAlphanumeric(obj.password)) {
? Encrypt(obj.password) pwd = Encrypt(obj.password);
: obj.password; }
EditConnString({ EditConnString({
...obj, ...obj,
oldName: formObj.name, oldName: formObj.name,
......
...@@ -36,16 +36,20 @@ const AddModal = props => { ...@@ -36,16 +36,20 @@ const AddModal = props => {
}); });
return encrypted.ciphertext.toString().toUpperCase(); return encrypted.ciphertext.toString().toUpperCase();
}; };
const isAlphanumeric = str => {
return /^[A-Za-z0-9]+$/.test(str);
};
// 提交 // 提交
const onSubmit = () => { const onSubmit = () => {
form.validateFields().then(validate => { form.validateFields().then(validate => {
if (validate) { if (validate) {
setLoading(true); setLoading(true);
let obj = form.getFieldsValue(); let obj = form.getFieldsValue();
let pwd = let pwd = obj.password;
Decrypt(obj.password) === '' || Decrypt(obj.password).indexOf('\u0004') !== -1 if (obj.password.length < 32 || !isAlphanumeric(obj.password)) {
? Encrypt(obj.password) pwd = Encrypt(obj.password);
: obj.password; }
if (type === 'add') { if (type === 'add') {
AddConnString({ AddConnString({
type: 'mysql', type: 'mysql',
...@@ -82,10 +86,10 @@ const AddModal = props => { ...@@ -82,10 +86,10 @@ const AddModal = props => {
}; };
const handleEdit = () => { const handleEdit = () => {
let obj = form.getFieldsValue(); let obj = form.getFieldsValue();
let pwd = let pwd = obj.password;
Decrypt(obj.password) === '' || Decrypt(obj.password).indexOf('\u0004') !== -1 if (obj.password.length < 32 || !isAlphanumeric(obj.password)) {
? Encrypt(obj.password) pwd = Encrypt(obj.password);
: obj.password; }
EditConnString({ EditConnString({
type: 'mysql', type: 'mysql',
...obj, ...obj,
......
...@@ -36,16 +36,20 @@ const AddModal = props => { ...@@ -36,16 +36,20 @@ const AddModal = props => {
}); });
return encrypted.ciphertext.toString().toUpperCase(); return encrypted.ciphertext.toString().toUpperCase();
}; };
const isAlphanumeric = str => {
return /^[A-Za-z0-9]+$/.test(str);
};
// 提交 // 提交
const onSubmit = () => { const onSubmit = () => {
form.validateFields().then(validate => { form.validateFields().then(validate => {
if (validate) { if (validate) {
setLoading(true); setLoading(true);
let obj = form.getFieldsValue(); let obj = form.getFieldsValue();
let pwd = let pwd = obj.password;
Decrypt(obj.password) === '' || Decrypt(obj.password).indexOf('\u0004') !== -1 if (obj.password.length < 32 || !isAlphanumeric(obj.password)) {
? Encrypt(obj.password) pwd = Encrypt(obj.password);
: obj.password; }
if (type === 'add') { if (type === 'add') {
AddConnString({ AddConnString({
...obj, ...obj,
...@@ -82,10 +86,10 @@ const AddModal = props => { ...@@ -82,10 +86,10 @@ const AddModal = props => {
}; };
const handleEdit = () => { const handleEdit = () => {
let obj = form.getFieldsValue(); let obj = form.getFieldsValue();
let pwd = let pwd = obj.password;
Decrypt(obj.password) === '' || Decrypt(obj.password).indexOf('\u0004') !== -1 if (obj.password.length < 32 || !isAlphanumeric(obj.password)) {
? Encrypt(obj.password) pwd = Encrypt(obj.password);
: obj.password; }
EditConnString({ EditConnString({
type: 'oracle', type: 'oracle',
...obj, ...obj,
......
...@@ -36,16 +36,17 @@ const AddModal = props => { ...@@ -36,16 +36,17 @@ const AddModal = props => {
}); });
return encrypted.ciphertext.toString().toUpperCase(); return encrypted.ciphertext.toString().toUpperCase();
}; };
// 提交 // 提交
const onSubmit = () => { const onSubmit = () => {
form.validateFields().then(validate => { form.validateFields().then(validate => {
if (validate) { if (validate) {
setLoading(true); setLoading(true);
let obj = form.getFieldsValue(); let obj = form.getFieldsValue();
let pwd = let pwd = obj.password;
Decrypt(obj.password) === '' || Decrypt(obj.password).indexOf('\u0004') !== -1 if (obj.password.length < 32 || !isAlphanumeric(obj.password)) {
? Encrypt(obj.password) pwd = Encrypt(obj.password);
: obj.password; }
if (type === 'add') { if (type === 'add') {
AddConnString({ AddConnString({
...obj, ...obj,
...@@ -80,12 +81,16 @@ const AddModal = props => { ...@@ -80,12 +81,16 @@ const AddModal = props => {
} }
}); });
}; };
const isAlphanumeric = str => {
return /^[A-Za-z0-9]+$/.test(str);
};
const handleEdit = () => { const handleEdit = () => {
let obj = form.getFieldsValue(); let obj = form.getFieldsValue();
let pwd = let pwd = obj.password;
Decrypt(obj.password) === '' || Decrypt(obj.password).indexOf('\u0004') !== -1 if (obj.password.length < 32 || !isAlphanumeric(obj.password)) {
? Encrypt(obj.password) pwd = Encrypt(obj.password);
: obj.password; }
EditConnString({ EditConnString({
...obj, ...obj,
oldName: formObj.name, oldName: formObj.name,
......
...@@ -36,16 +36,21 @@ const AddModal = props => { ...@@ -36,16 +36,21 @@ const AddModal = props => {
}); });
return encrypted.ciphertext.toString().toUpperCase(); return encrypted.ciphertext.toString().toUpperCase();
}; };
const isAlphanumeric = str => {
return /^[A-Za-z0-9]+$/.test(str);
};
// 提交 // 提交
const onSubmit = () => { const onSubmit = () => {
form.validateFields().then(validate => { form.validateFields().then(validate => {
if (validate) { if (validate) {
setLoading(true); setLoading(true);
let obj = form.getFieldsValue(); let obj = form.getFieldsValue();
let pwd = let pwd = obj.password;
Decrypt(obj.password) === '' || Decrypt(obj.password).indexOf('\u0004') !== -1 if (obj.password.length < 32 || !isAlphanumeric(obj.password)) {
? Encrypt(obj.password) pwd = Encrypt(obj.password);
: obj.password; }
if (type === 'add') { if (type === 'add') {
AddConnString({ AddConnString({
...obj, ...obj,
...@@ -82,10 +87,10 @@ const AddModal = props => { ...@@ -82,10 +87,10 @@ const AddModal = props => {
}; };
const handleEdit = () => { const handleEdit = () => {
let obj = form.getFieldsValue(); let obj = form.getFieldsValue();
let pwd = let pwd = obj.password;
Decrypt(obj.password) === '' || Decrypt(obj.password).indexOf('\u0004') !== -1 if (obj.password.length < 32 || !isAlphanumeric(obj.password)) {
? Encrypt(obj.password) pwd = Encrypt(obj.password);
: obj.password; }
EditConnString({ EditConnString({
...obj, ...obj,
oldName: formObj.name, oldName: formObj.name,
......
...@@ -94,12 +94,16 @@ const AppendModal = props => { ...@@ -94,12 +94,16 @@ const AppendModal = props => {
return encrypted.ciphertext.toString().toUpperCase(); return encrypted.ciphertext.toString().toUpperCase();
}; };
const isAlphanumeric = str => {
return /^[A-Za-z0-9]+$/.test(str);
};
const getProduct = () => { const getProduct = () => {
setLoading(true); setLoading(true);
let pwd = let pwd = value.password;
Decrypt(value.password) === '' || Decrypt(value.password).indexOf('\u0004') !== -1 if (value.password.length < 32 || !isAlphanumeric(value.password)) {
? Encrypt(value.password) pwd = Encrypt(value.password);
: value.password; }
GetLicenseDifference({ ...value, password: pwd }).then(res => { GetLicenseDifference({ ...value, password: pwd }).then(res => {
setLoading(false); setLoading(false);
if (res.code === 0) { if (res.code === 0) {
......
...@@ -439,12 +439,16 @@ const DatabaseInitialization = props => { ...@@ -439,12 +439,16 @@ const DatabaseInitialization = props => {
}); });
}; };
const isAlphanumeric = str => {
return /^[A-Za-z0-9]+$/.test(str);
};
const GetDbChangeFirst = kk => { const GetDbChangeFirst = kk => {
let obj = form.getFieldsValue(); let obj = form.getFieldsValue();
let pwd = let pwd = obj.password;
Decrypt(obj.password) === '' || Decrypt(obj.password).indexOf('\u0004') !== -1 if (obj.password.length < 32 || !isAlphanumeric(obj.password)) {
? Encrypt(obj.password) pwd = Encrypt(obj.password);
: obj.password; }
GetDbProduct({ ...obj, password: pwd }).then(res => { GetDbProduct({ ...obj, password: pwd }).then(res => {
setCardLoading(false); setCardLoading(false);
if (res.code === 0) { if (res.code === 0) {
...@@ -495,10 +499,10 @@ const DatabaseInitialization = props => { ...@@ -495,10 +499,10 @@ const DatabaseInitialization = props => {
const GetDbChange = e => { const GetDbChange = e => {
let obj = form.getFieldsValue(); let obj = form.getFieldsValue();
let pwd = let pwd = obj.password;
Decrypt(obj.password) === '' || Decrypt(obj.password).indexOf('\u0004') !== -1 if (obj.password.length < 32 || !isAlphanumeric(obj.password)) {
? Encrypt(obj.password) pwd = Encrypt(obj.password);
: obj.password; }
GetDbProduct({ ...obj, password: pwd }).then(res => { GetDbProduct({ ...obj, password: pwd }).then(res => {
setCardLoading(false); setCardLoading(false);
if (res.code === 0) { if (res.code === 0) {
...@@ -614,10 +618,10 @@ const DatabaseInitialization = props => { ...@@ -614,10 +618,10 @@ const DatabaseInitialization = props => {
const GetDbChangeAppend = () => { const GetDbChangeAppend = () => {
let obj = form.getFieldsValue(); let obj = form.getFieldsValue();
let pwd = let pwd = obj.password;
Decrypt(obj.password) === '' || Decrypt(obj.password).indexOf('\u0004') !== -1 if (obj.password.length < 32 || !isAlphanumeric(obj.password)) {
? Encrypt(obj.password) pwd = Encrypt(obj.password);
: obj.password; }
GetDbProduct({ ...obj, password: pwd }).then(res => { GetDbProduct({ ...obj, password: pwd }).then(res => {
setCardLoading(false); setCardLoading(false);
if (res.code === 0) { if (res.code === 0) {
...@@ -702,10 +706,10 @@ const DatabaseInitialization = props => { ...@@ -702,10 +706,10 @@ const DatabaseInitialization = props => {
handleShowModal('initVisible', false); handleShowModal('initVisible', false);
setInitVisible(true); setInitVisible(true);
doInitLog(); doInitLog();
let pwd = let pwd = obj.password;
Decrypt(obj.password) === '' || Decrypt(obj.password).indexOf('\u0004') !== -1 if (obj.password.length < 32 || !isAlphanumeric(obj.password)) {
? Encrypt(obj.password) pwd = Encrypt(obj.password);
: obj.password; }
NewInitAddDataBase({ ...obj, productSetting, password: pwd }).then(res => { NewInitAddDataBase({ ...obj, productSetting, password: pwd }).then(res => {
if (res.code === 0) { if (res.code === 0) {
GetDbChangeAppend(); // 刷星已初始化的产品勾选 GetDbChangeAppend(); // 刷星已初始化的产品勾选
...@@ -764,10 +768,10 @@ const DatabaseInitialization = props => { ...@@ -764,10 +768,10 @@ const DatabaseInitialization = props => {
setInitVisible(true); setInitVisible(true);
doInitLog(); doInitLog();
let obj = form.getFieldsValue(); let obj = form.getFieldsValue();
let pwd = let pwd = obj.password;
Decrypt(obj.password) === '' || Decrypt(obj.password).indexOf('\u0004') !== -1 if (obj.password.length < 32 || !isAlphanumeric(obj.password)) {
? Encrypt(obj.password) pwd = Encrypt(obj.password);
: obj.password; }
InitEditDataBase({ InitEditDataBase({
...obj, ...obj,
password: pwd, password: pwd,
...@@ -833,10 +837,10 @@ const DatabaseInitialization = props => { ...@@ -833,10 +837,10 @@ const DatabaseInitialization = props => {
// setKeepValue([]); // setKeepValue([]);
setProduct([]); setProduct([]);
setCardLoading(true); setCardLoading(true);
let pwd = let pwd = obj.password;
Decrypt(obj.password) === '' || Decrypt(obj.password).indexOf('\u0004') !== -1 if (obj.password.length < 32 || !isAlphanumeric(obj.password)) {
? Encrypt(obj.password) pwd = Encrypt(obj.password);
: obj.password; }
GetProductList({ ...obj, password: pwd }).then(res => { GetProductList({ ...obj, password: pwd }).then(res => {
if (res.code === 0) { if (res.code === 0) {
console.log(res.data); console.log(res.data);
...@@ -870,10 +874,10 @@ const DatabaseInitialization = props => { ...@@ -870,10 +874,10 @@ const DatabaseInitialization = props => {
const onCheckLaster = aa => { const onCheckLaster = aa => {
// 此时有授权码才能进入 // 此时有授权码才能进入
let obj = form.getFieldsValue(); let obj = form.getFieldsValue();
let pwd = let pwd = obj.password;
Decrypt(obj.password) === '' || Decrypt(obj.password).indexOf('\u0004') !== -1 if (obj.password.length < 32 || !isAlphanumeric(obj.password)) {
? Encrypt(obj.password) pwd = Encrypt(obj.password);
: obj.password; }
CheckDatabaseIsExist({ ...obj, password: pwd }).then(res => { CheckDatabaseIsExist({ ...obj, password: pwd }).then(res => {
setCardLoading(false); setCardLoading(false);
if (res.code == 0) { if (res.code == 0) {
...@@ -918,10 +922,10 @@ const DatabaseInitialization = props => { ...@@ -918,10 +922,10 @@ const DatabaseInitialization = props => {
setAppendType('no'); setAppendType('no');
let obj = form.getFieldsValue(); let obj = form.getFieldsValue();
if (obj.ip && obj.userName && obj.password && obj.dbName && obj.providerType) { if (obj.ip && obj.userName && obj.password && obj.dbName && obj.providerType) {
let pwd = let pwd = obj.password;
Decrypt(obj.password) === '' || Decrypt(obj.password).indexOf('\u0004') !== -1 if (obj.password.length < 32 || !isAlphanumeric(obj.password)) {
? Encrypt(obj.password) pwd = Encrypt(obj.password);
: obj.password; }
GetProductList({ ...obj, password: pwd }).then(res => { GetProductList({ ...obj, password: pwd }).then(res => {
setCardLoading(false); setCardLoading(false);
if (res.code === 0) { if (res.code === 0) {
...@@ -951,10 +955,10 @@ const DatabaseInitialization = props => { ...@@ -951,10 +955,10 @@ const DatabaseInitialization = props => {
const findCheck = aa => { const findCheck = aa => {
let obj = form.getFieldsValue(); let obj = form.getFieldsValue();
let pwd = let pwd = obj.password;
Decrypt(obj.password) === '' || Decrypt(obj.password).indexOf('\u0004') !== -1 if (obj.password.length < 32 || !isAlphanumeric(obj.password)) {
? Encrypt(obj.password) pwd = Encrypt(obj.password);
: obj.password; }
CheckDatabaseIsExist({ ...obj, password: pwd }).then(res => { CheckDatabaseIsExist({ ...obj, password: pwd }).then(res => {
setCardLoading(false); setCardLoading(false);
if (res.code === 0) { if (res.code === 0) {
...@@ -1004,10 +1008,10 @@ const DatabaseInitialization = props => { ...@@ -1004,10 +1008,10 @@ const DatabaseInitialization = props => {
const findCheck1 = aa => { const findCheck1 = aa => {
let obj = form.getFieldsValue(); let obj = form.getFieldsValue();
let pwd = let pwd = obj.password;
Decrypt(obj.password) === '' || Decrypt(obj.password).indexOf('\u0004') !== -1 if (obj.password.length < 32 || !isAlphanumeric(obj.password)) {
? Encrypt(obj.password) pwd = Encrypt(obj.password);
: obj.password; }
CheckDatabaseIsExist({ ...obj, password: pwd }).then(res => { CheckDatabaseIsExist({ ...obj, password: pwd }).then(res => {
setCardLoading(false); setCardLoading(false);
if (res.code === 0) { if (res.code === 0) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment