Github user alopresto commented on a diff in the pull request:

    https://github.com/apache/nifi/pull/1692#discussion_r113585054
  
    --- Diff: 
nifi-nar-bundles/nifi-cybersecurity-bundle/nifi-cybersecurity-processors/src/main/java/org/apache/nifi/processors/cybersecurity/CompareFuzzyHash.java
 ---
    @@ -183,38 +181,24 @@ public void onTrigger(ProcessContext context, 
ProcessSession session) throws Pro
                 return;
             }
     
    -        Digest inputDigest = null;
    -        SpamSum spamSum = null;
    +        FuzzyHashMatcher fuzzyHashMatcher = null;
     
             switch (algorithm) {
                 case tlsh:
    -                // In case we are using TLSH, makes sense to create the 
source Digest just once
    -                inputDigest = compareStringToTLSHDigest(inputHash);
    -                // we test the validation for null (failed)
    -                if (inputDigest == null) {
    -                    // and if that is the case we log
    -                    logger.error("Invalid hash provided. Sending to 
failure");
    -                    //  and send to failure
    -                    session.transfer(flowFile, REL_FAILURE);
    -                    session.commit();
    -                    return;
    -                }
    +                fuzzyHashMatcher = new TLSHHashMatcher(getLogger());
                     break;
                 case ssdeep:
    -                // However, in SSDEEP, the compare function uses the two 
desired strings.
    -                // So we try a poor man validation (the SpamSum comparison 
function seems to
    -                // be resilient enough but we still want to route to 
failure in case it
    -                // clearly bogus data
    -                if (looksLikeSpamSum(inputHash) == true) {
    -                    spamSum = new SpamSum();
    -                } else {
    -                    // and if that is the case we log
    -                    logger.error("Invalid hash provided. Sending to 
failure");
    -                    //  and send to failure
    -                    session.transfer(flowFile, REL_FAILURE);
    -                    session.commit();
    -                    return;
    -                }
    +                fuzzyHashMatcher = new SSDeepHashMatcher(getLogger());
    +                break;
    +        }
    --- End diff --
    
    I think there should be a `default` case to handle no `algorithm` provided. 


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

Reply via email to