Add a new crash dump to the database, optionally filtering them by signature to avoid duplicates. @type crash: L{Crash} @param crash: Crash object. @type allow_duplicates: bool @param allow_duplicates: (Optional) C{True} to always add
(self, crash, allow_duplicates=True)
| 736 | |
| 737 | @Transactional |
| 738 | def add(self, crash, allow_duplicates=True): |
| 739 | """ |
| 740 | Add a new crash dump to the database, optionally filtering them by |
| 741 | signature to avoid duplicates. |
| 742 | |
| 743 | @type crash: L{Crash} |
| 744 | @param crash: Crash object. |
| 745 | |
| 746 | @type allow_duplicates: bool |
| 747 | @param allow_duplicates: (Optional) |
| 748 | C{True} to always add the new crash dump. |
| 749 | C{False} to only add the crash dump if no other crash with the |
| 750 | same signature is found in the database. |
| 751 | |
| 752 | Sometimes, your fuzzer turns out to be I{too} good. Then you find |
| 753 | youself browsing through gigabytes of crash dumps, only to find |
| 754 | a handful of actual bugs in them. This simple heuristic filter |
| 755 | saves you the trouble by discarding crashes that seem to be similar |
| 756 | to another one you've already found. |
| 757 | """ |
| 758 | |
| 759 | # Filter out duplicated crashes, if requested. |
| 760 | if not allow_duplicates: |
| 761 | signature = pickle.dumps(crash.signature, protocol=0) |
| 762 | if self._session.query(CrashDTO.id).filter_by(signature=signature).count() > 0: |
| 763 | return |
| 764 | |
| 765 | # Fill out a new row for the crashes table. |
| 766 | crash_id = self.__add_crash(crash) |
| 767 | |
| 768 | # Fill out new rows for the memory dump. |
| 769 | self.__add_memory(crash_id, crash.memoryMap) |
| 770 | |
| 771 | # On success set the row ID for the Crash object. |
| 772 | # WARNING: In nested calls, make sure to delete |
| 773 | # this property before a session rollback! |
| 774 | crash._rowid = crash_id |
| 775 | |
| 776 | # Store the Crash object into the crashes table. |
| 777 | def __add_crash(self, crash): |