1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 package org.owasp.dependencycheck.maven;
19
20 import org.owasp.dependencycheck.utils.Filter;
21 import static org.apache.maven.artifact.Artifact.SCOPE_COMPILE_PLUS_RUNTIME;
22 import static org.apache.maven.artifact.Artifact.SCOPE_RUNTIME;
23 import static org.apache.maven.artifact.Artifact.SCOPE_SYSTEM;
24 import static org.apache.maven.artifact.Artifact.SCOPE_TEST;
25 import static org.apache.maven.artifact.Artifact.SCOPE_PROVIDED;
26
27
28
29
30
31
32 public class ArtifactScopeExcluded extends Filter<String> {
33
34
35
36
37 private final boolean skipTestScope;
38
39
40
41 private final boolean skipProvidedScope;
42
43
44
45 private final boolean skipSystemScope;
46
47
48
49 private final boolean skipRuntimeScope;
50
51
52
53
54
55
56
57
58
59 public ArtifactScopeExcluded(final boolean skipTestScope, final boolean skipProvidedScope,
60 final boolean skipSystemScope, final boolean skipRuntimeScope) {
61 this.skipTestScope = skipTestScope;
62 this.skipProvidedScope = skipProvidedScope;
63 this.skipSystemScope = skipSystemScope;
64 this.skipRuntimeScope = skipRuntimeScope;
65 }
66
67
68
69
70
71
72
73
74
75 @Override
76 public boolean passes(final String scope) {
77 if (skipTestScope && SCOPE_TEST.equals(scope)) {
78 return true;
79 }
80 if (skipProvidedScope && SCOPE_PROVIDED.equals(scope)) {
81 return true;
82 }
83 if (skipSystemScope && SCOPE_SYSTEM.equals(scope)) {
84 return true;
85 }
86 if (skipRuntimeScope && SCOPE_RUNTIME.equals(scope)) {
87 return true;
88 }
89 if (skipRuntimeScope && skipSystemScope && SCOPE_COMPILE_PLUS_RUNTIME.equals(scope)) {
90 return true;
91 }
92 return false;
93 }
94 }