Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion addOns/addOns.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,6 @@ subprojects {
val lintFlags = mutableListOf("-processing")
if (JavaVersion.current().getMajorVersion() >= "21") {
lintFlags.add("-this-escape")
options.compilerArgs = options.compilerArgs - "-Werror"
}
options.compilerArgs = options.compilerArgs + "-Xlint:${lintFlags.joinToString(",")}"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@
*/
package org.zaproxy.zap.extension.ascanrulesBeta;

import java.net.MalformedURLException;
import java.net.URL;
import java.net.URISyntaxException;
import java.time.Instant;
import java.time.ZonedDateTime;
import java.util.Collections;
Expand Down Expand Up @@ -188,13 +187,16 @@ public void scan() {
String requestUrl = "Unknown URL";
try {
requestUrl =
new URL(
new java.net.URI(

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These will have the same problem as shown by the spider tests.

requestUri.getScheme(),
null,
requestUri.getHost(),
requestUri.getPort(),
requestUri.getPath())
requestUri.getPath(),
null,
null)
.toString();
} catch (MalformedURLException e) {
} catch (URISyntaxException e) {
// no point in continuing. The URL is invalid. This is a peculiarity in the Zap
// core,
// and can happen when
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@
import java.awt.BorderLayout;
import java.awt.Dimension;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URI;
import java.net.URISyntaxException;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicReference;
Expand Down Expand Up @@ -104,8 +105,8 @@ public void loadContent(final String content) {

private static String toURL(String str) {
try {
return new URL(str).toExternalForm();
} catch (MalformedURLException exception) {
return new URI(str).toURL().toExternalForm();
} catch (MalformedURLException | URISyntaxException exception) {
return null;
}
}
Expand Down
3 changes: 2 additions & 1 deletion addOns/bruteforce/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ All notable changes to this add-on will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).

## Unreleased

### Changed
- Maintenance changes.

## [20] - 2025-12-15
### Changed
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
import com.sittinglittleduck.DirBuster.SimpleHttpClient.HttpMethod;
import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URI;
import java.net.URISyntaxException;
import java.net.URL;
import java.util.Vector;
import java.util.regex.Matcher;
Expand Down Expand Up @@ -84,16 +86,16 @@ public static BaseCase genBaseCase(
String baseResponce = "";
URL failurl = null;
if (isDir) {
failurl = new URL(url + failString + "/");
failurl = toUrl(url + failString + "/");
} else {
if (manager.isBlankExt()) {
fileExtention = "";
failurl = new URL(url + failString + fileExtention);
failurl = toUrl(url + failString + fileExtention);
} else {
if (!fileExtention.startsWith(".")) {
fileExtention = "." + fileExtention;
}
failurl = new URL(url + failString + fileExtention);
failurl = toUrl(url + failString + fileExtention);
}
}

Expand Down Expand Up @@ -175,7 +177,7 @@ public static BaseCase genBaseCase(

baseCase =
new BaseCase(
new URL(url),
toUrl(url),
failcode,
isDir,
failurl,
Expand Down Expand Up @@ -207,7 +209,7 @@ public static BaseCase genURLFuzzBaseCase(Manager manager, String fuzzStart, Str
boolean useRegexInstead = false;
String regex = null;

URL failurl = new URL(fuzzStart + failString + FuzzEnd);
URL failurl = toUrl(fuzzStart + failString + FuzzEnd);

HttpResponse response = manager.getHttpClient().send(HttpMethod.GET, failurl.toString());

Expand Down Expand Up @@ -277,4 +279,14 @@ private static String getBaseCaseAgain(Manager manager, URL failurl, String fail
return null;
}
}

private static URL toUrl(String value) throws MalformedURLException {
try {
return new URI(value).toURL();
} catch (URISyntaxException e) {
MalformedURLException ex = new MalformedURLException(e.getMessage());
ex.initCause(e);
throw ex;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
import com.sittinglittleduck.DirBuster.SimpleHttpClient.HttpMethod;
import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URI;
import java.net.URISyntaxException;
import java.net.URL;
import java.util.Vector;
import net.htmlparser.jericho.Attribute;
Expand Down Expand Up @@ -102,7 +104,8 @@ public void run() {
if (attr != null) {
// creates a full qulaifed domian name, based on the page we
// have just tested
URL tempURL = new URL(work.getWork(), attr.getValue());
URL tempURL =
work.getWork().toURI().resolve(attr.getValue()).toURL();

String urlString = tempURL.getPath();
// check it is not already there and the link is from the same
Expand All @@ -125,7 +128,7 @@ public void run() {
}
}

} catch (MalformedURLException e) {
} catch (MalformedURLException | URISyntaxException e) {
LOGGER.debug("Bad URL", e);
}
}
Expand Down Expand Up @@ -179,11 +182,16 @@ public void run() {
// ports
WorkUnit workUnit =
new WorkUnit(
new URL(
work.getWork().getProtocol(),
work.getWork().getHost(),
work.getWork().getPort(),
founditem),
new URI(
work.getWork()
.getProtocol(),
null,
work.getWork().getHost(),
work.getWork().getPort(),
founditem,
null,
null)
.toURL(),
founditem.endsWith("/"),
method,
baseCase,
Expand All @@ -198,7 +206,7 @@ public void run() {
// workUnit.getWork().toString() + " to the work
// queue");
}
} catch (MalformedURLException ex) {
} catch (MalformedURLException | URISyntaxException ex) {
LOGGER.debug("Bad URL", ex);
} catch (InterruptedException ex) {
LOGGER.debug(ex);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
import com.sittinglittleduck.DirBuster.workGenerators.WorkerGenerator;
import com.sittinglittleduck.DirBuster.workGenerators.WorkerGeneratorURLFuzz;
import java.net.MalformedURLException;
import java.net.URI;
import java.net.URISyntaxException;
import java.net.URL;
import java.util.Date;
import java.util.Locale;
Expand Down Expand Up @@ -214,10 +216,10 @@ public void setupManager(
// add the start point to the running list
// TODO change this so it sctually checks for it
try {
url = new URL(firstPartOfURL + startPoint);
url = new URI(firstPartOfURL + startPoint).toURL();
// gui.addResult(new ResultsTableObject("Dir", url.getPath(), "---", "Scanning",
// url.toString(), "Start point of testing", null, null, this.recursive, null));
} catch (MalformedURLException ex) {
} catch (MalformedURLException | URISyntaxException ex) {
LOGGER.error("Bad URL", ex);
}

Expand Down Expand Up @@ -266,10 +268,10 @@ public void setupManager(

// add the start point to the running list
try {
url = new URL(firstPartOfURL + startPoint);
url = new URI(firstPartOfURL + startPoint).toURL();
// gui.addResult(new ResultsTableObject("Dir", url.getPath(), "---", "Scanning",
// url.toString(), "Start point of testing", null, null, this.recursive, null));
} catch (MalformedURLException ex) {
} catch (MalformedURLException | URISyntaxException ex) {
LOGGER.error("Bad URL", ex);
}

Expand Down Expand Up @@ -872,7 +874,7 @@ public synchronized BaseCase getBaseCase(String base, boolean isDir, String file
for (int a = 0; a < producedBasesCases.size(); a++) {
BaseCase tempBaseCase = producedBasesCases.elementAt(a);

if (tempBaseCase.getBaseCaseURL().equals(new URL(base))
if (tempBaseCase.getBaseCaseURL().equals(new URI(base).toURL())
&& tempBaseCase.isDir() == isDir) {
if (!isDir) {
if (tempBaseCase.getFileExt().equals(fileExt)) {
Expand All @@ -883,7 +885,7 @@ public synchronized BaseCase getBaseCase(String base, boolean isDir, String file
}
}
}
} catch (MalformedURLException ex) {
} catch (MalformedURLException | URISyntaxException ex) {
// do nothing I dont care
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@
import com.sittinglittleduck.DirBuster.WorkUnit;
import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URI;
import java.net.URISyntaxException;
import java.net.URL;
import java.util.concurrent.BlockingQueue;
import org.apache.logging.log4j.LogManager;
Expand Down Expand Up @@ -83,7 +85,7 @@ public void run() {

if (manager.getAuto()) {
try {
URL headurl = new URL(firstPart);
URL headurl = new URI(firstPart).toURL();

int responceCode =
manager.getHttpClient()
Expand All @@ -96,7 +98,7 @@ public void run() {
// switch the mode to just GET requests
manager.setAuto(false);
}
} catch (IOException e) {
} catch (IOException | URISyntaxException e) {
LOGGER.error(e, e);
}
}
Expand Down Expand Up @@ -177,12 +179,12 @@ private void showString(int len, String baseCase, BaseCase baseCaseObj) {
method = HttpMethod.GET;
}

URL currentURL = new URL(firstPart + urlFuzzStart + temp + urlFuzzEnd);
URL currentURL = new URI(firstPart + urlFuzzStart + temp + urlFuzzEnd).toURL();
workQueue.put(new WorkUnit(currentURL, true, method, baseCaseObj, temp));

} catch (InterruptedException e) {
LOGGER.debug(e);
} catch (MalformedURLException e) {
} catch (MalformedURLException | URISyntaxException e) {
LOGGER.debug("Bad URL", e);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@
import com.sittinglittleduck.DirBuster.WorkUnit;
import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URI;
import java.net.URISyntaxException;
import java.net.URL;
import java.util.Vector;
import java.util.concurrent.BlockingQueue;
Expand Down Expand Up @@ -95,7 +97,7 @@ public void run() {

if (manager.getAuto()) {
try {
URL headurl = new URL(firstPart);
URL headurl = new URI(firstPart).toURL();

int responceCode =
manager.getHttpClient()
Expand All @@ -108,7 +110,7 @@ public void run() {
// switch the mode to just GET requests
manager.setAuto(false);
}
} catch (IOException e) {
} catch (IOException | URISyntaxException e) {
LOGGER.error(e, e);
}
}
Expand Down Expand Up @@ -232,18 +234,18 @@ private void showString(int len, String baseCase, BaseCase baseCaseObj) {
}

if (doingDirs) {
URL currentURL = new URL(firstPart + currentDir + temp + "/");
URL currentURL = new URI(firstPart + currentDir + temp + "/").toURL();

workQueue.put(new WorkUnit(currentURL, true, method, baseCaseObj, temp));

} else {
URL currentURL = new URL(firstPart + currentDir + temp + fileExtention);
URL currentURL = new URI(firstPart + currentDir + temp + fileExtention).toURL();

workQueue.put(new WorkUnit(currentURL, false, method, baseCaseObj, temp));
}
} catch (InterruptedException e) {
LOGGER.debug(e);
} catch (MalformedURLException e) {
} catch (MalformedURLException | URISyntaxException e) {
LOGGER.debug("Bad URL", e);
}
}
Expand Down
Loading
Loading