Wei Zhang

28 papers C 2Journal 16Unranked 10
YearRankTypeTitle / Venue / Authors
2026 J jnl
IEEE Trans Autom. Sci. Eng.
Xucun Yan, Wei Zhang, Yiwen Jiao, Tao Wu, Guixin Li, Hong Ma, Hongbin Ma, You Cui, Zihuai Lin, Zhiyun Lin
2026 J jnl
Multim. Syst.
Kombou Victor, Qi Xia, Wei Zhang, Hu Xia, Jianbin Gao, Kuiche Sop Brinda Leaticia
2025 C conf
CSCWD
Qiufang Li, Wei Zhang, Jun Zhong, Qi Xia, Hu Xia, Isaac Amankona Obiri, Grace Mupoyi Ntuala, Jianbin Gao, Xinyu Lin
2025 conf
ICCIP
Ziji Guo, Danpu Liu, Zhilong Zhang, Guixin Li, Wei Zhang
2025 J jnl
ACM Trans. Multim. Comput. Commun. Appl.
Kombou Victor, Qi Xia, Hu Xia, Jianbin Gao, Wei Zhang, Eyezo'o Benjamin Fabien, Befoum Stephane Richard, Anto Leoba Jonathan, Kuiche Sop Brinda Leaticia
2023 conf
ICCEIC
Chao Li, Shiyuan Fu, Yiwen Jiao, Hongbin Ma, Wei Zhang, Chao Yun
2023 conf
ICAIT
Wei Zhang, Tao Wu, Hong Ma, Chao Li
2022 conf
ICSIM
Wei Zhang, Tao Wu, Hong Ma, Chao Li
2021 conf
ICIT
Wei Zhang, Chao Li, Tao Wu
2020 J jnl
IEEE Access
Bo Hu, Tao Wu, Yang Cai, Wei Zhang, Bao-Ling Zhang
2019 J jnl
Int. J. Distributed Sens. Networks
Wei Zhang, Hong Ma, Tao Wu, Xueshu Shi, Yiwen Jiao
2017 J jnl
Sensors
Feilong Li, Zhiqiang Li, Guangxia Li, Feihong Dong, Wei Zhang
2016 J jnl
J. Commun. Inf. Networks
Wei Zhang, Gengxin Zhang, Zhidong Xie, Dongming Bian, Yongqiang Li
2016 J jnl
J. Commun. Inf. Networks
Liang Gou, Gengxin Zhang, Wei Zhang, Dongming Bian
2016 J jnl
J. Commun. Networks
Liang Gou, Gengxin Zhang, Dongming Bian, Wei Zhang, Zhidong Xie
2016 J jnl
Int. J. Distributed Sens. Networks
Bo Kong, Gengxin Zhang, Wei Zhang, Dongming Bian, Zhidong Xie
2016 J jnl
KSII Trans. Internet Inf. Syst.
Bo Kong, Gengxin Zhang, Wei Zhang, Feihong Dong
2016 J jnl
Int. J. Distributed Sens. Networks
Bo Kong, Gengxin Zhang, Wei Zhang, Dongming Bian, Zhidong Xie
2016 conf
VTC Spring
Wei Zhang, Gengxin Zhang
2015 J jnl
KSII Trans. Internet Inf. Syst.
Wei Zhang, Gengxin Zhang, Liang Gou, Bo Kong, Dongming Bian
2015 J jnl
Int. J. Distributed Sens. Networks
Feihong Dong, Qinfei Huang, Hongjun Li, Bo Kong, Wei Zhang
2015 conf
WCSP
Wei Zhang, Dongming Bian, Zhidong Xie, Gengxin Zhang
2015 J jnl
Sensors
Wei Zhang, Gengxin Zhang, Feihong Dong, Zhidong Xie, Dongming Bian
2015 J jnl
Int. J. Distributed Sens. Networks
Wei Zhang, Gengxin Zhang, Liang Gou, Bo Kong, Dongming Bian
2015 conf
WCSP
Bo Kong, Zhidong Xie, Wei Zhang, Gengxin Zhang, Lei Cheng
2015 conf
WCSP
Feihong Dong, Quan Liu, Wei Zhang, Lei Guo, Xionglin Zhou
2013 C conf
ACC
Di Guo, Wei Zhang, Gangfeng Yan, Zhiyun Lin, Minyue Fu
2011 conf
WCSP
Wei Zhang, Gengxin Zhang
tests/unit/test_decompile_strings.py
← Index tests/unit/test_decompile_strings.py python
"""Unit tests for bninja/analysis/strings.py — StringAnalysis."""
import pytest
import math
from unittest.mock import MagicMock


