chore: implement Phase 1 and 2 security remediations
Some checks failed
Automated Container Build / build-and-push (push) Has been cancelled
Some checks failed
Automated Container Build / build-and-push (push) Has been cancelled
This commit is contained in:
parent
82731e93b1
commit
701766b611
14 changed files with 213 additions and 55 deletions
|
|
@ -213,17 +213,14 @@ func generateAudioThumbnail(src, dest string) error {
|
|||
|
||||
func generateOfficeThumbnail(filePath, destPath string, cfg *config.Config) error {
|
||||
// Generate a download token for the Conversion API to fetch the file from our backend
|
||||
token, err := middleware.GenerateDownloadToken(0, "system_worker", cfg.JWTSecret)
|
||||
token, err := middleware.GenerateDownloadToken(0, "system_worker", cfg.JWTSecret, filePath)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to generate download token: %w", err)
|
||||
}
|
||||
|
||||
// Assuming backend runs on port from config, but we need the external URL or internal docker URL that Document Server can reach.
|
||||
// Since we saw in OnlyOfficeEditor that the Document Server can reach the host at 192.168.50.81:5827, we use that.
|
||||
// We'll try to build a robust URL.
|
||||
hostIP := "192.168.50.81" // Hardcoded as per OnlyOfficeEditor.tsx implementation for this specific deployment
|
||||
port := cfg.Port
|
||||
fileUrl := fmt.Sprintf("http://%s:%s/api/public/onlyoffice/download?path=%s&token=%s", hostIP, port, url.QueryEscape(filePath), token)
|
||||
internalURL := cfg.InternalAPIURL
|
||||
fileUrl := fmt.Sprintf("%s/public/onlyoffice/download?path=%s&token=%s", internalURL, url.QueryEscape(filePath), token)
|
||||
|
||||
ext := strings.TrimPrefix(filepath.Ext(filePath), ".")
|
||||
if ext == "" {
|
||||
|
|
@ -344,7 +341,8 @@ func generateOfficeThumbnail(filePath, destPath string, cfg *config.Config) erro
|
|||
}
|
||||
|
||||
// Download the resulting image
|
||||
imgResp, err := http.Get(finalImgUrl)
|
||||
client := &http.Client{Timeout: 30 * time.Second}
|
||||
imgResp, err := client.Get(finalImgUrl)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to download converted image: %w", err)
|
||||
}
|
||||
|
|
|
|||
Reference in a new issue