View Javadoc
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  
20  import org.owasp.dependencycheck.utils.Settings;
21  
22  /**
23   * Collection of the standard ecosystems for dependency-check.
24   *
25   * @author Jeremy Long
26   */
27  public final class Ecosystem {
28  
29      /**
30       * The Ruby ecosystem.
31       */
32      public static final String RUBY = "ruby";
33      /**
34       * The dotnet ecosystem.
35       */
36      public static final String DOTNET = "dotnet";
37      /**
38       * The iOS ecosystem.
39       */
40      public static final String IOS = "ios";
41      /**
42       * The PHP ecosystem.
43       */
44      public static final String PHP = "php";
45      /**
46       * The Golang ecosystem.
47       */
48      public static final String GOLANG = "golang";
49      /**
50       * The Java ecosystem.
51       */
52      public static final String JAVA = "java";
53      /**
54       * The native ecosystem.
55       */
56      public static final String NATIVE = "native";
57      /**
58       * The Python ecosystem.
59       */
60      public static final String PYTHON = "python";
61      /**
62       * The JavaScript ecosystem.
63       */
64      public static final String JAVASCRIPT = "js";
65      /**
66       * The Node.JS ecosystem.
67       */
68      public static final String NODEJS = "nodejs";
69      /**
70       * The rust ecosystem.
71       */
72      public static final String RUST = "rust";
73      /**
74       * The rust ecosystem.
75       */
76      public static final String COLDFUSION = "coldfusion";
77      /**
78       * The Perl ecosystem.
79       */
80      public static final String PERL = "perl";
81      /**
82       * The Elixir ecosystem.
83       */
84      public static final String ELIXIR = "exlixir";
85  
86      /**
87       * The Dart ecosystem.
88       */
89      public static final String DART = "dart";
90  
91  
92      /**
93       * A reference to the ODC settings.
94       */
95      private final Settings settings;
96      /**
97       * The lucene default query size.
98       */
99      private final int defaultQuerySize;
100 
101     /**
102      * Instantiates the ecosystem utility class.
103      *
104      * @param settings the ODC configuration
105      */
106     public Ecosystem(Settings settings) {
107         this.settings = settings;
108         this.defaultQuerySize = settings.getInt(Settings.KEYS.MAX_QUERY_SIZE_DEFAULT, 100);
109     }
110 
111     /**
112      * Returns the max query result size for the Lucene search for each
113      * ecosystem.
114      *
115      * @param ecosystem the ecosystem
116      * @return the max query result size
117      */
118     public int getLuceneMaxQueryLimitFor(String ecosystem) {
119         return settings.getInt(Settings.KEYS.MAX_QUERY_SIZE_PREFIX + ecosystem, defaultQuerySize);
120     }
121 }