Moved from jsonb to arrays for olevba results and macros
This commit is contained in:
parent
38feee1360
commit
a381ef8cf6
4 changed files with 25 additions and 23 deletions
|
@ -63,8 +63,8 @@ CREATE TABLE IF NOT EXISTS msoffice (
|
|||
nb_iocs INTEGER,
|
||||
nb_macros INTEGER,
|
||||
nb_suspicious INTEGER,
|
||||
olevba_results JSONB,
|
||||
macros JSONB
|
||||
olevba_results TEXT[][],
|
||||
macros TEXT[][]
|
||||
);
|
||||
|
||||
|
||||
|
@ -84,6 +84,6 @@ CREATE INDEX idx_processing_jobs_file_id ON processing_jobs (file_id);
|
|||
CREATE INDEX idx_msoffice_oleid_file_id ON msoffice_oleid (file_id);
|
||||
CREATE INDEX idx_msoffice_olevba_file_id ON msoffice_olevba (file_id);
|
||||
CREATE INDEX idx_msoffice_mraptor_file_id ON msoffice_mraptor (file_id);
|
||||
CREATE INDEX idx_msoffice_results_file_id ON msoffice_results (file_id);
|
||||
CREATE INDEX idx_msoffice_results_file_id ON msoffice (file_id);
|
||||
CREATE INDEX idx_file_properties_id ON file_properties (id);
|
||||
CREATE INDEX idx_file_id ON files (id);
|
||||
|
|
|
@ -1,9 +1,6 @@
|
|||
package msoffice
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"log/slog"
|
||||
|
||||
"git.jmbit.de/jmb/scanfile/server/internal/database"
|
||||
"git.jmbit.de/jmb/scanfile/server/internal/sqlc"
|
||||
)
|
||||
|
@ -24,29 +21,34 @@ func MSOfficeProcessing(job sqlc.ProcessingJob) error {
|
|||
FileID: job.FileID,
|
||||
}
|
||||
params.ContainerFormat.String = oleidResp.ContainerFormat
|
||||
params.ContainerFormat.Valid = true
|
||||
params.Encrypted.Bool = oleidResp.Encrypted
|
||||
params.Encrypted.Valid = true
|
||||
params.FileFormat.String = oleidResp.FileFormat
|
||||
params.FileFormat.Valid = true
|
||||
params.VbaMacros.String = oleidResp.VBAMacros
|
||||
params.VbaMacros.Valid = true
|
||||
params.XlmMacros.String = oleidResp.XLMMacros
|
||||
params.XlmMacros.Valid = true
|
||||
params.VbaStomping.Bool = olevbaResp.Stomping
|
||||
params.VbaStomping.Valid = true
|
||||
params.NbAutoexec.Int32 = int32(olevbaResp.NbAutoexec)
|
||||
params.NbAutoexec.Valid = true
|
||||
params.NbIocs.Int32 = int32(olevbaResp.NbIocs)
|
||||
params.NbIocs.Valid = true
|
||||
params.NbMacros.Int32 = int32(olevbaResp.NbMacros)
|
||||
params.NbIocs.Valid = true
|
||||
params.NbSuspicious.Int32 = int32(olevbaResp.NbSuspicious)
|
||||
params.NbSuspicious.Valid = true
|
||||
|
||||
params.OlevbaResults, err = json.Marshal(olevbaResp.Results)
|
||||
if err != nil {
|
||||
slog.Error("Error in MSOfficeProcessing while marshaling olevba results to json", "file-uuid", job.FileID.String(), "error", err, "job-id", job.ID)
|
||||
database.FailProcessingJob(job.ID, err)
|
||||
return err
|
||||
}
|
||||
|
||||
params.Macros, err = json.Marshal(olevbaResp.Macros)
|
||||
if err != nil {
|
||||
slog.Error("Error in MSOfficeProcessing while marshaling macros to json", "file-uuid", job.FileID.String(), "error", err, "job-id", job.ID)
|
||||
database.FailProcessingJob(job.ID, err)
|
||||
return err
|
||||
params.OlevbaResults = olevbaResp.Results
|
||||
params.Macros = olevbaResp.Macros
|
||||
if olevbaResp.NbSuspicious > 0 || olevbaResp.NbIocs > 0 || olevbaResp.NbAutoexec > 0 {
|
||||
params.Verdict.String = "suspicious"
|
||||
} else {
|
||||
params.Verdict.String = "inconspicous"
|
||||
}
|
||||
params.Verdict.Valid = true
|
||||
|
||||
err = database.InsertMSOfficeResults(params)
|
||||
if err != nil {
|
||||
|
|
|
@ -48,8 +48,8 @@ type Msoffice struct {
|
|||
NbIocs pgtype.Int4
|
||||
NbMacros pgtype.Int4
|
||||
NbSuspicious pgtype.Int4
|
||||
OlevbaResults []byte
|
||||
Macros []byte
|
||||
OlevbaResults [][]string
|
||||
Macros [][]string
|
||||
}
|
||||
|
||||
type MsofficeMraptor struct {
|
||||
|
|
|
@ -137,8 +137,8 @@ type InsertMSOfficeResultsParams struct {
|
|||
NbIocs pgtype.Int4
|
||||
NbMacros pgtype.Int4
|
||||
NbSuspicious pgtype.Int4
|
||||
OlevbaResults []byte
|
||||
Macros []byte
|
||||
OlevbaResults [][]string
|
||||
Macros [][]string
|
||||
}
|
||||
|
||||
func (q *Queries) InsertMSOfficeResults(ctx context.Context, arg InsertMSOfficeResultsParams) error {
|
||||
|
|
Loading…
Add table
Reference in a new issue