Skip to content

Commit c5c131c

Browse files
committed
perf(pe): Disable CLR metadata parsing
CLR metadata parsing is not considered useful for detection purposes so we can safely disable it.
1 parent a8dc8da commit c5c131c

File tree

3 files changed

+6
-10
lines changed

3 files changed

+6
-10
lines changed

go.mod

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ require (
2222
github.com/pkg/errors v0.9.1
2323
github.com/qmuntal/stateless v1.6.0
2424
github.com/rifflock/lfshook v0.0.0-20180920164130-b9218ef580f5
25-
github.com/saferwall/pe v1.5.4
25+
github.com/saferwall/pe v1.5.6
2626
github.com/sirupsen/logrus v1.9.3
2727
github.com/spf13/cobra v0.0.3
2828
github.com/spf13/pflag v1.0.5
@@ -87,4 +87,4 @@ require (
8787
gopkg.in/yaml.v2 v2.3.0 // indirect
8888
)
8989

90-
go 1.21
90+
go 1.23

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -177,8 +177,8 @@ github.com/rivo/uniseg v0.4.2/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUc
177177
github.com/rogpeppe/fastuuid v0.0.0-20150106093220-6724a57986af/go.mod h1:XWv6SoW27p1b0cqNHllgS5HIMJraePCO15w5zCzIWYg=
178178
github.com/rogpeppe/go-internal v1.11.0 h1:cWPaGQEPrBb5/AsnsZesgZZ9yb1OQ+GOISoDNXVBh4M=
179179
github.com/rogpeppe/go-internal v1.11.0/go.mod h1:ddIwULY96R17DhadqLgMfk9H9tvdUzkipdSkR5nkCZA=
180-
github.com/saferwall/pe v1.5.4 h1:tLmMggEMUfeqrpJ25zS/okUQmyFdD5xWKL2+z9njCqg=
181-
github.com/saferwall/pe v1.5.4/go.mod h1:mJx+PuptmNpoPFBNhWs/uDMFL/kTHVZIkg0d4OUJFbQ=
180+
github.com/saferwall/pe v1.5.6 h1:DrRLnoQFxHWJ5lJUmrH7X2L0xeUu6SUS95Dc61eW2Yc=
181+
github.com/saferwall/pe v1.5.6/go.mod h1:mJx+PuptmNpoPFBNhWs/uDMFL/kTHVZIkg0d4OUJFbQ=
182182
github.com/sebdah/goldie v1.0.0 h1:9GNhIat69MSlz/ndaBg48vl9dF5fI+NBB6kfOxgfkMc=
183183
github.com/sebdah/goldie v1.0.0/go.mod h1:jXP4hmWywNEwZzhMuv2ccnqTSFpuq8iyQhtQdkkZBH4=
184184
github.com/secDre4mer/pkcs7 v0.0.0-20240322103146-665324a4461d h1:RQqyEogx5J6wPdoxqL132b100j8KjcVHO1c0KLRoIhc=

pkg/pe/parser.go

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,7 @@ func newParserOpts(opts opts) *peparser.Options {
211211
OmitExceptionDirectory: true,
212212
OmitTLSDirectory: true,
213213
OmitCLRHeaderDirectory: !opts.parseCLR,
214+
OmitCLRMetadata: true,
214215
OmitDelayImportDirectory: true,
215216
OmitBoundImportDirectory: true,
216217
OmitArchitectureDirectory: true,
@@ -305,13 +306,8 @@ func parse(path string, data []byte, options ...Option) (*PE, error) {
305306
p.EntryPoint = format.UintToHex(uint64(oh32.AddressOfEntryPoint))
306307
}
307308

308-
// CLR directory parsing piggybacks on sections
309-
if opts.parseCLR {
310-
opts.parseSections = true
311-
}
312-
313309
// parse section header
314-
if opts.parseSections || opts.parseResources {
310+
if opts.parseSections || opts.parseResources || opts.parseCLR {
315311
err = pe.ParseSectionHeader()
316312
if err != nil {
317313
return nil, err

0 commit comments

Comments
 (0)