/** * Adds a value to the evidence collection. * * @param dependency the dependency being analyzed * @param type the type of evidence to add * @param confidence the confidence in the evidence being added * @param headers the properties collection * @param property the property name */ private static void addPropertyToEvidence(Dependency dependency, EvidenceType type, Confidence confidence, InternetHeaders headers, String property) { final String value = headers.getHeader(property, null); LOGGER.debug("Property: {}, Value: {}", property, value); if (StringUtils.isNotBlank(value)) { dependency.addEvidence(type, METADATA, property, value, confidence); } }
/** * Gathers evidence from the METADATA file. * * @param dependency the dependency being analyzed * @param file a reference to the manifest/properties file */ private static void collectWheelMetadata(Dependency dependency, File file) { final InternetHeaders headers = getManifestProperties(file); addPropertyToEvidence(dependency, EvidenceType.VERSION, Confidence.HIGHEST, headers, "Version"); addPropertyToEvidence(dependency, EvidenceType.PRODUCT, Confidence.HIGHEST, headers, "Name"); addPropertyToEvidence(dependency, EvidenceType.PRODUCT, Confidence.MEDIUM, headers, "Name"); final String name = headers.getHeader("Name", null); final String version = headers.getHeader("Version", null); final String packagePath = String.format("%s:%s", name, version); dependency.setName(name); dependency.setVersion(version); dependency.setPackagePath(packagePath); dependency.setDisplayFileName(packagePath); final String url = headers.getHeader("Home-page", null); if (StringUtils.isNotBlank(url)) { if (UrlStringUtils.isUrl(url)) { dependency.addEvidence(EvidenceType.VENDOR, METADATA, "vendor", url, Confidence.MEDIUM); } } addPropertyToEvidence(dependency, EvidenceType.VENDOR, Confidence.LOW, headers, "Author"); final String summary = headers.getHeader("Summary", null); if (StringUtils.isNotBlank(summary)) { JarAnalyzer.addDescription(dependency, summary, METADATA, "summary"); } }
/** * Get all the headers for this header_name. Note that certain * headers may be encoded as per RFC 2047 if they contain * non US-ASCII characters and these should be decoded. * * @param name name of header * @return array of headers * @see javax.mail.internet.MimeUtility */ public String[] getHeader(String name) throws MessagingException { return headers.getHeader(name); }
/** * Get all the headers for this header_name. Note that certain * headers may be encoded as per RFC 2047 if they contain * non US-ASCII characters and these should be decoded. * * @param name name of header * @return array of headers * @see javax.mail.internet.MimeUtility */ @Override public String[] getHeader(String name) throws MessagingException { return headers.getHeader(name); }
/** * Get all the headers for this header name, returned as a single * String, with headers separated by the delimiter. If the * delimiter is <code>null</code>, only the first header is * returned. * * @param name the name of this header * @param delimiter separator between values * @return the value fields for all headers with * this name * @exception MessagingException for failures */ public String getHeader(String name, String delimiter) throws MessagingException { return headers.getHeader(name, delimiter); }
/** * Get all the headers for this header name, returned as a single * String, with headers separated by the delimiter. If the * delimiter is <code>null</code>, only the first header is * returned. * * @param name the name of this header * @param delimiter delimiter between fields in returned string * @return the value fields for all headers with * this name * @exception MessagingException for failures */ public String getHeader(String name, String delimiter) throws MessagingException { return headers.getHeader(name, delimiter); }
/** * Get all the headers for this header name, returned as a single * String, with headers separated by the delimiter. If the * delimiter is <code>null</code>, only the first header is * returned. * * @param name the name of this header * @param delimiter delimiter between fields in returned string * @return the value fields for all headers with * this name * @exception MessagingException for failures */ @Override public String getHeader(String name, String delimiter) throws MessagingException { return headers.getHeader(name, delimiter); }
/** * Get all the headers for this header name, returned as a single * String, with headers separated by the delimiter. If the * delimiter is <code>null</code>, only the first header is * returned. * * @param name the name of this header * @param delimiter separator between values * @return the value fields for all headers with * this name * @exception MessagingException for failures */ @Override public String getHeader(String name, String delimiter) throws MessagingException { return headers.getHeader(name, delimiter); }
/** * Get all the headers for this header_name. Note that certain * headers may be encoded as per RFC 2047 if they contain * non US-ASCII characters and these should be decoded. <p> * * This implementation obtains the headers from the * <code>headers</code> InternetHeaders object. * * @param name name of header * @return array of headers * @exception MessagingException for failures * @see javax.mail.internet.MimeUtility */ public String[] getHeader(String name) throws MessagingException { return headers.getHeader(name); }
/** * Get all the headers for this header_name. Note that certain * headers may be encoded as per RFC 2047 if they contain * non US-ASCII characters and these should be decoded. <p> * * This implementation obtains the headers from the * <code>headers</code> InternetHeaders object. * * @param name name of header * @return array of headers * @exception MessagingException for failures * @see javax.mail.internet.MimeUtility */ @Override public String[] getHeader(String name) throws MessagingException { return headers.getHeader(name); }
/** * Get all the headers for this header_name. Note that certain * headers may be encoded as per RFC 2047 if they contain * non US-ASCII characters and these should be decoded. <p> * * @param name name of header * @return array of headers * @exception MessagingException for failures * @see javax.mail.internet.MimeUtility */ public String[] getHeader(String name) throws MessagingException { if (headers == null) loadHeaders(); return headers.getHeader(name); }
/** * Get all the headers for this header name, returned as a single * String, with headers separated by the delimiter. If the * delimiter is <code>null</code>, only the first header is * returned. Returns <code>null</code> * if no headers with the specified name exist. * * @param name header name * @param delimiter delimiter * @return the value fields for all headers with * this name, or null if none */ public String getHeader(String name, String delimiter) { String s[] = getHeader(name); if (s == null) return null; if ((s.length == 1) || delimiter == null) return s[0]; StringBuffer r = new StringBuffer(s[0]); for (int i = 1; i < s.length; i++) { r.append(delimiter); r.append(s[i]); } return r.toString(); }
/** * Get all the headers for this header name, returned as a single * String, with headers separated by the delimiter. If the * delimiter is <code>null</code>, only the first header is * returned. Returns <code>null</code> * if no headers with the specified name exist. * * @param name header name * @param delimiter delimiter * @return the value fields for all headers with * this name, or null if none */ public String getHeader(String name, String delimiter) { String s[] = getHeader(name); if (s == null) return null; if ((s.length == 1) || delimiter == null) return s[0]; StringBuilder r = new StringBuilder(s[0]); for (int i = 1; i < s.length; i++) { r.append(delimiter); r.append(s[i]); } return r.toString(); }
/** * Get all the headers for this header_name. Note that certain * headers may be encoded as per RFC 2047 if they contain * non US-ASCII characters and these should be decoded. <p> * * @param name name of header * @return array of headers * @exception MessagingException for failures * @see javax.mail.internet.MimeUtility */ @Override public String[] getHeader(String name) throws MessagingException { if (headers == null) loadHeaders(); return headers.getHeader(name); }
/** * Get all the headers for this header name, returned as a single * String, with headers separated by the delimiter. If the * delimiter is <code>null</code>, only the first header is * returned. * * @param name the name of this header * @param delimiter delimiter between returned headers * @return the value fields for all headers with * this name * @exception MessagingException for failures */ public String getHeader(String name, String delimiter) throws MessagingException { if (headers == null) loadHeaders(); return headers.getHeader(name, delimiter); }
/** * Get all the headers for this header name, returned as a single * String, with headers separated by the delimiter. If the * delimiter is <code>null</code>, only the first header is * returned. * * @param name the name of this header * @param delimiter delimiter between returned headers * @return the value fields for all headers with * this name * @exception MessagingException for failures */ @Override public String getHeader(String name, String delimiter) throws MessagingException { if (headers == null) loadHeaders(); return headers.getHeader(name, delimiter); }
/** * Get the named header. */ public String getHeader(String name, String delimiter) throws MessagingException { checkExpunged(); // force the header to be loaded by invoking getHeader(name) if (getHeader(name) == null) return null; return headers.getHeader(name, delimiter); }
/** * Get the named header. */ @Override public String getHeader(String name, String delimiter) throws MessagingException { checkExpunged(); // force the header to be loaded by invoking getHeader(name) if (getHeader(name) == null) return null; return headers.getHeader(name, delimiter); }