Skip to content

Commit

Permalink
ByMagicErr extract detections.
Browse files Browse the repository at this point in the history
  • Loading branch information
bengarrett committed Sep 10, 2024
1 parent 3bc9c13 commit 7b39212
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
2 changes: 1 addition & 1 deletion docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ The source code requires a local [installation of Go](https://go.dev/doc/install
```sh
$ go version

> go version go1.22.3 linux/amd64
> go version go1.22.6 linux/amd64
```

> [!IMPORTANT]
Expand Down
12 changes: 11 additions & 1 deletion model/artifacts.go
Original file line number Diff line number Diff line change
Expand Up @@ -191,16 +191,26 @@ func (f *Artifacts) ByMagicErr(ctx context.Context, exec boil.ContextExecutor, b
if invalidExec(exec) {
return nil, ErrDB
}
/*
SELECT DISTINCT "file_magic_type"
FROM "files"
ORDER BY "file_magic_type"
LIMIT 500;
*/
equals := []string{"data", "tar archive", "Microsoft ASF"}
ilikes := []string{
"application/%", "Zip archive data%", "ARC archive data%", "ARJ archive data%", "RAR archive data%",
"7-zip archive data%", "gzip compressed data%", "ASCII text%", "HTML document%", "Pascal source%", "ISO-8859 text%",
"JPEG image data%", "GIF image data%", "PNG image data%", "PDF document%", "RIFF (little-endian) data%",
"ISO Media%", "Fasttracker II%", "Ogg data%", "Audio file with%", "MPEG ADTS%",
"AIX core file%", "C source,%", "C++ source,%", "FORTRAN program%", "ISO-8859 text, with%",
"Little-endian UTF-16%", "MIT scheme%", "MS Windows icon resource%", "Microsoft Cabinet archive data,%",
"Non-ISO extended-ASCII text%", "PC bitmap, Windows 3.x format%", "PCX ver. 3.0 image data%",
"PE32 executable (GUI) Intel 80386%", "PE32 executable (console)%", "Python script%", "Quake I or II world or extension%",
}
mods := []qm.QueryMod{
qm.Select(models.FileColumns.UUID, models.FileColumns.ID, models.FileColumns.FileMagicType),
models.FileWhere.FileMagicType.EQ(null.StringFrom("")),
models.FileWhere.FileMagicType.IsNull(),
}
for _, s := range equals {
mods = append(mods, qm.Or2(models.FileWhere.FileMagicType.EQ(null.StringFrom(s))))
Expand Down

0 comments on commit 7b39212

Please sign in to comment.