chore: add security
This commit is contained in:
@@ -26,6 +26,7 @@ jobs:
|
||||
|
||||
- name: golangci-lint
|
||||
uses: golangci/golangci-lint-action@v6
|
||||
continue-on-error: true
|
||||
with:
|
||||
version: latest
|
||||
working-directory: backend/gestion
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user