# StringAnalysis has no binaryninja imports, just collections and math
from redb.extractors.decompiler.bninja.analysis.strings import StringAnalysis


# ============================================================================
# Helper mocks
# ============================================================================

class MockStringEntry:
    """Mock for a Binary Ninja string reference."""
    def __init__(self, value, raw=None, start=0, length=0, type_name="Utf8String"):
        self.value = value
        self.raw = raw if raw is not None else (value.encode("utf-8") if isinstance(value, str) else value)
        self.start = start
        self.length = length if length else len(self.raw)
        self.type = MagicMock()
        self.type.name = type_name


class MockBinaryView:
    """Mock binary view with a strings list."""
    def __init__(self, strings=None):
        self.strings = strings or []


# ============================================================================
# 6a. StringAnalysis
# ============================================================================


class TestStringAnalysisEntropy:
    def setup_method(self):
        self.sa = StringAnalysis(bv=MockBinaryView(), functions=[])

    def test_entropy_empty_string(self):
        assert self.sa.entropy("") == 0.0

    def test_entropy_single_char(self):
        assert self.sa.entropy("aaaa") == 0.0

    def test_entropy_uniform_distribution(self):
        # "abcd" -> 4 unique chars, each p=1/4, entropy = log2(4) = 2.0
        result = self.sa.entropy("abcd")
        assert result == pytest.approx(2.0)

    def test_entropy_binary_string(self):
        # "ab" -> 2 unique chars, each p=1/2, entropy = log2(2) = 1.0
        result = self.sa.entropy("ab")
        assert result == pytest.approx(1.0)


class TestStringAnalysisAnalyze:
    def test_analyze_deduplication(self):
        """Duplicate (string, encoding) pairs -> only first kept."""
        entries = [
            MockStringEntry("hello", start=100, type_name="Utf8String"),
            MockStringEntry("hello", start=200, type_name="Utf8String"),
        ]
        bv = MockBinaryView(strings=entries)
        sa = StringAnalysis(bv=bv, functions=[])
        result = sa.analyze()
        assert len(result) == 1
        assert result[0]["string_offset"] == 100

    def test_analyze_sorted_by_address(self):
        """First occurrence (lowest offset) is the one kept."""
        entries = [
            MockStringEntry("world", start=500, type_name="Utf8String"),
            MockStringEntry("world", start=100, type_name="Utf8String"),
        ]
        bv = MockBinaryView(strings=entries)
        sa = StringAnalysis(bv=bv, functions=[])
        result = sa.analyze()
        assert len(result) == 1
        # The analyze() sorts by start, so 100 comes first
        assert result[0]["string_offset"] == 100

    def test_analyze_empty_bv(self):
        bv = MockBinaryView(strings=[])
        sa = StringAnalysis(bv=bv, functions=[])
        result = sa.analyze()
        assert result == []

    def test_analyze_output_schema(self):
        entries = [MockStringEntry("test_string", start=0, type_name="Utf8String")]
        bv = MockBinaryView(strings=entries)
        sa = StringAnalysis(bv=bv, functions=[])
        result = sa.analyze()
        assert len(result) == 1
        r = result[0]
        required_keys = [
            "string",
            "string_raw",
            "string_encoding",
            "string_offset",
            "string_length",
            "string_raw_length",
            "string_entropy",
        ]
        for key in required_keys:
            assert key in r, f"Missing key: {key}"