chore: add security

This commit is contained in:
2026-03-11 21:21:04 +01:00
parent b86315b60b
commit f5902665ec
2 changed files with 5 additions and 2 deletions
+4 -2
View File
@@ -1,10 +1,11 @@
package utils
import (
"crypto/rand"
"fmt"
"gestion/db"
"gestion/models"
"math/rand"
"math/big"
"os"
"path/filepath"
)
@@ -22,7 +23,8 @@ func GetMediaForProduct(productID int) ([]models.Media, error) {
// --------------------------------------------
func GenerateUniqueFileName(productName string, originalFileName string) string {
randomString := fmt.Sprintf("%d", rand.Intn(1000000))
n, _ := rand.Int(rand.Reader, big.NewInt(1000000))
randomString := fmt.Sprintf("%d", n.Int64())
ext := filepath.Ext(originalFileName)
return fmt.Sprintf("%s_%s%s", productName, randomString, ext)
}