Vega icon indicating copy to clipboard operation
Vega copied to clipboard

AlertExporter exportAllAlerts() not working properly - Proposal

Open leisipeisi opened this issue 7 years ago • 0 comments

Hi everyone,

I just found out that the method exportAllAlerts() of AlertExporter is not working properly as it is only exporting the alerts of the last scan. This is due to an overwriting of the result file. Please find a fix for this in the following:

public void exportAllAlerts() {
		System.out.println("started exporting...");
                //to prevent NullPointerExceptions
		if(alertRepository == null)
		{
			alertRepository = Activator.getDefault().getModel().getCurrentWorkspace().getScanAlertRepository();
		}
		List <IScanInstance> scanInstances = alertRepository.getAllScanInstances();
		System.out.println("finished finding all instances.");
		int i = 0;
                //write must happen outside of the loop.
		List<IScanAlert> scanInstanceAlerts = new ArrayList<IScanAlert>();
		for (IScanInstance s : scanInstances) {
			i++;
			System.out.println("save instance nr. " + i);
			scanInstanceAlerts.addAll(s.getAllAlerts());
			
		}
		writeFile("tmp/test.html",renderer.renderList(scanInstanceAlerts));
	}

(I don't know if this is the right place to mention that, if there is a better one please tell me.)

leisipeisi avatar Feb 13 '18 11:02 leisipeisi