-
-
Notifications
You must be signed in to change notification settings - Fork 673
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
automation: Handle Outdated Jobs #4560
base: main
Are you sure you want to change the base?
Conversation
addOns/automation/src/main/java/org/zaproxy/addon/automation/ExtensionAutomation.java
Outdated
Show resolved
Hide resolved
System.out.println(plan.getJobIndex(job)); | ||
System.out.println(job); | ||
|
||
List<AutomationJob> jobs = plan.getJobs(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could use an advanced for and avoid the intermediate storage
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually I did try to use the advanced for loop. But it was giving me an exception called ConcurrentModificationException
, which was telling me to not change the iterator object (planJob
). Although, I wasn't changing it but maybe the function which I was passing that on was changing it. So the only solution I could find on the forums was to just switch to the old for loops.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does an advanced for work with the intermediate store? Ex: leave this line assigning to “jobs” then iterate it instead of “plan.getJobs”.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does an advanced for work with the intermediate store?
I think, no. It is still giving me that exception on run-time.
Is using the traditional for loop a bad practice though?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nope, that’s fine. Just trying to simplify 😉
Have a look on this please. I have fixed the cases where it was showing errors. After a job is I am using some things like sets, keysets to iterate over the Also, as per the comment by @thc202 zaproxy/zaproxy#7799 (comment) |
Signed-off-by: Sparsh Sethi <sparshsethi15@gmail.com>
11cdc2a
to
f1f6061
Compare
Added the test case for it. Also, are there no test cases present (or needed) for the Automation GUI? |
Yes, that happens when the add-on is updated, rather than just being uninstalled. That case should still work, the plan will still have the job but the new version. (Note that we should not be changing the contents of the plan.) There are no GUI tests currently. |
okay okay, got it. is it related to copyZapAddOn command? |
You can install/update the add-ons with the task |
One problem I am facing is that, whenever the add-on is updated using the installZapAddOn task, it first uninstalls it (un-registers from Automation) and then installs it again with the new version. Now since the job is already removed from the plan upon uninstallation (based on my current changes), I cant access it in the |
Update: Still not able to figure out a way to handle that problem. The first part (add-on uninstallation case) is working fine though. But Since the update process goes like this only (first uninstall then re install), I am not sure if it's even possible to do the second part. Currently, with these changes an add-on update will remove that job from the plan just like an un-installation instead of retaining that job in the plan with the newer version. But still, it would atleast be able to prevent those exceptions thrown at run-time. Please let me know your views on this... as I was also wondering if I should just go ahead with the current changes and make it un-draft? Or should I wait and keep the PR the way it is, for now. |
How about adding the necessary check? If it is present or not? If it is present the default action of uninstall and reinstall fits! if it's not then just installing the latest should be the way to go. |
Fixes zaproxy/zaproxy#7799
Changes