parserOpts traverses all fields/segments declared in the expression and dynamically determines what aspects of the PE need to be parsed.
()
| 1031 | // parserOpts traverses all fields/segments declared in the expression and |
| 1032 | // dynamically determines what aspects of the PE need to be parsed. |
| 1033 | func (pa *peAccessor) parserOpts() []pe.Option { |
| 1034 | var opts []pe.Option |
| 1035 | var peSections bool |
| 1036 | |
| 1037 | for _, f := range pa.fields { |
| 1038 | if f.Name.IsPeSectionsPseudo() { |
| 1039 | peSections = true |
| 1040 | } |
| 1041 | if f.Name.IsPeSection() || f.Name.IsPeModified() { |
| 1042 | opts = append(opts, pe.WithSections()) |
| 1043 | } |
| 1044 | if f.Name.IsPeSymbol() { |
| 1045 | opts = append(opts, pe.WithSymbols()) |
| 1046 | } |
| 1047 | if f.Name.IsPeVersionResource() || f.Name.IsPeVersionResources() { |
| 1048 | opts = append(opts, pe.WithVersionResources()) |
| 1049 | } |
| 1050 | if f.Name.IsPeImphash() { |
| 1051 | opts = append(opts, pe.WithImphash()) |
| 1052 | } |
| 1053 | if f.Name.IsPeDotnet() || f.Name.IsPeModified() { |
| 1054 | opts = append(opts, pe.WithCLR()) |
| 1055 | } |
| 1056 | if f.Name.IsPeAnomalies() { |
| 1057 | opts = append(opts, pe.WithSections(), pe.WithSymbols()) |
| 1058 | } |
| 1059 | if f.Name.IsPeSignature() { |
| 1060 | opts = append(opts, pe.WithSecurity()) |
| 1061 | } |
| 1062 | } |
| 1063 | |
| 1064 | for _, s := range pa.segments { |
| 1065 | if peSections && s.IsEntropy() { |
| 1066 | opts = append(opts, pe.WithSections(), pe.WithSectionEntropy()) |
| 1067 | } |
| 1068 | } |
| 1069 | |
| 1070 | return opts |
| 1071 | } |
| 1072 | |
| 1073 | // ErrPeNilCertificate indicates the PE certificate is not available |
| 1074 | var ErrPeNilCertificate = errors.New("pe certificate is nil") |
no test coverage detected