■ ■ ■ ■ ■ ■
src/main/java/com/nccgroup/loggerplusplus/logview/processor/LogProcessor.java
| skipped 8 lines |
9 | 9 | | import com.coreyd97.BurpExtenderUtilities.Preferences; |
10 | 10 | | import com.nccgroup.loggerplusplus.LoggerPlusPlus; |
11 | 11 | | import com.nccgroup.loggerplusplus.exports.ExportController; |
| 12 | + | import com.nccgroup.loggerplusplus.filter.FilterExpression; |
12 | 13 | | import com.nccgroup.loggerplusplus.filter.colorfilter.TableColorRule; |
13 | 14 | | import com.nccgroup.loggerplusplus.filter.tag.Tag; |
| 15 | + | import com.nccgroup.loggerplusplus.logentry.FieldGroup; |
14 | 16 | | import com.nccgroup.loggerplusplus.logentry.LogEntry; |
15 | 17 | | import com.nccgroup.loggerplusplus.logentry.Status; |
16 | 18 | | import com.nccgroup.loggerplusplus.logview.logtable.LogTableController; |
| skipped 233 lines |
250 | 252 | | } |
251 | 253 | | } |
252 | 254 | | |
253 | | - | private void submitNewEntryProcessingRunnable(final LogEntry logEntry){ |
254 | | - | entriesPendingProcessing.put(logEntry.getIdentifier(), logEntry); |
255 | | - | RunnableFuture<LogEntry> processingRunnable = new FutureTask<>(() -> { |
256 | | - | entriesPendingProcessing.remove(logEntry.getIdentifier()); |
257 | | - | LogEntry result = processEntry(logEntry); |
258 | | - | |
259 | | - | if(result == null) { |
260 | | - | entryProcessingFutures.remove(logEntry.getIdentifier()); |
261 | | - | return null; //Ignored entry. Skip it. |
262 | | - | }else{ |
263 | | - | addProcessedEntry(logEntry, true); |
264 | | - | |
265 | | - | if(result.getStatus() == Status.PROCESSED){ |
266 | | - | //If the entry was fully processed, remove it from the processing list. |
267 | | - | entryProcessingFutures.remove(logEntry.getIdentifier()); |
268 | | - | }else{ |
269 | | - | //We're waiting on the response, we'll use this future to know we're done later. |
270 | | - | } |
271 | | - | return result; |
272 | | - | } |
273 | | - | }); |
274 | | - | entryProcessingFutures.put(logEntry.getIdentifier(), processingRunnable); |
275 | | - | entryProcessExecutor.submit(processingRunnable); |
276 | | - | } |
277 | | - | |
278 | 255 | | /** |
279 | 256 | | * Create a runnable to be used in an executor which will process a |
280 | 257 | | * HTTP object and store the results in the provided LogEntry object. |
| skipped 6 lines |
287 | 264 | | |
288 | 265 | | //If the status has been changed |
289 | 266 | | if (logEntry.getStatus() != logEntry.getPreviousStatus()) { |
290 | | - | if (logEntry.getStatus() == Status.IGNORED) return null; //Don't care about entry |
| 267 | + | FilterExpression doNotLogExpression = preferences.getSetting(PREF_DO_NOT_LOG_IF_MATCH); |
| 268 | + | if(doNotLogExpression != null){ |
| 269 | + | if (logEntry.getStatus() == Status.PROCESSED || !doNotLogExpression.getRequiredContexts().contains(FieldGroup.RESPONSE)) { |
| 270 | + | //If we're dealing with a complete entry, or if the filter doesn't need the response. |
| 271 | + | if(doNotLogExpression.matches(logEntry)){ |
| 272 | + | return null; |
| 273 | + | } |
| 274 | + | } |
| 275 | + | } |
291 | 276 | | |
292 | 277 | | //Check against color filters |
293 | 278 | | HashMap<UUID, TableColorRule> colorFilters = preferences.getSetting(PREF_COLOR_FILTERS); |
| skipped 11 lines |
305 | 290 | | return logEntry; |
306 | 291 | | } |
307 | 292 | | |
| 293 | + | private void submitNewEntryProcessingRunnable(final LogEntry logEntry){ |
| 294 | + | entriesPendingProcessing.put(logEntry.getIdentifier(), logEntry); |
| 295 | + | RunnableFuture<LogEntry> processingRunnable = new FutureTask<>(() -> { |
| 296 | + | entriesPendingProcessing.remove(logEntry.getIdentifier()); |
| 297 | + | LogEntry result = processEntry(logEntry); |
| 298 | + | |
| 299 | + | if(result == null) { |
| 300 | + | entryProcessingFutures.remove(logEntry.getIdentifier()); |
| 301 | + | return null; //Ignored entry. Skip it. |
| 302 | + | }else{ |
| 303 | + | addNewEntry(logEntry, true); |
| 304 | + | |
| 305 | + | if(result.getStatus() == Status.PROCESSED){ |
| 306 | + | //If the entry was fully processed, remove it from the processing list. |
| 307 | + | entryProcessingFutures.remove(logEntry.getIdentifier()); |
| 308 | + | }else{ |
| 309 | + | //We're waiting on the response, we'll use this future to know we're done later. |
| 310 | + | } |
| 311 | + | return result; |
| 312 | + | } |
| 313 | + | }); |
| 314 | + | entryProcessingFutures.put(logEntry.getIdentifier(), processingRunnable); |
| 315 | + | entryProcessExecutor.submit(processingRunnable); |
| 316 | + | } |
| 317 | + | |
308 | 318 | | private RunnableFuture<LogEntry> createEntryUpdateRunnable(final Future<LogEntry> processingFuture, |
309 | 319 | | final HttpResponse requestResponse, |
310 | 320 | | final Date arrivalTime){ |
| skipped 1 lines |
312 | 322 | | //Block until initial processing is complete. |
313 | 323 | | LogEntry logEntry = processingFuture.get(); |
314 | 324 | | if (logEntry == null) { |
315 | | - | return null; //Request to an ignored host. Stop processing. |
| 325 | + | //Request was filtered during response processing. We can just ignore the response. |
| 326 | + | return null; |
316 | 327 | | } |
| 328 | + | |
| 329 | + | //Request was processed successfully... now process the response. |
317 | 330 | | logEntry.addResponse(requestResponse, arrivalTime); |
318 | | - | processEntry(logEntry); |
| 331 | + | LogEntry updatedEntry = processEntry(logEntry); |
| 332 | + | |
| 333 | + | if(updatedEntry == null){ |
| 334 | + | //Response must have been filtered out. Delete the existing entry and stop processing |
| 335 | + | removeExistingEntry(logEntry); |
| 336 | + | entryProcessingFutures.remove(logEntry.getIdentifier()); |
| 337 | + | return null; |
| 338 | + | } |
319 | 339 | | |
320 | 340 | | if (logEntry.getStatus() == Status.PROCESSED) { |
321 | 341 | | //If the entry was fully processed, remove it from the processing list. |
| skipped 51 lines |
373 | 393 | | this.entryImportExecutor.shutdownNow(); |
374 | 394 | | } |
375 | 395 | | |
376 | | - | void addProcessedEntry(LogEntry logEntry, boolean sendToAutoExporters) { |
377 | | - | if (sendToAutoExporters) exportController.exportNewEntry(logEntry); |
| 396 | + | void addNewEntry(LogEntry logEntry, boolean sendToAutoExporters) { |
| 397 | + | FilterExpression doNotLogExpression = preferences.getSetting(PREF_DO_NOT_LOG_IF_MATCH); |
378 | 398 | | SwingUtilities.invokeLater(() -> { |
| 399 | + | if (sendToAutoExporters) exportController.exportNewEntry(logEntry); |
379 | 400 | | logTableController.getLogTableModel().addEntry(logEntry); |
380 | 401 | | }); |
381 | 402 | | } |
| skipped 2 lines |
384 | 405 | | exportController.exportUpdatedEntry(logEntry); |
385 | 406 | | SwingUtilities.invokeLater(() -> { |
386 | 407 | | logTableController.getLogTableModel().updateEntry(logEntry); |
| 408 | + | }); |
| 409 | + | } |
| 410 | + | |
| 411 | + | void removeExistingEntry(LogEntry logEntry){ |
| 412 | + | SwingUtilities.invokeLater(() -> { |
| 413 | + | logTableController.getLogTableModel().removeLogEntry(logEntry); |
387 | 414 | | }); |
388 | 415 | | } |
389 | 416 | | |
| skipped 56 lines |