H. S. Lee

15 papers A* 1C 1Misc 1Journal 6Unranked 6
YearRankTypeTitle / Venue / Authors
2024 conf
VLSI Technology and Circuits
K. S. Choi, S. H. Kim, J. W. Seo, H. S. Kang, Seung Wan Chu, S. W. Bae, J. H. Kwon, G. S. Kim, Y. T. Park, J. H. Kwak, D. I. Song, S. M. Park, Y. T. Kim, K. C. Jang, J. S. Cho, H. S. Lee, B. H. Lee, J. W. Park, J. H. Lee, H. H. Kwon, D. S. You, C. S. Hyun, J. J. Lee, S. C. Lee, I. D. Kim, J. H. Myung, H. S. Won, J. H. Chun, K. H. Kim, J. H. Kang, S. B. Kim, K. H. Lee, S. O. Chung, S. S. Kim, I. S. Jin, B. K. Lee, C. W. Kim, Joodong Park, S. Y. Cha
2017 conf
ICSAI
H. S. Lee, J. S. Won, K. S. Park, M. C. Shin, D. Y. Sun, S. Hur, E. J. Lee
2015 A* conf
ICRA
H. S. Lee, J. D. Jeon, Beom Hee Lee
2015 C conf
ETFA
H. S. Lee, Jung H. Oh, Beom Hee Lee
2005 J jnl
Environ. Model. Softw.
H. S. Lee, C. J. Matthews, Roger D. Braddock, Graham C. Sander, F. Gandola
2004 J jnl
Environ. Model. Softw.
H. S. Lee, C. J. Matthews, Roger D. Braddock, Graham C. Sander, F. Gandola
2002 J jnl
Comput. Aided Des.
R. I. Campbell, Massimo Martorelli, H. S. Lee
2002 conf
VTC Spring
H. K. Son, H. S. Lee
1999 J jnl
Int. J. Comput. Math.
H. S. Lee
1998 J jnl
Ann. Oper. Res.
H. S. Lee, A. Bouhchouch, Yves Dallery, Yannick Frein
1997 Misc conf
PDPTA
Sung-Ho Woo, H. S. Lee, Sung-Bong Yang, Tack-Don Han, Shin-Dug Kim
1995 J jnl
Speech Commun.
H. S. Lee, Ah Chung Tsoi
1991 conf
EUROSPEECH
Il K. Kim, H. S. Lee
1991 conf
IntCAD
John S. Gero, K. W. Tham, H. S. Lee
1991 conf
ISA
H. S. Lee, Ruei-Chuan Chang
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}"