-
Notifications
You must be signed in to change notification settings - Fork 152
Resource Tree Bytes and Strings Search Bar #334
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
dannyp303
wants to merge
32
commits into
redballoonsecurity:master
from
dannyp303:feature/search-bar
Closed
Changes from all commits
Commits
Show all changes
32 commits
Select commit
Hold shift + click to select a range
de95979
Add search bar with request
0195377
Filter works, erronious lines in tree
d07d52d
Remove extra lines
04b3107
Force bytes input to be valid with spaces
e57f46e
Hook bytes request up to front end
a3c837b
Didn't commit try catch in bytes validation
2f2751c
Prevent bad bytes format from displaying if entered before valid
7feb457
semicolon
c00331a
Merge branch 'master' of github.com:dannyp303/ofrak into feature/sear…
1b702d3
Update to new search API
dfe9eb6
Use POST and but search query in body
7a33d53
Regex works with checkbox among other things
6b292f5
live update search
257f1e3
Add case insensitivity option
a7b34a1
Add tests for search
30f43b1
Some fortmatting stuff
dba7a5d
Update frontend/src/ResourceSearchBar.svelte
dannyp303 2ec9917
update tests to test good and back conditions
84c0602
removed dead code
8e16f33
Do input placeholder css properly
5e6d180
lint
d077ea8
Move empty search check up
92f7690
Catch exceptions in search bar
25b7db1
Update ofrak_core/ofrak/gui/server.py
dannyp303 1a8ebc7
Update ofrak_core/ofrak/gui/server.py
dannyp303 d9f1d14
Remove live update
44edba2
remove dummy filter variable
14133d2
Skip backend request for empty search
366ef43
Why is no one else seeing this?
32ff28a
Use re.escape for no-regex + case ignore
51dfa0f
make mypy smile
bf17c9c
Fix the case ignore and tests
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,137 @@ | ||
| <style> | ||
| select { | ||
| background-color: var(--main-bg-color); | ||
| color: inherit; | ||
| border: 1px solid; | ||
| border-color: inherit; | ||
| border-radius: 0; | ||
| font-size: inherit; | ||
| font-family: var(--font); | ||
| box-shadow: none; | ||
| } | ||
|
|
||
| input { | ||
| background: inherit; | ||
| color: inherit; | ||
| border: 1px solid; | ||
| border-bottom: 1px solid var(--main-fg-color); | ||
| flex: 1; | ||
| text-indent: 0.5em; | ||
| } | ||
|
|
||
| form { | ||
| display: inherit; | ||
| flex: 1; | ||
| } | ||
|
|
||
| label { | ||
| display: inherit; | ||
| flex: 1; | ||
| } | ||
|
|
||
| .searchbar { | ||
| display: flex; | ||
| align-items: left; | ||
| width: 100%; | ||
| flex-grow: 1; | ||
| height: 2em; | ||
| } | ||
|
|
||
| .optionbar { | ||
| padding-bottom: 0; | ||
| padding-top: 0; | ||
| } | ||
| </style> | ||
|
|
||
| <script> | ||
| import Checkbox from "./Checkbox.svelte"; | ||
| export let rootResource, searchFilter; | ||
| let searchType, | ||
| searchQuery, | ||
| bytesInput, | ||
| regex, | ||
| placeholderString, | ||
| caseIgnore, | ||
| errorMessage; | ||
| let searchTypes = ["String", "Bytes"]; | ||
|
|
||
| $: if (searchQuery && searchType === "Bytes") { | ||
| try { | ||
| searchQuery = searchQuery.match(/[0-9a-fA-F]{1,2}/g).join(" "); | ||
| bytesInput?.setCustomValidity(""); | ||
| } catch { | ||
| searchQuery = ""; | ||
| bytesInput?.setCustomValidity("Invalid bytes representation."); | ||
| } | ||
| } | ||
|
|
||
| $: if (searchType == "String") { | ||
| if (regex) { | ||
| placeholderString = "Search for a Regex Pattern"; | ||
| } else { | ||
| placeholderString = "Search for a String"; | ||
| } | ||
| } else if (searchType == "Bytes") { | ||
| regex = false; // Regex for bytes not yet implemented | ||
| placeholderString = "Search for Bytes"; | ||
| } | ||
| </script> | ||
|
|
||
| <div class="searchbar"> | ||
| <select bind:value="{searchType}"> | ||
| {#each searchTypes as type} | ||
| <option value="{type}"> | ||
| {type} | ||
| </option> | ||
| {/each} | ||
| </select> | ||
| <form | ||
| on:submit|preventDefault="{async (e) => { | ||
| try { | ||
| if (searchType == 'String') { | ||
| if (searchQuery === '') { | ||
| searchFilter = null; | ||
| } else { | ||
| searchFilter = await rootResource.search_for_string( | ||
| searchQuery, | ||
| regex, | ||
| caseIgnore | ||
| ); | ||
| } | ||
| } else if (searchType == 'Bytes') { | ||
| if (searchQuery === '') { | ||
| searchFilter = null; | ||
| } else { | ||
| searchFilter = await rootResource.search_for_bytes( | ||
| searchQuery, | ||
| false | ||
| ); | ||
| } | ||
| } | ||
| } catch (err) { | ||
| try { | ||
| errorMessage = JSON.parse(err.message).message; | ||
| } catch (_) { | ||
| errorMessage = err.message; | ||
| } | ||
| console.log('Search Failed!'); | ||
| console.log(errorMessage); | ||
| } | ||
| }}" | ||
| > | ||
| <label> | ||
| <input placeholder="{placeholderString}" bind:value="{searchQuery}" /> | ||
| </label> | ||
| </form> | ||
| </div> | ||
|
|
||
| <div class="optionbar"> | ||
| {#if searchType == "String"} | ||
| <Checkbox checked="{false}" bind:value="{regex}" leftbox="{true}"> | ||
| Pattern | ||
| </Checkbox> | ||
| <Checkbox checked="{false}" bind:value="{caseIgnore}" leftbox="{true}"> | ||
| Ignore Case | ||
| </Checkbox> | ||
| {/if} | ||
| </div> | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.