Skip to content

Add Apache Log4j Advisories#1744

Open
NucleonGodX wants to merge 6 commits intoaboutcode-org:mainfrom
NucleonGodX:apachelog
Open

Add Apache Log4j Advisories#1744
NucleonGodX wants to merge 6 commits intoaboutcode-org:mainfrom
NucleonGodX:apachelog

Conversation

@NucleonGodX
Copy link

This pull request addresses issue #586 by adding an importer for Apache Log4j advisories
image

Signed-off-by: NucleonGodX <racerpro41@gmail.com>
Signed-off-by: NucleonGodX <racerpro41@gmail.com>
@NucleonGodX NucleonGodX marked this pull request as draft January 15, 2025 06:58
@NucleonGodX NucleonGodX marked this pull request as ready for review January 17, 2025 11:12
@TG1999
Copy link
Contributor

TG1999 commented Jan 23, 2025

@NucleonGodX thanks for your contributions, can you please use pipeline structure. https://github.com/aboutcode-org/vulnerablecode/blob/main/vulnerabilities/pipelines/nvd_importer.py check this for example

Copy link
Member

@pombredanne pombredanne left a comment

Choose a reason for hiding this comment

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

Thanks! In addition to use the new pipelines, here are a few comments for your consideration. We also need some tests.

@@ -0,0 +1,252 @@
import logging
Copy link
Member

Choose a reason for hiding this comment

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

Use the same header as in other files

@@ -0,0 +1,252 @@
import logging
import xml.etree.ElementTree as ET
Copy link
Member

Choose a reason for hiding this comment

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

Consider using the cyclonedx python library to parse this, and not parsing XML yourself

Parse the XML content and create AdvisoryData objects.
"""
advisories = []
version_mapping = [
Copy link
Member

Choose a reason for hiding this comment

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

Why use mapping? are you positively sure that these are forever all the known versions of log4j? Also this would not be a mapping, rather just a set of some versions?

Copy link
Author

Choose a reason for hiding this comment

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

"2.17.1",
]

try:
Copy link
Member

Choose a reason for hiding this comment

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

Why a try/except here?

]

try:
root = ET.fromstring(xml_content)
Copy link
Member

Choose a reason for hiding this comment

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

Use the cyclonedx parser.


class Log4jImprover(ValidVersionImprover):
importer = ApacheLog4jImporter
ignorable_versions = []
Copy link
Member

Choose a reason for hiding this comment

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

We likely need some improver to get and expand the list of known versions

Signed-off-by: NucleonGodX <racerpro41@gmail.com>
Signed-off-by: NucleonGodX <racerpro41@gmail.com>
Signed-off-by: NucleonGodX <racerpro41@gmail.com>
Comment on lines +231 to +232
unique_versions = sorted(set(versions), key=lambda x: MavenVersion(x))
version_range_str = f"vers:maven/{('|'.join(unique_versions))}"
Copy link
Member

Choose a reason for hiding this comment

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

Why not use MavenVersionRange instead?

Copy link
Author

Choose a reason for hiding this comment

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

oh yeah, I'll try to use that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants