Skip to content

Commit 43c7acf

Browse files
magl0copybara-github
authored andcommitted
Allow templated plugin to ignore HTTP client failures.
PiperOrigin-RevId: 840085951 Change-Id: I8a1c22ed16351c3cfd7d9aff7e5e96bca4b1e92a
1 parent 7643dc6 commit 43c7acf

File tree

2 files changed

+21
-3
lines changed

2 files changed

+21
-3
lines changed

templated/templateddetector/proto/action_http.proto

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,17 @@ message HttpAction {
110110
// By default, we follow redirects so this flag can be used to disable this
111111
// behavior.
112112
bool disable_follow_redirects = 1;
113+
114+
// Whether the HTTP client exceptions should be ignored.
115+
//
116+
// By default, any HTTP client failure will fail the plugin execution and
117+
// checks are not performed. However, in some cases the tested server might
118+
// just execute a payload and hang forever and the HTTP client will timeout.
119+
//
120+
// Ignoring HTTP client exceptions will allow the workflow to proceed with
121+
// vulnerability verifications, like checking whether callback servers
122+
// received an interaction.
123+
bool ignore_http_client_errors = 2;
113124
}
114125

115126
// The HTTP method to use (e.g. GET, POST, ...).

templated/templateddetector/src/main/java/com/google/tsunami/plugins/detectors/templateddetector/actions/HttpActionRunner.java

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -98,9 +98,16 @@ private boolean run(
9898
try {
9999
response = httpClient.send(requestBuilder.build());
100100
} catch (IOException e) {
101-
logger.atSevere().withCause(e).log(
102-
"Action '%s' failed with exception: %s", action.getName(), e.getMessage());
103-
return false;
101+
if (httpAction.getClientOptions().getIgnoreHttpClientErrors()) {
102+
logger.atWarning().withCause(e).log(
103+
"HTTP client failed. Error is ignored and Action '%s' is considered succeeded.",
104+
action.getName());
105+
return true;
106+
} else {
107+
logger.atSevere().withCause(e).log(
108+
"Action '%s' failed with exception: %s", action.getName(), e.getMessage());
109+
return false;
110+
}
104111
}
105112

106113
if (this.debug) {

0 commit comments

Comments
 (0)