Ecosystem.java

  1. /*
  2.  * This file is part of dependency-check-core.
  3.  *
  4.  * Licensed under the Apache License, Version 2.0 (the "License");
  5.  * you may not use this file except in compliance with the License.
  6.  * You may obtain a copy of the License at
  7.  *
  8.  *     http://www.apache.org/licenses/LICENSE-2.0
  9.  *
  10.  * Unless required by applicable law or agreed to in writing, software
  11.  * distributed under the License is distributed on an "AS IS" BASIS,
  12.  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13.  * See the License for the specific language governing permissions and
  14.  * limitations under the License.
  15.  *
  16.  * Copyright (c) 2020 The OWASP Foundation. All Rights Reserved.
  17.  */
  18. package org.owasp.dependencycheck.data.nvd.ecosystem;

  19. import org.owasp.dependencycheck.utils.Settings;

  20. /**
  21.  * Collection of the standard ecosystems for dependency-check.
  22.  *
  23.  * @author Jeremy Long
  24.  */
  25. public final class Ecosystem {

  26.     /**
  27.      * The Ruby ecosystem.
  28.      */
  29.     public static final String RUBY = "ruby";
  30.     /**
  31.      * The dotnet ecosystem.
  32.      */
  33.     public static final String DOTNET = "dotnet";
  34.     /**
  35.      * The iOS ecosystem.
  36.      */
  37.     public static final String IOS = "ios";
  38.     /**
  39.      * The PHP ecosystem.
  40.      */
  41.     public static final String PHP = "php";
  42.     /**
  43.      * The Golang ecosystem.
  44.      */
  45.     public static final String GOLANG = "golang";
  46.     /**
  47.      * The Java ecosystem.
  48.      */
  49.     public static final String JAVA = "java";
  50.     /**
  51.      * The native ecosystem.
  52.      */
  53.     public static final String NATIVE = "native";
  54.     /**
  55.      * The Python ecosystem.
  56.      */
  57.     public static final String PYTHON = "python";
  58.     /**
  59.      * The JavaScript ecosystem.
  60.      */
  61.     public static final String JAVASCRIPT = "js";
  62.     /**
  63.      * The Node.JS ecosystem.
  64.      */
  65.     public static final String NODEJS = "nodejs";
  66.     /**
  67.      * The rust ecosystem.
  68.      */
  69.     public static final String RUST = "rust";
  70.     /**
  71.      * The rust ecosystem.
  72.      */
  73.     public static final String COLDFUSION = "coldfusion";
  74.     /**
  75.      * The Perl ecosystem.
  76.      */
  77.     public static final String PERL = "perl";
  78.     /**
  79.      * The Elixir ecosystem.
  80.      */
  81.     public static final String ELIXIR = "exlixir";

  82.     /**
  83.      * The Dart ecosystem.
  84.      */
  85.     public static final String DART = "dart";


  86.     /**
  87.      * A reference to the ODC settings.
  88.      */
  89.     private final Settings settings;
  90.     /**
  91.      * The lucene default query size.
  92.      */
  93.     private final int defaultQuerySize;

  94.     /**
  95.      * Instantiates the ecosystem utility class.
  96.      *
  97.      * @param settings the ODC configuration
  98.      */
  99.     public Ecosystem(Settings settings) {
  100.         this.settings = settings;
  101.         this.defaultQuerySize = settings.getInt(Settings.KEYS.MAX_QUERY_SIZE_DEFAULT, 100);
  102.     }

  103.     /**
  104.      * Returns the max query result size for the Lucene search for each
  105.      * ecosystem.
  106.      *
  107.      * @param ecosystem the ecosystem
  108.      * @return the max query result size
  109.      */
  110.     public int getLuceneMaxQueryLimitFor(String ecosystem) {
  111.         return settings.getInt(Settings.KEYS.MAX_QUERY_SIZE_PREFIX + ecosystem, defaultQuerySize);
  112.     }
  113. }