return;
}
LOGGER.error("Fail to process request " + request, e);
- sendErrors(response, 500, new Errors().add(Message.of(e.getMessage())));
+ // Sending exception message into response is a vulnerability. Error must be
+ // displayed only in logs.
+ sendErrors(response, 500, new Errors().add(Message.of("error_occurred")));
}
}
@Rule
public UserSessionRule userSessionRule = UserSessionRule.standalone();
- I18n i18n = mock(I18n.class);
-
- WebServiceEngine underTest = new WebServiceEngine(new WebService[] {new SystemWs()}, i18n, userSessionRule);
+ private I18n i18n = mock(I18n.class);
+ private WebServiceEngine underTest = new WebServiceEngine(new WebService[] {new SystemWs()}, i18n, userSessionRule);
@Before
public void start() {
DumbResponse response = new DumbResponse();
underTest.execute(request, response);
- assertThat(response.stream().outputAsString()).isEqualTo("{\"errors\":[{\"msg\":\"Unexpected\"}]}");
+ assertThat(response.stream().outputAsString()).isEqualTo("{\"errors\":[{\"msg\":\"error_occurred\"}]}");
assertThat(response.stream().status()).isEqualTo(500);
assertThat(response.stream().mediaType()).isEqualTo(MediaTypes.JSON);
+ assertThat(logTester.logs(LoggerLevel.ERROR)).filteredOn(l -> l.contains("Fail to process request")).isNotEmpty();
}
@Test
coding_rules=Rules
click_to_add_to_favorites=Click to add to favorites
click_to_remove_from_favorites=Click to remove from favorites
+error_occurred=An error has occurred. Please contact your administrator.
contact_admin=Please contact your administrator.
created_by=Created by
deactivate_all=Deactivate all