package msoffice import ( "encoding/json" "fmt" "log/slog" "net/http" "net/url" "git.jmbit.de/jmb/scanfile/server/internal/database" "github.com/jackc/pgx/v5/pgtype" "github.com/spf13/viper" ) func OleVBAScan(fileID pgtype.UUID) error { slog.Debug("Starting OLEvba scan", "file-uuid", fileID.String()) oleidUrl, err := url.Parse(viper.GetString("processing.oleurl")) if err != nil { slog.Error("Error parsing URL for ole service", "file-uuid", fileID.String(), "error", err) } oleidUrl.Path = "/olevba/analyze" oleidUrl.Query().Add("file", fileID.String()) oleidResp, err := http.Get(oleidUrl.String()) slog.Debug("OleVBAScan request", "file-uuid", fileID.String(), "url", oleidUrl.String(), "status-code", oleidResp.StatusCode) if err != nil { slog.Error("Error getting olevba info from service", "file-uuid", fileID.String(), "error", err) } var body []byte _, err = oleidResp.Body.Read(body) if err != nil { slog.Error("Error parsing olevba body", "file-uuid", fileID.String(), "error", err) } if json.Valid(body) == false { return fmt.Errorf("JSON not valid") } slog.Debug("OleVBAScan", "file-uuid", fileID.String(), "data", body) database.InsertJsonResult(fileID, body, "msoffice_olevba") return nil }