Fix: duplicate results
What: Compares the scan id in globals, set at the beginning of the scan, with the one found in the main kb. It helps to detect that the kb was not taken by another task/scan, and that the current plugins does not stores results in a wrong kb.
Jira: SC-378
Why: A scan can left result in a kb, which is later taken for a new scan. This produces that results from an interrupted scan are shown in the report of a new scan. With this patch, the scanner checks the kb before leaving a new result.
How: Run a scan. The race condition is hard to reproduce.
Checklist:
- [ ] Tests
- [ ] PR merge commit message adjusted
I found several kb_item_push_str where the check is missing:
- https://github.com/jjnicola/openvas-scanner/blob/kb-inconsitency/misc/network.c#L1994
- https://github.com/jjnicola/openvas-scanner/blob/kb-inconsitency/nasl/nasl_host.c#L138
- https://github.com/jjnicola/openvas-scanner/blob/kb-inconsitency/nasl/nasl_host.c#L140
- https://github.com/jjnicola/openvas-scanner/blob/kb-inconsitency/src/attack.c#L185
- https://github.com/jjnicola/openvas-scanner/blob/kb-inconsitency/src/attack.c#L219
- https://github.com/jjnicola/openvas-scanner/blob/kb-inconsitency/src/attack.c#L706
- https://github.com/jjnicola/openvas-scanner/blob/kb-inconsitency/src/attack.c#L771
- https://github.com/jjnicola/openvas-scanner/blob/kb-inconsitency/src/openvas.c#L400 Not sure if it is necessary in all cases, but wouldn't it be better if the consistency is automatically checked when trying to push things into it? So we do not have to check this on our own every time?
replaced by:https://github.com/greenbone/openvas-scanner/pull/1159