Skip to content

Commit

Permalink
Only use name in field options if not empty (#1)
Browse files Browse the repository at this point in the history
  • Loading branch information
guspascual authored Sep 12, 2024
1 parent 0a18445 commit 034c888
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
4 changes: 3 additions & 1 deletion generator/generator.go
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,9 @@ func (g *Generator) getName(d desc.Descriptor) (name string) {
if ext, err := proto.GetExtension(d.GetOptions(), yara.E_MessageOptions); err == nil {
name = ext.(*yara.MessageOptions).GetName()
} else if ext, err := proto.GetExtension(d.GetOptions(), yara.E_FieldOptions); err == nil {
name = ext.(*yara.FieldOptions).GetName()
if ext.(*yara.FieldOptions).GetName() != "" {
name = ext.(*yara.FieldOptions).GetName()
}
} else if ext, err := proto.GetExtension(d.GetOptions(), yara.E_EnumOptions); err == nil {
name = ext.(*yara.EnumOptions).GetName()
}
Expand Down
2 changes: 2 additions & 0 deletions pb/yara.proto
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ message ModuleOptions {
}

message FieldOptions {
// Name of the field in YARA rules. Ignored if empty.
string name = 1;

bool ignore = 2;
}

Expand Down

0 comments on commit 034c888

Please sign in to comment.