Skip to content
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

alert: Add CWE Alert Tag when building and CWE ID has been set #8190

Merged
merged 1 commit into from
Nov 24, 2023

Conversation

kingthorin
Copy link
Member

I also looked at doing this for WASC IDs but they don't have a handy URL, we'd have to add a pre-populated map which isn't impossible, but did seem like too much work for this morning 😀

@kingthorin kingthorin force-pushed the tagify-cwe-wasc branch 3 times, most recently from 257ee53 to 24a4eb5 Compare November 14, 2023 14:20
Copy link
Member

@ricekot ricekot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The function Alert#setCweId should be updated too?

@kingthorin
Copy link
Member Author

I dunno we didn't update the old alert functionality when we implemented addTag/removeTag.

I'm happy to do either, but was trying to stay consistent.

@thc202
Copy link
Member

thc202 commented Nov 15, 2023

Whatever we do we should document these side effects to avoid surprises (e.g. I can see this breaking our unit tests as there will be more tags now).

@kingthorin
Copy link
Member Author

kingthorin commented Nov 15, 2023

Okay how about this?

  1. I'll deprecate the existing setCwe(int) and add setCwe(int, boolean). This can easily be handled with a regex search and replace (with grouping/interpolation) when we update to new core. Where boolean true is to add the tag.

  2. In Builder.build() use boolean true then it's added (this behavior can be documented, and a build(boolean) added?)

  3. Add functionality/tests to not set multiple tags.

  4. In the older non-Builder Alert functionality I'll add an addCweTag() method? Or also do 1-3 there?

@kingthorin
Copy link
Member Author

Or, we could go a totally different way.

Implement convenience methods in Common Lib for it and then make sure that it gets used in all scan rules. We could even add generic tests for it 🤷‍♂️

In guess that'd be more maintenance friendly as far as the URL goes.

@kingthorin
Copy link
Member Author

Crew I need some feedback on this so that it can be moved ahead.

@kingthorin
Copy link
Member Author

Anyone out there?

@ricekot
Copy link
Member

ricekot commented Nov 22, 2023

I like the original approach of adding the tags in the builder (i.e. in Builder#build), if a valid CWE ID is set.

@thc202
Copy link
Member

thc202 commented Nov 22, 2023

I'm also happy with the builder way, my only concern is the URL (though that one should stay stable…).

@kingthorin
Copy link
Member Author

Thank you both! I'll get this reworked.

@kingthorin kingthorin force-pushed the tagify-cwe-wasc branch 2 times, most recently from 0f4303f to 7359e0a Compare November 22, 2023 12:57
@kingthorin
Copy link
Member Author

Tweaked.

@kingthorin kingthorin force-pushed the tagify-cwe-wasc branch 3 times, most recently from 8b12b87 to 66d6887 Compare November 22, 2023 13:27
@kingthorin
Copy link
Member Author

Tweaked

@kingthorin kingthorin changed the title alert: Add CWE Alert Tag when setting CWE alert: Add CWE Alert Tag when building and CWE ID has been set Nov 22, 2023
@kingthorin kingthorin force-pushed the tagify-cwe-wasc branch 2 times, most recently from 3da75c2 to 53ccfcc Compare November 22, 2023 14:58
@kingthorin
Copy link
Member Author

Okay think I got this into a more expected state.

@kingthorin kingthorin force-pushed the tagify-cwe-wasc branch 2 times, most recently from 3bfda0a to ac4486f Compare November 22, 2023 16:17
@kingthorin
Copy link
Member Author

Tweaked again.

@kingthorin kingthorin force-pushed the tagify-cwe-wasc branch 2 times, most recently from b620652 to 34d38b6 Compare November 22, 2023 16:35
@kingthorin
Copy link
Member Author

Okay hopefully this is finally good to go.

@kingthorin kingthorin force-pushed the tagify-cwe-wasc branch 2 times, most recently from ef1dd73 to 7ab557f Compare November 23, 2023 02:04
@kingthorin
Copy link
Member Author

I had to re-work it a bit more because I was getting NPE and unmodifiable map exceptions while working on something else this evening. Hopefully it's in a good state now.

@thc202 thc202 added this to the 2.15.0 milestone Nov 24, 2023
@kingthorin kingthorin force-pushed the tagify-cwe-wasc branch 2 times, most recently from 758f337 to 0c59091 Compare November 24, 2023 13:50
@thc202
Copy link
Member

thc202 commented Nov 24, 2023

Thank you!

@kingthorin
Copy link
Member Author

For the record this will mean that we need to update "expected mappings" type unit tests when zap-extensions migrates to 2.15.

Signed-off-by: kingthorin <kingthorin@users.noreply.github.com>
@thc202 thc202 merged commit 056f803 into zaproxy:main Nov 24, 2023
9 checks passed
@kingthorin kingthorin deleted the tagify-cwe-wasc branch November 24, 2023 14:13
Copy link

This PR has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked and limited conversation to collaborators Feb 23, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Development

Successfully merging this pull request may close these issues.

None yet

4 participants