Skip to content

Commit 562e298

Browse files
authored
chore: allow messages via EngineVersionCheck (#7353)
1 parent 04df1ab commit 562e298

File tree

2 files changed

+23
-3
lines changed

2 files changed

+23
-3
lines changed

core/src/main/java/org/owasp/dependencycheck/data/update/EngineVersionCheck.java

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,9 @@
2121
import java.net.MalformedURLException;
2222
import java.net.URL;
2323
import java.nio.charset.StandardCharsets;
24+
import java.util.Arrays;
2425
import javax.annotation.concurrent.ThreadSafe;
26+
2527
import org.owasp.dependencycheck.Engine;
2628
import org.owasp.dependencycheck.data.nvdcve.CveDB;
2729
import org.owasp.dependencycheck.data.nvdcve.DatabaseException;
@@ -167,13 +169,21 @@ public boolean update(Engine engine) throws UpdateException {
167169
* github documentation site or accessing the local database.
168170
*/
169171
protected boolean shouldUpdate(final long lastChecked, final long now, final DatabaseProperties properties,
170-
String currentVersion) throws UpdateException {
172+
String currentVersion) throws UpdateException {
171173
//check every 30 days if we know there is an update, otherwise check every 7 days
172174
final int checkRange = 30;
173175
if (!DateUtil.withinDateRange(lastChecked, now, checkRange)) {
174176
LOGGER.debug("Checking web for new version.");
175-
final String currentRelease = getCurrentReleaseVersion();
176-
if (currentRelease != null) {
177+
final String publishedData = getCurrentReleaseVersion();
178+
if (publishedData != null) {
179+
final String[] parts = publishedData.split("\n");
180+
if (parts.length > 1) {
181+
final String message = String.join("\n", Arrays.copyOfRange(parts, 1, parts.length)).trim();
182+
LOGGER.warn("\n\n*********************************************************\n"
183+
+ message
184+
+ "\n*********************************************************\n");
185+
}
186+
final String currentRelease = parts[0].trim();
177187
final DependencyVersion v = new DependencyVersion(currentRelease);
178188
if (v.getVersionParts() != null && v.getVersionParts().size() >= 3) {
179189
updateToVersion = v.toString();

core/src/test/java/org/owasp/dependencycheck/utils/DependencyVersionTest.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ public void testParseVersion() {
4646
assertEquals("2", parts.get(1));
4747
assertEquals("r1", parts.get(2));
4848

49+
version = "x6.0";
4950
instance.parseVersion("x6.0");
5051
parts = instance.getVersionParts();
5152
assertEquals(2, parts.size());
@@ -54,6 +55,15 @@ public void testParseVersion() {
5455
// TODO(code review): should this be here/do something?
5556
//assertEquals("0", parts.get(2));
5657

58+
59+
version = "1.2.3\nThis is a test message";
60+
instance = new DependencyVersion();
61+
instance.parseVersion(version);
62+
parts = instance.getVersionParts();
63+
assertEquals(3, parts.size());
64+
assertEquals("1", parts.get(0));
65+
assertEquals("2", parts.get(1));
66+
assertEquals("3", parts.get(2));
5767
}
5868

5969
/**

0 commit comments

Comments
 (0)