zap-extensions icon indicating copy to clipboard operation
zap-extensions copied to clipboard

brk: migrate from core

Open aryangupta701 opened this issue 1 year ago • 60 comments

Overview

Part of zaproxy/zaproxy#8153

  • [x] migrate brk form core to addon
  • [ ] update plugnhack to use brk addon
  • [ ] update websocket to use brk addon
  • [ ] update brk addon to use network addon

Related Issues

Specify any related issues or pull requests by linking to them.

Checklist

  • [ ] Update help
  • [ ] Update changelog
  • [ ] Run ./gradlew spotlessApply for code formatting
  • [ ] Write tests
  • [ ] Check code coverage
  • [ ] Sign-off commits
  • [ ] Squash commits
  • [ ] Use a descriptive title

For more details, please refer to the developer rules and guidelines.

I have read the CLA Document and I hereby sign the CLA

aryangupta701 avatar Jan 13 '24 10:01 aryangupta701

You need to add the new add-on/project to the settings.gradle.kts file: https://github.com/zaproxy/zap-extensions/blob/ac4cae7b7c237afab4e72f824e0210018dbc6d7f/settings.gradle.kts#L27

Note that network should not depend on the new add-on.

thc202 avatar Jan 14 '24 08:01 thc202

why should the network not depend on the break addon? I mean it will be using it right?

aryangupta701 avatar Jan 14 '24 10:01 aryangupta701

also how should I use this class? WithConfigsTest I am not able to use it directly I think I will have to create a clone for it in zap-extensions also?

aryangupta701 avatar Jan 14 '24 10:01 aryangupta701

https://github.com/zaproxy/zap-extensions/pull/5213#issuecomment-1890910636

The network add-on does not need the break functionality to work, it could be an optional dependency but even in that case there's no networking functionality that would depend on it. What should be done is change the network add-on to allow to set the serializer and the break add-on would set it.

https://github.com/zaproxy/zap-extensions/pull/5213#issuecomment-1890912818

You need to adapt the tests to use TestUtils from the testutils project.

thc202 avatar Jan 14 '24 13:01 thc202

can plugnhack and websocket depend on break addon? @thc202

aryangupta701 avatar Jan 14 '24 16:01 aryangupta701

Yes, although it could be an optional dependency.

thc202 avatar Jan 14 '24 16:01 thc202

can you share an example of how to add an optional dependency?

aryangupta701 avatar Jan 14 '24 17:01 aryangupta701

https://github.com/zaproxy/zap-extensions/blob/ac4cae7b7c237afab4e72f824e0210018dbc6d7f/addOns/quickstart/quickstart.gradle.kts#L53-L64

thc202 avatar Jan 14 '24 18:01 thc202

are there any any existing help pages for brk extension? @thc202

aryangupta701 avatar Jan 15 '24 09:01 aryangupta701

https://github.com/zaproxy/zap-extensions/pull/5213#discussion_r1452103377

You need to create a new extension in the corresponding add-ons (in the previous example, ExtensionQuickStartSpider which accesses the spider add-on). The classnames should allow classes (though simpler with a package) of the add-on itself not of the dependency.

https://github.com/zaproxy/zap-extensions/pull/5213#issuecomment-1891721849

Yes, they are all currently in the zap-core-help repo (e.g. https://github.com/zaproxy/zap-core-help/blob/73a4fd1d5d2ae72fef6607ff35e3b22e49ea667a/addOns/help/src/main/javahelp/contents/ui/dialogs/addbreak.html).

thc202 avatar Jan 15 '24 10:01 thc202

I am planning to do this in 4 different PRs as updated in this PR's description. Will it be fine?

aryangupta701 avatar Jan 15 '24 10:01 aryangupta701

Thats fine as long as the changes are consistant and dont break things inbetween the PRs.

psiinon avatar Jan 15 '24 11:01 psiinon

Sure Simon.

I wanted to know how do we generate the help files for all the languages. What is the command for that?

aryangupta701 avatar Jan 15 '24 11:01 aryangupta701

They are added automatically when syncing from Crowdin.

thc202 avatar Jan 15 '24 11:01 thc202

https://github.com/zaproxy/zap-extensions/pull/5213#issuecomment-1891812419

It might just be a matter of updating the task text, but the network add-on should not use the brk add-on, it should be the other way around.

thc202 avatar Jan 15 '24 12:01 thc202

I think it will be worth getting a review for the first task now i.e. migrate brk form core to addon. So that I can continue with the updation of other addons as well.

aryangupta701 avatar Jan 15 '24 12:01 aryangupta701

Quick comments:

  • The functionality provided by the add-on should be added conditionally based on core's state, installing the add-on in dev/weekly should not cause any warns/errors (before and after the core changes). Same for main release but for that we can just require minimum of 2.15.
  • The help is incomplete (e.g. helpset, index, toc) and it's missing core help pages.
  • The extension should be unloadable (also worth double check that all is).

thc202 avatar Jan 15 '24 14:01 thc202

I am not able to understand how the help pages should be imported. Since the break page on the core help page links to multiple pages and those pages then further link to many more so this would not be trivial to add

aryangupta701 avatar Feb 03 '24 22:02 aryangupta701

re : The functionality provided by the add-on should be added conditionally based on core's state,

Where should this condition be present? Like in which file?

aryangupta701 avatar Feb 03 '24 23:02 aryangupta701

https://github.com/zaproxy/zap-extensions/pull/5213#issuecomment-1925477396

See e.g. zaproxy/zap-core-help#450 and #3848.

https://github.com/zaproxy/zap-extensions/pull/5213#issuecomment-1925478921

See e.g. zaproxy/zaproxy#7335 and https://github.com/zaproxy/zap-extensions/pull/3848/files#diff-1bce03d563372eb477beadc27d3a09f7581995a416dd3a09f60d47b920fc4671R76

thc202 avatar Feb 05 '24 07:02 thc202

thank you. Sorry for not getting much time but will complete this very soon

aryangupta701 avatar Feb 08 '24 12:02 aryangupta701

CLA Assistant Lite bot All contributors have signed the CLA ✍️ ✅

github-actions[bot] avatar Feb 14 '24 22:02 github-actions[bot]

Please remove the merge and do a rebase.

kingthorin avatar Feb 14 '24 22:02 kingthorin

is there any automated way to generate these three files in java help?

  1. index.xml
  2. map.jhm
  3. loc.xml

aryangupta701 avatar Feb 14 '24 22:02 aryangupta701

Nope.

kingthorin avatar Feb 14 '24 22:02 kingthorin

I don't know much about these files and how they work. Could you provide a little guidance for it please

aryangupta701 avatar Feb 14 '24 22:02 aryangupta701

Just model it based on another add-on, it should only require updating the add-on name (vs others).

kingthorin avatar Feb 14 '24 23:02 kingthorin

okay thank you

aryangupta701 avatar Feb 14 '24 23:02 aryangupta701

Do what it says: https://github.com/zaproxy/zap-extensions/pull/5213#issuecomment-1944776621

kingthorin avatar Feb 14 '24 23:02 kingthorin

I have read the CLA Document and I hereby sign the CLA

aryangupta701 avatar Feb 15 '24 00:02 aryangupta701