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 java.util.Locale;
21 import java.util.logging.Level;
22 import java.util.logging.Logger;
23 import org.apache.maven.plugin.MojoExecutionException;
24 import org.apache.maven.plugin.MojoFailureException;
25 import org.apache.maven.plugins.annotations.LifecyclePhase;
26 import org.apache.maven.plugins.annotations.Mojo;
27 import org.apache.maven.plugins.annotations.ResolutionScope;
28 import org.owasp.dependencycheck.data.nvdcve.DatabaseException;
29 import org.owasp.dependencycheck.utils.Settings;
30
31
32
33
34
35
36 @Mojo(
37 name = "update-only",
38 defaultPhase = LifecyclePhase.GENERATE_RESOURCES,
39 threadSafe = true,
40 requiresDependencyResolution = ResolutionScope.NONE,
41 requiresOnline = true
42 )
43 public class UpdateMojo extends BaseDependencyCheckMojo {
44
45
46
47
48 private static final Logger LOGGER = Logger.getLogger(UpdateMojo.class.getName());
49
50
51
52
53
54
55 @Override
56 public boolean canGenerateReport() {
57 return false;
58 }
59
60
61
62
63
64
65
66 @Override
67 public void runCheck() throws MojoExecutionException, MojoFailureException {
68 final Engine engine;
69 try {
70 engine = initializeEngine();
71 engine.update();
72 } catch (DatabaseException ex) {
73 LOGGER.log(Level.FINE, "Database connection error", ex);
74 throw new MojoExecutionException("An exception occured connecting to the local database. Please see the log file for more details.", ex);
75 }
76 engine.cleanup();
77 Settings.cleanup();
78 }
79
80
81
82
83
84
85
86 public String getName(Locale locale) {
87 return "dependency-check-update";
88 }
89
90
91
92
93
94
95
96 public String getDescription(Locale locale) {
97 return "Updates the local cache of the NVD data from NIST.";
98 }
99
100 }