proto: don't use name property due to top level python decorator name

This commit is contained in:
Willi Ballenthin
2023-03-22 11:03:18 +01:00
parent f54ef35a7a
commit ec785f9d6d
4 changed files with 100 additions and 98 deletions

View File

@@ -111,7 +111,7 @@ message FeatureNode {
ClassFeature class_ = 14;
NamespaceFeature namespace = 15;
APIFeature api = 16;
PropertyFeature property = 17;
PropertyFeature property_ = 17; // property is a Python top-level decorator name
NumberFeature number = 18;
BytesFeature bytes = 19;
OffsetFeature offset = 20;
@@ -246,7 +246,7 @@ message OperandOffsetFeature {
message PropertyFeature {
string type = 1;
string property = 2;
string property_ = 2; // property is a Python top-level decorator name
optional string access = 3;
optional string description = 4;
}

File diff suppressed because one or more lines are too long

View File

@@ -397,7 +397,7 @@ class FeatureNode(google.protobuf.message.Message):
CLASS__FIELD_NUMBER: builtins.int
NAMESPACE_FIELD_NUMBER: builtins.int
API_FIELD_NUMBER: builtins.int
PROPERTY_FIELD_NUMBER: builtins.int
PROPERTY__FIELD_NUMBER: builtins.int
NUMBER_FIELD_NUMBER: builtins.int
BYTES_FIELD_NUMBER: builtins.int
OFFSET_FIELD_NUMBER: builtins.int
@@ -438,7 +438,8 @@ class FeatureNode(google.protobuf.message.Message):
@property
def api(self) -> global___APIFeature: ...
@property
def property(self) -> global___PropertyFeature: ...
def property_(self) -> global___PropertyFeature:
"""property is a Python top-level decorator name"""
@property
def number(self) -> global___NumberFeature: ...
@property
@@ -472,7 +473,7 @@ class FeatureNode(google.protobuf.message.Message):
class_: global___ClassFeature | None = ...,
namespace: global___NamespaceFeature | None = ...,
api: global___APIFeature | None = ...,
property: global___PropertyFeature | None = ...,
property_: global___PropertyFeature | None = ...,
number: global___NumberFeature | None = ...,
bytes: global___BytesFeature | None = ...,
offset: global___OffsetFeature | None = ...,
@@ -481,9 +482,9 @@ class FeatureNode(google.protobuf.message.Message):
operand_offset: global___OperandOffsetFeature | None = ...,
basic_block: global___BasicBlockFeature | None = ...,
) -> None: ...
def HasField(self, field_name: typing_extensions.Literal["api", b"api", "arch", b"arch", "basic_block", b"basic_block", "bytes", b"bytes", "characteristic", b"characteristic", "class_", b"class_", "export", b"export", "feature", b"feature", "format", b"format", "function_name", b"function_name", "import_", b"import_", "match", b"match", "mnemonic", b"mnemonic", "namespace", b"namespace", "number", b"number", "offset", b"offset", "operand_number", b"operand_number", "operand_offset", b"operand_offset", "os", b"os", "property", b"property", "regex", b"regex", "section", b"section", "string", b"string", "substring", b"substring"]) -> builtins.bool: ...
def ClearField(self, field_name: typing_extensions.Literal["api", b"api", "arch", b"arch", "basic_block", b"basic_block", "bytes", b"bytes", "characteristic", b"characteristic", "class_", b"class_", "export", b"export", "feature", b"feature", "format", b"format", "function_name", b"function_name", "import_", b"import_", "match", b"match", "mnemonic", b"mnemonic", "namespace", b"namespace", "number", b"number", "offset", b"offset", "operand_number", b"operand_number", "operand_offset", b"operand_offset", "os", b"os", "property", b"property", "regex", b"regex", "section", b"section", "string", b"string", "substring", b"substring", "type", b"type"]) -> None: ...
def WhichOneof(self, oneof_group: typing_extensions.Literal["feature", b"feature"]) -> typing_extensions.Literal["os", "arch", "format", "match", "characteristic", "export", "import_", "section", "function_name", "substring", "regex", "string", "class_", "namespace", "api", "property", "number", "bytes", "offset", "mnemonic", "operand_number", "operand_offset", "basic_block"] | None: ...
def HasField(self, field_name: typing_extensions.Literal["api", b"api", "arch", b"arch", "basic_block", b"basic_block", "bytes", b"bytes", "characteristic", b"characteristic", "class_", b"class_", "export", b"export", "feature", b"feature", "format", b"format", "function_name", b"function_name", "import_", b"import_", "match", b"match", "mnemonic", b"mnemonic", "namespace", b"namespace", "number", b"number", "offset", b"offset", "operand_number", b"operand_number", "operand_offset", b"operand_offset", "os", b"os", "property_", b"property_", "regex", b"regex", "section", b"section", "string", b"string", "substring", b"substring"]) -> builtins.bool: ...
def ClearField(self, field_name: typing_extensions.Literal["api", b"api", "arch", b"arch", "basic_block", b"basic_block", "bytes", b"bytes", "characteristic", b"characteristic", "class_", b"class_", "export", b"export", "feature", b"feature", "format", b"format", "function_name", b"function_name", "import_", b"import_", "match", b"match", "mnemonic", b"mnemonic", "namespace", b"namespace", "number", b"number", "offset", b"offset", "operand_number", b"operand_number", "operand_offset", b"operand_offset", "os", b"os", "property_", b"property_", "regex", b"regex", "section", b"section", "string", b"string", "substring", b"substring", "type", b"type"]) -> None: ...
def WhichOneof(self, oneof_group: typing_extensions.Literal["feature", b"feature"]) -> typing_extensions.Literal["os", "arch", "format", "match", "characteristic", "export", "import_", "section", "function_name", "substring", "regex", "string", "class_", "namespace", "api", "property_", "number", "bytes", "offset", "mnemonic", "operand_number", "operand_offset", "basic_block"] | None: ...
global___FeatureNode = FeatureNode
@@ -977,23 +978,24 @@ class PropertyFeature(google.protobuf.message.Message):
DESCRIPTOR: google.protobuf.descriptor.Descriptor
TYPE_FIELD_NUMBER: builtins.int
PROPERTY_FIELD_NUMBER: builtins.int
PROPERTY__FIELD_NUMBER: builtins.int
ACCESS_FIELD_NUMBER: builtins.int
DESCRIPTION_FIELD_NUMBER: builtins.int
type: builtins.str
property: builtins.str
property_: builtins.str
"""property is a Python top-level decorator name"""
access: builtins.str
description: builtins.str
def __init__(
self,
*,
type: builtins.str = ...,
property: builtins.str = ...,
property_: builtins.str = ...,
access: builtins.str | None = ...,
description: builtins.str | None = ...,
) -> None: ...
def HasField(self, field_name: typing_extensions.Literal["_access", b"_access", "_description", b"_description", "access", b"access", "description", b"description"]) -> builtins.bool: ...
def ClearField(self, field_name: typing_extensions.Literal["_access", b"_access", "_description", b"_description", "access", b"access", "description", b"description", "property", b"property", "type", b"type"]) -> None: ...
def ClearField(self, field_name: typing_extensions.Literal["_access", b"_access", "_description", b"_description", "access", b"access", "description", b"description", "property_", b"property_", "type", b"type"]) -> None: ...
@typing.overload
def WhichOneof(self, oneof_group: typing_extensions.Literal["_access", b"_access"]) -> typing_extensions.Literal["access"] | None: ...
@typing.overload

View File

@@ -299,8 +299,8 @@ def feature_to_pb2(f: frzf.Feature) -> capa_pb2.FeatureNode:
elif isinstance(f, frzf.PropertyFeature):
return capa_pb2.FeatureNode(
type="feature",
property=capa_pb2.PropertyFeature(
type=f.type, access=f.access, property=f.property, description=f.description
property_=capa_pb2.PropertyFeature(
type=f.type, access=f.access, property_=f.property, description=f.description
),
)