fix backend audit findings (auth, upload, sync, data, ocr, contract)
CI / lint-backend (push) Failing after 1m39s
CI / lint-mobile (push) Canceled after 11m8s
CI / test-backend (push) Canceled after 0s
CI / test-mobile (push) Canceled after 0s
CI / build-backend (push) Canceled after 0s
CI / docker (push) Canceled after 0s

This commit is contained in:
m
2026-09-21 19:59:52 +02:00
parent df7dc76405
commit a6b7f2002b
60 changed files with 3414 additions and 412 deletions
+11 -1
View File
@@ -1,6 +1,7 @@
package handlers
import (
"errors"
"net/http"
"github.com/gin-gonic/gin"
@@ -18,9 +19,18 @@ func ShareLinkGet(c *gin.Context) {
return
}
token := c.Param("token")
// Contrat V1 : les tokens de lien sont du 32-hex (cf. docs/api-v1.md).
// Malformé → 400 INVALID_REQUEST (pas 404 : ce n'est pas « introuvable »,
// c'est « requête invalide »). deviceIDPattern (devices.go, même package)
// exprime exactement ce format.
if !deviceIDPattern.MatchString(token) {
api.Error(c, http.StatusBadRequest, "INVALID_REQUEST", "malformed link token")
return
}
link, err := Store.Repository.Shares.GetPublicLink(token)
if err != nil {
if err == repository.ErrNotFound {
// A6 : errors.Is (pas ==) — le repo peut envelopper ErrNotFound.
if errors.Is(err, repository.ErrNotFound) {
api.Error(c, http.StatusNotFound, "NOT_FOUND", "link not found or revoked")
return
}