use of org.graylog2.audit.jersey.NoAuditEvent in project graylog2-server by Graylog2.
the class QueryValidationResource method validateQuery.
@POST
@Produces(MediaType.APPLICATION_JSON)
@ApiOperation("Validate a search query")
@NoAuditEvent("Only validating query structure, not changing any data")
public ValidationResponseDTO validateQuery(@ApiParam(name = "validationRequest") ValidationRequestDTO validationRequest, @Context SearchUser searchUser) {
final ValidationRequest.Builder q = ValidationRequest.Builder.builder().query(validationRequest.query()).timerange(validationRequest.timerange().orElse(defaultTimeRange())).streams(searchUser.streams().readableOrAllIfEmpty(validationRequest.streams())).parameters(resolveParameters(validationRequest));
validationRequest.filter().ifPresent(q::filter);
final ValidationResponse response = queryValidationService.validate(q.build());
return ValidationResponseDTO.create(toStatus(response.status()), toExplanations(response));
}
use of org.graylog2.audit.jersey.NoAuditEvent in project graylog2-server by Graylog2.
the class SearchResource method executeSyncJobv2.
@POST
@ApiOperation(value = "Execute a new synchronous search", notes = "Executes a new search and waits for its result", response = SearchJobDTO.class)
@Path("sync")
@NoAuditEvent("Creating audit event manually in method body.")
@Consumes({ SEARCH_FORMAT_V2 })
@Produces({ SEARCH_FORMAT_V2 })
public Response executeSyncJobv2(@ApiParam @NotNull(message = "Search body is mandatory") SearchDTOv2 searchRequest, @ApiParam(name = "timeout", defaultValue = "60000") @QueryParam("timeout") @DefaultValue("60000") long timeout, @Context SearchUser searchUser) {
final Search search = searchRequest.toSearch();
final SearchJob searchJob = searchExecutor.execute(search, searchUser, ExecutionState.empty());
postAuditEvent(searchJob);
final SearchJobDTO searchJobDTO = SearchJobDTO.fromSearchJob(searchJob);
return Response.ok(searchJobDTO).build();
}
use of org.graylog2.audit.jersey.NoAuditEvent in project graylog2-server by Graylog2.
the class SearchResource method executeSyncJob.
@POST
@ApiOperation(value = "Execute a new synchronous search", notes = "Executes a new search and waits for its result", response = SearchJobDTO.class)
@Path("sync")
@NoAuditEvent("Creating audit event manually in method body.")
@Consumes({ MediaType.APPLICATION_JSON, SEARCH_FORMAT_V1 })
@Produces({ MediaType.APPLICATION_JSON, SEARCH_FORMAT_V1 })
public Response executeSyncJob(@ApiParam @NotNull(message = "Search body is mandatory") SearchDTO searchRequest, @ApiParam(name = "timeout", defaultValue = "60000") @QueryParam("timeout") @DefaultValue("60000") long timeout, @Context SearchUser searchUser) {
final Search search = searchRequest.toSearch();
final SearchJob searchJob = searchExecutor.execute(search, searchUser, ExecutionState.empty());
postAuditEvent(searchJob);
final SearchJobDTO searchJobDTO = SearchJobDTO.fromSearchJob(searchJob);
return Response.ok(searchJobDTO).build();
}
use of org.graylog2.audit.jersey.NoAuditEvent in project graylog2-server by Graylog2.
the class SearchMetadataResource method metadataForObject.
@POST
@ApiOperation(value = "Metadata for the posted Search object", notes = "Intended for search objects that aren't yet persisted (e.g. for validation or interactive purposes)")
@NoAuditEvent("Only returning metadata for given search, not changing any data")
public SearchMetadata metadataForObject(@ApiParam @NotNull(message = "Search body is mandatory") SearchDTO searchDTO) {
if (searchDTO == null) {
throw new IllegalArgumentException("Search must not be null.");
}
final Search search = searchDTO.toSearch();
final Map<String, QueryMetadata> queryMetadatas = StreamEx.of(search.queries()).toMap(Query::id, query -> queryEngine.parse(search, query));
return SearchMetadata.create(queryMetadatas, Maps.uniqueIndex(search.parameters(), Parameter::name));
}
use of org.graylog2.audit.jersey.NoAuditEvent in project graylog2-server by Graylog2.
the class StreamAlertResource method sendDummyAlert.
@POST
@Timed
@Path("sendDummyAlert")
@ApiOperation(value = "Send a test mail for a given stream")
@ApiResponses(value = { @ApiResponse(code = 404, message = "Stream not found."), @ApiResponse(code = 400, message = "Invalid ObjectId."), @ApiResponse(code = 400, message = "Stream has no alarm callbacks") })
@NoAuditEvent("only used to test alert emails")
public void sendDummyAlert(@ApiParam(name = "streamId", value = "The stream id the test alert should be sent for.", required = true) @PathParam("streamId") String streamId) throws TransportConfigurationException, EmailException, NotFoundException {
checkPermission(RestPermissions.STREAMS_EDIT, streamId);
final Stream stream = streamService.load(streamId);
final DummyAlertCondition dummyAlertCondition = new DummyAlertCondition(stream, null, Tools.nowUTC(), getSubject().getPrincipal().toString(), Collections.emptyMap(), "Test Alert");
try {
AbstractAlertCondition.CheckResult checkResult = dummyAlertCondition.runCheck();
List<AlarmCallbackConfiguration> callConfigurations = alarmCallbackConfigurationService.getForStream(stream);
if (callConfigurations.size() == 0) {
final String message = "Stream has no alarm callbacks, cannot send test alert.";
LOG.warn(message);
throw new BadRequestException(message);
}
for (AlarmCallbackConfiguration configuration : callConfigurations) {
AlarmCallback alarmCallback = alarmCallbackFactory.create(configuration);
alarmCallback.call(stream, checkResult);
}
} catch (AlarmCallbackException | ClassNotFoundException | AlarmCallbackConfigurationException e) {
throw new InternalServerErrorException(e.getMessage(), e);
}
}
Aggregations