|
65 | 65 | <java.minVersion>17</java.minVersion> |
66 | 66 | <antlr4.version>4.13.2</antlr4.version> |
67 | 67 | <dependencyCheck.version>13.0.0</dependencyCheck.version> |
68 | | - <dependencyCheck.skip>false</dependencyCheck.skip> |
| 68 | + <!-- Off unless an NVD API key reaches the build; the nvd-api-key profile |
| 69 | + below turns it on. The scan genuinely cannot run without one: the NVD |
| 70 | + API rejects an empty key outright rather than falling back to |
| 71 | + anonymous access ("Invalid API Key, length of 0 too short"), and |
| 72 | + keyless access is throttled to 5 requests per rolling 30s, which is |
| 73 | + far too slow to populate the vulnerability cache from cold. Skipping |
| 74 | + is the honest default - handed no key the scan does not degrade, it |
| 75 | + fails the build without having checked anything. A key is free from |
| 76 | + https://nvd.nist.gov/developers/request-an-api-key; see the profile |
| 77 | + for how to supply it. --> |
| 78 | + <dependencyCheck.skip>true</dependencyCheck.skip> |
69 | 79 | <dependencyCheck.threshold>7</dependencyCheck.threshold> |
70 | | - <!-- Read the NVD API key from the environment so the secret is never |
71 | | - passed on the command line (visible in the process list). Can still |
72 | | - be overridden with -DdependencyCheck.NVDApiKey=... if needed. --> |
73 | | - <dependencyCheck.NVDApiKey>${env.NVD_API_KEY}</dependencyCheck.NVDApiKey> |
| 80 | + <!-- Empty on purpose, and only ever read when the scan is skipped: the |
| 81 | + nvd-api-key profile below supplies the real value from the |
| 82 | + environment. An empty key is worse than no key at all - that is the |
| 83 | + NVD error quoted above - so nothing here ever hands the plugin a |
| 84 | + blank credential. --> |
| 85 | + <dependencyCheck.NVDApiKey></dependencyCheck.NVDApiKey> |
74 | 86 | </properties> |
75 | 87 | <dependencies> |
76 | 88 | <dependency> |
|
268 | 280 | </plugin> |
269 | 281 | </plugins> |
270 | 282 | </reporting> |
| 283 | + <profiles> |
| 284 | + <!-- Enables the dependency-check scan, reading the key from the |
| 285 | + environment so the secret is never passed on the command line, where |
| 286 | + the process list would show it. |
| 287 | + |
| 288 | + Activation is by presence rather than value, and the empty case is |
| 289 | + the point: Maven activates a valueless <property> only when the |
| 290 | + property is non-empty, and CI expands an unset secret or variable to |
| 291 | + the empty string. So a fork, or a repository where the secret was |
| 292 | + never added, leaves the scan off instead of failing the build with a |
| 293 | + blank credential. |
| 294 | + |
| 295 | + To run it locally: NVD_API_KEY=... ./mvnw verify. To force it on with |
| 296 | + the key supplied some other way (a settings.xml server entry, say): |
| 297 | + -DdependencyCheck.skip=false. --> |
| 298 | + <profile> |
| 299 | + <id>nvd-api-key</id> |
| 300 | + <activation> |
| 301 | + <property><name>env.NVD_API_KEY</name></property> |
| 302 | + </activation> |
| 303 | + <properties> |
| 304 | + <dependencyCheck.skip>false</dependencyCheck.skip> |
| 305 | + <dependencyCheck.NVDApiKey>${env.NVD_API_KEY}</dependencyCheck.NVDApiKey> |
| 306 | + </properties> |
| 307 | + </profile> |
| 308 | + </profiles> |
271 | 309 | </project> |
0 commit comments