From c5a2b5b3d8d8e482942d1996806ab4b421495260 Mon Sep 17 00:00:00 2001
From: Jeremy Long
Note, if the evidence
- * is longer then 200 characters it will be truncated.
+ * Returns the text created by concatenating the text and the values from the EvidenceCollection (filtered for a specific
+ * confidence). This attempts to prevent duplicate terms from being added.
Note, if the evidence is longer then 200
+ * characters it will be truncated.
*
* @param text the base text.
* @param ec an EvidenceCollection
@@ -244,8 +243,8 @@ public class CPEAnalyzer implements Analyzer {
* version.
- * If either the vendorWeightings or productWeightings lists have been populated this data is used to add weighting - * factors to the search.
+ * If either the vendorWeightings or productWeightings lists have been populated this data is used to add weighting factors to + * the search. * * @param vendor the text used to search the vendor field * @param product the text used to search the product field @@ -270,13 +269,6 @@ public class CPEAnalyzer implements Analyzer { final IndexEntry entry = new IndexEntry(); entry.setVendor(doc.get(Fields.VENDOR)); entry.setProduct(doc.get(Fields.PRODUCT)); -// if (d.score < 0.08) { -// System.out.print(entry.getVendor()); -// System.out.print(":"); -// System.out.print(entry.getProduct()); -// System.out.print(":"); -// System.out.println(d.score); -// } entry.setSearchScore(d.score); if (!ret.contains(entry)) { ret.add(entry); @@ -301,8 +293,8 @@ public class CPEAnalyzer implements Analyzer { * Builds a Lucene search string by properly escaping data and constructing a valid search query. * *- * If either the possibleVendor or possibleProducts lists have been populated this data is used to add weighting - * factors to the search string generated.
+ * If either the possibleVendor or possibleProducts lists have been populated this data is used to add weighting factors to + * the search string generated. * * @param vendor text to search the vendor field * @param product text to search the product field @@ -328,9 +320,8 @@ public class CPEAnalyzer implements Analyzer { } /** - * This method constructs a Lucene query for a given field. The searchText is split into separate words and if the - * word is within the list of weighted words then an additional weighting is applied to the term as it is appended - * into the query. + * This method constructs a Lucene query for a given field. The searchText is split into separate words and if the word is + * within the list of weighted words then an additional weighting is applied to the term as it is appended into the query. * * @param sb a StringBuilder that the query text will be appended to. * @param field the field within the Lucene index that the query is searching. @@ -401,8 +392,8 @@ public class CPEAnalyzer implements Analyzer { } /** - * Ensures that the CPE Identified matches the dependency. This validates that the product, vendor, and version - * information for the CPE are contained within the dependencies evidence. + * Ensures that the CPE Identified matches the dependency. This validates that the product, vendor, and version information + * for the CPE are contained within the dependencies evidence. * * @param entry a CPE entry. * @param dependency the dependency that the CPE entries could be for. @@ -491,9 +482,9 @@ public class CPEAnalyzer implements Analyzer { } /** - * Retrieves a list of CPE values from the CveDB based on the vendor and product passed in. The list is then - * validated to find only CPEs that are valid for the given dependency. It is possible that the CPE identified is a - * best effort "guess" based on the vendor, product, and version information. + * Retrieves a list of CPE values from the CveDB based on the vendor and product passed in. The list is then validated to find + * only CPEs that are valid for the given dependency. It is possible that the CPE identified is a best effort "guess" based on + * the vendor, product, and version information. * * @param dependency the Dependency being analyzed * @param vendor the vendor for the CPE being analyzed @@ -601,8 +592,8 @@ public class CPEAnalyzer implements Analyzer { */ BEST_GUESS, /** - * The entire vendor/product group must be added (without a guess at version) because there is a CVE with a VS - * that only specifies vendor/product. + * The entire vendor/product group must be added (without a guess at version) because there is a CVE with a VS that only + * specifies vendor/product. */ BROAD_MATCH } @@ -750,8 +741,7 @@ public class CPEAnalyzer implements Analyzer { // /** - * Standard implementation of compareTo that compares identifier confidence, evidence confidence, and then the - * identifier. + * Standard implementation of compareTo that compares identifier confidence, evidence confidence, and then the identifier. * * @param o the IdentifierMatch to compare to * @return the natural ordering of IdentifierMatch