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

Magic Overhaul #966

Merged
merged 10 commits into from
Mar 24, 2020
Merged

Magic Overhaul #966

merged 10 commits into from
Mar 24, 2020

Conversation

n1073645
Copy link
Contributor

An overhaul of the magic operation.

It's to extend the functionality of Magic by adding the following to each operation, where appropriate:

- More input criteria.
- More output criteria.
- Entropy of the input data and output data.
- Some mime-checking of operations that return files.
- Then some extra ones that don't fit into any of the above.

@n1073645 n1073645 changed the title New magic Magic Overhaul Feb 26, 2020
@n1073645 n1073645 added the WIP label Feb 26, 2020
@@ -26,7 +26,7 @@ export function ipv4CidrRange(cidr, includeNetworkInfo, enumerateAddresses, allo
let output = "";

if (cidrRange < 0 || cidrRange > 31) {
return "IPv4 CIDR must be less than 32";
throw new OperationError("IPv4 CIDR must be less than 32");
Copy link
Member

@d98762625 d98762625 Mar 3, 2020

Choose a reason for hiding this comment

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

You've changed the return behaviour of this function, please update the function doc comment to reflect this. (I know this is WIP)

*/
checkOutputFromPrevious() {
let score = 0;
if ("regex" in this.prevOp.output) {
Copy link
Member

Choose a reason for hiding this comment

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

This in operator usage looks way cleaner than the Object.prototype.hasOwnProperty.call(object, key) call. Please just do a mental check each time you use it to make sure you won't be hitting on something up the object's prototype chain. See inherited properties here for more info. (I can't see any bad uses here)

@n1474335
Copy link
Member

Currently reviewing this and making some changes. Don't push any more updates.

@n1474335 n1474335 merged commit 26fa66e into gchq:master Mar 24, 2020
@n1474335
Copy link
Member

Really good stuff @n1073645. I made some changes to improve performance, simplify markup and get better test coverage. Take a look here: b765534

Very happy that we can detect deflated data without any headers - that's a nice addition.

@n1073645 n1073645 deleted the newMagic branch October 29, 2021 09:46
This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants