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

Operation: Extract Hash Values #512

Merged
merged 11 commits into from Apr 2, 2024
Merged

Conversation

MShwed
Copy link
Contributor

@MShwed MShwed commented Mar 12, 2019

References #466

Adds operation for extracting hash values from text blocks. Searches text for hashes based on length.
Options for:

  • Searching for hashes of all lengths. Potential hash lengths taken from "Analyse Hashes" operation.
  • Displaying total hashes found.

Screen Shot 2019-03-11 at 20 01 24

If it makes more sense to select hash types by name from a dropdown rather than by character length, I can change that.

@a3957273
Copy link
Member

Hey, would you be able to resolve the conflicts and update this to the latest version of master? Would be good to get this merged in :)

@MShwed
Copy link
Contributor Author

MShwed commented Mar 31, 2024

No problem! I'll get that resolved

@a3957273
Copy link
Member

I'm loving the number of people who are still around 5 years later. Apologies it took so long to get to this!

const results = [];
let hashCount = 0;

const hashLength = args[0];
Copy link
Member

Choose a reason for hiding this comment

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

Nitpick: This can be shortened to:

const [hashLength, serachAllHashes, showDisplayTotal] = args

/**
* Extract Hash Values operation
*/
class ExtractHashes extends Operation {
Copy link
Member

Choose a reason for hiding this comment

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

Please could you add some unit tests. This would help ensure we are extracting the correct hashes in the future!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No problem! I've added some unit tests.

const regex = new RegExp(`(\\b|^)[a-f0-9]{${hashCharacterLength}}(\\b|$)`, "g");
const searchResults = search(input, regex, null, false);

hashCount += searchResults.split("\n").length - 1;
Copy link
Member

Choose a reason for hiding this comment

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

This area crashed for me when I tested it out. I've made some changes to hopefully resolve the issues I saw. Could you verify it works for you as well?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thank you! That works for me as well.

@MShwed MShwed requested a review from a3957273 April 2, 2024 02:46
@a3957273
Copy link
Member

a3957273 commented Apr 2, 2024

Looks great to me, thanks for continuing to contribute when you originally opened your PR over 5 years ago!

@a3957273 a3957273 merged commit 1d4c810 into gchq:master Apr 2, 2024
4 checks passed
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.

None yet

2 participants