All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.owasp.dependencycheck.utils.DefaultCveUrlModifiedParser Maven / Gradle / Ivy

Go to download

dependency-check-utils is a collection of common utility classes used within dependency-check that might be useful in other projects.

There is a newer version: 11.1.1
Show newest version
package org.owasp.dependencycheck.utils;

import java.util.Objects;

/**
 * Default implementation of a {@code CveUrlParser}.
 *
 * @author nhumblot
 *
 */
public final class DefaultCveUrlModifiedParser implements CveUrlParser {

  private static final String URL_SEPARATOR = "/";

  private final Settings settings;

  DefaultCveUrlModifiedParser(Settings settings) {
    this.settings = settings;
  }

  @Override
  public String getDefaultCveUrlModified(String baseUrl) {
    String defaultBaseUrlEnd = URL_SEPARATOR + settings.getString(Settings.KEYS.CVE_BASE_DEFAULT_FILENAME);
    if (Objects.nonNull(baseUrl) && baseUrl.endsWith(defaultBaseUrlEnd)) {
      String defaultModifiedUrlEnd = URL_SEPARATOR + settings.getString(Settings.KEYS.CVE_MODIFIED_DEFAULT_FILENAME);
      return baseUrl.substring(0, baseUrl.length() - defaultBaseUrlEnd.length()) + defaultModifiedUrlEnd;
    }
    return null;
  }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy