Rania Mzid

29 papers B 4C 2Journal 12Unranked 10
YearRankTypeTitle / Venue / Authors
2026 J jnl
Inf. Softw. Technol.
Syrine Wardi, Rania Mzid, Tewfik Ziadi
2025 J jnl
J. Supercomput.
Bakhta Haouari, Rania Mzid, Olfa Mosbahi
2025 J jnl
Innov. Syst. Softw. Eng.
Rania Mzid, Mohamed Abid
2025 J jnl
Clust. Comput.
Rania Mzid, Bakhta Haouari, Olfa Mosbahi
2024 B conf
ECSA
Rania Mzid, Ilyes Rezgui, Tewfik Ziadi
2024 J jnl
J. Supercomput.
Rania Mzid
2024 B conf
ENASE
Bakhta Haouari, Rania Mzid, Olfa Mosbahi
2024 J jnl
SN Comput. Sci.
Rania Mzid, Sonia Selvi, Mohamed Abid
2023 J jnl
Neural Comput. Appl.
Bakhta Haouari, Rania Mzid, Olfa Mosbahi
2023 C conf
SEKE
Bakhta Haouari, Rania Mzid, Olfa Mosbahi
2022 conf
ISDA (3)
Rahma Lassoued, Rania Mzid
2022 conf
ISDA (3)
Bakhta Haouari, Rania Mzid, Olfa Mosbahi
2022 C conf
MODELSWARD
Rania Mzid, Asma Charfi, Nejmeddine Etteyeb
2020 J jnl
Inf. Sci.
Wafa Lakhdhar, Rania Mzid, Mohamed Khalgui, Georg Frey, ZhiWu Li, MengChu Zhou
2019 J jnl
Int. J. Embed. Syst.
Rania Mzid, Chokri Mraidha, Jean-Philippe Babau, Mohamed Abid
2019 J jnl
IEEE Trans. Syst. Man Cybern. Syst.
Wafa Lakhdhar, Rania Mzid, Mohamed Khalgui, ZhiWu Li, Georg Frey, Abdulrahman Al-Ahmari
2018 B conf
ENASE
Wafa Lakhdhar, Rania Mzid, Mohamed Khalgui, Georg Frey
2018 conf
ENASE (Selected Papers)
Wafa Lakhdhar, Rania Mzid, Mohamed Khalgui, Georg Frey
2016 conf
ICSOFT (Selected Papers)
Wafa Lakhdhar, Rania Mzid, Mohamed Khalgui, Nicolas Trèves
2016 conf
ICSOFT-EA
Wafa Lakhdhar, Rania Mzid, Mohamed Khalgui, Nicolas Trèves
2016 conf
IDT
Rania Mzid, Mohamed Abid
2014 J jnl
J. Softw.
Rania Mzid, Chokri Mraidha, Jean-Philippe Babau, Mohamed Abid
2014
Rania Mzid
2014 conf
QoSA
Rania Mzid, Chokri Mraidha, Jean-Philippe Babau, Mohamed Abid
2013 B conf
ECMFA
Rania Mzid, Chokri Mraidha, Asma Mehiaoui, Sara Tucci Piergiovanni, Jean-Philippe Babau, Mohamed Abid
2012 conf
EUROMICRO-SEAA
Rania Mzid, Chokri Mraidha, Jean-Philippe Babau, Mohamed Abid
2012 conf
ACES-MB@MoDELS
Rania Mzid, Chokri Mraidha, Jean-Philippe Babau, Mohamed Abid
2011 J jnl
J. Commun.
Manel Boujelben, Habib Youssef, Rania Mzid, Mohamed Abid
2010 conf
ICWUS
Rania Mzid, Manel Boujelben, Habib Youssef, Mohamed Abid
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}"