Skip to content
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

Sha256 value for each matched file #156

Merged
merged 10 commits into from
May 11, 2020
Merged

Sha256 value for each matched file #156

merged 10 commits into from
May 11, 2020

Conversation

KWMORALE
Copy link
Member

@KWMORALE KWMORALE commented May 7, 2020

Your checklist for this pull request

  • I've read the contributing guideline.
  • I've tested my changes by building and running mquery, and testing changed functionality (if applicable)

What is the new behaviour?
Show sha256 hash along with matched samples.
Sha256 is calculated in daemon by external function for each sample file and then it is sent via metadata.

Closing issues
#34

src/daemon.py Outdated
Comment on lines 153 to 156
try:
metadata.update(set_sha(file_path))
except Exception:
logging.exception("Failed to set hash for %s", file_path)
Copy link
Contributor

Choose a reason for hiding this comment

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

Errors here are pretty severe and there's no good way to handle it - I'd just let this exception bubble up and fail.

Suggested change
try:
metadata.update(set_sha(file_path))
except Exception:
logging.exception("Failed to set hash for %s", file_path)
metadata.update(set_sha(file_path))

Thoughts?

<span className="badge badge-pill badge-warning">
{v.display_text}
</span>
{!v.hidden && (
Copy link
Contributor

Choose a reason for hiding this comment

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

if the element is hidden, you should hide the whole tag (so including a href above)

Copy link
Contributor

Choose a reason for hiding this comment

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

(or actually you should just filter it before the .map() )

</a>
));

const hashes = Object.values(props.meta).map((v) => (
<span>
Copy link
Contributor

Choose a reason for hiding this comment

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

unnecessary span I think?

</a>
));

const hashes = Object.values(props.meta).map((v) => (
<span>
{v.hidden && (
Copy link
Contributor

Choose a reason for hiding this comment

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

instead of relying on hidden, find v with key equal to sha256

@@ -206,6 +219,7 @@ class QueryResultsStatus extends Component {
<thead>
<tr>
<th>Matches</th>
<th style={{ width: "32%" }}>SHA256</th>
Copy link
Contributor

Choose a reason for hiding this comment

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

weirdly specific

Use bootstrap classes (probably something like col-md-4). Bootstrap grid system will probably also allow to automatically hide/flow the columns on resize

src/setsha.py Outdated
@@ -0,0 +1,13 @@
import hashlib

def set_sha(filename):
Copy link
Contributor

Choose a reason for hiding this comment

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

add type annotations

@KWMORALE KWMORALE changed the title WIP: Sha256 value for each matched file Sha256 value for each matched file May 8, 2020
@KWMORALE KWMORALE marked this pull request as ready for review May 8, 2020 14:41
@KWMORALE KWMORALE requested review from psrok1 and msm-code May 8, 2020 14:41
@KWMORALE
Copy link
Member Author

KWMORALE commented May 8, 2020

image

few changes regarding display:

  1. tags are displayed in the next row instead of shortening the sample name.
  2. column with sha 256 hashes has been added, where after clicking on the hash it is copied to the clipboard.
  3. the hash column is hidden when the page resolution is reduced and in the editor view

@KWMORALE
Copy link
Member Author

Closing issue: #16
if we consider sha256 instead of sha1

@msm-code
Copy link
Contributor

Not really closing #16, because this feature won't work after removing physical samples after indexing. To do this we'd have to keep the hashes in ursadb somehow

@msm-code msm-code merged commit 6b8b7d5 into master May 11, 2020
@msm-code msm-code deleted the feature/sha branch May 11, 2020 19:36
@msm-code msm-code linked an issue May 14, 2020 that may be closed by this pull request
KWMORALE added a commit to KWMORALE/mquery that referenced this pull request Jul 29, 2020
* Display hash value for each matched file

* View improvments

* Add copy to clipboard for sha256

* Update daemon.py remove unused import

* Update QueryResultsStatus.js

* Fix web serwer console warnings

* Update repo to current master and add hashes filter behind map function

* prettier QueryStatus

* Small UI changes

Co-authored-by: msm <[email protected]>
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.

Add a Copy button for for all hashes, and for each single hash
2 participants