feat(web): mask real file paths when working with TFM database
This commit is contained in:
parent
94b55c8a87
commit
f5eb8dac06
@ -11,15 +11,17 @@ import (
|
|||||||
"os"
|
"os"
|
||||||
"path"
|
"path"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
type JSON struct {
|
type JSON struct {
|
||||||
Status bool `json:"status,omitempty"`
|
Status bool `json:"status"`
|
||||||
Token string `json:"token,omitempty"`
|
Token string `json:"token,omitempty"`
|
||||||
TRC uint8 `json:"trc,omitempty"`
|
TRC uint8 `json:"trc,omitempty"`
|
||||||
TRDB string `json:"trdb,omitempty"`
|
TRDB string `json:"trdb,omitempty"`
|
||||||
TRB string `json:"trb,omitempty"`
|
TRB string `json:"trb,omitempty"`
|
||||||
|
Data []map[string]interface{} `json:"data,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
var tdbms TDBMSConnection
|
var tdbms TDBMSConnection
|
||||||
@ -128,6 +130,19 @@ func HandlerTDBMS(w http.ResponseWriter, r *http.Request) {
|
|||||||
http.Error(w, "Failed to execute request", http.StatusInternalServerError)
|
http.Error(w, "Failed to execute request", http.StatusInternalServerError)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
if request.TRDB == "$TFM" && (request.TRC == 0b10000 || request.TRC == 0b101000) {
|
||||||
|
var json_response JSON
|
||||||
|
err = json.Unmarshal(response, &json_response)
|
||||||
|
if err != nil {
|
||||||
|
http.Error(w, "TDBMS error", http.StatusInternalServerError)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
for index, element := range json_response.Data {
|
||||||
|
json_response.Data[index]["path"] =
|
||||||
|
strings.ReplaceAll(element["path"].(string), "/srv/data/tfm/", "")
|
||||||
|
}
|
||||||
|
response, err = json.Marshal(json_response)
|
||||||
|
}
|
||||||
w.Header().Set("Content-Type", "application/json; charset=utf-8")
|
w.Header().Set("Content-Type", "application/json; charset=utf-8")
|
||||||
_, err = w.Write(response)
|
_, err = w.Write(response)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user