Skip to content

ida: address IDA 9.5 IDAPython DeprecationWarnings #3222

Open

Description

@mr-tz

IDA 9.5 emits DeprecationWarnings during tests/test_idalib_features.py (see https://github.com/mandiant/capa/actions/runs/41627670879):

  • capa/features/extractors/ida/helpers.py:107: getnseg() -> get_segment_info_by_num()
  • capa/features/extractors/ida/helpers.py:452: get_func_cmt() -> get_func_cmt_ea()
  • capa/features/extractors/ida/file.py:151: get_segm_name() -> get_segment_name()
  • capa/features/extractors/ida/file.py:183 (and other callers): get_func() -> get_func_start / get_func_entry_info()
  • capa/features/extractors/ida/insn.py:489: getseg() -> get_segment_info()
  • tests/fixtures/__init__.py:882: update_func() -> set_func_entry_info()

Since CI still supports IDA 9.2-9.4, replacements may require version shims where the new APIs are unavailable.

Activity

  1. Pratham21223 commented on Nov 5, 2026

    @Pratham21223

    Hi @mr-tz, I would like to work on this issue. I think we can have a fallback mechanism for functions in the newer version are not there in the older version.

    For example:

    if hasattr(idaapi, "get_segment_info_by_num"):
        # Use the newer API version (9.5+)
    else:
        # Fallback for older versions (CI versions)
  2. williballenthin commented on Nov 5, 2026

    @williballenthin
    Collaborator

    @Pratham21223

    we already have a pattern somewhat like this here:

    if hasattr(ida_bytes, "parse_binpat_str"):
    # TODO (mr): use find_bytes
    # https://github.com/mandiant/capa/issues/2339
    def find_byte_sequence(start: int, end: int, seq: bytes) -> Iterator[int]:
    """yield all ea of a given byte sequence
    args:
    start: min virtual address
    end: max virtual address
    seq: bytes to search e.g. b"\x01\x03"
    """
    patterns = ida_bytes.compiled_binpat_vec_t()
    seqstr = " ".join([f"{b:02x}" for b in seq])
    err = ida_bytes.parse_binpat_str(patterns, 0, seqstr, 16, IDA_NALT_ENCODING)
    if err:
    return
    while True:
    ea = ida_bytes.bin_search(start, end, patterns, ida_bytes.BIN_SEARCH_FORWARD)
    if isinstance(ea, int):
    # "ea_t" in IDA 8.4, 8.3
    pass
    elif isinstance(ea, tuple):
    # "drc_t" in IDA 9
    ea = ea[0]
    else:
    raise NotImplementedError(f"bin_search returned unhandled type: {type(ea)}")
    if ea == idaapi.BADADDR:
    break
    start = ea + 1
    yield ea
    else:
    # for IDA 7.5 and older; using deprecated find_binary instead of bin_search
    def find_byte_sequence(start: int, end: int, seq: bytes) -> Iterator[int]:
    """yield all ea of a given byte sequence
    args:
    start: min virtual address
    end: max virtual address
    seq: bytes to search e.g. b"\x01\x03"
    """
    seqstr = " ".join([f"{b:02x}" for b in seq])
    while True:
    ea = idaapi.find_binary(start, end, seqstr, 0, idaapi.SEARCH_DOWN)
    if ea == idaapi.BADADDR:
    break
    start = ea + 1
    yield ea

    note that we check a single time at the top level of the file and then define helpers based on whats available. please do not check for IDA features directly within the program's logic.

  3. williballenthin commented on Nov 5, 2026

    @williballenthin
    Collaborator

    alternatively we could migrate to the Domain API
    #2810

  4. Pratham21223 commented on Nov 5, 2026

    @Pratham21223

    Hi @williballenthin thanks for pinpoint me to the pr, I just now got the broader level understanding of Domain API integration obv I would be deep diving in! Would you prefer me contributing to Domain API migration rather than introducing individual compatibility shims?

  5. williballenthin commented on Nov 5, 2026

    @williballenthin
    Collaborator

    stick to fixing just the deprecation warnings for this PR. it's possible we take an alternative approach with the domain API, but it's not the plan right now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions