fix: Fix an exception caused by insufficient encryption string length (#8114)

This commit is contained in:
ssongliu 2025-03-10 22:18:57 +08:00 committed by GitHub
parent 1f842b49cc
commit 6c251e1a49
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 20 additions and 3 deletions

View file

@ -43,8 +43,8 @@ func Start() {
validator.Init()
gin.SetMode("debug")
cron.Run()
InitOthers()
hook.Init()
InitOthers()
rootRouter := router.Routers()

View file

@ -29,6 +29,13 @@ func StringEncryptWithKey(text, key string) (string, error) {
if len(text) == 0 {
return "", nil
}
if len(key) < 16 {
for len(key) < 16 {
key += "u"
}
} else {
key = key[:16]
}
pass := []byte(text)
xpass, err := aesEncryptWithSalt([]byte(key), pass)
if err == nil {
@ -65,6 +72,13 @@ func StringDecryptWithKey(text, key string) (string, error) {
if len(text) == 0 {
return "", nil
}
if len(key) < 16 {
for len(key) < 16 {
key += "u"
}
} else {
key = key[:16]
}
bytesPass, err := base64.StdEncoding.DecodeString(text)
if err != nil {
return "", err

View file

@ -69,6 +69,9 @@ interface DialogProps {
containerName: string;
}
const acceptParams = (props: DialogProps): void => {
form.newImageName = '';
form.comment = '';
form.author = '';
form.containerID = props.containerID;
form.containerName = props.containerName;
drawerVisible.value = true;

View file

@ -540,7 +540,7 @@ const search = async () => {
form.labels = res.data.labels || [];
form.env = res.data.env || [];
form.exposedPorts = res.data.exposedPorts || [];
for (const item of res.data.exposedPorts) {
for (const item of form.exposedPorts) {
if (item.hostIP) {
item.host = item.hostIP + ':' + item.hostPort;
} else {

View file

@ -1,5 +1,5 @@
<template>
<DrawerPro v-model="drawerVisible" :header="$t('terminal.exportImage')" @close="handleClose" size="small">
<DrawerPro v-model="drawerVisible" :header="$t('container.exportImage')" @close="handleClose" size="small">
<el-form v-loading="loading" label-position="top" ref="formRef" :model="form" label-width="80px">
<el-form-item :label="$t('container.tag')" :rules="Rules.requiredSelect" prop="tagName">
<el-select filterable v-model="form.tagName">