Skip to content

Commit

Permalink
pre-commit run black fix
Browse files Browse the repository at this point in the history
  • Loading branch information
harshit-wadhwani committed Oct 4, 2024
1 parent 14920a6 commit ca09cda
Showing 1 changed file with 13 additions and 39 deletions.
52 changes: 13 additions & 39 deletions capa/features/freeze/features.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,22 +27,16 @@ def to_capa(self) -> capa.features.common.Feature:
return capa.features.common.Arch(self.arch, description=self.description)

elif isinstance(self, FormatFeature):
return capa.features.common.Format(
self.format, description=self.description
)
return capa.features.common.Format(self.format, description=self.description)

elif isinstance(self, MatchFeature):
return capa.features.common.MatchedRule(
self.match, description=self.description
)
return capa.features.common.MatchedRule(self.match, description=self.description)

elif isinstance(
self,
CharacteristicFeature,
):
return capa.features.common.Characteristic(
self.characteristic, description=self.description
)
return capa.features.common.Characteristic(self.characteristic, description=self.description)

elif isinstance(self, ExportFeature):
return capa.features.file.Export(self.export, description=self.description)
Expand All @@ -51,35 +45,25 @@ def to_capa(self) -> capa.features.common.Feature:
return capa.features.file.Import(self.import_, description=self.description)

elif isinstance(self, SectionFeature):
return capa.features.file.Section(
self.section, description=self.description
)
return capa.features.file.Section(self.section, description=self.description)

elif isinstance(self, FunctionNameFeature):
return capa.features.file.FunctionName(
self.function_name, description=self.description
)
return capa.features.file.FunctionName(self.function_name, description=self.description)

elif isinstance(self, SubstringFeature):
return capa.features.common.Substring(
self.substring, description=self.description
)
return capa.features.common.Substring(self.substring, description=self.description)

elif isinstance(self, RegexFeature):
return capa.features.common.Regex(self.regex, description=self.description)

elif isinstance(self, StringFeature):
return capa.features.common.String(
self.string, description=self.description
)
return capa.features.common.String(self.string, description=self.description)

elif isinstance(self, ClassFeature):
return capa.features.common.Class(self.class_, description=self.description)

elif isinstance(self, NamespaceFeature):
return capa.features.common.Namespace(
self.namespace, description=self.description
)
return capa.features.common.Namespace(self.namespace, description=self.description)

elif isinstance(self, BasicBlockFeature):
return capa.features.basicblock.BasicBlock(description=self.description)
Expand All @@ -88,25 +72,19 @@ def to_capa(self) -> capa.features.common.Feature:
return capa.features.insn.API(self.api, description=self.description)

elif isinstance(self, PropertyFeature):
return capa.features.insn.Property(
self.property, access=self.access, description=self.description
)
return capa.features.insn.Property(self.property, access=self.access, description=self.description)

elif isinstance(self, NumberFeature):
return capa.features.insn.Number(self.number, description=self.description)

elif isinstance(self, BytesFeature):
return capa.features.common.Bytes(
binascii.unhexlify(self.bytes), description=self.description
)
return capa.features.common.Bytes(binascii.unhexlify(self.bytes), description=self.description)

elif isinstance(self, OffsetFeature):
return capa.features.insn.Offset(self.offset, description=self.description)

elif isinstance(self, MnemonicFeature):
return capa.features.insn.Mnemonic(
self.mnemonic, description=self.description
)
return capa.features.insn.Mnemonic(self.mnemonic, description=self.description)

elif isinstance(self, OperandNumberFeature):
return capa.features.insn.OperandNumber(
Expand Down Expand Up @@ -197,9 +175,7 @@ def feature_from_capa(f: capa.features.common.Feature) -> "Feature":

elif isinstance(f, capa.features.insn.Property):
assert isinstance(f.value, str)
return PropertyFeature(
property=f.value, access=f.access, description=f.description
)
return PropertyFeature(property=f.value, access=f.access, description=f.description)

elif isinstance(f, capa.features.insn.Number):
assert isinstance(f.value, (int, float))
Expand All @@ -208,9 +184,7 @@ def feature_from_capa(f: capa.features.common.Feature) -> "Feature":
elif isinstance(f, capa.features.common.Bytes):
buf = f.value
assert isinstance(buf, bytes)
return BytesFeature(
bytes=binascii.hexlify(buf).decode("ascii"), description=f.description
)
return BytesFeature(bytes=binascii.hexlify(buf).decode("ascii"), description=f.description)

elif isinstance(f, capa.features.insn.Offset):
assert isinstance(f.value, int)
Expand Down

0 comments on commit ca09cda

Please sign in to comment.