| 1 | |
|
| 2 | |
|
| 3 | |
|
| 4 | |
|
| 5 | |
|
| 6 | |
|
| 7 | |
|
| 8 | |
|
| 9 | |
|
| 10 | |
|
| 11 | |
|
| 12 | |
|
| 13 | |
|
| 14 | |
|
| 15 | |
|
| 16 | |
|
| 17 | |
|
| 18 | |
package org.owasp.dependencycheck.analyzer; |
| 19 | |
|
| 20 | |
import java.util.ArrayList; |
| 21 | |
import java.util.Iterator; |
| 22 | |
import java.util.Set; |
| 23 | |
import org.owasp.dependencycheck.Engine; |
| 24 | |
import org.owasp.dependencycheck.dependency.Confidence; |
| 25 | |
import org.owasp.dependencycheck.dependency.Dependency; |
| 26 | |
import org.owasp.dependencycheck.dependency.Evidence; |
| 27 | |
|
| 28 | |
|
| 29 | |
|
| 30 | |
|
| 31 | |
|
| 32 | 7 | public class HintAnalyzer extends AbstractAnalyzer implements Analyzer { |
| 33 | |
|
| 34 | |
|
| 35 | |
|
| 36 | |
|
| 37 | |
|
| 38 | |
private static final String ANALYZER_NAME = "Hint Analyzer"; |
| 39 | |
|
| 40 | |
|
| 41 | |
|
| 42 | 1 | private static final AnalysisPhase ANALYSIS_PHASE = AnalysisPhase.PRE_IDENTIFIER_ANALYSIS; |
| 43 | |
|
| 44 | |
|
| 45 | |
|
| 46 | 1 | private static final Set<String> EXTENSIONS = null; |
| 47 | |
|
| 48 | |
|
| 49 | |
|
| 50 | |
|
| 51 | |
|
| 52 | |
|
| 53 | |
public Set<String> getSupportedExtensions() { |
| 54 | 132 | return EXTENSIONS; |
| 55 | |
} |
| 56 | |
|
| 57 | |
|
| 58 | |
|
| 59 | |
|
| 60 | |
|
| 61 | |
|
| 62 | |
public String getName() { |
| 63 | 9 | return ANALYZER_NAME; |
| 64 | |
} |
| 65 | |
|
| 66 | |
|
| 67 | |
|
| 68 | |
|
| 69 | |
|
| 70 | |
|
| 71 | |
|
| 72 | |
public boolean supportsExtension(String extension) { |
| 73 | 9 | return true; |
| 74 | |
} |
| 75 | |
|
| 76 | |
|
| 77 | |
|
| 78 | |
|
| 79 | |
|
| 80 | |
|
| 81 | |
public AnalysisPhase getAnalysisPhase() { |
| 82 | 6 | return ANALYSIS_PHASE; |
| 83 | |
} |
| 84 | |
|
| 85 | |
|
| 86 | |
|
| 87 | |
|
| 88 | |
|
| 89 | |
|
| 90 | |
|
| 91 | |
|
| 92 | |
|
| 93 | |
|
| 94 | |
@Override |
| 95 | |
public void analyze(Dependency dependency, Engine engine) throws AnalysisException { |
| 96 | 15 | final Evidence springTest1 = new Evidence("Manifest", |
| 97 | |
"Implementation-Title", |
| 98 | |
"Spring Framework", |
| 99 | |
Confidence.HIGH); |
| 100 | |
|
| 101 | 15 | final Evidence springTest2 = new Evidence("Manifest", |
| 102 | |
"Implementation-Title", |
| 103 | |
"org.springframework.core", |
| 104 | |
Confidence.HIGH); |
| 105 | |
|
| 106 | 15 | final Evidence springTest3 = new Evidence("Manifest", |
| 107 | |
"Bundle-Vendor", |
| 108 | |
"SpringSource", |
| 109 | |
Confidence.HIGH); |
| 110 | |
|
| 111 | 15 | Set<Evidence> evidence = dependency.getProductEvidence().getEvidence(); |
| 112 | 15 | if (evidence.contains(springTest1) || evidence.contains(springTest2)) { |
| 113 | 2 | dependency.getProductEvidence().addEvidence("hint analyzer", "product", "springsource_spring_framework", Confidence.HIGH); |
| 114 | 2 | dependency.getVendorEvidence().addEvidence("hint analyzer", "vendor", "SpringSource", Confidence.HIGH); |
| 115 | 2 | dependency.getVendorEvidence().addEvidence("hint analyzer", "vendor", "vmware", Confidence.HIGH); |
| 116 | |
} |
| 117 | |
|
| 118 | 15 | evidence = dependency.getVendorEvidence().getEvidence(); |
| 119 | 15 | if (evidence.contains(springTest3)) { |
| 120 | 2 | dependency.getProductEvidence().addEvidence("hint analyzer", "product", "springsource_spring_framework", Confidence.HIGH); |
| 121 | 2 | dependency.getVendorEvidence().addEvidence("hint analyzer", "vendor", "vmware", Confidence.HIGH); |
| 122 | |
} |
| 123 | 15 | final Iterator<Evidence> itr = dependency.getVendorEvidence().iterator(); |
| 124 | 15 | final ArrayList<Evidence> newEntries = new ArrayList<Evidence>(); |
| 125 | 121 | while (itr.hasNext()) { |
| 126 | 106 | final Evidence e = itr.next(); |
| 127 | 106 | if ("sun".equalsIgnoreCase(e.getValue(false))) { |
| 128 | 2 | final Evidence newEvidence = new Evidence(e.getSource() + " (hint)", e.getName(), "oracle", e.getConfidence()); |
| 129 | 2 | newEntries.add(newEvidence); |
| 130 | 2 | } else if ("oracle".equalsIgnoreCase(e.getValue(false))) { |
| 131 | 0 | final Evidence newEvidence = new Evidence(e.getSource() + " (hint)", e.getName(), "sun", e.getConfidence()); |
| 132 | 0 | newEntries.add(newEvidence); |
| 133 | |
} |
| 134 | 106 | } |
| 135 | 15 | for (Evidence e : newEntries) { |
| 136 | 2 | dependency.getVendorEvidence().addEvidence(e); |
| 137 | 2 | } |
| 138 | |
|
| 139 | 15 | } |
| 140 | |
} |