mirror of
https://github.com/ysoftdevs/DependencyCheck.git
synced 2026-03-22 00:59:34 +01:00
Put Fields first in class as requested by codacy/pr automated review
This commit is contained in:
@@ -35,23 +35,6 @@ import org.owasp.dependencycheck.dependency.Evidence;
|
|||||||
*/
|
*/
|
||||||
public class EvidenceMatcher {
|
public class EvidenceMatcher {
|
||||||
|
|
||||||
/**
|
|
||||||
* Creates a new EvidenceMatcher objects.
|
|
||||||
*
|
|
||||||
* @param source the source of the evidence, a source that is {@code null} indicates any source should match.
|
|
||||||
* @param name the non-{@code null} name of the evidence.
|
|
||||||
* @param value the non-{@code null} value of the evidence.
|
|
||||||
* @param regex whether value is a regex.
|
|
||||||
* @param confidence the confidence of the evidence, a confidence that is {@code null} indicates any confidence should match.
|
|
||||||
*/
|
|
||||||
public EvidenceMatcher(String source, String name, String value, boolean regex, Confidence confidence) {
|
|
||||||
this.source = source;
|
|
||||||
this.name = name;
|
|
||||||
this.value = value;
|
|
||||||
this.confidence = confidence;
|
|
||||||
this.regex = regex;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The name that the {@link Evidence} should have for a match.
|
* The name that the {@link Evidence} should have for a match.
|
||||||
*/
|
*/
|
||||||
@@ -81,6 +64,23 @@ public class EvidenceMatcher {
|
|||||||
*/
|
*/
|
||||||
private Confidence confidence;
|
private Confidence confidence;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new EvidenceMatcher objects.
|
||||||
|
*
|
||||||
|
* @param source the source of the evidence, a source that is {@code null} indicates any source should match.
|
||||||
|
* @param name the non-{@code null} name of the evidence.
|
||||||
|
* @param value the non-{@code null} value of the evidence.
|
||||||
|
* @param regex whether value is a regex.
|
||||||
|
* @param confidence the confidence of the evidence, a confidence that is {@code null} indicates any confidence should match.
|
||||||
|
*/
|
||||||
|
public EvidenceMatcher(String source, String name, String value, boolean regex, Confidence confidence) {
|
||||||
|
this.source = source;
|
||||||
|
this.name = name;
|
||||||
|
this.value = value;
|
||||||
|
this.confidence = confidence;
|
||||||
|
this.regex = regex;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests whether the given Evidence matches this EvidenceMatcher.
|
* Tests whether the given Evidence matches this EvidenceMatcher.
|
||||||
* @param evidence
|
* @param evidence
|
||||||
|
|||||||
@@ -34,6 +34,13 @@ public class EvidenceMatcherTest {
|
|||||||
private static final Evidence EVIDENCE_MEDIUM_SECOND_SOURCE = new Evidence("source 2", "name", "value", Confidence.MEDIUM);
|
private static final Evidence EVIDENCE_MEDIUM_SECOND_SOURCE = new Evidence("source 2", "name", "value", Confidence.MEDIUM);
|
||||||
private static final Evidence EVIDENCE_LOW = new Evidence("source", "name", "value", Confidence.LOW);
|
private static final Evidence EVIDENCE_LOW = new Evidence("source", "name", "value", Confidence.LOW);
|
||||||
|
|
||||||
|
private static final Evidence REGEX_EVIDENCE_HIGHEST = new Evidence("source", "name", "value 1", Confidence.HIGHEST);
|
||||||
|
private static final Evidence REGEX_EVIDENCE_HIGH = new Evidence("source", "name", "value 2", Confidence.HIGH);
|
||||||
|
private static final Evidence REGEX_EVIDENCE_MEDIUM = new Evidence("source", "name", "Value will not match because of case", Confidence.MEDIUM);
|
||||||
|
private static final Evidence REGEX_EVIDENCE_MEDIUM_SECOND_SOURCE = new Evidence("source 2", "name", "yet another value that will match", Confidence.MEDIUM);
|
||||||
|
private static final Evidence REGEX_EVIDENCE_MEDIUM_THIRD_SOURCE = new Evidence("source 3", "name", "and even more values to match", Confidence.MEDIUM);
|
||||||
|
private static final Evidence REGEX_EVIDENCE_LOW = new Evidence("source", "name", "val that should not match", Confidence.LOW);
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testExactMatching() throws Exception {
|
public void testExactMatching() throws Exception {
|
||||||
final EvidenceMatcher exactMatcherHighest = new EvidenceMatcher("source", "name", "value", false, Confidence.HIGHEST);
|
final EvidenceMatcher exactMatcherHighest = new EvidenceMatcher("source", "name", "value", false, Confidence.HIGHEST);
|
||||||
@@ -64,13 +71,6 @@ public class EvidenceMatcherTest {
|
|||||||
assertFalse("wildcard source matcher should not match EVIDENCE_LOW", wildcardSourceMatcher.matches(EVIDENCE_LOW));
|
assertFalse("wildcard source matcher should not match EVIDENCE_LOW", wildcardSourceMatcher.matches(EVIDENCE_LOW));
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final Evidence REGEX_EVIDENCE_HIGHEST = new Evidence("source", "name", "value 1", Confidence.HIGHEST);
|
|
||||||
private static final Evidence REGEX_EVIDENCE_HIGH = new Evidence("source", "name", "value 2", Confidence.HIGH);
|
|
||||||
private static final Evidence REGEX_EVIDENCE_MEDIUM = new Evidence("source", "name", "Value will not match because of case", Confidence.MEDIUM);
|
|
||||||
private static final Evidence REGEX_EVIDENCE_MEDIUM_SECOND_SOURCE = new Evidence("source 2", "name", "yet another value that will match", Confidence.MEDIUM);
|
|
||||||
private static final Evidence REGEX_EVIDENCE_MEDIUM_THIRD_SOURCE = new Evidence("source 3", "name", "and even more values to match", Confidence.MEDIUM);
|
|
||||||
private static final Evidence REGEX_EVIDENCE_LOW = new Evidence("source", "name", "val that should not match", Confidence.LOW);
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testRegExMatching() throws Exception {
|
public void testRegExMatching() throws Exception {
|
||||||
final EvidenceMatcher regexMediumMatcher = new EvidenceMatcher("source 2", "name", ".*value.*", true, Confidence.MEDIUM);
|
final EvidenceMatcher regexMediumMatcher = new EvidenceMatcher("source 2", "name", ".*value.*", true, Confidence.MEDIUM);
|
||||||
|
|||||||
Reference in New Issue
Block a user