add project URL evidence from pom

This commit is contained in:
bjiang
2016-04-15 11:28:33 -04:00
parent 739f595f13
commit 48af120db8
3 changed files with 32 additions and 2 deletions

View File

@@ -566,6 +566,11 @@ public class JarAnalyzer extends AbstractFileTypeAnalyzer {
addMatchingValues(classes, trimmedDescription, dependency.getProductEvidence()); addMatchingValues(classes, trimmedDescription, dependency.getProductEvidence());
} }
String projectURL = pom.getProjectURL();
if(projectURL != null && !projectURL.trim().isEmpty()) {
dependency.getVersionEvidence().addEvidence("pom", "url", projectURL, Confidence.HIGHEST);
}
extractLicense(pom, dependency); extractLicense(pom, dependency);
return foundSomething; return foundSomething;
} }

View File

@@ -261,6 +261,29 @@ public class Model {
licenses.add(license); licenses.add(license);
} }
/**
* The project URL.
*/
private String projectURL;
/**
* Get the value of projectURL.
*
* @return the value of projectURL
*/
public String getProjectURL() {
return projectURL;
}
/**
* Set the value of projectURL.
*
* @param parentVersion new value of projectURL
*/
public void setProjectURL(String projectURL) {
this.projectURL = projectURL;
}
/** /**
* Process the Maven properties file and interpolate all properties. * Process the Maven properties file and interpolate all properties.
* *
@@ -276,11 +299,11 @@ public class Model {
l.setUrl(interpolateString(l.getUrl(), properties)); l.setUrl(interpolateString(l.getUrl(), properties));
} }
this.name = interpolateString(this.name, properties); this.name = interpolateString(this.name, properties);
this.projectURL = interpolateString(this.projectURL, properties);
this.organization = interpolateString(this.organization, properties); this.organization = interpolateString(this.organization, properties);
this.parentGroupId = interpolateString(this.parentGroupId, properties); this.parentGroupId = interpolateString(this.parentGroupId, properties);
this.parentArtifactId = interpolateString(this.parentArtifactId, properties); this.parentArtifactId = interpolateString(this.parentArtifactId, properties);
this.parentVersion = interpolateString(this.parentVersion, properties); this.parentVersion = interpolateString(this.parentVersion, properties);
} }
/** /**
@@ -317,7 +340,7 @@ public class Model {
return substitutor.replace(text); return substitutor.replace(text);
} }
/** /**
* Utility class that can provide values from a Properties object to a StrSubstitutor. * Utility class that can provide values from a Properties object to a StrSubstitutor.
*/ */
private static class PropertyLookup extends StrLookup { private static class PropertyLookup extends StrLookup {

View File

@@ -145,6 +145,8 @@ public class PomHandler extends DefaultHandler {
model.setOrganization(currentText.toString()); model.setOrganization(currentText.toString());
} else if (DESCRIPTION.equals(qName)) { } else if (DESCRIPTION.equals(qName)) {
model.setDescription(currentText.toString()); model.setDescription(currentText.toString());
} else if (URL.equals(qName)) {
model.setProjectURL(currentText.toString());
} }
} else if (PARENT.equals(parentNode)) { } else if (PARENT.equals(parentNode)) {
if (GROUPID.equals(qName)) { if (GROUPID.equals(qName)) {