Skip to content

id :: updates to magic#1432

Open
dev-mlb wants to merge 2 commits into
NationalSecurityAgency:mainfrom
dev-mlb:magic-number
Open

id :: updates to magic#1432
dev-mlb wants to merge 2 commits into
NationalSecurityAgency:mainfrom
dev-mlb:magic-number

Conversation

@dev-mlb

@dev-mlb dev-mlb commented Jun 13, 2026

Copy link
Copy Markdown
Collaborator

What changed?

Updated how the system reads and analyzes file data to make it more accurate and reliable. Previously, when the system encountered certain numbers, Java's internal logic would accidentally misread high values as negative numbers, which completely threw off "greater than" or "less than" math. The old code also struggled to read files correctly when the bytes were arranged backward.

@dev-mlb
dev-mlb marked this pull request as ready for review June 13, 2026 01:23
@dev-mlb dev-mlb changed the title id :: updates to MagicNumber id :: updates to magic Jun 13, 2026
@dev-mlb
dev-mlb force-pushed the magic-number branch 5 times, most recently from e4cd7f3 to 19e91f7 Compare June 16, 2026 13:03
@cfkoehler cfkoehler added this to the v8.47.0 milestone Jul 2, 2026

@fbruton fbruton left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Recommend adding a unit test to MagicNumberTest The fourth test assertion failed prior to the changes in this PR.

    @Test
    void testGreaterThanBeshort2() throws ParseException, DecoderException {
        // AB
        MagicNumber m = MagicNumberFactory.buildMagicNumber("0 beshort >0x0000 FOO");
        assertFalse(m.test(Hex.decodeHex("0000")), "Greater than magic operator failed");
        assertTrue(m.test(Hex.decodeHex("0001")), "Greater than magic operator failed");
        assertTrue(m.test(Hex.decodeHex("0101")), "Greater than magic operator failed");
        assertTrue(m.test(Hex.decodeHex("0100")), "Greater than magic operator failed");
    }

@fbruton

fbruton commented Jul 6, 2026

Copy link
Copy Markdown
Collaborator

Here is another unit test

    @Test
    void testOrBeshort() throws ParseException, DecoderException {
        MagicNumber m = MagicNumberFactory.buildMagicNumber("0 beshort x0x1010 FOO");
        assertFalse(m.test(Hex.decodeHex("0000")), "OR magic operator failed");
        assertFalse(m.test(Hex.decodeHex("0001")), "OR magic operator failed");
        assertFalse(m.test(Hex.decodeHex("1100")), "OR magic operator failed");
        assertFalse(m.test(Hex.decodeHex("0011")), "OR magic magic operator failed");
        assertFalse(m.test(Hex.decodeHex("1010")), "OR magic magic operator failed");
        assertTrue(m.test(Hex.decodeHex("0101")), "OR magic magic operator failed");
        assertTrue(m.test(Hex.decodeHex("1111")), "OR magic magic operator failed");
    }
    ```

@fbruton

fbruton commented Jul 6, 2026

Copy link
Copy Markdown
Collaborator

I created a branch fixing the mulit-byte OR bug. Please use a reference for anything you think is useful.
https://github.com/NationalSecurityAgency/emissary/tree/magic-long-short-fix

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants