Skip to content

Commit

Permalink
fix null pointer when there is no url result
Browse files Browse the repository at this point in the history
  • Loading branch information
cccs-shellyw committed Nov 25, 2024
1 parent 1c45042 commit 3405be4
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/ca/gc/cyber/kangooroo/KangoorooStandaloneRunner.java
Original file line number Diff line number Diff line change
Expand Up @@ -109,9 +109,13 @@ public static KangoorooURLReport generateKangoorooReport(KangoorooResult result,
DigestUtils.md5Hex(url.toExternalForm()),
url.getHost(), result.getInitial().getServerIPAddress());

KangoorooURL actualUrl = new KangoorooURL(result.getUrl().toExternalForm(),
DigestUtils.md5Hex(result.getUrl().toExternalForm()),
result.getUrl().getHost(), lastHop.getServerIPAddress());
KangoorooURL actualUrl = null;

if (result.getUrl() != null){
actualUrl = new KangoorooURL(result.getUrl().toExternalForm(),
DigestUtils.md5Hex(result.getUrl().toExternalForm()),
result.getUrl().getHost(), lastHop.getServerIPAddress());
}

List<URLRedirection> urlRedirects = HarUtils.getHTTPRedirections(result.getHar());

Expand All @@ -137,6 +141,7 @@ private static void runKangooroo(boolean useSandbox, boolean useCaptchaSolver, b
long start = System.currentTimeMillis();
KangoorooResult res = browser.get(crawlUrl, windowSize, userAgent);
long processingTime = System.currentTimeMillis() - start;

browser.browserShutdown();

createKangoorooOutput(urlOutputDir, configuration, crawlUrl, res, processingTime, saveOriginalHar, urlType,
Expand Down Expand Up @@ -399,6 +404,7 @@ public static void main(String[] args) throws Throwable {
} finally {
// cleanup leftover files in the temporary directory
FileUtils.deleteQuietly(urlTempDir);
log.debug("Temp directory should be deleted.");
}

}
Expand Down

0 comments on commit 3405be4

Please sign in to comment.