Skip to content

Feature: GUI hex search#336

Closed
EdwardLarson wants to merge 22 commits into
redballoonsecurity:masterfrom
EdwardLarson:feature/gui_hex_search
Closed

Feature: GUI hex search#336
EdwardLarson wants to merge 22 commits into
redballoonsecurity:masterfrom
EdwardLarson:feature/gui_hex_search

Conversation

@EdwardLarson
Copy link
Copy Markdown
Contributor

@EdwardLarson EdwardLarson commented Jun 26, 2023

One sentence summary of this PR (This should go in the CHANGELOG!)
Add searchbar to HexView in order to search for a string or bytes within a resource.

Link to Related Issue(s)

Please describe the changes in your request.

Anyone you think should look at this, specifically?
@rbs-jacob
@dannyp303

@EdwardLarson EdwardLarson requested a review from rbs-jacob June 27, 2023 21:41
Copy link
Copy Markdown
Member

@rbs-jacob rbs-jacob left a comment

Choose a reason for hiding this comment

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

Requested changes.

I just reviewed by looking over stuff. I figure I'll actually run it, and probably make some CSS adjustments, after this first round of changes goes in. That way we don't spend time changing CSS when functionality will change, possibly rendering the CSS work obsolete.

Comment thread frontend/src/HexByte.svelte Outdated
Comment thread frontend/src/HexByte.svelte Outdated
Comment thread frontend/src/HexView.svelte Outdated
Comment thread frontend/src/HexView.svelte Outdated
Comment thread frontend/src/HexView.svelte Outdated
Comment thread ofrak_core/ofrak/service/data_service.py
Comment thread ofrak_core/ofrak/service/data_service_i.py Outdated
Comment thread ofrak_core/ofrak/service/data_service.py Outdated
Comment thread ofrak_core/ofrak/core/strings.py Outdated
Comment thread frontend/src/ResourceSearchBar.svelte Outdated
Copy link
Copy Markdown
Member

@rbs-jacob rbs-jacob left a comment

Choose a reason for hiding this comment

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

Actually ran it this time. Found a few small bugs/issues in terms of UI behavior, and made some CSS change recommendations. In the interest of learning, I did not commit them directly to the branch, but tried to break them out into PR comments that explain and justify.

Comment thread frontend/src/ResourceSearchBar.svelte
Comment thread frontend/src/ResourceSearchBar.svelte
Comment thread frontend/src/ResourceSearchBar.svelte
Comment on lines +31 to +38
.searchbar {
display: flex;
align-items: left;
flex-grow: 1;
height: 2em;
position: sticky;
padding-bottom: 1em;
}
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
.searchbar {
display: flex;
align-items: left;
flex-grow: 1;
height: 2em;
position: sticky;
padding-bottom: 1em;
}
.searchbar {
display: flex;
flex-direction: row;
flex-wrap: nowrap;
justify-content: flex-start;
align-items: stretch;
align-content: center;
height: 2em;
margin-bottom: 1em;
}

Comment thread frontend/src/ResourceSearchBar.svelte
Comment thread frontend/src/ResourceSearchBar.svelte
Comment thread frontend/src/ResourceSearchBar.svelte
Comment on lines +72 to +86
function nextMatch() {
let nextIndex = searchResults.index + 1;
if (nextIndex >= searchResults.matches.length) {
nextIndex = 0;
}
searchResults = { matches: searchResults.matches, index: nextIndex };
}

function prevMatch() {
let nextIndex = searchResults.index - 1;
if (nextIndex < 0) {
nextIndex = Math.max(searchResults.matches.length - 1, 0);
}
searchResults = { matches: searchResults.matches, index: nextIndex };
}
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

There is a bug with these functions where it jumps one line above a location first, before jumping to the location on the second click.

Seems to be an issue exclusively when there is only one result found.

Screen.Recording.2023-06-30.at.4.46.10.PM.mov

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

It's not just if there is only result found, the result has to be exactly at the start of a row. Honestly this sort of off-by-one error seems like it will take more time to fix than it's worth. The search bar still jumps basically to the match, so to the user experience is barely impacted. But this is definitely not intended behavior.

Comment thread frontend/src/ResourceSearchBar.svelte
Comment on lines +72 to +86
function nextMatch() {
let nextIndex = searchResults.index + 1;
if (nextIndex >= searchResults.matches.length) {
nextIndex = 0;
}
searchResults = { matches: searchResults.matches, index: nextIndex };
}

function prevMatch() {
let nextIndex = searchResults.index - 1;
if (nextIndex < 0) {
nextIndex = Math.max(searchResults.matches.length - 1, 0);
}
searchResults = { matches: searchResults.matches, index: nextIndex };
}
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Another strange characteristic is the way that multiple contiguous regions can be matched multiple times. Personally, I think this behavior should be considered a bug. Even if it's intended, it's unintuitive for the user what's going on.

Maybe the particular instance of the found string that corresponds to the latest find should be highlighted in a different color? Kind of how Ctrl+f in the browser will highlight all the instances it's found, but highlight the current one in a different color.

Screen.Recording.2023-06-30.at.4.59.40.PM.mov

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I did a simple implementation to try to address this, just underlining the bytes if the range they match (from the binary search) is the same index as the selected range. It sort of works, but doesn't work well for exactly the case being raised here: Multiple matching ranges overlapping, since not all of the bytes in the currently selected range are highlighted. I would guess that the binary search finds one of the overlapping ranges instead, not prioritizing the selected one.

So I think it would actually considerably complicate the logic, unless you see another simple way to try it. I think we should leave this as future work.

@EdwardLarson EdwardLarson mentioned this pull request Jul 3, 2023
1 task
@EdwardLarson
Copy link
Copy Markdown
Contributor Author

Folded into #345

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.

4 participants