freeze: support float operand numbers in feature serialization#2958
freeze: support float operand numbers in feature serialization#2958blenbot wants to merge 3 commits intomandiant:masterfrom
Conversation
Signed-off-by: blenbot <harshitiszz23@gmail.com>
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request addresses a serialization bug in the Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request correctly extends support for floating-point values in OperandNumber features during serialization and deserialization. The changes align capa's freezing mechanism with the feature definition, which already supported both integers and floats. My review includes a minor suggestion to improve code consistency. It would also be beneficial to add a regression test for OperandNumber with a float value in test_serialize_features to prevent future regressions.
|
hm we should add a test case for a program that has a float as an operant. tbh i'm not sure how that looks or whether this even works. then we can use that example to drives fixes like this. would you be willing to do this @blenbot |
Seems fair, I will do that first @williballenthin |
Summary
While going through
capa/feature/freeze/features.pyI noticedOperandNumberbranch does an assertion which isassert isinstance(f.value, int)butcapa.features.insn.OperandNumberaccepts eitherint/floattype for it's value.This leads to serializing a valid feature such as
OperandNumber(0, 1.5)to fail.Changes
OperandNumberto acceptintorfloat.Checklist